framework/freecad_workbench/freecad/robossembler/init_gui.py

95 lines
3 KiB
Python

import os
import FreeCADGui as Gui
import FreeCAD as App
from .TranslateUtils import translate
from . import ICONPATH, TRANSLATIONSPATH, Frames
from .version import __version__
__title__='Robossembler Workbench'
__author__ = 'brothermechanic, Mark Voltov, IDONTSUDO, Igor Brylyov'
__copyright__ = 'Copyright (c) 2023 brothermechanic'
__license__ = 'GPL-2.1'
__email__ = 'brothermechanic@gmail.com, ius.mark.alex@gmail.com'
__url__ = ["https://robossembler.org"]
__status__ = 'development'
class Robossembler(Gui.Workbench):
"""
class which gets initiated at startup of the gui
"""
MenuText = "Robossembler" # translate("cool", "Robossembler")
ToolTip = "Robossembler Workbench" # translate("cool", "a simple Robossembler")
Icon = os.path.join(ICONPATH, "robossembler.svg")
toolbox = []
def GetClassName(self):
return "Gui::PythonWorkbench"
def Initialize(self):
"""
This function is called at the first activation of the workbench.
here is the place to import all the commands
"""
# Add translations path
Gui.addLanguagePath(TRANSLATIONSPATH)
Gui.updateLocale()
self.framecommands = [
"BoMGeneration",
"FrameCommand",
"SelectedPartFrameCommand",
"AllPartFramesCommand",
"FeatureFrameCommand"
]
self.toolcommands = [
"ExportPlacementAndPropertiesCommand",
"Export_Entities",
"ExportGazeboModels",
"InsertGraspPose",
"Validate_Project",
"Publish_Project"
]
self.asmcommands = [
"Create Assembly Parameters",
"Create Fastener Set",
"Create Assembly Sequence",
"Export Assembly Settings",
"Compute Assembly Sequence",
# "Create Assembly Layers",
"Create Structure Graph",
"Create Assembly Graph"
]
self.appendToolbar(f"{__class__.__name__} Frames", self.framecommands)
self.appendToolbar(f"{__class__.__name__} Tools", self.toolcommands)
self.appendToolbar(f"{__class__.__name__} Assembly Setup", self.asmcommands)
App.Console.PrintMessage(translate("Console",
"Switching to robossembler") + "\n")
App.Console.PrintMessage(translate("Console",
"Switching to robossembler") + "\n")
# self.appendToolbar(translate("Toolbar", "Tools"), self.toolbox)
# self.appendMenu(translate("Menu", "Tools"), self.toolbox)
def Activated(self):
'''
code which should be computed when a user switch to this workbench
'''
pass
def Deactivated(self):
'''
code which should be computed when this workbench is deactivated
'''
pass
def ContextMenu(self, recipient):
"""This is execcuted whenever the user right-clicks on screen."""
pass
Gui.addWorkbench(Robossembler())