当前位置: 首页>>代码示例>>Python>>正文


Python shipUtils.Translator类代码示例

本文整理汇总了Python中shipUtils.Translator的典型用法代码示例。如果您正苦于以下问题:Python Translator类的具体用法?Python Translator怎么用?Python Translator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Translator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: accept

 def accept(self):
     msg = Translator.translate("Building data...\n")
     App.Console.PrintMessage(msg)
     # Get GUI data
     endTime = self.form.time.value()
     output  = []
     output.append(self.form.output.value())
     output.append(self.form.outputType.currentIndex())
     devId   = self.form.device.currentIndex() - 1 # First is not OpenCL
     # Get OpenCL device
     device = None
     count  = 0
     platforms = cl.get_platforms()
     for p in platforms:
         devs = p.get_devices()
         for d in devs:
             if count == devId:
                 device = d
             count = count + 1
     # Get free surfaces data
     FSMesh = SimInstance.FSMesh(self.sim)
     wData  = self.sim.Waves
     wDir   = self.sim.Waves_Dir
     waves  = []
     for i in range(0,len(wData)):
         waves.append([wData[i].x, wData[i].y, wData[i].z, wDir[i]])
     msg = Translator.translate("Launching simulation...\n")
     App.Console.PrintMessage(msg)
     # Build simulation thread
     simulator = Sim(device, endTime, output, FSMesh, waves)
     simulator.start()
     msg = Translator.translate("Done!\n")
     App.Console.PrintMessage(msg)
     return True
开发者ID:RoyOnWheels,项目名称:FreeCAD,代码行数:34,代码来源:TaskPanel.py

示例2: retranslateUi

 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Create a new ship"))
     self.form.findChild(QtGui.QLabel, "LengthLabel").setText(Translator.translate("Length"))
     self.form.findChild(QtGui.QLabel, "BeamLabel").setText(Translator.translate("Beam"))
     self.form.findChild(QtGui.QLabel, "DraftLabel").setText(Translator.translate("Draft"))
开发者ID:RoyOnWheels,项目名称:FreeCAD,代码行数:7,代码来源:TaskPanel.py

示例3: initValues

 def initValues(self):
     """ Set initial values for fields
     """
     # Get selected objects
     selObjs  = Geometry.getSelectedObjs()
     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
     # Load sections (if exist)
     self.loadSections()
     msg = Translator.translate("Ready to work\n")
     App.Console.PrintMessage(msg)
     return False
开发者ID:Koelie2,项目名称:freecad,代码行数:34,代码来源:TaskPanel.py

示例4: Initialize

 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"]
         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"]
         self.appendMenu("Simulation",list)
开发者ID:RoyOnWheels,项目名称:FreeCAD,代码行数:34,代码来源:InitGui.py

示例5: __init__

 def __init__(self, obj, fsMeshData, waves):
     """ Creates a new simulation instance on active document.
     @param obj Created Part::FeaturePython object.
     @param fsMeshData [L,B,N] Free surface mesh data, with lenght 
     (x), Beam (y) and desired number of points.
     @param waves [[A,T,phi,heading],] Waves involved 
     """
     # Add uniqueness property to identify Tank instances
     obj.addProperty("App::PropertyBool","IsShipSimulation","ShipSimulation", str(Translator.translate("True if is a valid ship simulation instance"))).IsShipSimulation=True
     # Compute free surface mesh
     self.createFSMesh(obj,fsMeshData)
     self.computeWaves(obj,waves)
     # Store waves
     obj.addProperty("App::PropertyVectorList","Waves","ShipSimulation", str(Translator.translate("Waves (Amplitude,period,phase)"))).Waves=[]
     obj.addProperty("App::PropertyFloatList","Waves_Dir","ShipSimulation", str(Translator.translate("Waves direction (0 deg to stern waves)"))).Waves_Dir=[]
     w = []
     d = []
     for i in range(0,len(waves)):
         w.append(Vector(waves[i][0], waves[i][1], waves[i][2]))
         d.append(waves[i][3])
     obj.Waves = w
     obj.Waves_Dir = d
     # Add shapes
     shape = self.computeShape(obj)
     if not shape:
         obj.IsShipSimulation=False
         return
     obj.Shape = shape
     obj.Proxy = self
开发者ID:c-lutaud,项目名称:FreeCAD_sf_master,代码行数:29,代码来源:SimInstance.py

示例6: retranslateUi

 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Plot hydrostatics"))
     self.form.findChild(QtGui.QLabel, "TrimLabel").setText(Translator.translate("Trim"))
     self.form.findChild(QtGui.QLabel, "MinDraftLabel").setText(Translator.translate("Minimum draft"))
     self.form.findChild(QtGui.QLabel, "MaxDraftLabel").setText(Translator.translate("Maximum draft"))
     self.form.findChild(QtGui.QLabel, "NDraftLabel").setText(Translator.translate("Number of points"))
