NEW FEATURE ! Sketcher Tool Settings.

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!
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by paddle »

So after further analysis and debugging the tools is working pretty well.
Now the only issue is : When the task window has focus (anywhere on the task, not only my widget), then pressing escape exit the edit instead of closing the sketchHandler. Beside I can't find a way to send other keypresses to the sketchHandler (for the mode change of polyline for instance).

As the edit still exit, I thought ViewProviderSketch::keyPressed is still triggered, but in fact no. The Escape key must be processed somewhere else and close the edit as well.

Code: Select all

bool ViewProviderSketch::keyPressed(bool pressed, int key)
I tried to figure it out but I'm out of my depth. Maybe a SketchViewProvider wizard could help me? Abdullah? :D
abdullah wrote: Sat Jan 08, 2022 6:59 pm Ping
Branch : https://github.com/PaddleStroke/FreeCAD ... ToolWidget
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by paddle »

paddle wrote: Sun Jan 16, 2022 7:17 am So after further analysis and debugging the tools is working pretty well.
Now the only issue is : When the task window has focus (anywhere on the task, not only my widget), then pressing escape exit the edit instead of closing the sketchHandler. Beside I can't find a way to send other keypresses to the sketchHandler (for the mode change of polyline for instance).

As the edit still exit, I thought ViewProviderSketch::keyPressed is still triggered, but in fact no. The Escape key must be processed somewhere else and close the edit as well.

Code: Select all

bool ViewProviderSketch::keyPressed(bool pressed, int key)
I tried to figure it out but I'm out of my depth. Maybe a SketchViewProvider wizard could help me? Abdullah? :D
abdullah wrote: Sat Jan 08, 2022 6:59 pm Ping
Branch : https://github.com/PaddleStroke/FreeCAD ... ToolWidget
This has been solved!
I added sketchView pointer to the widget parameters to access it's presskey function.

Ok So now it's working and with no issue.

I replaced the M shortcut to switch mode with the Shift key. The reason is that M key is catched by the spinbox when user type (he may want to type the unit (mm))

One detail that I want to do is that after entering a parameter in the tool setting widget, for the geometry to update you need to move the mouse. So I want to call

Code: Select all

ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventorViewer *viewer) 
from my widget. My problem is what parameters to feed to this function?
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by paddle »

paddle wrote: Sun Jan 16, 2022 7:17 am I tried to figure it out but I'm out of my depth. Maybe a SketchViewProvider wizard could help me? Abdullah? :D
abdullah wrote: Sat Jan 08, 2022 6:59 pm Ping
This has been solved!
I added sketchView pointer to the widget parameters to access it's presskey function.

Ok So now it's working and with no issue.

I replaced the M shortcut to switch mode with the Shift key. The reason is that M key is catched by the spinbox when user type (he may want to type the unit (mm))

Edit: this is solved:
One detail that I want to do is that after entering a parameter in the tool setting widget, for the geometry to update you need to move the mouse. So I want to call

Code: Select all

ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventorViewer *viewer) 
from my widget. My problem is what parameters to feed to this function?
Last edited by paddle on Mon Jan 17, 2022 12:56 pm, edited 2 times in total.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by adrianinsaval »

paddle wrote: Mon Jan 17, 2022 12:28 pm I replaced the M shortcut to switch mode with the Shift key. The reason is that M key is catched by the spinbox when user type (he may want to type the unit (mm))
I don't like this solution too much, does it really need to capture all keyboard input? I'm not sure if shift is a good alternative either. Could it maybe start capturing that only after pressing tab? I must admit I have a hard time thinking of good alternatives :oops:
Also do you have a demo for how this works with polyline? I'm curious to know how you plan to handle all the different modes it has.
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by paddle »

