Merge pull request #392 from berndhahnebach/bhbdev060

FEM context commands for FEM mesh
This commit is contained in:
Yorik van Havre 2016-12-23 19:01:04 -02:00 committed by GitHub
commit b6d5bc489f
10 changed files with 371 additions and 0 deletions

View File

@ -63,6 +63,7 @@ SOURCE_GROUP("Module" FILES ${Mod_SRCS})
SET(FemScripts_SRCS
_CommandAnalysis.py
_CommandBeamSection.py
_CommandClearMesh.py
_CommandControlSolver.py
_CommandConstraintSelfWeight.py
_CommandFEMMesh2Mesh.py
@ -71,6 +72,7 @@ SET(FemScripts_SRCS
_CommandMeshGmshFromShape.py
_CommandMeshNetgenFromShape.py
_CommandMeshRegion.py
_CommandPrintMeshInfo.py
_CommandPurgeResults.py
_CommandRunSolver.py
_CommandShellThickness.py

View File

@ -24,7 +24,9 @@ INSTALL(
TestFem.py
FemCommands.py
_CommandClearMesh.py
_CommandMeshNetgenFromShape.py
_CommandPrintMeshInfo.py
_CommandPurgeResults.py
_CommandRunSolver.py
_CommandControlSolver.py

View File

@ -25,10 +25,12 @@
<file>icons/fem-control-solver.svg</file>
<file>icons/fem-cylinder.svg</file>
<file>icons/fem-data.png</file>
<file>icons/fem-femmesh-clear-mesh.svg</file>
<file>icons/fem-femmesh-create-node-by-poly.svg</file>
<file>icons/fem-femmesh-from-shape.svg</file>
<file>icons/fem-femmesh-gmsh-from-shape.svg</file>
<file>icons/fem-femmesh-netgen-from-shape.svg</file>
<file>icons/fem-femmesh-print-info.svg</file>
<file>icons/fem-femmesh-region.svg</file>
<file>icons/fem-femmesh-to-mesh.svg</file>
<file>icons/fem-frequency-analysis.svg</file>

View File

@ -0,0 +1,120 @@
<?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.48.5 r10040"
sodipodi:docname="fem-femmesh-clear-mesh.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" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="radialGradient3703"
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">
<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>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="radialGradient3705"
gradientUnits="userSpaceOnUse"
cx="148.88333"
cy="81.869568"
fx="148.88333"
fy="81.869568"
r="19.467436"
gradientTransform="matrix(1.3852588,-5.1367833e-2,3.7056289e-2,0.9993132,-60.392403,7.7040438)" />
<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" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="5.5"
inkscape:cx="-0.90909091"
inkscape:cy="29.272727"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1280"
inkscape:window-height="750"
inkscape:window-x="156"
inkscape:window-y="158"
inkscape:window-maximized="0" />
<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="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.40000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:sans-serif"
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="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.40000001;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:sans-serif"
d="M 32,3.369141 C 16.223038,3.3691411 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.369141 32,3.369141 z m 0,6 C 44.534321,9.369141 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.3691411 32,9.369141 z"
id="path4152"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 271 KiB

View File

@ -50,6 +50,14 @@ Workbench::~Workbench()
{
}
void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const
{
StdWorkbench::setupContextMenu( recipient, item );
*item << "Separator"
<< "Fem_ClearMesh"
<< "Fem_PrintMeshInfo";
}
Gui::ToolBarItem* Workbench::setupToolBars() const
{
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();

View File

@ -38,6 +38,7 @@ class FemGuiExport Workbench : public Gui::StdWorkbench
public:
Workbench();
virtual ~Workbench();
void setupContextMenu(const char* recipient, Gui::MenuItem*) const;
protected:
Gui::ToolBarItem* setupToolBars() const;

View File

@ -48,6 +48,8 @@ class FemWorkbench (Workbench):
import _CommandShowResult
import _CommandRunSolver
import _CommandPurgeResults
import _CommandClearMesh
import _CommandPrintMeshInfo
import _CommandControlSolver
import _CommandFEMMesh2Mesh
import _CommandMeshGmshFromShape

View File

@ -0,0 +1,56 @@
# ***************************************************************************
# * *
# * Copyright (c) 2016 - Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * 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 *
# * *
# ***************************************************************************
__title__ = "Clear the FemMesh of a FEM mesh object"
__author__ = "Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
## @package CommandClearMesh
# \ingroup FEM
import FreeCAD
from FemCommands import FemCommands
import FreeCADGui
from PySide import QtCore
class _CommandClearMesh(FemCommands):
"clear the FEM mesh"
def __init__(self):
super(_CommandClearMesh, self).__init__()
self.resources = {'Pixmap': 'fem-femmesh-clear-mesh',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_ClearMesh", "Clear FEM mesh"),
# 'Accel': "Z, Z",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_ClearMesh", "Clear the Mesh of a FEM mesh object")}
self.is_active = 'with_femmesh'
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) == 1 and sel[0].isDerivedFrom("Fem::FemMeshObject"):
FreeCAD.ActiveDocument.openTransaction("Clear FEM mesh")
FreeCADGui.addModule("Fem")
FreeCADGui.doCommand("App.ActiveDocument." + sel[0].Name + ".FemMesh = Fem.FemMesh()")
FreeCADGui.doCommand("App.ActiveDocument.recompute()")
FreeCADGui.Selection.clearSelection()
FreeCADGui.addCommand('Fem_ClearMesh',_CommandClearMesh())

View File

@ -0,0 +1,59 @@
# ***************************************************************************
# * *
# * Copyright (c) 2016 - Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * 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 *
# * *
# ***************************************************************************
__title__ = "Print info of FEM mesh object"
__author__ = "Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
## @package CommandPrintMeshInfo
# \ingroup FEM
import FreeCAD
from FemCommands import FemCommands
import FreeCADGui
from PySide import QtCore
from PySide import QtGui
class _CommandPrintMeshInfo(FemCommands):
"Print FEM mesh info"
def __init__(self):
super(_CommandPrintMeshInfo, self).__init__()
self.resources = {'Pixmap': 'fem-femmesh-print-info',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_PrintMeshInfo", "Print FEM mesh info"),
# 'Accel': "Z, Z",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_PrintMeshInfo", "Print FEM mesh info")}
self.is_active = 'with_femmesh'
def Activated(self):
sel = FreeCADGui.Selection.getSelection()
if len(sel) == 1 and sel[0].isDerivedFrom("Fem::FemMeshObject"):
FreeCAD.ActiveDocument.openTransaction("Print FEM mesh info")
FreeCADGui.doCommand("print(App.ActiveDocument." + sel[0].Name + ".FemMesh)")
FreeCADGui.addModule("PySide")
FreeCADGui.doCommand("mesh_info = str(App.ActiveDocument." + sel[0].Name + ".FemMesh)")
FreeCADGui.doCommand("PySide.QtGui.QMessageBox.information(None, 'FEM Mesh Info', mesh_info)")
FreeCADGui.Selection.clearSelection()
FreeCADGui.addCommand('Fem_PrintMeshInfo',_CommandPrintMeshInfo())