本文整理汇总了Python中shipUtils.Locale.fromString方法的典型用法代码示例。如果您正苦于以下问题:Python Locale.fromString方法的具体用法?Python Locale.fromString怎么用?Python Locale.fromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shipUtils.Locale
的用法示例。
在下文中一共展示了Locale.fromString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: accept
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def accept(self):
if not self.ship:
return False
self.save()
# Plot data
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
draft = Units.Quantity(Locale.fromString(
form.draft.text())).getValueAs('m').Value
trim = Units.Quantity(Locale.fromString(
form.trim.text())).getValueAs('deg').Value
data = Hydrostatics.displacement(self.ship,
draft,
0.0,
trim)
disp = data[0]
xcb = data[1].x
data = Hydrostatics.areas(self.ship,
draft,
0.0,
trim)
x = []
y = []
for i in range(0, len(data)):
x.append(data[i][0])
y.append(data[i][1])
PlotAux.Plot(x, y, disp, xcb, self.ship)
self.preview.clean()
return True
示例2: accept
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def accept(self):
if not self.ship:
return False
self.save()
# Plot data
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
form.num = self.widget(QtGui.QSpinBox, "Num")
draft = Units.parseQuantity(Locale.fromString(form.draft.text()))
trim = Units.parseQuantity(Locale.fromString(form.trim.text()))
num = form.num.value()
disp, B, _ = Hydrostatics.displacement(self.ship,
draft,
Units.parseQuantity("0 deg"),
trim)
xcb = Units.Quantity(B.x, Units.Length)
data = Hydrostatics.areas(self.ship,
num,
draft=draft,
trim=trim)
x = []
y = []
for i in range(0, len(data)):
x.append(data[i][0].getValueAs("m").Value)
y.append(data[i][1].getValueAs("m^2").Value)
PlotAux.Plot(x, y, disp, xcb, self.ship)
self.preview.clean()
return True
示例3: onData
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def onData(self, value):
""" Method called when the tool input data is touched.
@param value Changed value.
"""
if not self.ship:
return
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
# Get the values (or fix them in bad setting case)
try:
draft = Units.parseQuantity(Locale.fromString(form.draft.text()))
except:
draft = self.ship.Draft
form.draft.setText(draft.UserString)
try:
trim = Units.parseQuantity(Locale.fromString(form.trim.text()))
except:
trim = Units.parseQuantity("0 deg")
form.trim.setText(trim.UserString)
bbox = self.ship.Shape.BoundBox
draft_min = Units.Quantity(bbox.ZMin, Units.Length)
draft_max = Units.Quantity(bbox.ZMax, Units.Length)
draft = self.clampValue(form.draft, draft_min, draft_max, draft)
trim_min = Units.parseQuantity("-180 deg")
trim_max = Units.parseQuantity("180 deg")
trim = self.clampValue(form.trim, trim_min, trim_max, trim)
self.onUpdate()
self.preview.update(draft, trim, self.ship)
示例4: save
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def save(self):
""" Saves the data into ship instance. """
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
form.num = self.widget(QtGui.QSpinBox, "Num")
draft = Units.parseQuantity(Locale.fromString(form.draft.text()))
trim = Units.parseQuantity(Locale.fromString(form.trim.text()))
num = form.num.value()
props = self.ship.PropertiesList
try:
props.index("AreaCurveDraft")
except ValueError:
try:
tooltip = str(QtGui.QApplication.translate(
"ship_areas",
"Areas curve tool draft selected [m]",
None))
except:
tooltip = "Areas curve tool draft selected [m]"
self.ship.addProperty("App::PropertyLength",
"AreaCurveDraft",
"Ship",
tooltip)
self.ship.AreaCurveDraft = draft
try:
props.index("AreaCurveTrim")
except ValueError:
try:
tooltip = str(QtGui.QApplication.translate(
"ship_areas",
"Areas curve tool trim selected [deg]",
None))
except:
tooltip = "Areas curve tool trim selected [deg]"
self.ship.addProperty("App::PropertyAngle",
"AreaCurveTrim",
"Ship",
tooltip)
self.ship.AreaCurveTrim = trim
try:
props.index("AreaCurveNum")
except ValueError:
try:
tooltip = str(QtGui.QApplication.translate(
"ship_areas",
"Areas curve tool number of points",
None))
except:
tooltip = "Areas curve tool number of points"
self.ship.addProperty("App::PropertyInteger",
"AreaCurveNum",
"Ship",
tooltip)
self.ship.AreaCurveNum = num
示例5: accept
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def accept(self):
if self.lc is None:
return False
self.save()
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.angle = self.widget(QtGui.QLineEdit, "Angle")
form.n_points = self.widget(QtGui.QSpinBox, "NumPoints")
form.var_trim = self.widget(QtGui.QCheckBox, "VariableTrim")
roll = Units.Quantity(Locale.fromString(form.angle.text()))
n_points = form.n_points.value()
var_trim = form.var_trim.isChecked()
rolls = []
for i in range(n_points):
rolls.append(roll * i / float(n_points - 1))
points = Tools.gz(self.lc, rolls, var_trim)
gzs = []
drafts = []
trims = []
for p in points:
gzs.append(p[0].getValueAs("m").Value)
drafts.append(p[1].getValueAs("m").Value)
trims.append(p[2].getValueAs("deg").Value)
PlotAux.Plot(rolls, gzs, drafts, trims)
return True
示例6: onUpdate
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def onUpdate(self):
""" Method called when the data update is requested. """
if not self.ship:
return
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
form.output = self.widget(QtGui.QTextEdit, "OutputData")
draft = Units.Quantity(Locale.fromString(
form.draft.text())).getValueAs('m').Value
trim = Units.Quantity(Locale.fromString(
form.trim.text())).getValueAs('deg').Value
# Calculate the drafts at each perpendicular
angle = math.radians(trim)
L = self.ship.Length.getValueAs('m').Value
B = self.ship.Breadth.getValueAs('m').Value
draftAP = draft + 0.5 * L * math.tan(angle)
if draftAP < 0.0:
draftAP = 0.0
draftFP = draft - 0.5 * L * math.tan(angle)
if draftFP < 0.0:
draftFP = 0.0
# Calculate the involved hydrostatics
data = Hydrostatics.displacement(self.ship,
draft,
0.0,
trim)
# Setup the html string
string = 'L = {0} [m]<BR>'.format(L)
string = string + 'B = {0} [m]<BR>'.format(B)
string = string + 'T = {0} [m]<HR>'.format(draft)
string = string + 'Trim = {0} [degrees]<BR>'.format(trim)
string = string + 'T<sub>AP</sub> = {0} [m]<BR>'.format(draftAP)
string = string + 'T<sub>FP</sub> = {0} [m]<HR>'.format(draftFP)
dispText = QtGui.QApplication.translate(
"ship_areas",
'Displacement',
None,
QtGui.QApplication.UnicodeUTF8)
string = string + dispText + ' = {0} [ton]<BR>'.format(data[0])
string = string + 'XCB = {0} [m]'.format(data[1].x)
form.output.setHtml(string)
示例7: save
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def save(self):
""" Saves the data into ship instance. """
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
draft = Units.Quantity(Locale.fromString(
form.draft.text())).getValueAs('m').Value
trim = Units.Quantity(Locale.fromString(
form.trim.text())).getValueAs('deg').Value
props = self.ship.PropertiesList
try:
props.index("AreaCurveDraft")
except ValueError:
try:
tooltip = str(QtGui.QApplication.translate(
"ship_areas",
"Areas curve tool draft selected [m]",
None,
QtGui.QApplication.UnicodeUTF8))
except:
tooltip = "Areas curve tool draft selected [m]"
self.ship.addProperty("App::PropertyLength",
"AreaCurveDraft",
"Ship",
tooltip)
self.ship.AreaCurveDraft = '{} m'.format(draft)
try:
props.index("AreaCurveTrim")
except ValueError:
try:
tooltip = str(QtGui.QApplication.translate(
"ship_areas",
"Areas curve tool trim selected [deg]",
None,
QtGui.QApplication.UnicodeUTF8))
except:
tooltip = "Areas curve tool trim selected [deg]"
self.ship.addProperty("App::PropertyAngle",
"AreaCurveTrim",
"Ship",
tooltip)
self.ship.AreaCurveTrim = '{} deg'.format(trim)
示例8: onUpdate
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def onUpdate(self):
""" Method called when the data update is requested. """
if not self.ship:
return
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
form.output = self.widget(QtGui.QTextEdit, "OutputData")
draft = Units.parseQuantity(Locale.fromString(form.draft.text()))
trim = Units.parseQuantity(Locale.fromString(form.trim.text()))
# Calculate the drafts at each perpendicular
angle = trim.getValueAs("rad").Value
L = self.ship.Length.getValueAs('m').Value
B = self.ship.Breadth.getValueAs('m').Value
draftAP = draft + 0.5 * self.ship.Length * math.tan(angle)
if draftAP < 0.0:
draftAP = 0.0
draftFP = draft - 0.5 * self.ship.Length * math.tan(angle)
if draftFP < 0.0:
draftFP = 0.0
# Calculate the involved hydrostatics
disp, B, _ = Hydrostatics.displacement(self.ship,
draft,
Units.parseQuantity("0 deg"),
trim)
xcb = Units.Quantity(B.x, Units.Length)
# Setup the html string
string = u'L = {0}<BR>'.format(self.ship.Length.UserString)
string += u'B = {0}<BR>'.format(self.ship.Breadth.UserString)
string += u'T = {0}<HR>'.format(draft.UserString)
string += u'Trim = {0}<BR>'.format(trim.UserString)
string += u'T<sub>AP</sub> = {0}<BR>'.format(draftAP.UserString)
string += u'T<sub>FP</sub> = {0}<HR>'.format(draftFP.UserString)
dispText = QtGui.QApplication.translate(
"ship_areas",
'Displacement',
None,
QtGui.QApplication.UnicodeUTF8)
string += dispText + u' = {0}<BR>'.format(disp.UserString)
string += u'XCB = {0}'.format(xcb.UserString)
form.output.setHtml(string)
示例9: onData
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def onData(self, value):
""" Method called when the tool input data is touched.
@param value Changed value.
"""
if not self.ship:
return
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.draft = self.widget(QtGui.QLineEdit, "Draft")
form.trim = self.widget(QtGui.QLineEdit, "Trim")
# Get the values (or fix them in bad setting case)
try:
draft = Units.Quantity(Locale.fromString(
form.draft.text())).getValueAs('m').Value
except:
draft = self.ship.Draft.getValueAs(USys.getLengthUnits()).Value
input_format = USys.getLengthFormat()
qty = Units.Quantity('{} m'.format(draft))
widget.setText(Locale.toString(input_format.format(
qty.getValueAs(USys.getLengthUnits()).Value)))
try:
trim = Units.Quantity(Locale.fromString(
form.trim.text())).getValueAs('deg').Value
except:
trim = 0.0
input_format = USys.getAngleFormat()
qty = Units.Quantity('{} deg'.format(trim))
widget.setText(Locale.toString(input_format.format(
qty.getValueAs(USys.getLengthUnits()).Value)))
bbox = self.ship.Shape.BoundBox
draft_min = bbox.ZMin / Units.Metre.Value
draft_max = bbox.ZMax / Units.Metre.Value
draft = self.clampLength(form.draft, draft_min, draft_max, draft)
trim_min = -180.0
trim_max = 180.0
trim = self.clampAngle(form.trim, trim_min, trim_max, trim)
self.onUpdate()
self.preview.update(draft, trim, self.ship)
示例10: accept
# 需要导入模块: from shipUtils import Locale [as 别名]
# 或者: from shipUtils.Locale import fromString [as 别名]
def accept(self):
"""Create the ship instance"""
mw = self.getMainWindow()
form = mw.findChild(QtGui.QWidget, "TaskPanel")
form.ship = self.widget(QtGui.QComboBox, "Ship")
form.weight = self.widget(QtGui.QLineEdit, "Weight")
ship = self.ships[form.ship.currentIndex()]
density = Units.parseQuantity(Locale.fromString(form.weight.text()))
Tools.createWeight(self.shapes, ship, density)
return True