|
|
@ -77,10 +77,16 @@ class TechDrawExtensions: |
|
|
|
|
|
|
|
|
|
|
|
enable_selected_part_highlight = False # disable for now, for performance reasons |
|
|
|
enable_selected_part_highlight = False # disable for now, for performance reasons |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initialized_documents = [] |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
def __init__(self): |
|
|
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench |
|
|
|
workbench = Gui.getWorkbench("AssemblyHandbookWorkbench") #: :type workbench: AssemblyHandbookWorkbench |
|
|
|
workbench.docObserver.onObjectTypeChanged('balloon_changed', 'TechDraw::DrawViewBalloon', lambda obj, prop: self.onBalloonChanged(obj, prop)) |
|
|
|
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.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): |
|
|
|
def repaint(self, view, fast_render = True): |
|
|
|
self.views_to_repaint[view] = fast_render |
|
|
|
self.views_to_repaint[view] = fast_render |
|
|
@ -646,8 +652,20 @@ class TechDrawExtensions: |
|
|
|
QTimer.singleShot(10, restoreKeepUpdated) |
|
|
|
QTimer.singleShot(10, restoreKeepUpdated) |
|
|
|
|
|
|
|
|
|
|
|
def refreshOverlays(self, page, callback = None): |
|
|
|
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 page.KeepUpdated: |
|
|
|
callback() |
|
|
|
if callback: |
|
|
|
|
|
|
|
callback() |
|
|
|
else: |
|
|
|
else: |
|
|
|
page.KeepUpdated = True |
|
|
|
page.KeepUpdated = True |
|
|
|
def restoreKeepUpdated(): |
|
|
|
def restoreKeepUpdated(): |
|
|
@ -772,3 +790,26 @@ class TechDrawExtensions: |
|
|
|
cache = ViewCache() |
|
|
|
cache = ViewCache() |
|
|
|
self.view_cache[view] = cache |
|
|
|
self.view_cache[view] = cache |
|
|
|
return 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) |
|
|
|