[New feature] Sketcher Constrain Contextually

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

Haavard wrote: Sun Jan 23, 2022 8:18 pm I'm unfortunately not able to compile, even with my corrections. PS, i have not studied the code, only tried to fix with the compile errors, so please check if those are actual corrections. I could make a PR, but it wont change the "not compilable" issue ;)
This is going to be very painful to debug as I don't have any error on VS!

First thing, FreecadCI also posted a message on the toolWidget PR. So that points to the fact that the error is on the tool Setting Widget. prvMoveCursorPos feels like a good candidate for the issue.

I checked and just adding static I get a compile error. So I checked how the DoubleClick struct is doing things and it seems they declare the SbVec2s variables in the cpp file. So I added the same in the .cpp :

Code: Select all

SbVec2s ViewProviderSketch::prvMoveCursorPos;
While in .h it's now :

Code: Select all

    static SbVec2s prvMoveCursorPos;
It compiles, I get no error and it still works as expected on my end.
Can you check if it works?

I added this prvMoveCursorPos variable to be able to have the cursor position available from the task setting widget. This way the widget can trigger the tool handler mousemove updating the geometry without having to move the mouse. If the problem persist, can you try removing the prvMoveCursorPos variable from ViewProviderSketch.cpp/.h and from TaskSketcherTool.cpp? See if it compiles then.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by adrianinsaval »

What about using the state of the auto/radius/diameter tool to decide which to use? And have m/shift/whateverKeyWIthEndUpUsingInPolyline to switch between them when needed? Actually it would be nice to have that as a general key to switch between the different constraint possibilities for the selected geometries.

I'll see if I can try to compile later. You could try building in a docker container were you most likely will get the errors so you can debug, I think MSVC might be able to compile because of the precompiled headers (whatever they are, I never compiled on windows but I've seen that was mentioned as the cause of undetected missing includes before)
cadcam
Posts: 273
Joined: Thu Apr 02, 2020 10:39 am

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by cadcam »

Actually it would be nice to have that as a general key to switch between the different constraint possibilities for the selected geometries.
Thinking aloud, would it be possible to do something just using the mouse. e.g. click RH mouse button to end action, hold RH mouse button down to have a context sensitive pullout menu of change options (as icons)

BW
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

adrianinsaval wrote: Mon Jan 24, 2022 2:20 pm What about using the state of the auto/radius/diameter tool to decide which to use? And have m/shift/whateverKeyWIthEndUpUsingInPolyline to switch between them when needed? Actually it would be nice to have that as a general key to switch between the different constraint possibilities for the selected geometries.

I'll see if I can try to compile later. You could try building in a docker container were you most likely will get the errors so you can debug, I think MSVC might be able to compile because of the precompiled headers (whatever they are, I never compiled on windows but I've seen that was mentioned as the cause of undetected missing includes before)
That's a good idea. Though the auto/radius/diameter tool comp reset at every restart of the system no? Or is there a preference setting already to decides which tool is set the comp?

Yes I currently setup Shift key to change constrain when other are available. Though so far the changes I found that made sens are :
- 1 point selected : distanceX+Y to origin (lock)/distanceX to origin/distance Y to origin.
- 1 circle selected : radius/diameter.

I was thinking that one line could also change between distances/vertical/horizontal but it needs the geometry to not solve directly when vertical/horizontal are applied as it is currently happening.

If you can try to compile that'd be awesome. I'm pants at IDE so I have a feeling that this docker container will take me ages to get rolling.
You are right precompiled header sounds like it could be the source of the problem. Maybe I should rebuild the whole project to check for error.
cadcam wrote: Mon Jan 24, 2022 3:08 pm Thinking aloud, would it be possible to do something just using the mouse. e.g. click RH mouse button to end action, hold RH mouse button down to have a context sensitive pullout menu of change options (as icons)

BW
Yes that'd be possible, but it needs much more work to get the menu.
cadcam
Posts: 273
Joined: Thu Apr 02, 2020 10:39 am

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by cadcam »

Yes that'd be possible, but it needs much more work to get the menu.
That is a shame, I could see it being useful to a newbie (or experienced using a constraint)
they don't often use. Also, if a standard fuction, being added in other places to aid access
to other easily edit functions, e.g. flipping pads, changing hole parameters without
having to move to the side and back.

Thanks for all the work you have put in it looks as if it will be a really nice addition
to FC.

BW
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

cadcam wrote: Mon Jan 24, 2022 4:05 pm
Yes that'd be possible, but it needs much more work to get the menu.
That is a shame, I could see it being useful to a newbie (or experienced using a constraint)
they don't often use. Also, if a standard fuction, being added in other places to aid access
to other easily edit functions, e.g. flipping pads, changing hole parameters without
having to move to the side and back.

