| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | """Provides GUI tools to enable and disable the working plane grid.""" |
| | |
| | |
| | |
| |
|
| | |
| | |
| | from PySide.QtCore import QT_TRANSLATE_NOOP |
| |
|
| | import FreeCAD as App |
| | import FreeCADGui as Gui |
| | import WorkingPlane |
| |
|
| | from draftguitools import gui_base |
| | from draftutils import gui_utils |
| | from draftutils.translate import translate |
| |
|
| |
|
| | class ToggleGrid(gui_base.GuiCommandSimplest): |
| | """The Draft ToggleGrid command definition. |
| | |
| | If the grid tracker is invisible (hidden), it makes it visible (shown); |
| | and if it is visible, it hides it. |
| | |
| | It inherits `GuiCommandSimplest` to set up the document |
| | and other behavior. See this class for more information. |
| | """ |
| |
|
| | def __init__(self): |
| | super().__init__(name=translate("draft", "Toggle Grid")) |
| |
|
| | def GetResources(self): |
| | """Set icon, menu and tooltip.""" |
| | return { |
| | "Pixmap": "Draft_Grid", |
| | "Accel": "G, R", |
| | "MenuText": QT_TRANSLATE_NOOP("Draft_ToggleGrid", "Toggle Grid"), |
| | "ToolTip": QT_TRANSLATE_NOOP( |
| | "Draft_ToggleGrid", "Toggles the visibility of the Draft grid" |
| | ), |
| | "CmdType": "ForEdit", |
| | } |
| |
|
| | def IsActive(self): |
| | """Return True when this command should be available.""" |
| | return bool(gui_utils.get_3d_view()) |
| |
|
| | def Activated(self): |
| | """Execute when the command is called.""" |
| | super().Activated() |
| |
|
| | if not hasattr(Gui, "Snapper"): |
| | return |
| | Gui.Snapper.setTrackers(update_grid=False) |
| | grid = Gui.Snapper.grid |
| | |
| | cmdactive = hasattr(App, "activeDraftCommand") and App.activeDraftCommand |
| |
|
| | if grid.Visible: |
| | grid.off() |
| | grid.show_always = False |
| | if cmdactive: |
| | grid.show_during_command = False |
| | elif cmdactive: |
| | grid.set() |
| | grid.show_during_command = True |
| | else: |
| | grid.set() |
| | WorkingPlane.get_working_plane() |
| | grid.show_always = True |
| |
|
| |
|
| | Gui.addCommand("Draft_ToggleGrid", ToggleGrid()) |
| |
|
| | |
| |
|