Browse Source

Added code to work arround TechDraw bugs when using the "annotate view" button

pull/2/head
Youen 2 years ago
parent
commit
b8f1e40de3
  1. 12
      ahb_cmd_view_annotate.py
  2. 38
      ahb_techdraw_extensions.py

12
ahb_cmd_view_annotate.py

@ -14,11 +14,19 @@ class AHB_View_Annotate:
def Activated(self): def Activated(self):
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench
if len(Gui.Selection.getSelection()) == 0:
page = workbench.techDrawExtensions.getActivePage()
workbench.techDrawExtensions.refreshOverlays(page)
return
if len(Gui.Selection.getSelection()) != 1: if len(Gui.Selection.getSelection()) != 1:
raise Exception("Please select exactly one TechDraw view") raise Exception("Please select exactly one TechDraw view")
view = Gui.Selection.getSelection()[0] view = Gui.Selection.getSelection()[0]
if view.TypeId != 'TechDraw::DrawViewPart': if view.TypeId == 'TechDraw::DrawPage':
workbench.techDrawExtensions.refreshOverlays(view)
return
elif view.TypeId != 'TechDraw::DrawViewPart':
raise Exception("Selected object is not a TechDraw view") raise Exception("Selected object is not a TechDraw view")
overlay_view = workbench.techDrawExtensions.getOverlayView(view) overlay_view = workbench.techDrawExtensions.getOverlayView(view)
@ -61,5 +69,7 @@ class AHB_View_Annotate:
for partLink in view.XSource: for partLink in view.XSource:
workbench.techDrawExtensions.add_or_update_balloon(view, partLink, '') workbench.techDrawExtensions.add_or_update_balloon(view, partLink, '')
workbench.techDrawExtensions.refreshOverlays(page)
from ahb_command import AHB_CommandWrapper from ahb_command import AHB_CommandWrapper
AHB_CommandWrapper.addGuiCommand('AHB_view_annotate', AHB_View_Annotate()) AHB_CommandWrapper.addGuiCommand('AHB_view_annotate', AHB_View_Annotate())

38
ahb_techdraw_extensions.py

@ -641,6 +641,44 @@ class TechDrawExtensions:
callback() callback()
QTimer.singleShot(10, restoreKeepUpdated) QTimer.singleShot(10, restoreKeepUpdated)
def refreshOverlays(self, page, callback = None):
if page.KeepUpdated:
callback()
else:
page.KeepUpdated = True
def restoreKeepUpdated():
for view in page.Views:
if view.TypeId == 'TechDraw::DrawViewPart':
if view.Name.endswith('_overlay'):
view.touch()
view.recompute()
for sub_view in page.Views:
try:
if sub_view.SourceView == view:
sub_view.recompute()
except:
pass
page.KeepUpdated = False
for view in page.Views:
if view.TypeId == 'TechDraw::DrawViewBalloon':
if view.ViewObject.Visibility:
# workaround for a TechDraw bug: sometimes the balloon should be visible but doesn't appear, showing it again fixes the issue
view.ViewObject.Visibility = False
def makeRedrawCallback(view):
def redrawBalloon():
view.ViewObject.Visibility = True
return redrawBalloon
QTimer.singleShot(0, makeRedrawCallback(view))
else:
# workaround for a TechDraw bug: sometimes the balloon text is visible even if the balloon is hidden, hiding it again fixes the issue
view.ViewObject.Visibility = True
view.ViewObject.Visibility = False
if callback is not None:
callback()
QTimer.singleShot(10, restoreKeepUpdated)
def getSourceView(self, view): def getSourceView(self, view):
if view.Name.endswith('_overlay'): if view.Name.endswith('_overlay'):
view = view.Document.getObject(view.Name[0:-8]) view = view.Document.getObject(view.Name[0:-8])

Loading…
Cancel
Save