FEM: objects, use fem name sheme for object package names
This commit is contained in:
committed by
Yorik van Havre
parent
07ae0e56c4
commit
c85afd0e44
@@ -0,0 +1,141 @@
|
||||
# ***************************************************************************
|
||||
# * *
|
||||
# * 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 femtools.femutils as FemUtils
|
||||
from . import ViewProviderFemConstraint
|
||||
from FreeCAD import Units
|
||||
|
||||
import FreeCADGui as Gui
|
||||
from . import FemSelectionWidgets
|
||||
|
||||
|
||||
class ViewProxy(ViewProviderFemConstraint.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/Resources/ui/FlowVelocity.ui")
|
||||
self._initParamWidget()
|
||||
self.form = [self._refWidget, self._paramWidget]
|
||||
analysis = FemUtils.findAnalysisOfMember(obj)
|
||||
self._mesh = FemUtils.getSingleMember(analysis, "Fem::FemMeshObject")
|
||||
self._part = None
|
||||
if hasattr(self._mesh, "Part"): # Geometry of Gmesh mesh obj
|
||||
self._part = self._mesh.Part
|
||||
elif hasattr(self._mesh, "Shape"): # Geometry of Netgen mesh obj
|
||||
self._part = self._mesh.Shape
|
||||
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()
|
||||
Reference in New Issue
Block a user