New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft toggle grid as a toggle button to indicate grid visibility #13972
base: main
Are you sure you want to change the base?
Conversation
993b542
to
c1f6af7
Compare
Nice improvement, I can confirm that it works properly. If the PR is ready to merge, can you undraft it? |
CAn we set the color of this grid already in a preference pack or stylesheet? |
@FEA-eng thank you for testing. Credit (as per commit authorship) goes to @MisterMakerNL I'm not sure I understand the question. Do you mean if the grid itself is themeable? If so, I don't have the answer, this PR deals only with the button to toggle the grid on and off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. There are some issues. The code does not handle multiple documents properly.
Scenario:
- Start FreeCAD.
- Create a document.
- Switch to the Draft WB.
- Grid is visible. Grid button appears checked. OK.
- Create another document.
- Grid is visible. Grid button appears checked. OK.
- Switch off the grid in the 2nd document.
- Switch back to the 1st document.
- Grid is visible. Grid button appears unchecked. Problem.
- Push the Grid button.
- Grid is invisible. Grid button appears unchecked. OK.
- Start a command, for example Draft_Circle.
- Grid is visible. Grid button appears unchecked. Problem.
I am surprised that both Grid buttons are updated separately. They belong to the same action.
Another problem:
Also the entry in the Utilities menu is not updated. Maybe handling this via the action is better. But I am not sure how that can be accomplished. |
This works (tested with the current dev version, not with the code of this PR):
|
@furgo16 I know this is a new PR but also on this one the heads up for the upcoming feature freeze on 2024-06-03 |
c1f6af7
to
9de0370
Compare
@Roy-043 thanks. That looks promising, as it sets the button status on all toolbars at once. However, as a quick test I simply added the following to the current action = FreeCADGui.Command.get("Draft_ToggleGrid").getAction()[0]
action.setCheckable(tbButtonEnabled)
action.setChecked(tbButtonChecked) I'm not sure if it's the actual cause, but having that last statement ( Traceback (most recent call last):
File "$HOME/dev/furgo16/FreeCAD/build/Mod/Draft/draftguitools/gui_grid.py", line 91, in Activated
WorkingPlane.get_working_plane()
File "$HOME/dev/furgo16/FreeCAD/build/Mod/Draft/WorkingPlane.py", line 1752, in get_working_plane
wp._update_all(_hist_add=False)
File "$HOME/dev/furgo16/FreeCAD/build/Mod/Draft/WorkingPlane.py", line 1687, in _update_all
self._update_grid()
File "$HOME/dev/furgo16/FreeCAD/build/Mod/Draft/WorkingPlane.py", line 1724, in _update_grid
FreeCADGui.Snapper.setGrid()
File "$HOME/dev/furgo16/FreeCAD/build/Mod/Draft/draftguitools/gui_snapper.py", line 1585, in setGrid
self.setTrackers()
File "$HOME/dev/furgo16/FreeCAD/build/Mod/Draft/draftguitools/gui_snapper.py", line 1590, in setTrackers
v = Draft.get3DView()
File "$HOME/dev/furgo16/FreeCAD/build/Mod/Draft/draftutils/gui_utils.py", line 67, in get_3d_view
import FreeCADGui as Gui
RecursionError: maximum recursion depth exceeded
Running the Python command 'Draft_ToggleGrid' failed, try to resume |
Try removing: |
@@ -62,7 +63,7 @@ def GetResources(self): | |||
"Toggles the Draft grid on and off."), | |||
"CmdType": "ForEdit"} | |||
|
|||
def Activated(self): | |||
def Activated(self, index = 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXME: I need to find out where this comes from and if it's needed. At the moment, it seems the index
parameter is unused.
Update after a quick test:
I'm not sure where to start looking to address the first point. For the rest and general testing, if someone who's interested in this feature wants to give this a go and report back, feedback will be welcome. |
Switching to the I don't think there is a need to change gui_grid.py. This may have been required before though. The references to the Draft Tray and the draftToolBar (which both point to the same GUI element) are not relevant. The code does not interact with the Tray.
It may be worth considering merging the code with WorkingPlane.py. We can then use a single view observer. And there is the intention to make the grid a property of the working plane in the future. I can help with the multi-document issue if you want. Either with a pointer (look there...) or with code. Just let me know. |
Thanks. We can start with the "teach a man how to fish" approach with pointers, and I can ask for further help where I get stuck. That said, I'll be cutting down my contribution time in the next few weeks, but I'll do my best to wrap up this PR before the 1.0 feature freeze. |
OK, the pointer then 😉
|
Fixes #13527
Makes the button for the Draft_ToggleGrid command act as a real toggle button:
Similar in spirit to the behavior of the Sketcher_Grid command, which is also a toggle button.
Submitting as authored and suggested by @Syres916 at #13527 (comment).