FEM: Add Purge FEM results button

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
Przemo Firszt 2015-04-30 22:13:42 +01:00
parent 97a6333f87
commit 749e772d85
4 changed files with 231 additions and 0 deletions

View File

@ -15,6 +15,7 @@
<file>icons/Fem_Inp_Editor.svg</file>
<file>icons/Fem_Material.svg</file>
<file>icons/Fem_NewAnalysis.svg</file>
<file>icons/Fem_Purge_Results.svg</file>
<file>icons/Fem_Result.svg</file>
<file>icons/Fem_ResultDisplacement.svg</file>
<file>icons/Fem_ResultStress.svg</file>

View File

@ -0,0 +1,185 @@
<?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="svg2860"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
sodipodi:docname="Fem_Purge_Results.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs2862">
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="radialGradient3692"
cx="45.883327"
cy="28.869568"
fx="45.883327"
fy="28.869568"
r="19.467436"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient3377">
<stop
id="stop3379"
offset="0"
style="stop-color:#faff2b;stop-opacity:1;" />
<stop
id="stop3381"
offset="1"
style="stop-color:#ffaa00;stop-opacity:1;" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2868" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377-8"
id="radialGradient3703-7"
gradientUnits="userSpaceOnUse"
cx="135.38333"
cy="97.369568"
fx="135.38333"
fy="97.369568"
r="19.467436"
gradientTransform="matrix(0.97435,0.2250379,-0.4623105,2.0016728,48.487554,-127.99883)" />
<linearGradient
id="linearGradient3377-8">
<stop
id="stop3379-0"
offset="0"
style="stop-color:#faff2b;stop-opacity:1;" />
<stop
id="stop3381-6"
offset="1"
style="stop-color:#ffaa00;stop-opacity:1;" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377-6"
id="radialGradient3703-1"
gradientUnits="userSpaceOnUse"
cx="135.38333"
cy="97.369568"
fx="135.38333"
fy="97.369568"
r="19.467436"
gradientTransform="matrix(0.97435,0.2250379,-0.4623105,2.0016728,48.487554,-127.99883)" />
<linearGradient
id="linearGradient3377-6">
<stop
style="stop-color:#00ff00;stop-opacity:1;"
offset="0"
id="stop3784" />
<stop
id="stop3786"
offset="0.5"
style="stop-color:#0003f8;stop-opacity:1;" />
<stop
id="stop3381-5"
offset="1"
style="stop-color:#ff0000;stop-opacity:1;" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3377-6"
id="linearGradient3788"
x1="-0.01679256"
y1="14.293757"
x2="64.0868"
y2="14.293757"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3377-6"
id="linearGradient3814"
x1="163.77647"
y1="96.396309"
x2="179.47777"
y2="96.396309"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3377-6"
id="linearGradient3816"
x1="12.594974"
y1="31.093735"
x2="53.898453"
y2="32.617771"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.01411218,-1.3055708,0.47684233,0.03863846,15.500382,72.056154)" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="4.369699"
inkscape:cx="-5.1476846"
inkscape:cy="34.508104"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1366"
inkscape:window-height="702"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1" />
<metadata
id="metadata2865">
<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 />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="fill:url(#linearGradient3816);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.32764792;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 45.533176,61.752047 17.129484,61.744506 17.468441,2.1933317 45.262316,2.4730246 z"
id="rect3520-7"
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:1.51256716px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 13.110404,79.471866 c 0.09167,0 0.183347,0 0,0 z"
id="path2394"
inkscape:connector-curvature="0" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 11.754269,47.678609 c -1.228162,1.228162 -1.228174,3.337636 0,4.565809 1.228166,1.228166 3.339029,1.229544 4.567192,0.0014 L 52.2458,16.321461 c 1.228162,-1.228163 1.226784,-3.339026 -0.0014,-4.567192 -1.228173,-1.228174 -3.337647,-1.228162 -4.565809,0 l -35.92434,35.92434 z"
id="rect4154"
inkscape:connector-curvature="0" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;baseline-shift:baseline;text-anchor:start;white-space:normal;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="M 32,3.3691406 C 16.223038,3.3691407 3.3691407,16.223038 3.3691406,32 3.3691406,47.776962 16.223038,60.630859 32,60.630859 47.776962,60.630859 60.630859,47.776962 60.630859,32 60.630859,16.223038 47.776962,3.3691406 32,3.3691406 Z m 0,6 C 44.534321,9.3691406 54.630859,19.465679 54.630859,32 54.630859,44.534321 44.534321,54.630859 32,54.630859 19.465679,54.630859 9.3691406,44.534321 9.3691406,32 9.3691407,19.465679 19.465679,9.3691407 32,9.3691406 Z"
id="path4152"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -69,6 +69,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "Fem_ConstraintPulley"
<< "Separator"
<< "Fem_MechanicalJobControl"
<< "Fem_PurgeResults"
<< "Fem_ShowResult";
return root;
}
@ -94,6 +95,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Fem_ConstraintPulley"
<< "Separator"
<< "Fem_MechanicalJobControl"
<< "Fem_PurgeResults"
<< "Fem_ShowResult";
return root;

View File

@ -131,6 +131,20 @@ class _CommandMechanicalJobControl:
return FreeCADGui.ActiveDocument is not None and FemGui.getActiveAnalysis() is not None
class _CommandPurgeFemResults:
def GetResources(self):
return {'Pixmap': 'Fem_Purge_Results',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results"),
'Accel': "S, S",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_PurgeResults", "Purge results from an analysis")}
def Activated(self):
purge_fem_results()
def IsActive(self):
return FreeCADGui.ActiveDocument is not None and results_present()
class _CommandMechanicalShowResult:
"the Fem JobControl command definition"
def GetResources(self):
@ -617,7 +631,36 @@ class _ResultControlTaskPanel:
def reject(self):
FreeCADGui.Control.closeDialog()
# Helpers
def results_present():
import FemGui
results = False
analysis_members = FemGui.getActiveAnalysis().Member
for o in analysis_members:
if o.isDerivedFrom('Fem::FemResultVector'):
results = True
elif o.isDerivedFrom("Fem::FemResultValue") and o.DataType == 'VonMisesStress':
results = True
return results
def purge_fem_results(Analysis=None):
import FemGui
if Analysis is None:
analysis_members = FemGui.getActiveAnalysis().Member
else:
analysis_members = FemGui.Analysis().Member
for o in analysis_members:
if (o.isDerivedFrom('Fem::FemResultVector') or
(o.isDerivedFrom("Fem::FemResultValue") and o.DataType == 'VonMisesStress') or
(o.isDerivedFrom("Fem::FemResultValue") and o.DataType == 'AnalysisStats')):
FreeCAD.ActiveDocument.removeObject(o.Name)
FreeCADGui.addCommand('Fem_NewMechanicalAnalysis', _CommandNewMechanicalAnalysis())
FreeCADGui.addCommand('Fem_CreateFromShape', _CommandFemFromShape())
FreeCADGui.addCommand('Fem_MechanicalJobControl', _CommandMechanicalJobControl())
FreeCADGui.addCommand('Fem_PurgeResults', _CommandPurgeFemResults())
FreeCADGui.addCommand('Fem_ShowResult', _CommandMechanicalShowResult())