コード例 #1
0
ファイル: InitGui.py プロジェクト: orlik80/free-cad
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)
コード例 #2
0
ファイル: ShipGui.py プロジェクト: h4ck3rm1k3/FreeCAD
 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}
コード例 #3
0
 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)
コード例 #4
0
ファイル: ShipGui.py プロジェクト: h4ck3rm1k3/FreeCAD
 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}
コード例 #5
0
ファイル: ShipGui.py プロジェクト: h4ck3rm1k3/FreeCAD
 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}
コード例 #6
0
ファイル: ShipGui.py プロジェクト: h4ck3rm1k3/FreeCAD
 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}
コード例 #7
0
ファイル: TaskPanel.py プロジェクト: h4ck3rm1k3/FreeCAD
 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()
コード例 #8
0
ファイル: TaskPanel.py プロジェクト: Koelie2/freecad
 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()
コード例 #9
0
ファイル: InitGui.py プロジェクト: h4ck3rm1k3/FreeCAD
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)
コード例 #10
0
ファイル: ShipGui.py プロジェクト: h4ck3rm1k3/FreeCAD
 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}
コード例 #11
0
ファイル: TaskPanel.py プロジェクト: lainegates/FreeCAD
	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)
コード例 #12
0
 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} 
コード例 #13
0
 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} 
コード例 #14
0
ファイル: ShipGui.py プロジェクト: msocorcim/FreeCAD
 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} 
コード例 #15
0
ファイル: ShipGui.py プロジェクト: msocorcim/FreeCAD
 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} 
コード例 #16
0
ファイル: ShipGui.py プロジェクト: c-lutaud/FreeCAD_sf_master
 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} 
コード例 #17
0
ファイル: ShipGui.py プロジェクト: c-lutaud/FreeCAD_sf_master
 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} 
コード例 #18
0
ファイル: ShipGui.py プロジェクト: c-lutaud/FreeCAD_sf_master
 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} 
コード例 #19
0
ファイル: ShipGui.py プロジェクト: c-lutaud/FreeCAD_sf_master
 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} 
コード例 #20
0
    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
コード例 #21
0
 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
コード例 #22
0
ファイル: ShipGui.py プロジェクト: h4ck3rm1k3/FreeCAD
 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}
コード例 #23
0
 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} 
コード例 #24
0
ファイル: ShipGui.py プロジェクト: c-lutaud/FreeCAD_sf_master
 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} 
コード例 #25
0
ファイル: ShipGui.py プロジェクト: h4ck3rm1k3/FreeCAD
 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}