FEM: constraint flow velocity, add object, command, icon, task panel, etc
This commit is contained in:
@@ -101,6 +101,7 @@ SET(FemObjectsScripts_SRCS
|
||||
PyObjects/__init__.py
|
||||
PyObjects/_FemConstraintSelfWeight.py
|
||||
PyObjects/_FemConstraintBodyHeatSource.py
|
||||
PyObjects/_FemConstraintFlowVelocity.py
|
||||
PyObjects/_FemElementFluid1D.py
|
||||
PyObjects/_FemElementGeometry1D.py
|
||||
PyObjects/_FemElementGeometry2D.py
|
||||
@@ -148,6 +149,7 @@ SET(FemGuiScripts_SRCS
|
||||
PyGui/_CommandFemAnalysis.py
|
||||
PyGui/_CommandFemConstraintSelfWeight.py
|
||||
PyGui/_CommandFemConstraintBodyHeatSource.py
|
||||
PyGui/_CommandFemConstraintFlowVelocity.py
|
||||
PyGui/_CommandFemElementFluid1D.py
|
||||
PyGui/_CommandFemElementGeometry1D.py
|
||||
PyGui/_CommandFemElementGeometry2D.py
|
||||
@@ -181,6 +183,7 @@ SET(FemGuiScripts_SRCS
|
||||
PyGui/_TaskPanelFemSolverControl.py
|
||||
PyGui/_ViewProviderFemConstraintSelfWeight.py
|
||||
PyGui/_ViewProviderFemConstraintBodyHeatSource.py
|
||||
PyGui/_ViewProviderFemConstraintFlowVelocity.py
|
||||
PyGui/_ViewProviderFemElementFluid1D.py
|
||||
PyGui/_ViewProviderFemElementGeometry1D.py
|
||||
PyGui/_ViewProviderFemElementGeometry2D.py
|
||||
@@ -204,6 +207,7 @@ SET(FemGuiScripts_SRCS
|
||||
PyGui/TaskPanelFemMeshRegion.ui
|
||||
PyGui/TaskPanelFemResultShow.ui
|
||||
PyGui/TaskPanelFemSolverCalculix.ui
|
||||
PyGui/TaskPanelFemFlowVelocity.ui
|
||||
)
|
||||
|
||||
SET(FemTests_SRCS
|
||||
|
||||
@@ -51,6 +51,7 @@ INSTALL(
|
||||
PyObjects/__init__.py
|
||||
PyObjects/_FemConstraintSelfWeight.py
|
||||
PyObjects/_FemConstraintBodyHeatSource.py
|
||||
PyObjects/_FemConstraintFlowVelocity.py
|
||||
PyObjects/_FemElementFluid1D.py
|
||||
PyObjects/_FemElementGeometry1D.py
|
||||
PyObjects/_FemElementGeometry2D.py
|
||||
@@ -108,6 +109,7 @@ INSTALL(
|
||||
PyGui/FemSelectionWidgets.py
|
||||
PyGui/__init__.py
|
||||
PyGui/_CommandFemConstraintBodyHeatSource.py
|
||||
PyGui/_CommandFemConstraintFlowVelocity.py
|
||||
PyGui/_CommandFemAnalysis.py
|
||||
PyGui/_CommandFemConstraintSelfWeight.py
|
||||
PyGui/_CommandFemElementFluid1D.py
|
||||
@@ -143,6 +145,7 @@ INSTALL(
|
||||
PyGui/_TaskPanelFemSolverControl.py
|
||||
PyGui/_ViewProviderFemConstraintSelfWeight.py
|
||||
PyGui/_ViewProviderFemConstraintBodyHeatSource.py
|
||||
PyGui/_ViewProviderFemConstraintFlowVelocity.py
|
||||
PyGui/_ViewProviderFemElementFluid1D.py
|
||||
PyGui/_ViewProviderFemElementGeometry1D.py
|
||||
PyGui/_ViewProviderFemElementGeometry2D.py
|
||||
@@ -166,6 +169,7 @@ INSTALL(
|
||||
PyGui/TaskPanelFemMeshRegion.ui
|
||||
PyGui/TaskPanelFemResultShow.ui
|
||||
PyGui/TaskPanelFemSolverCalculix.ui
|
||||
PyGui/TaskPanelFemFlowVelocity.ui
|
||||
DESTINATION
|
||||
Mod/Fem/PyGui
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<file>icons/fem-constraint-contact.svg</file>
|
||||
<file>icons/fem-constraint-displacement.svg</file>
|
||||
<file>icons/fem-constraint-fixed.svg</file>
|
||||
<file>icons/fem-constraint-flow-velocity.svg</file>
|
||||
<file>icons/fem-constraint-fluid-boundary.svg</file>
|
||||
<file>icons/fem-constraint-force.svg</file>
|
||||
<file>icons/fem-constraint-gear.svg</file>
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<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:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
id="svg8"
|
||||
version="1.1"
|
||||
viewBox="0 0 64 64"
|
||||
height="64"
|
||||
width="64"
|
||||
sodipodi:docname="fem-constraint-flow-velocity.svg"
|
||||
inkscape:version="0.92.2 (unknown)">
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1163"
|
||||
id="namedview10"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.375"
|
||||
inkscape:cx="18.37157"
|
||||
inkscape:cy="14.137902"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg8" />
|
||||
<defs
|
||||
id="defs2" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<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:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
transform="matrix(15.229651,0,0,15.229651,-3.9499368,-4458.0565)"
|
||||
id="layer1"
|
||||
style="stroke-width:0.06566139">
|
||||
<text
|
||||
id="text6140"
|
||||
y="296.17419"
|
||||
x="0.7462678"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.54142189px;line-height:1.25;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.00581337"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans Bold';stroke-width:0.00581337"
|
||||
y="296.17419"
|
||||
x="0.7462678"
|
||||
id="tspan6138">V</tspan></text>
|
||||
<text
|
||||
id="text6144"
|
||||
y="291.55859"
|
||||
x="2.7012193"
|
||||
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.01737291"
|
||||
xml:space="preserve"><tspan
|
||||
style="stroke-width:0.01737291"
|
||||
y="301.09158"
|
||||
x="2.7012193"
|
||||
id="tspan6142" /></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -104,7 +104,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
|
||||
Gui::ToolBarItem* fluid = new Gui::ToolBarItem(root);
|
||||
fluid->setCommand("Fluid Constraints");
|
||||
*fluid << "FEM_ConstraintFluidBoundary";
|
||||
*fluid << "FEM_ConstraintFluidBoundary"
|
||||
<< "FEM_AddConstraintFlowVelocity";
|
||||
|
||||
Gui::ToolBarItem* solve = new Gui::ToolBarItem(root);
|
||||
solve->setCommand("Solve");
|
||||
@@ -167,7 +168,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
|
||||
Gui::MenuItem* fluid = new Gui::MenuItem;
|
||||
fluid->setCommand("&Fluid Constraints");
|
||||
*fluid << "FEM_ConstraintFluidBoundary";
|
||||
*fluid << "FEM_ConstraintFluidBoundary"
|
||||
<< "FEM_AddConstraintFlowVelocity";
|
||||
|
||||
Gui::MenuItem* model = new Gui::MenuItem;
|
||||
root->insertItem(item, model);
|
||||
|
||||
@@ -48,6 +48,7 @@ class FemWorkbench (Workbench):
|
||||
import PyGui._CommandFemAnalysis
|
||||
import PyGui._CommandFemConstraintSelfWeight
|
||||
import PyGui._CommandFemConstraintBodyHeatSource
|
||||
import PyGui._CommandFemConstraintFlowVelocity
|
||||
import PyGui._CommandFemElementFluid1D
|
||||
import PyGui._CommandFemElementGeometry1D
|
||||
import PyGui._CommandFemElementGeometry2D
|
||||
|
||||
@@ -73,6 +73,17 @@ def makeConstraintFixed(doc, name="ConstraintFixed"):
|
||||
return obj
|
||||
|
||||
|
||||
def makeConstraintFlowVelocity(doc, name="ConstraintFlowVelocity"):
|
||||
'''makeConstraintFlowVelocity(document, [name]): makes a Fem ConstraintFlowVelocity object'''
|
||||
obj = doc.addObject("Fem::ConstraintPython", name)
|
||||
import PyObjects._FemConstraintFlowVelocity
|
||||
PyObjects._FemConstraintFlowVelocity.Proxy(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
import PyGui._ViewProviderFemConstraintFlowVelocity
|
||||
PyGui._ViewProviderFemConstraintFlowVelocity.ViewProxy(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
|
||||
def makeConstraintFluidBoundary(doc, name="ConstraintFluidBoundary"):
|
||||
'''makeConstraintFluidBoundary(document, name): makes a Fem ConstraintForce object'''
|
||||
obj = doc.addObject("Fem::ConstraintForce", name)
|
||||
|
||||
234
src/Mod/Fem/PyGui/TaskPanelFemFlowVelocity.ui
Normal file
234
src/Mod/Fem/PyGui/TaskPanelFemFlowVelocity.ui
Normal file
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Constraint Properties</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="volocityXLbl">
|
||||
<property name="text">
|
||||
<string>Velocity x:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="velocityYLbl">
|
||||
<property name="text">
|
||||
<string>Velocity y:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="velocityZLbl">
|
||||
<property name="text">
|
||||
<string>Velocity z:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Gui::InputField" name="velocityZTxt">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="singleStep" stdset="0">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string>m/s</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="velocityZBox">
|
||||
<property name="text">
|
||||
<string>unspecified</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="Gui::InputField" name="velocityXTxt">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="singleStep" stdset="0">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string>m/s</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="velocityXBox">
|
||||
<property name="text">
|
||||
<string>unspecified</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="Gui::InputField" name="velocityYTxt">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="singleStep" stdset="0">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string>m/s</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="velocityYBox">
|
||||
<property name="text">
|
||||
<string>unspecified</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="normalBox">
|
||||
<property name="text">
|
||||
<string>normal to boundary</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::InputField</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>Gui/InputField.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>velocityXBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>velocityXTxt</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>230</x>
|
||||
<y>44</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>230</x>
|
||||
<y>18</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>velocityXBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>velocityXTxt</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>230</x>
|
||||
<y>44</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>230</x>
|
||||
<y>18</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>velocityYBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>velocityYTxt</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>347</x>
|
||||
<y>53</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>184</x>
|
||||
<y>53</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>velocityYBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>velocityYTxt</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>347</x>
|
||||
<y>53</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>184</x>
|
||||
<y>53</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>velocityZBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>velocityZTxt</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>347</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>184</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>velocityZBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>velocityZTxt</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>347</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>184</x>
|
||||
<y>87</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
59
src/Mod/Fem/PyGui/_CommandFemConstraintFlowVelocity.py
Normal file
59
src/Mod/Fem/PyGui/_CommandFemConstraintFlowVelocity.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2017 - Markus Hovorka <m.hovorka@live.de> *
|
||||
# * *
|
||||
# * 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__ = "AddConstraintFlowVelocity"
|
||||
__author__ = "Markus Hovorka"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
from PySide import QtCore
|
||||
|
||||
import FreeCAD as App
|
||||
import FreeCADGui as Gui
|
||||
from PyGui import FemCommands
|
||||
|
||||
|
||||
class Command(FemCommands.FemCommands):
|
||||
|
||||
def __init__(self):
|
||||
super(Command, self).__init__()
|
||||
self.resources = {
|
||||
'Pixmap': 'fem-constraint-flow-velocity',
|
||||
'MenuText': QtCore.QT_TRANSLATE_NOOP(
|
||||
"FEM_ConstraintFlowVelocity",
|
||||
"Constraint Velocity"),
|
||||
'ToolTip': QtCore.QT_TRANSLATE_NOOP(
|
||||
"FEM_ConstraintFlowVelocity",
|
||||
"Creates a FEM constraint body heat flux")}
|
||||
self.is_active = 'with_analysis'
|
||||
|
||||
def Activated(self):
|
||||
App.ActiveDocument.openTransaction(
|
||||
"Create FemConstraintFlowVelocity")
|
||||
Gui.addModule("ObjectsFem")
|
||||
Gui.doCommand(
|
||||
"FemGui.getActiveAnalysis().Member += "
|
||||
"[ObjectsFem.makeConstraintFlowVelocity()]")
|
||||
|
||||
|
||||
Gui.addCommand('FEM_AddConstraintFlowVelocity', Command())
|
||||
137
src/Mod/Fem/PyGui/_ViewProviderFemConstraintFlowVelocity.py
Normal file
137
src/Mod/Fem/PyGui/_ViewProviderFemConstraintFlowVelocity.py
Normal file
@@ -0,0 +1,137 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2017 - Markus Hovorka <m.hovorka@live.de> *
|
||||
# * *
|
||||
# * 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__ = "view provider for constraint flow velocity object"
|
||||
__author__ = "Markus Hovorka, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
import FreeCAD as App
|
||||
import FemUtils
|
||||
import FemConstraint
|
||||
from FreeCAD import Units
|
||||
|
||||
import FreeCADGui as Gui
|
||||
from . import FemSelectionWidgets
|
||||
|
||||
|
||||
class ViewProxy(FemConstraint.ViewProxy):
|
||||
|
||||
def getIcon(self):
|
||||
return ":/icons/fem-constraint-flow-velocity.svg"
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
task = _TaskPanel(vobj.Object)
|
||||
Gui.Control.showDialog(task)
|
||||
|
||||
def unsetEdit(self, vobj, mode=0):
|
||||
Gui.Control.closeDialog()
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
if Gui.Control.activeDialog():
|
||||
Gui.Control.closeDialog()
|
||||
Gui.ActiveDocument.setEdit(vobj.Object.Name)
|
||||
return True
|
||||
|
||||
|
||||
class _TaskPanel(object):
|
||||
|
||||
def __init__(self, obj):
|
||||
self._obj = obj
|
||||
self._refWidget = FemSelectionWidgets.BoundarySelector()
|
||||
self._refWidget.setReferences(obj.References)
|
||||
self._paramWidget = Gui.PySideUic.loadUi(
|
||||
App.getHomePath() + "Mod/Fem/PyGui/TaskPanelFemFlowVelocity.ui")
|
||||
self._initParamWidget()
|
||||
self.form = [self._refWidget, self._paramWidget]
|
||||
analysis = FemUtils.findAnalysisOfMember(obj)
|
||||
self._mesh = FemUtils.getSingleMember(analysis, "Fem::FemMeshObject")
|
||||
self._part = self._mesh.Part if self._mesh is not None else None
|
||||
self._partVisible = None
|
||||
self._meshVisible = None
|
||||
|
||||
def open(self):
|
||||
if self._mesh is not None and self._part is not None:
|
||||
self._meshVisible = self._mesh.ViewObject.isVisible()
|
||||
self._partVisible = self._part.ViewObject.isVisible()
|
||||
self._mesh.ViewObject.hide()
|
||||
self._part.ViewObject.show()
|
||||
|
||||
def reject(self):
|
||||
self._restoreVisibility()
|
||||
return True
|
||||
|
||||
def accept(self):
|
||||
if self._obj.References != self._refWidget.references():
|
||||
self._obj.References = self._refWidget.references()
|
||||
self._applyWidgetChanges()
|
||||
self._obj.Document.recompute()
|
||||
self._restoreVisibility()
|
||||
return True
|
||||
|
||||
def _restoreVisibility(self):
|
||||
if self._mesh is not None and self._part is not None:
|
||||
if self._meshVisible:
|
||||
self._mesh.ViewObject.show()
|
||||
else:
|
||||
self._mesh.ViewObject.hide()
|
||||
if self._partVisible:
|
||||
self._part.ViewObject.show()
|
||||
else:
|
||||
self._part.ViewObject.hide()
|
||||
|
||||
def _initParamWidget(self):
|
||||
unit = "m/s"
|
||||
self._paramWidget.velocityXTxt.setText(
|
||||
str(self._obj.VelocityX) + unit)
|
||||
self._paramWidget.velocityYTxt.setText(
|
||||
str(self._obj.VelocityY) + unit)
|
||||
self._paramWidget.velocityZTxt.setText(
|
||||
str(self._obj.VelocityZ) + unit)
|
||||
self._paramWidget.velocityXBox.setChecked(
|
||||
not self._obj.VelocityXEnabled)
|
||||
self._paramWidget.velocityYBox.setChecked(
|
||||
not self._obj.VelocityYEnabled)
|
||||
self._paramWidget.velocityZBox.setChecked(
|
||||
not self._obj.VelocityZEnabled)
|
||||
self._paramWidget.normalBox.setChecked(
|
||||
self._obj.NormalToBoundary)
|
||||
|
||||
def _applyWidgetChanges(self):
|
||||
unit = "m/s"
|
||||
self._obj.VelocityXEnabled = \
|
||||
not self._paramWidget.velocityXBox.isChecked()
|
||||
if self._obj.VelocityXEnabled:
|
||||
quantity = Units.Quantity(self._paramWidget.velocityXTxt.text())
|
||||
self._obj.VelocityX = float(quantity.getValueAs(unit))
|
||||
self._obj.VelocityYEnabled = \
|
||||
not self._paramWidget.velocityYBox.isChecked()
|
||||
if self._obj.VelocityYEnabled:
|
||||
quantity = Units.Quantity(self._paramWidget.velocityYTxt.text())
|
||||
self._obj.VelocityY = float(quantity.getValueAs(unit))
|
||||
self._obj.VelocityZEnabled = \
|
||||
not self._paramWidget.velocityZBox.isChecked()
|
||||
if self._obj.VelocityZEnabled:
|
||||
quantity = Units.Quantity(self._paramWidget.velocityZTxt.text())
|
||||
self._obj.VelocityZ = float(quantity.getValueAs(unit))
|
||||
self._obj.NormalToBoundary = self._paramWidget.normalBox.isChecked()
|
||||
58
src/Mod/Fem/PyObjects/_FemConstraintFlowVelocity.py
Normal file
58
src/Mod/Fem/PyObjects/_FemConstraintFlowVelocity.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * Copyright (c) 2017 - Markus Hovorka <m.hovorka@live.de> *
|
||||
# * *
|
||||
# * 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__ = "the constraint flow velocity object"
|
||||
__author__ = "Markus Hovorka, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
|
||||
import FemConstraint
|
||||
|
||||
|
||||
class Proxy(FemConstraint.Proxy):
|
||||
|
||||
Type = "Fem::ConstraintFlowVelocity"
|
||||
|
||||
def __init__(self, obj):
|
||||
super(Proxy, self).__init__(obj)
|
||||
obj.addProperty(
|
||||
"App::PropertyFloat", "VelocityX",
|
||||
"Parameter", "Body heat flux")
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "VelocityXEnabled",
|
||||
"Parameter", "Body heat flux")
|
||||
obj.addProperty(
|
||||
"App::PropertyFloat", "VelocityY",
|
||||
"Parameter", "Body heat flux")
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "VelocityYEnabled",
|
||||
"Parameter", "Body heat flux")
|
||||
obj.addProperty(
|
||||
"App::PropertyFloat", "VelocityZ",
|
||||
"Parameter", "Body heat flux")
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "VelocityZEnabled",
|
||||
"Parameter", "Body heat flux")
|
||||
obj.addProperty(
|
||||
"App::PropertyBool", "NormalToBoundary",
|
||||
"Parameter", "Body heat flux")
|
||||
Reference in New Issue
Block a user