Imported the loading conditions definition tool from sourceforge
This commit is contained in:
parent
d63348acf9
commit
b8ede9747a
|
@ -80,6 +80,11 @@ SET(ShipCapacityCurve_SRCS
|
|||
)
|
||||
SOURCE_GROUP("shipcapacitycurve" FILES ${ShipCapacityCurve_SRCS})
|
||||
|
||||
SET(ShipCreateLoadCondition_SRCS
|
||||
shipCreateLoadCondition/__init__.py
|
||||
)
|
||||
SOURCE_GROUP("shipcreateloadcondition" FILES ${ShipCreateLoadCondition_SRCS})
|
||||
|
||||
SET(ShipGZ_SRCS
|
||||
shipGZ/__init__.py
|
||||
shipGZ/PlotAux.py
|
||||
|
@ -97,7 +102,7 @@ SET(ShipUtils_SRCS
|
|||
)
|
||||
SOURCE_GROUP("shiputils" FILES ${ShipUtils_SRCS})
|
||||
|
||||
SET(all_files ${ShipMain_SRCS} ${ShipExamples_SRCS} ${ShipLoadExample_SRCS} ${ShipCreateShip_SRCS} ${ShipOutlineDraw_SRCS} ${ShipAreasCurve_SRCS} ${ShipHydrostatics_SRCS} ${ShipCreateWeight_SRCS} ${ShipCreateTank_SRCS} ${ShipCapacityCurve_SRCS} ${ShipGZ_SRCS} ${ShipUtils_SRCS})
|
||||
SET(all_files ${ShipMain_SRCS} ${ShipExamples_SRCS} ${ShipLoadExample_SRCS} ${ShipCreateShip_SRCS} ${ShipOutlineDraw_SRCS} ${ShipAreasCurve_SRCS} ${ShipHydrostatics_SRCS} ${ShipCreateWeight_SRCS} ${ShipCreateTank_SRCS} ${ShipCapacityCurve_SRCS} ${ShipCreateLoadCondition_SRCS} ${ShipGZ_SRCS} ${ShipUtils_SRCS})
|
||||
|
||||
ADD_CUSTOM_TARGET(Ship ALL
|
||||
SOURCES ${all_files} ${Ship_QRC_SRCS}
|
||||
|
@ -164,6 +169,12 @@ INSTALL(
|
|||
DESTINATION
|
||||
Mod/Ship/shipCapacityCurve
|
||||
)
|
||||
INSTALL(
|
||||
FILES
|
||||
${ShipCreateLoadCondition_SRCS}
|
||||
DESTINATION
|
||||
Mod/Ship/shipCreateLoadCondition
|
||||
)
|
||||
INSTALL(
|
||||
FILES
|
||||
${ShipGZ_SRCS}
|
||||
|
|
|
@ -53,6 +53,7 @@ class ShipWorkbench(Workbench):
|
|||
weightslist = ["Ship_Weight",
|
||||
"Ship_Tank",
|
||||
"Ship_Capacity",
|
||||
"Ship_LoadCondition",
|
||||
"Ship_GZ"]
|
||||
|
||||
self.appendToolbar(
|
||||
|
|
|
@ -109,6 +109,15 @@ class Ship:
|
|||
"Tanks",
|
||||
"Ship",
|
||||
tooltip).Tanks = []
|
||||
tooltip = str(QtGui.QApplication.translate(
|
||||
"Ship",
|
||||
"Set of load conditions",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8))
|
||||
obj.addProperty("App::PropertyStringList",
|
||||
"LoadConditions",
|
||||
"Ship",
|
||||
tooltip).LoadConditions = []
|
||||
|
||||
obj.Proxy = self
|
||||
|
||||
|
|
|
@ -170,6 +170,23 @@ class TankCapacity:
|
|||
'ToolTip': ToolTip}
|
||||
|
||||
|
||||
class LoadCondition:
|
||||
def Activated(self):
|
||||
import shipCreateLoadCondition
|
||||
shipCreateLoadCondition.load()
|
||||
|
||||
def GetResources(self):
|
||||
MenuText = QtCore.QT_TRANSLATE_NOOP(
|
||||
'ship_loadcondition',
|
||||
'Create a new loading condition')
|
||||
ToolTip = QtCore.QT_TRANSLATE_NOOP(
|
||||
'ship_loadcondition',
|
||||
'Create a new load condition spreadsheet')
|
||||
return {'Pixmap': 'Ship_LoadCondition',
|
||||
'MenuText': MenuText,
|
||||
'ToolTip': ToolTip}
|
||||
|
||||
|
||||
class GZ:
|
||||
def Activated(self):
|
||||
import shipGZ
|
||||
|
@ -195,4 +212,5 @@ FreeCADGui.addCommand('Ship_Hydrostatics', Hydrostatics())
|
|||
FreeCADGui.addCommand('Ship_Weight', CreateWeight())
|
||||
FreeCADGui.addCommand('Ship_Tank', CreateTank())
|
||||
FreeCADGui.addCommand('Ship_Capacity', TankCapacity())
|
||||
FreeCADGui.addCommand('Ship_LoadCondition', LoadCondition())
|
||||
FreeCADGui.addCommand('Ship_GZ', GZ())
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<file>icons/Ship_GZ.svg</file>
|
||||
<file>icons/Ship_Hydrostatics.svg</file>
|
||||
<file>icons/Ship_Load.svg</file>
|
||||
<file>icons/Ship_LoadCondition.svg</file>
|
||||
<file>icons/Ship_Logo.svg</file>
|
||||
<file>icons/Ship_Module.svg</file>
|
||||
<file>icons/Ship_OutlineDraw.svg</file>
|
||||
|
|
660
src/Mod/Ship/resources/icons/Ship_LoadCondition.svg
Normal file
660
src/Mod/Ship/resources/icons/Ship_LoadCondition.svg
Normal file
|
@ -0,0 +1,660 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="64px"
|
||||
height="64px"
|
||||
id="svg2985"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.4 r9939"
|
||||
sodipodi:docname="Ship_LoadCondition.svg">
|
||||
<defs
|
||||
id="defs2987">
|
||||
<linearGradient
|
||||
id="linearGradient3979">
|
||||
<stop
|
||||
id="stop3981"
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3983"
|
||||
offset="1"
|
||||
style="stop-color:#ff9600;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3971">
|
||||
<stop
|
||||
id="stop3973"
|
||||
offset="0"
|
||||
style="stop-color:#ffffff;stop-opacity:1;" />
|
||||
<stop
|
||||
id="stop3975"
|
||||
offset="1"
|
||||
style="stop-color:#be7300;stop-opacity:1;" />
|
||||
</linearGradient>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Send"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="Arrow1Send"
|
||||
style="overflow:visible;">
|
||||
<path
|
||||
id="path4031"
|
||||
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;"
|
||||
transform="scale(0.2) rotate(180) translate(6,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow2Send"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="Arrow2Send"
|
||||
style="overflow:visible;">
|
||||
<path
|
||||
id="path4049"
|
||||
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
|
||||
transform="scale(0.3) rotate(180) translate(-2.3,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow2Sstart"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="Arrow2Sstart"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path4046"
|
||||
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
|
||||
transform="scale(0.3) translate(-2.3,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="Arrow2Mstart"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="Arrow2Mstart"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path4040"
|
||||
style="fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round"
|
||||
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
|
||||
transform="scale(0.6) translate(0,0)" />
|
||||
</marker>
|
||||
<linearGradient
|
||||
id="linearGradient3900">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3902" />
|
||||
<stop
|
||||
style="stop-color:#a0a0a0;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3904" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3882">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3884" />
|
||||
<stop
|
||||
style="stop-color:#960000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3886" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3860">
|
||||
<stop
|
||||
style="stop-color:#1e76e3;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3862" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3864" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3860-6"
|
||||
id="linearGradient3866-5"
|
||||
x1="31.125395"
|
||||
y1="61.410763"
|
||||
x2="30.113636"
|
||||
y2="12.160761"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
id="linearGradient3860-6">
|
||||
<stop
|
||||
style="stop-color:#5a9ff5;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3862-4" />
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3864-4" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3905"
|
||||
id="linearGradient3949"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="7.7183714"
|
||||
x2="62.196697"
|
||||
y2="7.7183714" />
|
||||
<linearGradient
|
||||
id="linearGradient3905">
|
||||
<stop
|
||||
style="stop-color:#bebebe;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3907" />
|
||||
<stop
|
||||
style="stop-color:#585858;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3909" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3897"
|
||||
id="linearGradient3951"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="7.7183714"
|
||||
x2="62.196697"
|
||||
y2="7.7183714" />
|
||||
<linearGradient
|
||||
id="linearGradient3897">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3899" />
|
||||
<stop
|
||||
style="stop-color:#9f9f9f;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3901" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3905"
|
||||
id="linearGradient3941"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="7.7183714"
|
||||
x2="62.196697"
|
||||
y2="7.7183714" />
|
||||
<linearGradient
|
||||
id="linearGradient3176">
|
||||
<stop
|
||||
style="stop-color:#bebebe;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3178" />
|
||||
<stop
|
||||
style="stop-color:#585858;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3180" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3897"
|
||||
id="linearGradient3943"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="7.7183714"
|
||||
x2="62.196697"
|
||||
y2="7.7183714" />
|
||||
<linearGradient
|
||||
id="linearGradient3183">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3185" />
|
||||
<stop
|
||||
style="stop-color:#9f9f9f;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3187" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3905"
|
||||
id="linearGradient3945"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="7.7183714"
|
||||
x2="62.196697"
|
||||
y2="7.7183714" />
|
||||
<linearGradient
|
||||
id="linearGradient3190">
|
||||
<stop
|
||||
style="stop-color:#bebebe;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3192" />
|
||||
<stop
|
||||
style="stop-color:#585858;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3194" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3897"
|
||||
id="linearGradient3947"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="7.7183714"
|
||||
x2="62.196697"
|
||||
y2="7.7183714" />
|
||||
<linearGradient
|
||||
id="linearGradient3197">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3199" />
|
||||
<stop
|
||||
style="stop-color:#9f9f9f;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3201" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3925"
|
||||
id="linearGradient3961"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="35.450565"
|
||||
x2="62.196697"
|
||||
y2="35.450565" />
|
||||
<linearGradient
|
||||
id="linearGradient3925">
|
||||
<stop
|
||||
style="stop-color:#c98b8b;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3927" />
|
||||
<stop
|
||||
style="stop-color:#800000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3929" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3917"
|
||||
id="linearGradient3963"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="35.450565"
|
||||
x2="62.196697"
|
||||
y2="35.450565" />
|
||||
<linearGradient
|
||||
id="linearGradient3917">
|
||||
<stop
|
||||
style="stop-color:#450000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3919" />
|
||||
<stop
|
||||
style="stop-color:#c77c7c;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3921" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3925"
|
||||
id="linearGradient3953"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="35.450565"
|
||||
x2="62.196697"
|
||||
y2="35.450565" />
|
||||
<linearGradient
|
||||
id="linearGradient3212">
|
||||
<stop
|
||||
style="stop-color:#c98b8b;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3214" />
|
||||
<stop
|
||||
style="stop-color:#800000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3216" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3917"
|
||||
id="linearGradient3955"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="35.450565"
|
||||
x2="62.196697"
|
||||
y2="35.450565" />
|
||||
<linearGradient
|
||||
id="linearGradient3219">
|
||||
<stop
|
||||
style="stop-color:#450000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3221" />
|
||||
<stop
|
||||
style="stop-color:#c77c7c;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3223" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3925"
|
||||
id="linearGradient3957"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="35.450565"
|
||||
x2="62.196697"
|
||||
y2="35.450565" />
|
||||
<linearGradient
|
||||
id="linearGradient3226">
|
||||
<stop
|
||||
style="stop-color:#c98b8b;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3228" />
|
||||
<stop
|
||||
style="stop-color:#800000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3230" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3917"
|
||||
id="linearGradient3959"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="4.8033009"
|
||||
y1="35.450565"
|
||||
x2="62.196697"
|
||||
y2="35.450565" />
|
||||
<linearGradient
|
||||
id="linearGradient3233">
|
||||
<stop
|
||||
style="stop-color:#450000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3235" />
|
||||
<stop
|
||||
style="stop-color:#c77c7c;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3237" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
y2="35.450565"
|
||||
x2="62.196697"
|
||||
y1="35.450565"
|
||||
x1="4.8033009"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient3246"
|
||||
xlink:href="#linearGradient3925"
|
||||
inkscape:collect="always" />
|
||||
<linearGradient
|
||||
y2="35.450565"
|
||||
x2="62.196697"
|
||||
y1="35.450565"
|
||||
x1="4.8033009"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient3248"
|
||||
xlink:href="#linearGradient3917"
|
||||
inkscape:collect="always" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="4"
|
||||
inkscape:cx="105.96534"
|
||||
inkscape:cy="22.492481"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:window-width="1366"
|
||||
inkscape:window-height="720"
|
||||
inkscape:window-x="-2"
|
||||
inkscape:window-y="-3"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata2990">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
<cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/by-sa/3.0/">
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<g
|
||||
id="g3933"
|
||||
transform="matrix(0.95688842,0,0,0.82320192,0.252675,8.8113396)">
|
||||
<g
|
||||
style="fill:url(#linearGradient3949);fill-opacity:1;stroke:url(#linearGradient3951);stroke-opacity:1"
|
||||
id="g3893">
|
||||
<path
|
||||
sodipodi:nodetypes="cccscc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3883"
|
||||
d="M 33.5,-3.838753 C 29.699302,1.1109944 5.3033008,8.415215 5.3033008,8.415215 l 0,10.860281 c 0,0 8.6620582,-7.954951 24.2184072,-7.954951 15.556349,0 3.978292,0 3.978292,0 0,0 0,-9.2346409 0,-15.159298"
|
||||
style="fill:url(#linearGradient3941);fill-opacity:1;stroke:url(#linearGradient3943);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1" />
|
||||
<path
|
||||
style="fill:url(#linearGradient3945);fill-opacity:1;stroke:url(#linearGradient3947);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 33.5,-3.838753 C 37.300698,1.1109944 61.696699,8.415215 61.696699,8.415215 l 0,10.860281 c 0,0 -8.662058,-7.954951 -24.218407,-7.954951 -15.556349,0 -3.978292,0 -3.978292,0 0,0 0,-9.2346409 0,-15.159298"
|
||||
id="path3891-2"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccscc" />
|
||||
</g>
|
||||
<g
|
||||
style="fill:url(#linearGradient3246);fill-opacity:1;stroke:url(#linearGradient3248)"
|
||||
id="g3913">
|
||||
<path
|
||||
style="fill:url(#linearGradient3953);fill-opacity:1;stroke:url(#linearGradient3955);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="m 33.5,59.580583 c -12.727921,0 -28.1966992,-6.540738 -28.1966992,-24.571961 0,-10.076271 0,-15.733126 0,-15.733126 0,0 8.6620582,-7.954951 24.2184072,-7.954951 15.556349,0 3.978292,0 3.978292,0 z"
|
||||
id="path3064"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cscscc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cscscc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3889-6"
|
||||
d="m 33.5,59.580583 c 12.727921,0 28.196699,-6.540738 28.196699,-24.571961 0,-10.076271 0,-15.733126 0,-15.733126 0,0 -8.662058,-7.954951 -24.218407,-7.954951 -15.556349,0 -3.978292,0 -3.978292,0 z"
|
||||
style="fill:url(#linearGradient3957);fill-opacity:1;stroke:url(#linearGradient3959);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1" />
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="g4101"
|
||||
transform="matrix(1.5399613,0,0,1.5399613,-33.936572,-30.866243)">
|
||||
<g
|
||||
style="stroke-width:1.7280972;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
transform="matrix(0.86800673,0,0,0.86800673,10.345105,8.1458701)"
|
||||
id="g4047">
|
||||
<g
|
||||
style="stroke-width:1.7280972;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="g4043">
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3069"
|
||||
d="m 15.75,42.75 22.25,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<path
|
||||
transform="translate(10.75,12)"
|
||||
d="m 23.75,30.75 c 0,4.004064 -3.245936,7.25 -7.25,7.25 -4.004064,0 -7.25,-3.245936 -7.25,-7.25 0,-4.004064 3.245936,-7.25 7.25,-7.25 4.004064,0 7.25,3.245936 7.25,7.25 z"
|
||||
sodipodi:ry="7.25"
|
||||
sodipodi:rx="7.25"
|
||||
sodipodi:cy="30.75"
|
||||
sodipodi:cx="16.5"
|
||||
id="path3071"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:3.6"
|
||||
sodipodi:type="arc" />
|
||||
</g>
|
||||
<g
|
||||
style="stroke-width:1.7280972;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="g4031">
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 39.75,38.75 9.75,0 m 0,3.125 10.125,0"
|
||||
id="path3887"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3889"
|
||||
d="m 39.75,38.75 9.75,0 m 0,3.125 10.125,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3891"
|
||||
d="m 49.5,47.875 10.125,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 49.5,47.875 10.125,0"
|
||||
id="path3893"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
d="m 49.5,53.875 10.125,0"
|
||||
id="path3895"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3897"
|
||||
d="m 49.5,53.875 10.125,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3899"
|
||||
d="m 49.5,59.875 10.125,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
<g
|
||||
style="stroke-width:1.7280972;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
transform="translate(10,12)"
|
||||
id="g3907">
|
||||
<g
|
||||
style="stroke-width:1.7280972;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
id="g3903">
|
||||
<path
|
||||
sodipodi:nodetypes="cccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path3865"
|
||||
d="m 29.75,20.75 9.75,0 0,27.125 10.125,0"
|
||||
style="fill:none;stroke:#000000;stroke-width:1.7280972;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g
|
||||
id="g4087">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Liberation Mono;-inkscape-font-specification:Sans"
|
||||
x="46.072853"
|
||||
y="35.064079"
|
||||
id="text4063"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4065"
|
||||
x="46.072853"
|
||||
y="35.064079"
|
||||
style="font-size:3px">TF</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4067"
|
||||
y="40.501579"
|
||||
x="45.135353"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Liberation Mono;-inkscape-font-specification:Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:3px"
|
||||
y="40.501579"
|
||||
x="45.135353"
|
||||
id="tspan4069"
|
||||
sodipodi:role="line">F</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Liberation Mono;-inkscape-font-specification:Sans"
|
||||
x="61.31213"
|
||||
y="43.054005"
|
||||
id="text4071"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4073"
|
||||
x="61.31213"
|
||||
y="43.054005"
|
||||
style="font-size:3px">T</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4075"
|
||||
y="48.258511"
|
||||
x="61.31213"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Liberation Mono;-inkscape-font-specification:Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:3px"
|
||||
y="48.258511"
|
||||
x="61.31213"
|
||||
id="tspan4077"
|
||||
sodipodi:role="line">S</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Liberation Mono;-inkscape-font-specification:Sans"
|
||||
x="61.31213"
|
||||
y="53.46302"
|
||||
id="text4079"
|
||||
sodipodi:linespacing="125%"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan4081"
|
||||
x="61.31213"
|
||||
y="53.46302"
|
||||
style="font-size:3px">W</tspan></text>
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4083"
|
||||
y="58.744652"
|
||||
x="62.211544"
|
||||
style="font-size:40px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:end;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;font-family:Liberation Mono;-inkscape-font-specification:Sans"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-size:3px;text-align:end;text-anchor:end"
|
||||
y="58.744652"
|
||||
x="62.211544"
|
||||
id="tspan4085"
|
||||
sodipodi:role="line">WNA</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 24 KiB |
130
src/Mod/Ship/shipCreateLoadCondition/__init__.py
Normal file
130
src/Mod/Ship/shipCreateLoadCondition/__init__.py
Normal file
|
@ -0,0 +1,130 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2011, 2012 *
|
||||
#* Jose Luis Cercos Pita <jlcercos@gmail.com> *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* This program is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Library General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with this program; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
import Spreadsheet
|
||||
|
||||
|
||||
def load():
|
||||
"""Directly create the load condition"""
|
||||
# Check that a ship has been selected
|
||||
ship = None
|
||||
selObjs = Gui.Selection.getSelection()
|
||||
if not selObjs:
|
||||
msg = QtGui.QApplication.translate(
|
||||
"ship_console",
|
||||
"A ship instance must be selected before using this tool (no"
|
||||
" objects selected)",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8)
|
||||
App.Console.PrintError(msg + '\n')
|
||||
return
|
||||
for i in range(len(selObjs)):
|
||||
obj = selObjs[i]
|
||||
props = obj.PropertiesList
|
||||
try:
|
||||
props.index("IsShip")
|
||||
except ValueError:
|
||||
continue
|
||||
if obj.IsShip:
|
||||
if ship:
|
||||
msg = QtGui.QApplication.translate(
|
||||
"ship_console",
|
||||
"More than one ship have been selected (the extra"
|
||||
" ships will be ignored)",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8)
|
||||
App.Console.PrintWarning(msg + '\n')
|
||||
break
|
||||
ship = obj
|
||||
|
||||
if not ship:
|
||||
msg = QtGui.QApplication.translate(
|
||||
"ship_console",
|
||||
"A ship instance must be selected before using this tool (no"
|
||||
" valid ship found at the selected objects)",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8)
|
||||
App.Console.PrintError(msg + '\n')
|
||||
return
|
||||
|
||||
# Create the spreadsheet
|
||||
s = App.activeDocument().addObject('Spreadsheet::Sheet',
|
||||
'LoadCondition')
|
||||
|
||||
# Add a reference to the owner ship
|
||||
s.mergeCells('A1:D1')
|
||||
s.setAlignment('A1:A1', 'center', 'keep')
|
||||
s.setStyle('A1:A1', 'bold', 'add')
|
||||
s.setStyle('A1:A1', 'underline', 'add')
|
||||
s.set("A1", "SHIP")
|
||||
s.set("A2", "ship")
|
||||
s.set("A3", ship.Label)
|
||||
s.set("B2", "internal ref")
|
||||
s.set("B3", ship.Name)
|
||||
s.setForeground('A1:B3', (0.5,0.5,0.5))
|
||||
|
||||
# Add the weights data
|
||||
s.mergeCells('A4:D4')
|
||||
s.setAlignment('A4:A4', 'center', 'keep')
|
||||
s.setStyle('A4:A4', 'bold', 'add')
|
||||
s.setStyle('A4:A4', 'underline', 'add')
|
||||
s.set("A4", "WEIGHTS")
|
||||
s.set("A5", "weight")
|
||||
s.set("B5", "internal ref")
|
||||
for i in range(len(ship.Weights)):
|
||||
weight = App.activeDocument().getObject(ship.Weights[i])
|
||||
s.set("A{}".format(i + 6), weight.Label)
|
||||
s.set("B{}".format(i + 6), weight.Name)
|
||||
s.setForeground('A4:B{}'.format(5 + len(ship.Weights)), (0.5,0.5,0.5))
|
||||
|
||||
# Add the tanks data
|
||||
s.mergeCells('A{0}:D{0}'.format(6 + len(ship.Weights)))
|
||||
s.setAlignment('A{0}:A{0}'.format(6 + len(ship.Weights)), 'center', 'keep')
|
||||
s.setStyle('A{0}:A{0}'.format(6 + len(ship.Weights)), 'bold', 'add')
|
||||
s.setStyle('A{0}:A{0}'.format(6 + len(ship.Weights)), 'underline', 'add')
|
||||
s.set("A{}".format(6 + len(ship.Weights)), "TANKS")
|
||||
s.set("A{}".format(7 + len(ship.Weights)), "tank")
|
||||
s.set("B{}".format(7 + len(ship.Weights)), "internal ref")
|
||||
s.set("C{}".format(7 + len(ship.Weights)), "Fluid density [kg/m^3]")
|
||||
s.set("D{}".format(7 + len(ship.Weights)), "Filling ratio")
|
||||
for i in range(len(ship.Tanks)):
|
||||
tank = App.activeDocument().getObject(ship.Tanks[i])
|
||||
s.set("A{}".format(i + 8 + len(ship.Weights)), tank.Label)
|
||||
s.set("B{}".format(i + 8 + len(ship.Weights)), tank.Name)
|
||||
s.set("C{}".format(i + 8 + len(ship.Weights)), "998.0")
|
||||
s.set("D{}".format(i + 8 + len(ship.Weights)), "0.0")
|
||||
s.setForeground('A{0}:A{0}'.format(6 + len(ship.Weights)), (0.5,0.5,0.5))
|
||||
s.setForeground('A{0}:D{0}'.format(7 + len(ship.Weights)), (0.5,0.5,0.5))
|
||||
s.setForeground('A{}:B{}'.format(8 + len(ship.Weights),
|
||||
8 + len(ship.Weights) + len(ship.Tanks)),
|
||||
(0.5,0.5,0.5))
|
||||
|
||||
# Add the spreadsheet to the list of loading conditions of the ship
|
||||
lcs = ship.LoadConditions[:]
|
||||
lcs.append(s.Name)
|
||||
ship.LoadConditions = lcs
|
||||
|
||||
# Recompute to take the changes
|
||||
App.activeDocument().recompute()
|
|
@ -26,51 +26,17 @@ import FreeCAD as App
|
|||
import FreeCADGui as Gui
|
||||
import Units
|
||||
from PySide import QtGui, QtCore
|
||||
import Preview
|
||||
import PlotAux
|
||||
import Instance
|
||||
from shipUtils import Paths
|
||||
import shipUtils.Units as USys
|
||||
import shipUtils.Locale as Locale
|
||||
from shipHydrostatics import Tools as Hydrostatics
|
||||
|
||||
|
||||
class TaskPanel:
|
||||
def __init__(self):
|
||||
self.ui = Paths.modulePath() + "/shipAreasCurve/TaskPanel.ui"
|
||||
self.preview = Preview.Preview()
|
||||
self.ship = None
|
||||
self.ui = Paths.modulePath() + "/shipGZ/TaskPanel.ui"
|
||||
|
||||
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
|
||||
|
||||
def reject(self):
|
||||
|
@ -102,20 +68,14 @@ class TaskPanel:
|
|||
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")
|
||||
form.doc = QtGui.QTextDocument(form.output)
|
||||
form.angle = self.widget(QtGui.QLineEdit, "Angle")
|
||||
form.n_points = self.widget(QtGui.QSpinBox, "NPoints")
|
||||
form.var_draft = self.widget(QtGui.QCheckBox, "VariableDraft")
|
||||
form.var_trim = self.widget(QtGui.QCheckBox, "VariableTrim")
|
||||
self.form = form
|
||||
if self.initValues():
|
||||
return True
|
||||
self.retranslateUi()
|
||||
QtCore.QObject.connect(form.draft,
|
||||
QtCore.SIGNAL("valueChanged(double)"),
|
||||
self.onData)
|
||||
QtCore.QObject.connect(form.trim,
|
||||
QtCore.SIGNAL("valueChanged(double)"),
|
||||
self.onData)
|
||||
|
||||
def getMainWindow(self):
|
||||
toplevel = QtGui.qApp.topLevelWidgets()
|
||||
|
@ -138,75 +98,6 @@ class TaskPanel:
|
|||
def initValues(self):
|
||||
""" Set initial values for fields
|
||||
"""
|
||||
selObjs = Gui.Selection.getSelection()
|
||||
if not selObjs:
|
||||
msg = QtGui.QApplication.translate(
|
||||
"ship_console",
|
||||
"A ship instance must be selected before using this tool (no"
|
||||
" objects selected)",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8)
|
||||
App.Console.PrintError(msg + '\n')
|
||||
return True
|
||||
for i in range(0, len(selObjs)):
|
||||
obj = selObjs[i]
|
||||
props = obj.PropertiesList
|
||||
try:
|
||||
props.index("IsShip")
|
||||
except ValueError:
|
||||
continue
|
||||
if obj.IsShip:
|
||||
if self.ship:
|
||||
msg = QtGui.QApplication.translate(
|
||||
"ship_console",
|
||||
"More than one ship have been selected (the extra"
|
||||
" ships will be ignored)",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8)
|
||||
App.Console.PrintWarning(msg + '\n')
|
||||
break
|
||||
self.ship = obj
|
||||
if not self.ship:
|
||||
msg = QtGui.QApplication.translate(
|
||||
"ship_console",
|
||||
"A ship instance must be selected before using this tool (no"
|
||||
" valid ship found at the selected objects)",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8)
|
||||
App.Console.PrintError(msg + '\n')
|
||||
return True
|
||||
|
||||
length_format = USys.getLengthFormat()
|
||||
angle_format = USys.getAngleFormat()
|
||||
|
||||
mw = self.getMainWindow()
|
||||
form = mw.findChild(QtGui.QWidget, "TaskPanel")
|
||||
form.draft = self.widget(QtGui.QLineEdit, "Draft")
|
||||
form.trim = self.widget(QtGui.QLineEdit, "Trim")
|
||||
form.draft.setText(Locale.toString(length_format.format(
|
||||
self.ship.Draft.getValueAs(USys.getLengthUnits()).Value)))
|
||||
form.trim.setText(Locale.toString(angle_format.format(0.0)))
|
||||
# Try to use saved values
|
||||
props = self.ship.PropertiesList
|
||||
try:
|
||||
props.index("AreaCurveDraft")
|
||||
form.draft.setText(Locale.toString(length_format.format(
|
||||
self.ship.AreaCurveDraft.getValueAs(
|
||||
USys.getLengthUnits()).Value)))
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
props.index("AreaCurveTrim")
|
||||
form.trim.setText(Locale.toString(angle_format.format(
|
||||
self.ship.AreaCurveTrim.getValueAs(
|
||||
USys.getAngleUnits()).Value)))
|
||||
except ValueError:
|
||||
pass
|
||||
# Update GUI
|
||||
draft = Units.Quantity(form.draft.text()).getValueAs('m').Value
|
||||
trim = Units.Quantity(form.trim.text()).getValueAs('deg').Value
|
||||
self.preview.update(draft, trim, self.ship)
|
||||
self.onUpdate()
|
||||
return False
|
||||
|
||||
def retranslateUi(self):
|
||||
|
@ -214,178 +105,34 @@ class TaskPanel:
|
|||
mw = self.getMainWindow()
|
||||
form = mw.findChild(QtGui.QWidget, "TaskPanel")
|
||||
form.setWindowTitle(QtGui.QApplication.translate(
|
||||
"ship_areas",
|
||||
"Plot the transversal areas curve",
|
||||
"ship_gz",
|
||||
"Plot the GZ curve",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8))
|
||||
self.widget(QtGui.QLabel, "DraftLabel").setText(
|
||||
self.widget(QtGui.QLabel, "AngleLabel").setText(
|
||||
QtGui.QApplication.translate(
|
||||
"ship_areas",
|
||||
"Draft",
|
||||
"ship_gz",
|
||||
"Angle",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8))
|
||||
self.widget(QtGui.QLabel, "TrimLabel").setText(
|
||||
self.widget(QtGui.QLabel, "NPointsLabel").setText(
|
||||
QtGui.QApplication.translate(
|
||||
"ship_areas",
|
||||
"Trim",
|
||||
"ship_gz",
|
||||
"Number of points",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8))
|
||||
self.widget(QtGui.QCheckBox, "VariableDraft").setText(
|
||||
QtGui.QApplication.translate(
|
||||
"ship_gz",
|
||||
"Variable draft",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8))
|
||||
self.widget(QtGui.QCheckBox, "VariableTrim").setText(
|
||||
QtGui.QApplication.translate(
|
||||
"ship_gz",
|
||||
"Variable trim",
|
||||
None,
|
||||
QtGui.QApplication.UnicodeUTF8))
|
||||
|
||||
def clampLength(self, widget, val_min, val_max, val):
|
||||
if val >= val_min and val <= val_max:
|
||||
return val
|
||||
input_format = USys.getLengthFormat()
|
||||
val = min(val_max, max(val_min, val))
|
||||
qty = Units.Quantity('{} m'.format(val))
|
||||
widget.setText(Locale.toString(input_format.format(
|
||||
qty.getValueAs(USys.getLengthUnits()).Value)))
|
||||
return val
|
||||
|
||||
def clampAngle(self, widget, val_min, val_max, val):
|
||||
if val >= val_min and val <= val_max:
|
||||
return val
|
||||
input_format = USys.getAngleFormat()
|
||||
val = min(val_max, max(val_min, val))
|
||||
qty = Units.Quantity('{} deg'.format(val))
|
||||
widget.setText(Locale.toString(input_format.format(
|
||||
qty.getValueAs(USys.getLengthUnits()).Value)))
|
||||
return val
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
def createTask():
|
||||
|
|
Loading…
Reference in New Issue
Block a user