PathGui: ViewProviderPath visual enhancement #625

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

PathGui: ViewProviderPath visual enhancement #625

Post by realthunder »

Hello fellow Pathers, I've just submit a patch for ViewProviderPath with the following enhancement,
  • Enabled preselect
  • Shows GCode command and movement direction when preselected
  • Support single/multi-stepping using property 'StartIndex' and 'ShowCount'
Screenshot from 2017-03-18 14-51-42.png
Screenshot from 2017-03-18 14-51-42.png (176.89 KiB) Viewed 2073 times
You are welcome to try my branch at https://github.com/realthunder/FreeCAD/ ... iewEnhance

One problem, though. I've slightly changed Path::Command to make the output command shorter if asked. But it caused Path test failure. Is it necessary for a gcode file to have a fixed number of decimals? Could Path test author have a look at it? The error looks like these.

Code: Select all

Traceback (most recent call last):
  File "C:\projects\freecad\build\Mod\Path\PathTests\TestPathCore.py", line 99, in test10
    self.assertEqual(p.toGCode(), 'G1 X1.000000 Y0.000000\nG1 X0.000000 Y2.000000\nG1 X1.000000 Y0.000000\n')
AssertionError: 'G1 X1.00000 Y0.00000\nG1 X0.00000 Y2.00000\nG1 X1.00000 Y0.00000\n' != 'G1 X1.000000 Y0.000000\nG1 X0.000000 Y2.000000\nG1 X1.000000 Y0.000000\n'
It is kind of weird, because the original Path::Command C++ code uses 5 decimal precision, which is what I used for default. How come it didn't cause problem before?
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
chrisb
Veteran
Posts: 53930
Joined: Tue Mar 17, 2015 9:14 am

Re: PathGui: ViewProviderPath visual enhancement #625

Post by chrisb »

GCode itself doesn't require a certain precision. The precision depended in the old days on the machines capabilities. Thus until now it was only a matter for the post processor. Since the new display gives a hint to the GCode generated it might well use the post processors information. However, I don't like the mixing of levels, until now the post processor was completely independent from the rest of the path workbench.

What I would like to see:
- All calculations should use the full double precision.
- Make all post processors precision aware by means of a parameter.
- The precision can be defined in the Job.
- If set, it is transferred to the post processor
- if set, it is used for display if needed.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: PathGui: ViewProviderPath visual enhancement #625

Post by sliptonic »

Realthunder,
This is a really nice feature! I especially like being able to limit the elements shown and set the start index. It will be very helpful to inspect the path when it gets dense.

This does break the regular Path operations. I'm getting this error trying to create a new contour or other operation. Should be an easy fix but might be needed in a few places. :

Code: Select all

  File "<string>", line 6, in <module>
  File "/home/brad/FC/Mod/Path/PathScripts/PathLoadTool.py", line 104, in __init__
    vobj.setEditorMode('ShowFirstRapid', mode)
AttributeError: Property container has no property 'ShowFirstRapid'
Don't worry about the test failure. The tests are too simplistic. They just compare output to hard-coded values so they're not taking precision into account at all. The tests should be re-written.

Path uses the preferences 'number of decimals' setting most places and the fmt() function from PathUtils in others. fmt() is hard-coded to 4 decimal places. I agree with chrisb that we need a preference for post-processor precision which would default into the job. I will work on that. issue #2970

One thing to clarify, the display on the screen is NOT derived from the output gcode. It's built from the path commands so it should never be affected by any output precision setting.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: PathGui: ViewProviderPath visual enhancement #625

Post by realthunder »

sliptonic wrote:This does break the regular Path operations. I'm getting this error trying to create a new contour or other operation. Should be an easy fix but might be needed in a few places. :

Code: Select all

  File "<string>", line 6, in <module>
  File "/home/brad/FC/Mod/Path/PathScripts/PathLoadTool.py", line 104, in __init__
    vobj.setEditorMode('ShowFirstRapid', mode)
AttributeError: Property container has no property 'ShowFirstRapid'
Oh, right, I removed that property from ViewProviderPath, since it can now set a start index, this property is obsolete, which effectively means StartIndex=1
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: PathGui: ViewProviderPath visual enhancement #625

Post by mlampert »

realthunder wrote:

Code: Select all

Traceback (most recent call last):
  File "C:\projects\freecad\build\Mod\Path\PathTests\TestPathCore.py", line 99, in test10
    self.assertEqual(p.toGCode(), 'G1 X1.000000 Y0.000000\nG1 X0.000000 Y2.000000\nG1 X1.000000 Y0.000000\n')
AssertionError: 'G1 X1.00000 Y0.00000\nG1 X0.00000 Y2.00000\nG1 X1.00000 Y0.00000\n' != 'G1 X1.000000 Y0.000000\nG1 X0.000000 Y2.000000\nG1 X1.000000 Y0.000000\n'
It is kind of weird, because the original Path::Command C++ code uses 5 decimal precision, which is what I used for default. How come it didn't cause problem before?
It seems you increased the precision from 5 to 6 digits, that's fine. I don't know how you print the command but be aware that it has to be valid g-code, you can't use "%g" because it'll use exponents. 5 digits was a compromise between resolution (100nm) and .fcstd file size.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: PathGui: ViewProviderPath visual enhancement #625

Post by realthunder »

mlampert wrote:It seems you increased the precision from 5 to 6 digits, that's fine. I don't know how you print the command but be aware that it has to be valid g-code, you can't use "%g" because it'll use exponents. 5 digits was a compromise between resolution (100nm) and .fcstd file size.
No, I kept the default 5 digits. That's why I think it is strange. How can the test pass before? And no, I am not using %g, but C++ stringstream.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: PathGui: ViewProviderPath visual enhancement #625

Post by mlampert »

realthunder wrote: No, I kept the default 5 digits. That's why I think it is strange. How can the test pass before? And no, I am not using %g, but C++ stringstream.
I'm not sure if you haven't reverted the fix for #2770. Could you verify that this doesn't create entries like "1e4" if the value is 10000. Preferrably in a unit test?
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: PathGui: ViewProviderPath visual enhancement #625

Post by mlampert »

realthunder wrote: No, I kept the default 5 digits. That's why I think it is strange. How can the test pass before?
Arrrgh - I got confused. The current default precision is 6 digits, 10nm, and you decreased it to 5. The set precision in the old code is not used, the formatting comes from std::to_string which always results in 6 digits.

My bad, it's been a while since I looked at that code.

In order to fix the unit tests you just have to increase your default precision to 6.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: PathGui: ViewProviderPath visual enhancement #625

Post by realthunder »

Mystery solved! Change committed.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
mlampert
Veteran
Posts: 1772
Joined: Fri Sep 16, 2016 9:28 pm

Re: PathGui: ViewProviderPath visual enhancement #625

Post by mlampert »

realthunder wrote:Mystery solved! Change committed.
yay - can you still verify that the stream operator for doubles doesn't use exponents please
Post Reply