Fixed the Units usage
This commit is contained in:
parent
493d1cc48b
commit
fcfac342f2
|
@ -83,7 +83,7 @@ class Plot(object):
|
||||||
areas.line.set_linewidth(2.0)
|
areas.line.set_linewidth(2.0)
|
||||||
areas.line.set_color((0.0, 0.0, 0.0))
|
areas.line.set_color((0.0, 0.0, 0.0))
|
||||||
# Get perpendiculars data
|
# Get perpendiculars data
|
||||||
Lpp = ship.Length
|
Lpp = ship.Length.getValueAs('m').Value
|
||||||
FPx = 0.5 * Lpp
|
FPx = 0.5 * Lpp
|
||||||
APx = -0.5 * Lpp
|
APx = -0.5 * Lpp
|
||||||
maxArea = max(y)
|
maxArea = max(y)
|
||||||
|
@ -177,7 +177,7 @@ class Plot(object):
|
||||||
Output.write(" ######################################################"
|
Output.write(" ######################################################"
|
||||||
"###########\n")
|
"###########\n")
|
||||||
# Get perpendiculars data
|
# Get perpendiculars data
|
||||||
Lpp = ship.Length
|
Lpp = ship.Length.getValueAs('m').Value
|
||||||
FPx = 0.5 * Lpp
|
FPx = 0.5 * Lpp
|
||||||
APx = -0.5 * Lpp
|
APx = -0.5 * Lpp
|
||||||
maxArea = max(y)
|
maxArea = max(y)
|
||||||
|
|
|
@ -176,23 +176,19 @@ class TaskPanel:
|
||||||
bbox = self.ship.Shape.BoundBox
|
bbox = self.ship.Shape.BoundBox
|
||||||
form.draft.setMaximum(bbox.ZMax / Units.Metre.Value)
|
form.draft.setMaximum(bbox.ZMax / Units.Metre.Value)
|
||||||
form.draft.setMinimum(bbox.ZMin / Units.Metre.Value)
|
form.draft.setMinimum(bbox.ZMin / Units.Metre.Value)
|
||||||
form.draft.setValue(self.ship.Draft)
|
form.draft.setValue(self.ship.Draft.getValueAs('m').Value)
|
||||||
# Try to use saved values
|
# Try to use saved values
|
||||||
props = self.ship.PropertiesList
|
props = self.ship.PropertiesList
|
||||||
flag = True
|
|
||||||
try:
|
try:
|
||||||
props.index("AreaCurveDraft")
|
props.index("AreaCurveDraft")
|
||||||
|
form.draft.setValue(self.ship.AreaCurveDraft.getValueAs('m').Value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag = False
|
form.draft.setValue(self.ship.Draft.getValueAs('m').Value)
|
||||||
if flag:
|
|
||||||
form.draft.setValue(self.ship.AreaCurveDraft)
|
|
||||||
flag = True
|
|
||||||
try:
|
try:
|
||||||
props.index("AreaCurveTrim")
|
props.index("AreaCurveTrim")
|
||||||
|
form.trim.setValue(self.ship.AreaCurveTrim.getValueAs('deg').Value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
flag = False
|
form.trim.setValue(0.0)
|
||||||
if flag:
|
|
||||||
form.trim.setValue(self.ship.AreaCurveTrim)
|
|
||||||
# Update GUI
|
# Update GUI
|
||||||
self.preview.update(form.draft.value(), form.trim.value(), self.ship)
|
self.preview.update(form.draft.value(), form.trim.value(), self.ship)
|
||||||
self.onUpdate()
|
self.onUpdate()
|
||||||
|
@ -244,7 +240,8 @@ class TaskPanel:
|
||||||
form.output = self.widget(QtGui.QTextEdit, "OutputData")
|
form.output = self.widget(QtGui.QTextEdit, "OutputData")
|
||||||
# Calculate the drafts at each perpendicular
|
# Calculate the drafts at each perpendicular
|
||||||
angle = math.radians(form.trim.value())
|
angle = math.radians(form.trim.value())
|
||||||
L = self.ship.Length
|
L = self.ship.Length.getValueAs('m').Value
|
||||||
|
B = self.ship.Breadth.getValueAs('m').Value
|
||||||
draftAP = form.draft.value() + 0.5 * L * math.tan(angle)
|
draftAP = form.draft.value() + 0.5 * L * math.tan(angle)
|
||||||
if draftAP < 0.0:
|
if draftAP < 0.0:
|
||||||
draftAP = 0.0
|
draftAP = 0.0
|
||||||
|
@ -257,8 +254,8 @@ class TaskPanel:
|
||||||
0.0,
|
0.0,
|
||||||
form.trim.value())
|
form.trim.value())
|
||||||
# Setup the html string
|
# Setup the html string
|
||||||
string = 'L = {0} [m]<BR>'.format(self.ship.Length)
|
string = 'L = {0} [m]<BR>'.format(L)
|
||||||
string = string + 'B = {0} [m]<BR>'.format(self.ship.Breadth)
|
string = string + 'B = {0} [m]<BR>'.format(B)
|
||||||
string = string + 'T = {0} [m]<HR>'.format(form.draft.value())
|
string = string + 'T = {0} [m]<HR>'.format(form.draft.value())
|
||||||
string = string + 'Trim = {0} [degrees]<BR>'.format(form.trim.value())
|
string = string + 'Trim = {0} [degrees]<BR>'.format(form.trim.value())
|
||||||
string = string + 'T<sub>AP</sub> = {0} [m]<BR>'.format(draftAP)
|
string = string + 'T<sub>AP</sub> = {0} [m]<BR>'.format(draftAP)
|
||||||
|
@ -290,11 +287,11 @@ class TaskPanel:
|
||||||
QtGui.QApplication.UnicodeUTF8))
|
QtGui.QApplication.UnicodeUTF8))
|
||||||
except:
|
except:
|
||||||
tooltip = "Areas curve tool draft selected [m]"
|
tooltip = "Areas curve tool draft selected [m]"
|
||||||
self.ship.addProperty("App::PropertyFloat",
|
self.ship.addProperty("App::PropertyLength",
|
||||||
"AreaCurveDraft",
|
"AreaCurveDraft",
|
||||||
"Ship",
|
"Ship",
|
||||||
tooltip)
|
tooltip)
|
||||||
self.ship.AreaCurveDraft = form.draft.value()
|
self.ship.AreaCurveDraft = '{} m'.format(form.draft.value())
|
||||||
try:
|
try:
|
||||||
props.index("AreaCurveTrim")
|
props.index("AreaCurveTrim")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -306,11 +303,11 @@ class TaskPanel:
|
||||||
QtGui.QApplication.UnicodeUTF8))
|
QtGui.QApplication.UnicodeUTF8))
|
||||||
except:
|
except:
|
||||||
tooltip = "Areas curve tool trim selected [deg]"
|
tooltip = "Areas curve tool trim selected [deg]"
|
||||||
self.ship.addProperty("App::PropertyFloat",
|
self.ship.addProperty("App::PropertyAngle",
|
||||||
"AreaCurveTrim",
|
"AreaCurveTrim",
|
||||||
"Ship",
|
"Ship",
|
||||||
tooltip)
|
tooltip)
|
||||||
self.ship.AreaCurveTrim = form.trim.value()
|
self.ship.AreaCurveTrim = '{} deg'.format(form.trim.value())
|
||||||
|
|
||||||
|
|
||||||
def createTask():
|
def createTask():
|
||||||
|
|
Loading…
Reference in New Issue
Block a user