Reworked Sketcher constraint icons
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Reworked Sketcher constraint icons
I've done a bit of work on the drawing of constraint icons in Sketcher, and was hoping to get some testing/feedback before submitting a pull request.
Currently, icons are often drawn on top of each other, for example: The branch at https://github.com/ianrrees/FreeCAD_tin ... cher-icons groups icons together and hopefully makes them easier to read: Any thoughts? -Ian-
Currently, icons are often drawn on top of each other, for example: The branch at https://github.com/ianrrees/FreeCAD_tin ... cher-icons groups icons together and hopefully makes them easier to read: Any thoughts? -Ian-
Last edited by ian.rees on Thu Jul 10, 2014 3:10 am, edited 1 time in total.
Re: Reworked Sketcher constraint icons
This may solve issue #752; another thing that's nice to have!
-
- Posts: 655
- Joined: Fri Jul 22, 2011 8:37 pm
- Contact:
Re: Reworked Sketcher constraint icons
Hi Ian,
The results look pretty good and has been needed for a long time.
Code wise looks good and thank you for tidying up some bits and adding new functions to make it clearer in ViewProviderSketch
I like the use of a queue structure for the constraint icons and will be useful that you can now draw names. I don't understand where the original functions for the icon overlapping went when i originally did them but that doesn't matter and mine wasn't that elegant which use a SoRayPick...
I'm not sure what the dragging constraints functionality is because I cannot test at the minute. Ideally in the future, we need to group the icons into one SoNode because performance supposedly worsens when increase the number of nodes when tree traversing and similarily with the SoDatumLabels. This I don't know if can be easily accomplished but is low priority
In summary I'm happy with the changes so people get testing!
Thanks
Luke
The results look pretty good and has been needed for a long time.
Code wise looks good and thank you for tidying up some bits and adding new functions to make it clearer in ViewProviderSketch
I like the use of a queue structure for the constraint icons and will be useful that you can now draw names. I don't understand where the original functions for the icon overlapping went when i originally did them but that doesn't matter and mine wasn't that elegant which use a SoRayPick...
I'm not sure what the dragging constraints functionality is because I cannot test at the minute. Ideally in the future, we need to group the icons into one SoNode because performance supposedly worsens when increase the number of nodes when tree traversing and similarily with the SoDatumLabels. This I don't know if can be easily accomplished but is low priority
In summary I'm happy with the changes so people get testing!
Thanks
Luke
Development blog - http://freecadamusements.blogspot.co.uk/
Re: Reworked Sketcher constraint icons
Glad you like it Luke!
I think you're right about grouping icons together into the same node, but I didn't want to let the scope of this patch creep too far. Probably making some accessor functions for the constraint group, to get away from the static ordering at each constraint separator, would be a good start towards that goal. -Ian-
I think you're right about grouping icons together into the same node, but I didn't want to let the scope of this patch creep too far. Probably making some accessor functions for the constraint group, to get away from the static ordering at each constraint separator, would be a good start towards that goal. -Ian-
Re: Reworked Sketcher constraint icons
Hi,
I tried out your improvements and they are definitely most needed. There are some usability issues and unfortunately some bugs. First the issues I noticed:
- Multiple icons/constraints on a line are now all preselected and subsequently selected as well. I found it very inconvenient to try to remove a single constraint, since it can't be selecte individually, for example an horizontal constraint. I think the constraints should be selectable individually. You should figure out how to achieve this when multiple similar constraints are grouped under a single icon with only their numbers listed to distinguish them.
- The icons and texts tend to overlap the lines of the sketch. This could be avoided to some degree by aligning the now vertically placed icons to the line they are related to. I'm not sure if some of the icons should be rotated as well, since the parallel and equal icons could get mixed up. Of course they could be made more different from eachother to prevent this. No point in rotating ho/vert icons either. Rotated constarint numbers could be a better visual clue to which line the are related to.
- Moving the edges of a rectangle, created with the tool but otherwise unconstrained (only hor/vert), seems to occasionally move the unselected/undragged edges as well. This could be some solver or grid snap issue, haven't tested this without your changes.
Unfortunately I ran into SIGSEGVs while testing this with a sketch you can find as an attachment to this post (Cut/Sketch). First I noticed some coin warning messages about some function being called, which shouldn't be done. Unfortunately I could nto reproduce these messages to paste them here. I'll post them here if I run into them again.
The SIGSEGVs were generated by multiple ways. I got them at least while adding lines to the rightmost part of the sketch and hovering the mouse over the constraint icon groups. I couldn't reproduce them by any specific means, they seemed to be generated more or less randomly, just like the coin warnings.
Here is my platform information and the beginnig of a backtrace from a typical SIGSEGV:
OS: Ubuntu 14.04 LTS
Word size: 64-bit
Version: 0.14.3699 (Git)
Branch: sketcher-icons
Hash: c36ea0c227da2147780d7854ea12033f8cda3cfa
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
SoQt version: 1.6.0a
OCC version: 6.7.0
0x00007ffff3c1f00c in SoField::isConnectedFromField() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
(gdb) bt
#0 0x00007ffff3c1f00c in SoField::isConnectedFromField() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
#1 0x00007ffff3c1f049 in SoField::isConnected() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
#2 0x00007ffff3c1fbb5 in SoField::evaluateField() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
#3 0x00007ffff749f16b in SoField::evaluate (this=0x237ff28) at /usr/include/Inventor/fields/SoField.h:142
#4 0x00007ffff749f22a in SoSFVec3f::getValue (this=0x237ff28) at /usr/include/Inventor/fields/SoSFVec3f.h:43
#5 0x00007fffc59d7e0a in SketcherGui::ViewProviderSketch::drawConstraintIcons (this=0x21ca220) at /home/sponssi/devel/sketchericons/source/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp:2061
#6 0x00007fffc59e29e7 in SketcherGui::ViewProviderSketch::draw (this=0x21ca220, temp=true) at /home/sponssi/devel/sketchericons/source/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp:3077
#7 0x00007fffc59e4762 in SketcherGui::ViewProviderSketch::updateData (this=0x21ca220, prop=0x21c9f40) at /home/sponssi/devel/sketchericons/source/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp:3276
#8 0x00007ffff76b10b8 in Gui::ViewProvider::update (this=0x21ca220, prop=0x21c9f40) at /home/sponssi/devel/sketchericons/source/src/Gui/ViewProvider.cpp:219
#9 0x00007ffff745ff93 in Gui::Document::slotChangedObject (this=0x1f826c0, Obj=..., Prop=...) at /home/sponssi/devel/sketchericons/source/src/Gui/Document.cpp:451
#10 0x00007ffff7470fdc in boost::_mfi::mf2<void, Gui::Document, App::DocumentObject const&, App::Property const&>::operator() (this=0x1f83570, p=0x1f826c0, a1=..., a2=...) at /usr/include/boost/bind/mem_fn_template.hpp:280
The beginning of the backtrace seemed to be always the same, but the end parts differed from eachother. I didn't look into this any deeped.
I hope this helps in fixing the problems.
I tried out your improvements and they are definitely most needed. There are some usability issues and unfortunately some bugs. First the issues I noticed:
- Multiple icons/constraints on a line are now all preselected and subsequently selected as well. I found it very inconvenient to try to remove a single constraint, since it can't be selecte individually, for example an horizontal constraint. I think the constraints should be selectable individually. You should figure out how to achieve this when multiple similar constraints are grouped under a single icon with only their numbers listed to distinguish them.
- The icons and texts tend to overlap the lines of the sketch. This could be avoided to some degree by aligning the now vertically placed icons to the line they are related to. I'm not sure if some of the icons should be rotated as well, since the parallel and equal icons could get mixed up. Of course they could be made more different from eachother to prevent this. No point in rotating ho/vert icons either. Rotated constarint numbers could be a better visual clue to which line the are related to.
- Moving the edges of a rectangle, created with the tool but otherwise unconstrained (only hor/vert), seems to occasionally move the unselected/undragged edges as well. This could be some solver or grid snap issue, haven't tested this without your changes.
Unfortunately I ran into SIGSEGVs while testing this with a sketch you can find as an attachment to this post (Cut/Sketch). First I noticed some coin warning messages about some function being called, which shouldn't be done. Unfortunately I could nto reproduce these messages to paste them here. I'll post them here if I run into them again.
The SIGSEGVs were generated by multiple ways. I got them at least while adding lines to the rightmost part of the sketch and hovering the mouse over the constraint icon groups. I couldn't reproduce them by any specific means, they seemed to be generated more or less randomly, just like the coin warnings.
Here is my platform information and the beginnig of a backtrace from a typical SIGSEGV:
OS: Ubuntu 14.04 LTS
Word size: 64-bit
Version: 0.14.3699 (Git)
Branch: sketcher-icons
Hash: c36ea0c227da2147780d7854ea12033f8cda3cfa
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
SoQt version: 1.6.0a
OCC version: 6.7.0
0x00007ffff3c1f00c in SoField::isConnectedFromField() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
(gdb) bt
#0 0x00007ffff3c1f00c in SoField::isConnectedFromField() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
#1 0x00007ffff3c1f049 in SoField::isConnected() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
#2 0x00007ffff3c1fbb5 in SoField::evaluateField() const () from /usr/lib/x86_64-linux-gnu/libCoin.so.80
#3 0x00007ffff749f16b in SoField::evaluate (this=0x237ff28) at /usr/include/Inventor/fields/SoField.h:142
#4 0x00007ffff749f22a in SoSFVec3f::getValue (this=0x237ff28) at /usr/include/Inventor/fields/SoSFVec3f.h:43
#5 0x00007fffc59d7e0a in SketcherGui::ViewProviderSketch::drawConstraintIcons (this=0x21ca220) at /home/sponssi/devel/sketchericons/source/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp:2061
#6 0x00007fffc59e29e7 in SketcherGui::ViewProviderSketch::draw (this=0x21ca220, temp=true) at /home/sponssi/devel/sketchericons/source/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp:3077
#7 0x00007fffc59e4762 in SketcherGui::ViewProviderSketch::updateData (this=0x21ca220, prop=0x21c9f40) at /home/sponssi/devel/sketchericons/source/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp:3276
#8 0x00007ffff76b10b8 in Gui::ViewProvider::update (this=0x21ca220, prop=0x21c9f40) at /home/sponssi/devel/sketchericons/source/src/Gui/ViewProvider.cpp:219
#9 0x00007ffff745ff93 in Gui::Document::slotChangedObject (this=0x1f826c0, Obj=..., Prop=...) at /home/sponssi/devel/sketchericons/source/src/Gui/Document.cpp:451
#10 0x00007ffff7470fdc in boost::_mfi::mf2<void, Gui::Document, App::DocumentObject const&, App::Property const&>::operator() (this=0x1f83570, p=0x1f826c0, a1=..., a2=...) at /usr/include/boost/bind/mem_fn_template.hpp:280
The beginning of the backtrace seemed to be always the same, but the end parts differed from eachother. I didn't look into this any deeped.
I hope this helps in fixing the problems.
- Attachments
-
- Napa.fcstd
- (45.25 KiB) Downloaded 53 times
Re: Reworked Sketcher constraint icons
Thanks sponssi!
Your selection issue is definitely valid, I just wanted to be sure that the new grouping scheme works before writing the code to select individual icons out of a group. If people like the current scheme, then I'll work on selecting individual constraints.
I agree that orienting icons with the objects that they're attached to would be nice, but it looks like it would be a lot of work to do properly. I'd like to get a bit more comfortable with other parts of FreeCAD before jumping into this one, because I think the best solution will be to make up a new class of "meta objects" above the Sketcher level. These meta objects would include things like the constraint icons, but also measurements, reference points, grids, etc. Rendering of meta objects would work a little differently than for regular objects, because they'd need to move around to minimise overlapping depending on the camera position, be visible "through" regular objects, etc.
Think the issue with moving the rectangle is probably normal solver behaviour, but I'll play around with that in case it's a bug in my code.
Will have a look at your SIGSEVs tonight - probably has something to do with adding nodes into the constraint tree in Coin. Thanks for the info, and the example file to play with! -Ian-
Your selection issue is definitely valid, I just wanted to be sure that the new grouping scheme works before writing the code to select individual icons out of a group. If people like the current scheme, then I'll work on selecting individual constraints.
I agree that orienting icons with the objects that they're attached to would be nice, but it looks like it would be a lot of work to do properly. I'd like to get a bit more comfortable with other parts of FreeCAD before jumping into this one, because I think the best solution will be to make up a new class of "meta objects" above the Sketcher level. These meta objects would include things like the constraint icons, but also measurements, reference points, grids, etc. Rendering of meta objects would work a little differently than for regular objects, because they'd need to move around to minimise overlapping depending on the camera position, be visible "through" regular objects, etc.
Think the issue with moving the rectangle is probably normal solver behaviour, but I'll play around with that in case it's a bug in my code.
Will have a look at your SIGSEVs tonight - probably has something to do with adding nodes into the constraint tree in Coin. Thanks for the info, and the example file to play with! -Ian-
Re: Reworked Sketcher constraint icons
Hi sponssi, I think I've fixed the bug you reported - mind having a try at reproducing it again? Thanks! -Ian-
Re: Reworked Sketcher constraint icons
Hi Ian!
Very nice this thing you did with the constraints! The visualization as it is now I like it. Unfortunately, I can not test at the moment.
One thing I have realised about constraints (without your "patch"), is that sometimes it is even difficult to identify the symbol when the lines overlap the constraints, see for example this symetry constraint:
I think from your screenshoot that you have implemented some kind of offset, so that the lines of the symbols do not overlap with the geometric object, e.g. line, arc, circle, (or the overlap is minimal). I am very thankful for this.
Well done!
Very nice this thing you did with the constraints! The visualization as it is now I like it. Unfortunately, I can not test at the moment.
One thing I have realised about constraints (without your "patch"), is that sometimes it is even difficult to identify the symbol when the lines overlap the constraints, see for example this symetry constraint:
I think from your screenshoot that you have implemented some kind of offset, so that the lines of the symbols do not overlap with the geometric object, e.g. line, arc, circle, (or the overlap is minimal). I am very thankful for this.
Well done!
Re: Reworked Sketcher constraint icons
Not really, what I've done is more about keeping the constraint icons from overlapping with other constraint icons in some specific cases. What you're suggesting would be nice, but I think it would require a bit more thinking and work to accomplish.I think from your screenshoot that you have implemented some kind of offset, so that the lines of the symbols do not overlap with the geometric object, e.g. line, arc, circle, (or the overlap is minimal).
No rush on testing, and thanks for the feedback! -Ian-
Re: Reworked Sketcher constraint icons
I quickly tested the most recent version and didn't experience any crashes or coin warnings. There were still some issues I noticed, two of them shown in the image below:
- An equality constraint applied to the vertical line and another one not shown in the image is not aligned to the other constraint icons and is selectable by its own.
- The perpendicular constraint 35 was initially applied to the lower horizontal line. When I added perpendicular constraint 37 to the upper horizontal line, 35 moved to this line also. This didn't happen every time I tried it with the same lines. The lower line still seems to be perpendicular to the vertical line, since moving the rightmost point doesn't change the line direction.
* I just tried adding another line below the two lines and applied perpendicularity to the vertical line. Now all the icons jumpd to the new line. All lines seem to be perpendicular. And yes, the constraint icons seem to jump to the most recent line drawed. The other group with the equality and a verticality on the line not shown hasn't jumped anywhere.
- I thought an redundant horizontal might have been added when adding the perpendicularity, but I guess it was just due to the icon jumping.
I can take another look once the icons stick to the proper lines.
I haven't had the time to take a look at the code and thus have no idea how you did the positioning, or how it worked originally. But since you can position the icons somehow and the offset line was mentioned, would it be possible to calculate the offset line, simply find n points on it for the n icons, equidistant from each other around the midpoint of the offset line, and place the icons to these points. This way icon alignment could be seen in action without too much effort.
- An equality constraint applied to the vertical line and another one not shown in the image is not aligned to the other constraint icons and is selectable by its own.
- The perpendicular constraint 35 was initially applied to the lower horizontal line. When I added perpendicular constraint 37 to the upper horizontal line, 35 moved to this line also. This didn't happen every time I tried it with the same lines. The lower line still seems to be perpendicular to the vertical line, since moving the rightmost point doesn't change the line direction.
* I just tried adding another line below the two lines and applied perpendicularity to the vertical line. Now all the icons jumpd to the new line. All lines seem to be perpendicular. And yes, the constraint icons seem to jump to the most recent line drawed. The other group with the equality and a verticality on the line not shown hasn't jumped anywhere.
- I thought an redundant horizontal might have been added when adding the perpendicularity, but I guess it was just due to the icon jumping.
I can take another look once the icons stick to the proper lines.
I haven't had the time to take a look at the code and thus have no idea how you did the positioning, or how it worked originally. But since you can position the icons somehow and the offset line was mentioned, would it be possible to calculate the offset line, simply find n points on it for the n icons, equidistant from each other around the midpoint of the offset line, and place the icons to these points. This way icon alignment could be seen in action without too much effort.