|
|
|
@ -77,10 +77,16 @@ class TechDrawExtensions:
|
|
|
|
|
|
|
|
|
|
enable_selected_part_highlight = False # disable for now, for performance reasons |
|
|
|
|
|
|
|
|
|
initialized_documents = [] |
|
|
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench |
|
|
|
|
workbench.docObserver.onObjectTypeChanged('balloon_changed', 'TechDraw::DrawViewBalloon', lambda obj, prop: self.onBalloonChanged(obj, prop)) |
|
|
|
|
workbench.docObserver.onObjectTypeSelected('balloon_selected', 'TechDraw::DrawViewBalloon', lambda operation, obj, sub, point: self.onBalloonSelected(operation, obj, sub, point)) |
|
|
|
|
workbench.docObserver.onDocumentEvent('techdrawext_doc_event', lambda doc, event: self.onDocumentEvent(doc, event)) |
|
|
|
|
|
|
|
|
|
if App.ActiveDocument is not None: |
|
|
|
|
self.onDocumentEvent(App.ActiveDocument, 'activate') |
|
|
|
|
|
|
|
|
|
def repaint(self, view, fast_render = True): |
|
|
|
|
self.views_to_repaint[view] = fast_render |
|
|
|
@ -646,7 +652,19 @@ class TechDrawExtensions:
|
|
|
|
|
QTimer.singleShot(10, restoreKeepUpdated) |
|
|
|
|
|
|
|
|
|
def refreshOverlays(self, page, callback = None): |
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
doc = page.Document |
|
|
|
|
for image in page.Views: |
|
|
|
|
if image.TypeId == 'TechDraw::DrawViewImage': |
|
|
|
|
folder_name = '/' + os.path.basename(doc.FileName).replace('.FCStd', '') + '_raster/' |
|
|
|
|
if folder_name in image.ImageFile: |
|
|
|
|
full_path = doc.FileName.replace('.FCStd', '') + '_raster/' + image.ImageFile.split(folder_name)[1] |
|
|
|
|
if image.ImageFile != full_path: |
|
|
|
|
image.ImageFile = full_path |
|
|
|
|
|
|
|
|
|
if page.KeepUpdated: |
|
|
|
|
if callback: |
|
|
|
|
callback() |
|
|
|
|
else: |
|
|
|
|
page.KeepUpdated = True |
|
|
|
@ -772,3 +790,26 @@ class TechDrawExtensions:
|
|
|
|
|
cache = ViewCache() |
|
|
|
|
self.view_cache[view] = cache |
|
|
|
|
return cache |
|
|
|
|
|
|
|
|
|
def onDocumentEvent(self, doc, event): |
|
|
|
|
if event == 'activate': |
|
|
|
|
if doc not in self.initialized_documents: |
|
|
|
|
self.initialized_documents.append(doc) |
|
|
|
|
self.initializeDocument(doc) |
|
|
|
|
elif event == 'deleted': |
|
|
|
|
if doc in self.initialized_documents: |
|
|
|
|
self.initialized_documents.remove(doc) |
|
|
|
|
|
|
|
|
|
def initializeDocument(self, doc): |
|
|
|
|
def doInit(): |
|
|
|
|
try: |
|
|
|
|
for obj in doc.Objects: |
|
|
|
|
if obj.TypeId == 'TechDraw::DrawPage': |
|
|
|
|
self.onPageLoaded(obj) |
|
|
|
|
except: |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
QTimer.singleShot(0, doInit) |
|
|
|
|
|
|
|
|
|
def onPageLoaded(self, page): |
|
|
|
|
self.refreshOverlays(page) |
|
|
|
|