forked from youen/assembly_handbook
Added button to redraw a page
This commit is contained in:
parent
477d49e1e8
commit
5f2bfc1f6f
@ -110,6 +110,9 @@ class AssemblyHandbookWorkbench(Gui.Workbench):
|
|||||||
toolbox.append("AHB_view_edit_source_parts")
|
toolbox.append("AHB_view_edit_source_parts")
|
||||||
toolbox.append("AHB_view_add_source_parts")
|
toolbox.append("AHB_view_add_source_parts")
|
||||||
toolbox.append("AHB_view_remove_source_parts")
|
toolbox.append("AHB_view_remove_source_parts")
|
||||||
|
|
||||||
|
self.importModule('ahb_cmd_view_refresh')
|
||||||
|
toolbox.append("AHB_view_refresh")
|
||||||
|
|
||||||
if self.dev:
|
if self.dev:
|
||||||
self.importModule('ahb_cmd_reload')
|
self.importModule('ahb_cmd_reload')
|
||||||
|
@ -86,11 +86,8 @@ class AHB_New_Step:
|
|||||||
obj.Assembly_handbook_PreviousStepView = view.Name
|
obj.Assembly_handbook_PreviousStepView = view.Name
|
||||||
print(obj.Label + ' has been moved after the new step')
|
print(obj.Label + ' has been moved after the new step')
|
||||||
|
|
||||||
if not page.KeepUpdated and len(view.XSource) > 0:
|
if len(view.XSource) > 0:
|
||||||
page.KeepUpdated = True
|
workbench.techDrawExtensions.forceRedrawPage(page)
|
||||||
def restoreKeepUpdated():
|
|
||||||
page.KeepUpdated = False
|
|
||||||
QTimer.singleShot(100, restoreKeepUpdated)
|
|
||||||
|
|
||||||
Gui.Selection.clearSelection()
|
Gui.Selection.clearSelection()
|
||||||
Gui.Selection.addSelection(page)
|
Gui.Selection.addSelection(page)
|
||||||
|
22
ahb_cmd_view_refresh.py
Normal file
22
ahb_cmd_view_refresh.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import FreeCADGui as Gui
|
||||||
|
import FreeCAD as App
|
||||||
|
|
||||||
|
class AHB_RefreshView:
|
||||||
|
def GetResources(self):
|
||||||
|
return {"MenuText": "Refresh page",
|
||||||
|
"ToolTip": "Redraws the current page",
|
||||||
|
"Pixmap": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
def IsActive(self):
|
||||||
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
|
||||||
|
return workbench.techDrawExtensions.getActivePage() is not None
|
||||||
|
|
||||||
|
def Activated(self):
|
||||||
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
|
||||||
|
page = workbench.techDrawExtensions.getActivePage()
|
||||||
|
if page is not None:
|
||||||
|
workbench.techDrawExtensions.forceRedrawPage(page)
|
||||||
|
|
||||||
|
from ahb_command import AHB_CommandWrapper
|
||||||
|
AHB_CommandWrapper.addGuiCommand('AHB_view_refresh', AHB_RefreshView())
|
@ -257,6 +257,12 @@ class TechDrawExtensions:
|
|||||||
balloon.ViewObject.Fontsize = 4
|
balloon.ViewObject.Fontsize = 4
|
||||||
balloon.BubbleShape = 'Inspection'
|
balloon.BubbleShape = 'Inspection'
|
||||||
balloon.EndTypeScale = 4
|
balloon.EndTypeScale = 4
|
||||||
|
|
||||||
|
def getActivePage(self):
|
||||||
|
activeView = Gui.activeView()
|
||||||
|
if activeView is None: return None
|
||||||
|
activePage = activeView.getPage() if hasattr(activeView, 'getPage') else None
|
||||||
|
return activePage
|
||||||
|
|
||||||
def getViewPage(self, view):
|
def getViewPage(self, view):
|
||||||
for obj in view.InList:
|
for obj in view.InList:
|
||||||
@ -265,6 +271,20 @@ class TechDrawExtensions:
|
|||||||
return obj
|
return obj
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def forceRedrawPage(self, page, callback = None):
|
||||||
|
if page.KeepUpdated:
|
||||||
|
for view in page.Views:
|
||||||
|
view.recompute()
|
||||||
|
if callback is not None:
|
||||||
|
callback()
|
||||||
|
else:
|
||||||
|
page.KeepUpdated = True
|
||||||
|
def restoreKeepUpdated():
|
||||||
|
page.KeepUpdated = False
|
||||||
|
if callback is not None:
|
||||||
|
callback()
|
||||||
|
QTimer.singleShot(10, restoreKeepUpdated)
|
||||||
|
|
||||||
def computePartCenter(self, view, obj):
|
def computePartCenter(self, view, obj):
|
||||||
if obj.TypeId == 'App::Link':
|
if obj.TypeId == 'App::Link':
|
||||||
partLink = obj
|
partLink = obj
|
||||||
|
Loading…
Reference in New Issue
Block a user