Thanks for all the work you have put in it looks as if it will be a really nice addition
to FC.

BW
Let's see if this gets integrated already :)
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by GeneFC »

cadcam wrote: Mon Jan 24, 2022 3:08 pm Thinking aloud, would it be possible to do something just using the mouse. e.g. click RH mouse button to end action, hold RH mouse button down to have a context sensitive pullout menu of change options (as icons)
Anything using mouse alone is at serious risk of running into conflict with some mouse model.

Gene
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by adrianinsaval »

paddle wrote: Mon Jan 24, 2022 3:33 pm I was thinking that one line could also change between distances/vertical/horizontal but it needs the geometry to not solve directly when vertical/horizontal are applied as it is currently happening.
why? are you keeping the same constraint values when switching from one to the next? I don't see why it would change geometry otherwise
User avatar
paddle
Veteran
Posts: 1391
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

adrianinsaval wrote: Mon Jan 24, 2022 4:35 pm why? are you keeping the same constraint values when switching from one to the next? I don't see why it would change geometry otherwise
It's because of the way the tool works. It actually creates the constraint at every step. Then delete and recreate the constraints on each steps. And if the tool abort (right click) then it delete the last seen constraint.
So the vertical/horizontal would get applied (as the equality for 2+ circles is which is not ideal) and the geometry would update to be vertical/horizontal. Even if the tool abort and the constraint is deleted the geometry would have moved.
Or I need a way to cancel (ctrl-z not just delete) the vertical/horizontal constraint. Is that possible from the code?
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Haavard »

Just compiled and tested this PR.

Yeah. Sketcher just got a new queen. This tool is in my opinion insanely powerful, even more than polyline. Absolutely wonderful job here paddle!

So far it almost totally replaces; radius, horizontal length, vertical height, distance, coincident, point-on-object, angle, equal, perpendicular, parallel and lock. In ONE TOOL! And it is really intuitive to use. :shock:

Using shift to toggle between polyline is also really nice, easier to find than M and very easy to get used to. Using Shift to also cycle between constraint type is very intuitive.

I will finish a small project using this tool this week, but for now i have some small ideas and feedback:
  • It would be nice if you could just press enter without having to type '0' first, since '0.00' is the default in tool settings.
  • When you click a first point, the tool defaults to lock (X and Y lengths). I rarely use lock, and this clutters the mouse pointer and makes it hard to select the second point. How about the default is no constraint, and you can cycle using shift, just as it works now, to lock, x and y?
  • This tool is so powerful it could be a bit difficult to learn all the features by testing. It would be cool with a hint somewhere, perhaps above the numbers in Tool settings. For example, you click two lines, and get asked to input angle. Then the hint could say "Input 0 ° for parallel, or 90 ° for perpendicular constraint". Or even better, if you could press shift so cycle between angle, parallel, perpendicular and tangent..?
  • Is there a need to accept letters in the number box? It already displays the default document units. Because of this keyboard shortcuts does not work when creating geometry, and i often like to switch between normal and construction geometry using a shortcut when sketching. This way those preferring M for polyline would not have an issue.
  • Could double clicking be used? Say i want to constrain two points witch coincident. Now i click the first, then the second, input 0, then enter. It would be nice to click the first, then doubleclick the second to apply coincident. Also if i press a line, and would like to make it equal to another line, i could doubleclick the second line, sort of like if i was clicking on three lines. And you could create coincident constraint on multiple points this way, by clicking on many points and doubleclicking the last point.
  • When creating geometry, if 0mm x or y is input, it is probably better to use coincident or point-on-object instead of 0mm distance. Either coincident to origin if both is 0, or point on object to one axis if one is zero.
  • After constraining, you must verify by left clicking, and right clicking disregards the last constraints and the tool. It is a bit weird at first, but now i kind of like it.
  • The name and icon could definitely be better. I know "Smart constraint" it perhaps a bit disliked by some, but maybe something similar? It would at least be fitting for this tool. "Contextual Constraint" would tell me absolutely nothing if i didn't know about it beforehand. Super constrain? Multi constrain? Genius constrain? Any other ideas?
  • Creating a new settings block in Preferences -> Sketcher is probably needed. When people begin to use this i guess many will have their own preferences between tool cycling, default settings e.g. And even if i think the auto radius/diameter should be default for curves, it would be nice to have it as an option in settings for those who disagree.

    These are only suggestions, not criticism :)

I just have to repeat myself: even in this alpha state, this tool is incredible. No more click - search toolbar - click - search toolbar. Just select the tool and constrain away. 2022 just got a lot better :D
Post Reply