Fem: Improve constraint section print (#14046)
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
@@ -361,6 +361,7 @@ SET(FemGuiSymbol_IV
|
||||
Resources/symbols/ConstraintPlaneRotation.iv
|
||||
Resources/symbols/ConstraintPressure.iv
|
||||
Resources/symbols/ConstraintRigidBody.iv
|
||||
Resources/symbols/ConstraintSectionPrint.iv
|
||||
Resources/symbols/ConstraintSpring.iv
|
||||
Resources/symbols/ConstraintTemperature.iv
|
||||
Resources/symbols/ConstraintTie.iv
|
||||
|
||||
19
src/Mod/Fem/Gui/Resources/symbols/ConstraintSectionPrint.iv
Normal file
19
src/Mod/Fem/Gui/Resources/symbols/ConstraintSectionPrint.iv
Normal file
@@ -0,0 +1,19 @@
|
||||
#Inventor V2.1 ascii
|
||||
|
||||
|
||||
Separator {
|
||||
|
||||
Separator {
|
||||
|
||||
Translation {
|
||||
translation 0 0.05 0
|
||||
|
||||
}
|
||||
Cube {
|
||||
width 0.75
|
||||
height 0.1
|
||||
depth 0.75
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,17 +15,33 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
<property name="title">
|
||||
<string>Parameter</string>
|
||||
</property>
|
||||
</spacer>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_variable">
|
||||
<property name="text">
|
||||
<string>Variable</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cb_variable"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@@ -31,6 +31,7 @@ __url__ = "https://www.freecad.org"
|
||||
|
||||
from . import base_fempythonobject
|
||||
|
||||
_PropHelper = base_fempythonobject._PropHelper
|
||||
|
||||
class ConstraintSectionPrint(base_fempythonobject.BaseFemPythonObject):
|
||||
"""
|
||||
@@ -41,3 +42,30 @@ class ConstraintSectionPrint(base_fempythonobject.BaseFemPythonObject):
|
||||
|
||||
def __init__(self, obj):
|
||||
super(ConstraintSectionPrint, self).__init__(obj)
|
||||
|
||||
for prop in self._get_properties():
|
||||
prop.add_to_object(obj)
|
||||
|
||||
|
||||
def _get_properties(self):
|
||||
prop = []
|
||||
|
||||
prop.append(_PropHelper(
|
||||
type = "App::PropertyEnumeration",
|
||||
name = "Variable",
|
||||
group = "Constraint Section Print",
|
||||
doc = "Set facial variable",
|
||||
value = ["Section Force", "Heat Flux", "Drag Stress"]
|
||||
)
|
||||
)
|
||||
|
||||
return prop
|
||||
|
||||
|
||||
def onDocumentRestored(self, obj):
|
||||
# update old project with new properties
|
||||
for prop in self._get_properties():
|
||||
try:
|
||||
obj.getPropertyByName(prop.name)
|
||||
except:
|
||||
prop.add_to_object(obj)
|
||||
|
||||
@@ -64,8 +64,16 @@ def write_constraint(f, femobj, sectionprint_obj, ccxwriter):
|
||||
|
||||
# floats read from ccx should use {:.13G}, see comment in writer module
|
||||
|
||||
variable = sectionprint_obj.Variable
|
||||
if variable == "Section Force":
|
||||
key = "SOF, SOM, SOAREA"
|
||||
elif variable == "Heat Flux":
|
||||
key = "FLUX"
|
||||
elif variable == "Drag Stress":
|
||||
key = "DRAG"
|
||||
|
||||
f.write(
|
||||
"*SECTION PRINT, SURFACE=SECTIONFACE{}, NAME=SECTIONPRINT{}\n"
|
||||
.format(sectionprint_obj.Name, sectionprint_obj.Name)
|
||||
)
|
||||
f.write("SOF, SOM, SOAREA\n")
|
||||
f.write(key + "\n")
|
||||
|
||||
@@ -29,6 +29,7 @@ __url__ = "https://www.freecad.org"
|
||||
# \ingroup FEM
|
||||
# \brief task panel for constraint section print object
|
||||
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
|
||||
import FreeCAD
|
||||
@@ -52,6 +53,14 @@ class _TaskPanel:
|
||||
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/ConstraintSectionPrint.ui"
|
||||
)
|
||||
|
||||
self.init_parameter_widget()
|
||||
|
||||
QtCore.QObject.connect(
|
||||
self.parameterWidget.cb_variable,
|
||||
QtCore.SIGNAL("currentIndexChanged(int)"),
|
||||
self.variable_changed
|
||||
)
|
||||
|
||||
# geometry selection widget
|
||||
self.selectionWidget = selection_widgets.GeometryElementsSelection(
|
||||
obj.References,
|
||||
@@ -61,15 +70,11 @@ class _TaskPanel:
|
||||
)
|
||||
|
||||
# form made from param and selection widget
|
||||
self.form = [self.parameterWidget, self.selectionWidget]
|
||||
self.form = [self.selectionWidget, self.parameterWidget]
|
||||
|
||||
def accept(self):
|
||||
# check values
|
||||
items = len(self.selectionWidget.references)
|
||||
FreeCAD.Console.PrintMessage(
|
||||
"Task panel: found references: {}\n{}\n"
|
||||
.format(items, self.selectionWidget.references)
|
||||
)
|
||||
|
||||
if items != 1:
|
||||
msgBox = QtGui.QMessageBox()
|
||||
@@ -87,6 +92,8 @@ class _TaskPanel:
|
||||
return False
|
||||
elif msgBox.clickedButton() == ignoreButton:
|
||||
pass
|
||||
|
||||
self.obj.Variable = self.variable
|
||||
self.obj.References = self.selectionWidget.references
|
||||
self.recompute_and_set_back_all()
|
||||
return True
|
||||
@@ -102,3 +109,13 @@ class _TaskPanel:
|
||||
if self.selectionWidget.sel_server:
|
||||
FreeCADGui.Selection.removeObserver(self.selectionWidget.sel_server)
|
||||
doc.resetEdit()
|
||||
|
||||
def init_parameter_widget(self):
|
||||
self.variable = self.obj.Variable
|
||||
self.variable_enum = self.obj.getEnumerationsOfProperty("Variable")
|
||||
self.parameterWidget.cb_variable.addItems(self.variable_enum)
|
||||
index = self.variable_enum.index(self.variable)
|
||||
self.parameterWidget.cb_variable.setCurrentIndex(index)
|
||||
|
||||
def variable_changed(self, index):
|
||||
self.variable = self.variable_enum[index]
|
||||
|
||||
@@ -38,6 +38,12 @@ class VPConstraintSectionPrint(view_base_femconstraint.VPBaseFemConstraint):
|
||||
A View Provider for the ConstraintSectionPrint object
|
||||
"""
|
||||
|
||||
def __init__(self, vobj):
|
||||
super().__init__(vobj)
|
||||
mat = vobj.ShapeAppearance[0]
|
||||
mat.DiffuseColor = (0.0, 0.165, 1.0, 0.0)
|
||||
vobj.ShapeAppearance = mat
|
||||
|
||||
def setEdit(self, vobj, mode=0):
|
||||
view_base_femconstraint.VPBaseFemConstraint.setEdit(
|
||||
self,
|
||||
@@ -45,3 +51,7 @@ class VPConstraintSectionPrint(view_base_femconstraint.VPBaseFemConstraint):
|
||||
mode,
|
||||
task_constraint_sectionprint._TaskPanel
|
||||
)
|
||||
|
||||
def attach(self, vobj):
|
||||
super().attach(vobj)
|
||||
vobj.loadSymbol(self.resource_symbol_dir + "ConstraintSectionPrint.iv")
|
||||
|
||||
Reference in New Issue
Block a user