forked from youen/assembly_handbook
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.8 KiB
130 lines
3.8 KiB
#sys.path.append('/usr/local/lib/python3.9/dist-packages/') |
|
#import pydevd |
|
#pydevd.settrace() |
|
|
|
import os |
|
|
|
import FreeCADGui as Gui |
|
import FreeCAD as App |
|
|
|
import ahb_locator |
|
|
|
global ahb_icon |
|
ahb_icon = os.path.join(os.path.dirname(ahb_locator.__file__), "resources/assembly-handbook.svg") |
|
|
|
class AssemblyHandbookWorkbench(Gui.Workbench): |
|
""" |
|
class which gets initiated at startup of the gui |
|
""" |
|
|
|
MenuText = "Assembly handbook" |
|
ToolTip = "A workbench for automating creation of an assembly handbook" |
|
Icon = ahb_icon |
|
|
|
dev = True # indicates development mode (enables additional tools, log, debug checks, etc.) |
|
|
|
context = None |
|
docObserver = None |
|
partsCache = None |
|
techDrawExtensions = None |
|
|
|
def GetClassName(self): |
|
return "Gui::PythonWorkbench" |
|
|
|
def Initialize(self): |
|
""" |
|
This function is called at the first activation of the workbench. |
|
""" |
|
self.registerCommands() |
|
|
|
def Activated(self): |
|
""" |
|
code which should be computed when a user switch to this workbench |
|
""" |
|
if self.context is None: |
|
self.initializeContext() |
|
|
|
if self.docObserver is None: |
|
import ahb_document_observer |
|
self.docObserver = ahb_document_observer.DocObserver() |
|
App.addDocumentObserver(self.docObserver) |
|
|
|
if self.partsCache is None: |
|
import ahb_parts_cache |
|
self.partsCache = ahb_parts_cache.PartsCache() |
|
|
|
if self.techDrawExtensions is None: |
|
import ahb_techdraw_extensions |
|
self.techDrawExtensions = ahb_techdraw_extensions.TechDrawExtensions() |
|
|
|
def Deactivated(self): |
|
""" |
|
code which should be computed when this workbench is deactivated |
|
""" |
|
pass |
|
|
|
def initializeContext(self): |
|
import ahb_context |
|
self.context = ahb_context.AHB_Context() |
|
|
|
def registerCommands(self): |
|
toolbox = [] |
|
|
|
#self.importModule('ahb_cmd_export_csv') |
|
#toolbox.append("AHB_exportCsv") |
|
|
|
#self.importModule('ahb_cmd_set_active_stage') |
|
#toolbox.append("AHB_setActiveStage") |
|
|
|
#self.importModule('ahb_cmd_set_part_stage') |
|
#toolbox.append("AHB_setPartStage") |
|
|
|
#self.importModule('ahb_cmd_switch_visibility_mode') |
|
#toolbox.append("AHB_switchVisibilityMode") |
|
|
|
#self.importModule('ahb_cmd_render') |
|
#toolbox.append("AHB_render") |
|
|
|
#self.importModule('ahb_cmd_animate') |
|
#toolbox.append("AHB_animate") |
|
|
|
self.importModule('ahb_cmd_view_annotate') |
|
toolbox.append("AHB_view_annotate") |
|
|
|
if self.dev: |
|
self.importModule('ahb_cmd_reload') |
|
toolbox.append("AHB_reload") |
|
|
|
self.appendToolbar("Assembly Handbook", toolbox) |
|
self.appendMenu("Assembly Handbook", toolbox) |
|
|
|
def reload(self): |
|
# Used for development only |
|
self.removeToolbar("Assembly Handbook") |
|
self.removeMenu("Assembly Handbook") |
|
|
|
self.context.setAnimationActive(False) |
|
|
|
import importlib |
|
import ahb_context |
|
importlib.reload(ahb_context) |
|
|
|
import ahb_parts_cache |
|
importlib.reload(ahb_parts_cache) |
|
self.partsCache = ahb_parts_cache.PartsCache() |
|
|
|
import ahb_techdraw_extensions |
|
importlib.reload(ahb_techdraw_extensions) |
|
self.techDrawExtensions = ahb_techdraw_extensions.TechDrawExtensions() |
|
|
|
self.initializeContext() |
|
self.registerCommands() |
|
pass |
|
|
|
def importModule(self, moduleName): |
|
import importlib |
|
module = importlib.import_module(moduleName) |
|
if self.dev: |
|
importlib.reload(module) |
|
|
|
Gui.addWorkbench(AssemblyHandbookWorkbench())
|
|
|