adrianinsaval wrote: Mon Jan 17, 2022 12:44 pm
paddle wrote: Mon Jan 17, 2022 12:28 pm I replaced the M shortcut to switch mode with the Shift key. The reason is that M key is catched by the spinbox when user type (he may want to type the unit (mm))
I don't like this solution too much, does it really need to capture all keyboard input? I'm not sure if shift is a good alternative either. Could it maybe start capturing that only after pressing tab? I must admit I have a hard time thinking of good alternatives :oops:
Also do you have a demo for how this works with polyline? I'm curious to know how you plan to handle all the different modes it has.
The thing is that M key is captured in the case user wants to write an M (if he wants to write the unit 'mm' for instance.). We could try to have the spinbox capture the M press and pass the event down below. But that means it would write an M everytime you change mode. So that's bad.

Why don't you like the shift key? It changes habits which is bad, but beside that? End position is better.
Or is it used in another way? Ctrl is used for snapmod for instance so it can't be used.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by adrianinsaval »

I think I expressed myself incorrectly. Shift could very well be a good key choice, I don't know. From previous discussions it seems choosing key shortcuts is a big deal and should be done carefully, IIRC people didn't want many shortcuts that used Shift, Ctrl and Alt because they easily interfered with other shortcuts. Not sure if using Shift on its own is ok or will give problems somewhere else.
I personally think Alt is a little more fitting as it will switch to alternative modes for the tool, I don't know if using Alt is ok either, maybe abdullah would know.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by GeneFC »

adrianinsaval wrote: Mon Jan 17, 2022 1:07 pm I personally think Alt is a little more fitting as it will switch to alternative modes for the tool, I don't know if using Alt is ok either, maybe abdullah would know.
I have one computer where the left and right ALT keys are identical in function. I have another computer in which they are somewhat different in function.

Both computers are using a standard keyboard and both are using English language. Both are on the same version of Windows.

I do not know why this situation exists, but that sort of difference could cause problems if ALT is chosen as the shortcut key.

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

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by adrianinsaval »

usually left is alt and rigth is alt gr, sometimes they make both of them alt but I've never seen both them as alt gr so I think it's unlikely that we would have an issue with that if we set it to alt
User avatar
-alex-
Veteran
Posts: 1856
Joined: Wed Feb 13, 2019 9:42 pm
Location: France

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by -alex- »

Thanks @paddle for the great job done here.
But please do not use Maj or CTRL keys as shortkeys because Maj+RMB and CTRL+RMB are already used to rotate and pan in 3D view, even in sketch editing mode (a bit buggy in this mode BTW) . Rotate and pan this way is very useful to avoid carpal tunnel syndrom.
Last edited by -alex- on Mon Jan 17, 2022 3:33 pm, edited 1 time in total.
User avatar
paddle
Veteran
Posts: 1392
Joined: Mon Feb 03, 2020 4:47 pm

Re: NEW FEATURE ! Sketcher Tool Settings.

Post by paddle »

GeneFC wrote: Mon Jan 17, 2022 2:26 pm
adrianinsaval wrote: Mon Jan 17, 2022 1:07 pm I personally think Alt is a little more fitting as it will switch to alternative modes for the tool, I don't know if using Alt is ok either, maybe abdullah would know.
I have one computer where the left and right ALT keys are identical in function. I have another computer in which they are somewhat different in function.

Both computers are using a standard keyboard and both are using English language. Both are on the same version of Windows.

I do not know why this situation exists, but that sort of difference could cause problems if ALT is chosen as the shortcut key.

Gene
QT event take both alts in it's event. Same for shift/ctrl. While SoKeyboardEvent can make the difference between right and left.
But as some keyboard hardware don't make different keys for them, then it's not reliable to use only left of right as shortcut. So in the code currently both shift trigger the tool.

I think american keyboards don't have altgrp key. They have 2 alt keys.
-alex- wrote: Mon Jan 17, 2022 3:29 pm Thanks @paddle for the great job done hère.
But please do not use Maj or CTRL keys as shortkeys because Maj+RMB and CTRL+RMB are already used to rotate and pan in 3D view, even in sketch editing mode. Rotate and pan this way is very useful to avoid carpal tunnel syndrom.
By maj do you mean caplocks or shift?
Post Reply