[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: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

paddle wrote: Mon Jan 24, 2022 5:53 pm 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?
I found a way to do that.
Now if the tool is aborted, all changes are undone. Also it let us change of constraint mode.

So I removed the 0/90 angle replacement by parallel/perpendicular and added shift alternative when 2 lines are selected.
Haavard wrote: Tue Jan 25, 2022 12:00 ambing
Branch has been update if you want to try modifications and help spot errors/bugs.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by adrianinsaval »

as said before, geometrical constraints are preferred so I think it was good that 0 and 90 were replaced by parallel and perpendicular constraints by default. What's the rationale behind changing this? Replacing 0 distance with coincident is a good idea too. Every time it makes sense it would be better to replace with geometrical constrains.
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

adrianinsaval wrote: Tue Jan 25, 2022 7:02 pm as said before, geometrical constraints are preferred so I think it was good that 0 and 90 were replaced by parallel and perpendicular constraints by default. What's the rationale behind changing this? Replacing 0 distance with coincident is a good idea too. Every time it makes sense it would be better to replace with geometrical constrains.
Hmm the idea was to keep the angle to be able to change if if necessary. As parallel and perpendicular can be made easily with the SHIFT key.
But I can put it back on.

Though keep in mind that it's only when using the contextual constrain tool. If you change the angle later it will stay 90 or 180. This would need a larger scope modification.
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: Tue Jan 25, 2022 7:23 pm Though keep in mind that it's only when using the contextual constrain tool. If you change the angle later it will stay 90 or 180. This would need a larger scope modification.
That's ok, changing an already set angle constrain would be annoying, I only meant that it would be best if this tool prefers geometrical as that is the recommended method. This will result in better constrained sketches from newbies, is this auto change previewed somewhere? If not that might be a good improvement so people realize it and switch to angle for the cases were they might want to change them later. Note that I've still hadn't had the time to test this feature so this is all based on what I'm reading here.
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Haavard »

Testing now 8-)

The tool is a bit to advanced to just test "blind", so i will try to write down what i expect to happen, and then see what actually happens. And when this get merged, it will require proper documentation, and probably a nice video tutorial.

I find using shift to cycle between possible constants to be quick and nice, and very easy to reach for us right handed people.
And good job on getting both the new hints, and the geometry, to update in real time on each constraint change! :D So cool!

As mentioned, i think geometry constraints should be used as much as possible, and i think this also is considered best practice. This also leads to more robust and less cluttered sketches. Take a look at crisb's sketcher book for more information.
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

Haavard wrote: Tue Jan 25, 2022 12:00 am
  • 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.
What is the shortcut to toggle construction geometry while creating geometry tools? I can't find it.

I found a way to filter the keys. (in TaskSketcherTool.cpp event filter for future reference)

So we need to find which keys to filter out of the spinbox.

What shortcuts are used while creating geometries or creating constraints?

Beside I was thinking about using the SPACE key to alternate the available constraints and alternate polyline tool. And I was thinking that SHIFT could be used to toggle construction geometry.

My reasoning is that SHIFT key launchs the annoying sticky keys when pressed 5+ times on windows. So when you're alternating the available constraints (or the polyline modes), it gets triggered often and it's annoying.
Also space is big and very accessible, and seems to be available. Also the spinbox doesn't need space key.
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Haavard »

Good idea! I have X set to toggle normal/construction, but i don't know what the default is. And these shortcuts are being refractored anyway, so who knows what will land :)

Space to cycle should work just fine.
Edit: as long as it doesn't hide/show my sketch because sketch is active in tree view :lol:
User avatar
Chrismettal
Posts: 43
Joined: Fri Sep 18, 2020 11:44 am
Location: Germany
Contact:

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Chrismettal »

paddle wrote: Fri Jan 21, 2022 9:34 am
Haavard wrote: Thu Jan 20, 2022 11:34 pm 2: Other software will automatically switch between horizontal length, vertical length or distance, based on mouse position:

- Say you click on line A, you will only get vertical length as an option, or horizontal for B.
- If you click C, the position of the mouse in relation to the "projection" of the line will determine if distance or horizontal/vertical length should be applied.
That's it it's working and it's awesome! Thanks for the idea!
Thank you so much for this. This is exactly how I imagined "Shift+D" length constraint to work all along. This alone will save so many headaches when viewing a sketch at an angle and straight up guessing if the length you want to constaint is horizontal or vertical.
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by paddle »

Haavard wrote: Tue Jan 25, 2022 8:19 pm Testing now 8-)

The tool is a bit to advanced to just test "blind", so i will try to write down what i expect to happen, and then see what actually happens. And when this get merged, it will require proper documentation, and probably a nice video tutorial.

I find using shift to cycle between possible constants to be quick and nice, and very easy to reach for us right handed people.
And good job on getting both the new hints, and the geometry, to update in real time on each constraint change! :D So cool!

As mentioned, i think geometry constraints should be used as much as possible, and i think this also is considered best practice. This also leads to more robust and less cluttered sketches. Take a look at crisb's sketcher book for more information.
Oh it's a user defined key? Where is it? in preferences?
Haavard
Posts: 217
Joined: Wed Feb 17, 2021 10:48 pm

Re: NEW FEATURE ! Sketcher Constrain Contextually

Post by Haavard »

To switch between normal and construction geometry? Yes i added a custom shortcut, don't know if it has a default shortcut.
Post Reply