开发者ID:Koelie2,项目名称:freecad,代码行数:8,代码来源:TaskPanel.py

示例7: onTanksSelection

 def onTanksSelection(self):
     """ Called when tanks are selected or deselected.
     """
     # Set displacement label
     disp = self.computeDisplacement()
     self.form.disp.setText(Translator.translate("Displacement") + ' = %g [kg]' % (disp[0]))
     # Set draft label
     draft = self.computeDraft(disp[0], self.form.trim.value())
     self.form.draft.setText(Translator.translate("Draft") + ' = %g [m]' % (draft[0]))
开发者ID:Koelie2,项目名称:freecad,代码行数:9,代码来源:TaskPanel.py

示例8: onUpdate

 def onUpdate(self):
     """ Called when update displacement and draft is requested.
     """
     # Set displacement label
     disp = self.computeDisplacement()
     self.form.disp.setText(Translator.translate("Displacement") + ' = %g [kg]' % (disp[0]))
     # Set draft label
     draft = self.computeDraft(disp[0], self.form.trim.value())
     self.form.draft.setText(Translator.translate("Draft") + ' = %g [m]' % (draft[0]))
开发者ID:RoyOnWheels,项目名称:FreeCAD,代码行数:9,代码来源:TaskPanel.py

示例9: initValues

 def initValues(self):
     """ Set initial values for fields
     """
     # Get objects
     selObjs  = Geometry.getSelectedObjs()
     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
     # Get bounds
     bbox = self.ship.Shape.BoundBox
     self.form.draft.setMaximum(bbox.ZMax)
     self.form.draft.setMinimum(bbox.ZMin)
     self.form.draft.setValue(self.ship.Draft)
     # Try to use saved values
     props = self.ship.PropertiesList
     flag = True
     try:
         props.index("AreaCurveDraft")
     except ValueError:
         flag = False
     if flag:
         self.form.draft.setValue(self.ship.AreaCurveDraft)
     flag = True
     try:
         props.index("AreaCurveTrim")
     except ValueError:
         flag = False
     if flag:
         self.form.trim.setValue(self.ship.AreaCurveTrim)
     # Update GUI
     self.preview.update(self.form.draft.value(), self.form.trim.value(), self.ship)
     self.onUpdate()
     msg = Translator.translate("Ready to work\n")
     App.Console.PrintMessage(msg)
     return False
开发者ID:RoyOnWheels,项目名称:FreeCAD,代码行数:56,代码来源:TaskPanel.py

示例10: retranslateUi

 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Create a new tank"))
     name = Translator.translate("Filling level") + " (%)"
     self.form.findChild(QtGui.QLabel, "LevelLabel").setText(name)
     name = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">\n<html><body>'
     name = name + Translator.translate("Density")
     name = name + '(kg/m<span style=" vertical-align:super;">3</span>)</body></html>'
     self.form.findChild(QtGui.QLabel, "DensityLabel").setText(name)
开发者ID:archri,项目名称:freecad,代码行数:10,代码来源:TaskPanel.py

示例11: saveData

 def saveData(self, ship, trim, drafts):
     """ Write data file.
     @param ship Selected ship instance
     @param trim Trim in degrees.
     @param drafts List of drafts to be performed.
     @return True if error happens.
     """
     # Open the file
     filename = self.path + 'hydrostatics.dat'
     try:
         Output = open(filename, "w")
     except IOError:
         msg = Translator.translate("Can't write '" + filename + "' file.\n")
         FreeCAD.Console.PrintError(msg)
         return True
     # Print header
     Output.write(header)
     Output.write(" #\n")
     Output.write(" # File automatically exported by FreeCAD-Ship\n")
     Output.write(" # This file contains transversal areas data, filled with following columns:\n")
     Output.write(" #  1: Ship displacement [ton]\n")
     Output.write(" #  2: Draft [m]\n")
     Output.write(" #  3: Wetted surface [m2]\n")
     Output.write(" #  4: 1cm triming ship moment [ton m]\n")
     Output.write(" #  5: Bouyance center x coordinate\n")
     Output.write(" #  6: Floating area\n")
     Output.write(" #  7: KBt\n")
     Output.write(" #  8: BMt\n")
     Output.write(" #  9: Cb (block coefficient)\n")
     Output.write(" # 10: Cf (Floating coefficient)\n")
     Output.write(" # 11: Cm (Main frame coefficient)\n")
     Output.write(" #\n")
     Output.write(" #################################################################\n")
     # Get external faces
     faces = self.externalFaces(ship.Shape)
     if len(faces) == 0:
         msg = Translator.translate("Can't detect external faces from ship object.\n")
         FreeCAD.Console.PrintError(msg)
     else:
         faces = Part.makeShell(faces)
     # Print data
     FreeCAD.Console.PrintMessage("Computing hydrostatics...\n")
     for i in range(0,len(drafts)):
         FreeCAD.Console.PrintMessage("\t%d / %d\n" % (i+1, len(drafts)))
         draft = drafts[i]
         point = Tools.Point(ship,faces,draft,trim)
         string = "%f %f %f %f %f %f %f %f %f %f %f\n" % (point.disp, point.draft, point.wet, point.mom, point.xcb, point.farea, point.KBt, point.BMt, point.Cb, point.Cf, point.Cm)
         Output.write(string)
     # Close file
     Output.close()
     self.dataFile = filename
     msg = Translator.translate("Data saved at '" + self.dataFile + "'.\n")
     FreeCAD.Console.PrintMessage(msg)
     return False
