Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by Kunda1 »

issue #1951: Draft workbench preferences snap settings does not use "units" settings
In preferences general select an imperial units. Go to draft workbench then bring preferences up. Select draft->snap settings. Grid spacing is always mm
Ticket1951.png
Ticket1951.png (71.04 KiB) Viewed 3826 times
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by yorik »

All Draft/Arch prefs settings are in millimeters still.... Couldn't find out how to use the InputField widget in qt designer yet
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by Kunda1 »

Couldn't find out how to use the InputField widget in qt designer yet
Anyone know anything about this?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by Kunda1 »

Attached screenshot above instead of linking to the tracker link of the image
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by Kunda1 »

openBrain wrote:
@openBrain can you take a stab at this?
issue #1951
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by openBrain »

Kunda1 wrote: Sun Jan 23, 2022 1:39 am
openBrain wrote:
@openBrain can you take a stab at this?
issue #1951
Can give it a try in the coming week.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by Kunda1 »

openBrain wrote: Sun Jan 23, 2022 7:34 am Can give it a try in the coming week.
:pray:
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by openBrain »

Here's the basic fix as a PR : https://github.com/FreeCAD/FreeCAD/pull/5427

However I found 2 inconveniences with Draft grid :
* If Draft is already activated as a WB, when you create a new document grid isn't displayed, even if active. You have to disable + enable it again to get it.
* When the size in the preferences is changed, it isn't took into account immediately. You have to disable + enable grid to resize.

I'll try to fix this later. PR can be merged as is if needed, I'll eventually open, a new one. ;)
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by yorik »

openBrain wrote: Mon Jan 24, 2022 9:26 am* If Draft is already activated as a WB, when you create a new document grid isn't displayed, even if active. You have to disable + enable it again to get it.
There is no way for Draft to detect when a new document is created, unless we set up a document observer. At that time, I though this would be overkill, and preferred to have a check at the beginning of each Draft command to check and display the grid if needed. But document observers have evolved a lot, we could change our mind...
openBrain wrote: Mon Jan 24, 2022 9:26 am* When the size in the preferences is changed, it isn't took into account immediately. You have to disable + enable grid to resize.
Similar problem, there is no way for Draft to know when a preference has been changed. However, C++ preferences pages can trigger some action. Maybe there is a way to create a python function for that too...

There might be another way to solve these 2 issues at once, a QTimer that shoots at, say, each second (to not weight too much on the system), that would check both things and display the grid if needed...

Thanks for the PR! Looking at it ASAP
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Bug #1951: Draft workbench preferences snap settings does not use "units" settings

Post by openBrain »

yorik wrote: Mon Jan 24, 2022 1:01 pm There is no way for Draft to detect when a new document is created, unless we set up a document observer. At that time, I though this would be overkill, and preferred to have a check at the beginning of each Draft command to check and display the grid if needed. But document observers have evolved a lot, we could change our mind...
The idea is indeed to use a DocumentObserver.
Similar problem, there is no way for Draft to know when a preference has been changed. However, C++ preferences pages can trigger some action. Maybe there is a way to create a python function for that too...
Actually there is a way. You can attach a class to a parameter group whose 'onChange' function would be called when a parameter is changed inside the group. ;)

I started implemented something that you can see here : https://github.com/0penBrain/FreeCAD/co ... 12658da5df
Unfortunately I have several problems and now it would need more time that what I have ATM :
* Regarding DocumentObserver, but grid management in Draft (through the 'Snapper' tracker) is too complex (chunky ? :P) for me to achieve something working smoothly without having to deep dive into it
* Regarding parameter group 'Attach', it just doesn't work (the 'onChange' function isn't called). :? I can't know why because it perfectly works doing the same thing in a macro. :?:

If someone want to have a deeper look, feel free. ;)
Post Reply