Skip to content

Commit

Permalink
[WIP][Draft] Grid redrawing at new document or parameter change
Browse files Browse the repository at this point in the history
  • Loading branch information
0penBrain committed Jan 24, 2022
1 parent 1e4da60 commit d24821c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Mod/Draft/InitGui.py
Expand Up @@ -137,6 +137,12 @@ def QT_TRANSLATE_NOOP(context, text):
FreeCADGui.addPreferencePage(":/ui/preferences-drafttexts.ui", QT_TRANSLATE_NOOP("Draft", "Draft"))
FreeCADGui.draftToolBar.loadedPreferences = True

# Attach document observer
FreeCADGui.addDocumentObserver(self)

# Attach parameter observer
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").Attach(self)

FreeCAD.Console.PrintLog('Loading Draft workbench, done.\n')

def Activated(self):
Expand Down Expand Up @@ -167,6 +173,19 @@ def GetClassName(self):
"""Type of workbench."""
return "Gui::PythonWorkbench"

def slotActivateDocument(self, doc):
"""Called when a document is activated"""
if FreeCADGui.Snapper:
FreeCADGui.Snapper.setGrid()

def onChange(self, paramGrp, param):
"""Called when a parameter is changed"""
if param in ['grid','gridEvery','gridSize','gridTransparency','gridSpacing',
'alwaysShowGrid','gridBorder','gridShowHuman','coloredGridAxes',
'gridColor']:
if hasattr(FreeCADGui, 'Snapper') and hasattr(FreeCADGui.Snapper, 'grid'):
if FreeCADGui.Snapper.grid:
FreeCADGui.Snapper.grid.reset()

FreeCADGui.addWorkbench(DraftWorkbench)

Expand Down

0 comments on commit d24821c

Please sign in to comment.