开发者ID:c-lutaud,项目名称:FreeCAD_sf_master,代码行数:54,代码来源:Plot.py

示例12: initValues

 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
     # Get weights
     w = weights(self.ship)
     # Set the items
     self.form.weights.setRowCount(len(w) + 1)
     for i in range(0, len(w)):
         item = QtGui.QTableWidgetItem(w[i][0])
         self.form.weights.setItem(i, 0, item)
         string = "%g" % (w[i][1])
         item = QtGui.QTableWidgetItem(string)
         self.form.weights.setItem(i, 1, item)
         string = "%g" % (w[i][2].x)
         item = QtGui.QTableWidgetItem(string)
         self.form.weights.setItem(i, 2, item)
         string = "%g" % (w[i][2].y)
         item = QtGui.QTableWidgetItem(string)
         self.form.weights.setItem(i, 3, item)
         string = "%g" % (w[i][2].z)
         item = QtGui.QTableWidgetItem(string)
         self.form.weights.setItem(i, 4, item)
     msg = Translator.translate("Ready to work\n")
     App.Console.PrintMessage(msg)
     return False
开发者ID:archri,项目名称:freecad,代码行数:52,代码来源:TaskPanel.py

示例13: save

 def save(self):
     """ Saves data into ship instance.
     """
     props = self.ship.PropertiesList
     try:
         props.index("AreaCurveDraft")
     except ValueError:
         self.ship.addProperty("App::PropertyFloat","AreaCurveDraft","Ship", str(Translator.translate("Areas curve draft selected [m]")))
     self.ship.AreaCurveDraft = self.form.draft.value()
     try:
         props.index("AreaCurveTrim")
     except ValueError:
         self.ship.addProperty("App::PropertyFloat","AreaCurveTrim","Ship", str(Translator.translate("Areas curve trim selected [m]")))
     self.ship.AreaCurveTrim = self.form.trim.value()
开发者ID:RoyOnWheels,项目名称:FreeCAD,代码行数:14,代码来源:TaskPanel.py

示例14: stopSimulation

def stopSimulation():
    try:
        simulator = Sim()
        if not simulator.isRunning():
            msg = Translator.translate("Simulation already stopped\n")
            App.Console.PrintWarning(msg)
            return
    except:
        msg = Translator.translate("Any active simulation to stop!\n")
        App.Console.PrintError(msg)
        return
    simulator.stop()
    msg = Translator.translate("Simulation will stop at the end of actual iteration\n")
    App.Console.PrintMessage(msg)
开发者ID:RoyOnWheels,项目名称:FreeCAD,代码行数:14,代码来源:TaskPanel.py

示例15: __init__

 def __init__(self, obj, faces):
     """ Creates a new ship on active document.
     @param faces Ship faces (Part::Shape entities).
     """
     # Add uniqueness property to identify Ship instances
     obj.addProperty("App::PropertyBool","IsShip","Ship", str(Translator.translate("True if is a valid ship instance"))).IsShip=True
     # Add main dimensions
     obj.addProperty("App::PropertyLength","Length","Ship", str(Translator.translate("Ship length (Lpp) [m]"))).Length=0.0
     obj.addProperty("App::PropertyLength","Beam","Ship", str(Translator.translate("Ship beam (B) [m]"))).Beam=0.0
     obj.addProperty("App::PropertyLength","Draft","Ship", str(Translator.translate("Ship draft (T) [m]"))).Draft=0.0
     # Add shapes
     obj.Shape = Part.makeShell(faces)
     obj.Proxy = self
     self.obj = obj
开发者ID:Koelie2,项目名称:freecad,代码行数:14,代码来源:Instance.py


注:本文中的shipUtils.Translator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。