class ShipWorkbench(Workbench): """ @brief Workbench of Ship design module. Here toolbars & icons are append. """ from shipUtils import Paths, Translator import ShipGui Icon = Paths.iconsPath() + "/Ico.png" MenuText = str(Translator.translate("Ship design")) ToolTip = str(Translator.translate("Ship design")) def Initialize(self): # ToolBar list = [ "Ship_LoadExample", "Ship_CreateShip", "Ship_OutlineDraw", "Ship_AreasCurve", "Ship_Hydrostatics" ] self.appendToolbar("Ship design", list) list = ["Ship_Weights", "Ship_CreateTank", "Ship_GZ"] self.appendToolbar("Loading", list) # Menu list = [ "Ship_LoadExample", "Ship_CreateShip", "Ship_OutlineDraw", "Ship_AreasCurve", "Ship_Hydrostatics" ] self.appendMenu("Ship design", list) list = ["Ship_Weights", "Ship_CreateTank", "Ship_GZ"] self.appendToolbar("Loading", list)
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/HydrostaticsIco.png" MenuText = str(Translator.translate('GZ curve')) ToolTip = str( Translator.translate('Transversal stability GZ curve computation')) return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def setupUi(self): mw = self.getMainWindow() form = mw.findChild(QtGui.QWidget, "TaskPanel") form.length = form.findChild(QtGui.QDoubleSpinBox, "Length") form.beam = form.findChild(QtGui.QDoubleSpinBox, "Beam") form.draft = form.findChild(QtGui.QDoubleSpinBox, "Draft") form.mainLogo = form.findChild(QtGui.QLabel, "MainLogo") iconPath = Paths.iconsPath() + "/Ico.xpm" form.mainLogo.setPixmap(QtGui.QPixmap(iconPath)) self.form = form # Initial values if self.initValues(): return True self.retranslateUi() self.preview.update(self.L, self.B, self.T) # Connect Signals and Slots QtCore.QObject.connect(form.length, QtCore.SIGNAL("valueChanged(double)"), self.onData) QtCore.QObject.connect(form.beam, QtCore.SIGNAL("valueChanged(double)"), self.onData) QtCore.QObject.connect(form.draft, QtCore.SIGNAL("valueChanged(double)"), self.onData)
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Ico.png" MenuText = str(Translator.translate('Create a new ship')) ToolTip = str( Translator.translate( 'Create a new ship in order to work with them')) return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Weight.png" MenuText = str(Translator.translate('Set ship weights')) ToolTip = str( Translator.translate( 'Set ship weights, tanks must be added later')) return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/SimCreateIco.png" MenuText = str(Translator.translate('Create a new simulation')) ToolTip = str( Translator.translate( 'Create a new simulation in order to process later')) return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def setupUi(self): mw = self.getMainWindow() form = mw.findChild(QtGui.QWidget, "TaskPanel") form.ship = form.findChild(QtGui.QComboBox, "Ship") form.mainLogo = form.findChild(QtGui.QLabel, "MainLogo") iconPath = Paths.iconsPath() + "/Ico.xpm" form.mainLogo.setPixmap(QtGui.QPixmap(iconPath)) self.form = form self.retranslateUi()
class ShipWorkbench(Workbench): """ @brief Workbench of Ship design module. Here toolbars & icons are append. """ from shipUtils import Paths, Translator import ShipGui Icon = Paths.iconsPath() + "/Ico.png" MenuText = str(Translator.translate("Ship design")) ToolTip = str(Translator.translate("Ship design")) def Initialize(self): from shipUtils import Translator # ToolBar list = [ "Ship_LoadExample", "Ship_CreateShip", "Ship_OutlineDraw", "Ship_AreasCurve", "Ship_Hydrostatics" ] self.appendToolbar("Ship design", list) list = ["Ship_Weights", "Ship_CreateTank", "Ship_GZ"] self.appendToolbar("Weights", list) # Simulation stuff only if pyOpenCL & numpy are present hasOpenCL = True hasNumpy = True try: import pyopencl except ImportError: hasOpenCL = False msg = Translator.translate( "pyOpenCL not installed, ship simulations disabled\n") App.Console.PrintWarning(msg) try: import numpy except ImportError: hasNumpy = False msg = Translator.translate( "numpy not installed, ship simulations disabled\n") App.Console.PrintWarning(msg) if hasOpenCL and hasNumpy: list = [ "Ship_CreateSim", "Ship_RunSim", "Ship_StopSim", "Ship_TrackSim" ] self.appendToolbar("Simulation", list) # Menu list = [ "Ship_LoadExample", "Ship_CreateShip", "Ship_OutlineDraw", "Ship_AreasCurve", "Ship_Hydrostatics" ] self.appendMenu("Ship design", list) list = ["Ship_Weights", "Ship_CreateTank", "Ship_GZ"] self.appendMenu("Weights", list) if hasOpenCL and hasNumpy: list = [ "Ship_CreateSim", "Ship_RunSim", "Ship_StopSim", "Ship_TrackSim" ] self.appendMenu("Simulation", list)
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/LoadIco.png" MenuText = str(Translator.translate('Load an example ship geometry')) ToolTip = str( Translator.translate( 'Load an example ship geometry able to be converted into a ship.' )) return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/AreaCurveIco.png" MenuText = str(Translator.translate('Areas curve')) ToolTip = str(Translator.translate('Plot transversal areas curve')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/OutlineDrawIco.png" MenuText = str(Translator.translate('Outline draw')) ToolTip = str(Translator.translate('Plot ship outline draw')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Ico.png" MenuText = str(Translator.translate('Create a new ship')) ToolTip = str(Translator.translate('Create a new ship in order to work with them')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/LoadIco.png" MenuText = str(Translator.translate('Load an example ship geometry')) ToolTip = str(Translator.translate('Load an example ship geometry able to be converted into a ship.')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Weight.png" MenuText = str(Translator.translate('Set ship weights')) ToolTip = str(Translator.translate('Set ship weights, tanks must be added later')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/SimPostIco.png" MenuText = str(Translator.translate('Track simulation')) ToolTip = str(Translator.translate('Track simulation')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/HydrostaticsIco.png" MenuText = str(Translator.translate('GZ curve')) ToolTip = str(Translator.translate('Transversal stability GZ curve computation')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Tank.png" MenuText = str(Translator.translate('Create a new tank')) ToolTip = str(Translator.translate('Create a new ship tank')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def initValues(self): """ Get selected geometry. @return False if sucessfully values initialized. """ # Get selected objects selObjs = FreeCADGui.Selection.getSelection() if not selObjs: msg = QtGui.QApplication.translate( "ship_console", "Ship instance must be selected (no object selected)", None, QtGui.QApplication.UnicodeUTF8, ) App.Console.PrintError(msg) return True for i in range(0, len(selObjs)): obj = selObjs[i] # Test if is a ship instance props = obj.PropertiesList try: props.index("IsShip") except ValueError: continue if obj.IsShip: # Test if another ship already selected if self.ship: msg = QtGui.QApplication.translate( "ship_console", "More than one ship selected (extra ships will be neglected)", None, QtGui.QApplication.UnicodeUTF8, ) App.Console.PrintWarning(msg + "\n") break self.ship = obj # Test if any valid ship was selected if not self.ship: msg = QtGui.QApplication.translate( "ship_console", "Ship instance must be selected (no valid ship found at selected objects)", None, QtGui.QApplication.UnicodeUTF8, ) App.Console.PrintError(msg + "\n") return True props = self.ship.PropertiesList try: props.index("WeightNames") except: msg = QtGui.QApplication.translate( "ship_console", "Ship weights has not been set. You need to set weights before use this tool", None, QtGui.QApplication.UnicodeUTF8, ) App.Console.PrintError(msg + "\n") return True # Setup available tanks list objs = App.ActiveDocument.Objects iconPath = Paths.iconsPath() + "/Tank.xpm" icon = QtGui.QIcon(QtGui.QPixmap(iconPath)) for obj in objs: # Try to get valid tank property props = obj.PropertiesList try: props.index("IsShipTank") except ValueError: continue if not obj.IsShipTank: continue # Add tank to list name = obj.Name label = obj.Label tag = label + " (" + name + ")" self.tanks[tag] = name # self.tanks.append([name, tag]) item = QtGui.QListWidgetItem(tag) item.setIcon(icon) self.form.tanks.addItem(item) return False
def initValues(self): """ Get selected geometry. @return False if sucessfully values initialized. """ # Get selected objects selObjs = FreeCADGui.Selection.getSelection() if not selObjs: msg = Translator.translate( "Ship instance must be selected (no object selected)\n") App.Console.PrintError(msg) return True for i in range(0, len(selObjs)): obj = selObjs[i] # Test if is a ship instance props = obj.PropertiesList try: props.index("IsShip") except ValueError: continue if obj.IsShip: # Test if another ship already selected if self.ship: msg = Translator.translate( "More than one ship selected (extra ship will be neglected)\n" ) App.Console.PrintWarning(msg) break self.ship = obj # Test if any valid ship was selected if not self.ship: msg = Translator.translate( "Ship instance must be selected (no valid ship found at selected objects)\n" ) App.Console.PrintError(msg) return True props = self.ship.PropertiesList try: props.index("WeightNames") except: msg = Translator.translate( "Ship weights has not been set. You need to set weights before use this tool.\n" ) App.Console.PrintError(msg) return True # Setup available tanks list objs = App.ActiveDocument.Objects iconPath = Paths.iconsPath() + "/Tank.xpm" icon = QtGui.QIcon(QtGui.QPixmap(iconPath)) for obj in objs: # Try to get valid tank property props = obj.PropertiesList try: props.index("IsShipTank") except ValueError: continue if not obj.IsShipTank: continue # Add tank to list name = obj.Name label = obj.Label tag = label + ' (' + name + ')' self.tanks[tag] = name # self.tanks.append([name, tag]) item = QtGui.QListWidgetItem(tag) item.setIcon(icon) self.form.tanks.addItem(item) msg = Translator.translate("Ready to work\n") App.Console.PrintMessage(msg) return False
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/Tank.png" MenuText = str(Translator.translate('Create a new tank')) ToolTip = str(Translator.translate('Create a new ship tank')) return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/HydrostaticsIco.png" MenuText = str(Translator.translate('Hydrostatics')) ToolTip = str(Translator.translate('Plot ship hydrostatics')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/SimCreateIco.png" MenuText = str(Translator.translate('Create a new simulation')) ToolTip = str(Translator.translate('Create a new simulation in order to process later')) return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def GetResources(self): from shipUtils import Paths, Translator IconPath = Paths.iconsPath() + "/SimPostIco.png" MenuText = str(Translator.translate('Track simulation')) ToolTip = str(Translator.translate('Track simulation')) return {'Pixmap': IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}