Skip to content

Commit 740d051

Browse files
committed
Fem: Improve constraint section print
1 parent b72a8c4 commit 740d051

File tree

7 files changed

+114
-15
lines changed

7 files changed

+114
-15
lines changed

src/Mod/Fem/Gui/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ SET(FemGuiSymbol_IV
354354
Resources/symbols/ConstraintHeatFlux.iv
355355
Resources/symbols/ConstraintPlaneRotation.iv
356356
Resources/symbols/ConstraintPressure.iv
357+
Resources/symbols/ConstraintSectionPrint.iv
357358
Resources/symbols/ConstraintSpring.iv
358359
Resources/symbols/ConstraintTemperature.iv
359360
Resources/symbols/ConstraintTie.iv
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#Inventor V2.1 ascii
2+
3+
4+
Separator {
5+
6+
Separator {
7+
8+
Translation {
9+
translation 0 0.05 0
10+
11+
}
12+
Cube {
13+
width 0.75
14+
height 0.1
15+
depth 0.75
16+
17+
}
18+
}
19+
}

src/Mod/Fem/Gui/Resources/ui/ConstraintSectionPrint.ui

+25-9
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,33 @@
1515
</property>
1616
<layout class="QVBoxLayout" name="verticalLayout">
1717
<item>
18-
<spacer name="verticalSpacer_2">
19-
<property name="orientation">
20-
<enum>Qt::Vertical</enum>
18+
<widget class="QGroupBox" name="groupBox_3">
19+
<property name="sizePolicy">
20+
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
21+
<horstretch>0</horstretch>
22+
<verstretch>0</verstretch>
23+
</sizepolicy>
2124
</property>
22-
<property name="sizeHint" stdset="0">
23-
<size>
24-
<width>20</width>
25-
<height>40</height>
26-
</size>
25+
<property name="title">
26+
<string>Parameter</string>
2727
</property>
28-
</spacer>
28+
<layout class="QVBoxLayout" name="verticalLayout_5">
29+
<item>
30+
<layout class="QGridLayout" name="gridLayout_1">
31+
<item row="0" column="0">
32+
<widget class="QLabel" name="lbl_variable">
33+
<property name="text">
34+
<string>Variable</string>
35+
</property>
36+
</widget>
37+
</item>
38+
<item row="0" column="1">
39+
<widget class="QComboBox" name="cb_variable"/>
40+
</item>
41+
</layout>
42+
</item>
43+
</layout>
44+
</widget>
2945
</item>
3046
</layout>
3147
</widget>

src/Mod/Fem/femobjects/constraint_sectionprint.py

+28
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from . import base_fempythonobject
3333

34+
_PropHelper = base_fempythonobject._PropHelper
3435

3536
class ConstraintSectionPrint(base_fempythonobject.BaseFemPythonObject):
3637
"""
@@ -41,3 +42,30 @@ class ConstraintSectionPrint(base_fempythonobject.BaseFemPythonObject):
4142

4243
def __init__(self, obj):
4344
super(ConstraintSectionPrint, self).__init__(obj)
45+
46+
for prop in self._get_properties():
47+
prop.add_to_object(obj)
48+
49+
50+
def _get_properties(self):
51+
prop = []
52+
53+
prop.append(_PropHelper(
54+
type = "App::PropertyEnumeration",
55+
name = "Variable",
56+
group = "Constraint Section Print",
57+
doc = "Set facial variable",
58+
value = ["Section Load", "Heat Flux", "Drag Stress"]
59+
)
60+
)
61+
62+
return prop
63+
64+
65+
def onDocumentRestored(self, obj):
66+
# update old project with new properties
67+
for prop in self._get_properties():
68+
try:
69+
obj.getPropertyByName(prop.name)
70+
except:
71+
prop.add_to_object(obj)

src/Mod/Fem/femsolver/calculix/write_constraint_sectionprint.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,16 @@ def write_constraint(f, femobj, sectionprint_obj, ccxwriter):
6464

6565
# floats read from ccx should use {:.13G}, see comment in writer module
6666

67+
variable = sectionprint_obj.Variable
68+
if variable == "Section Load":
69+
key = "SOF, SOM, SOAREA"
70+
elif variable == "Heat Flux":
71+
key = "FLUX"
72+
elif variable == "Drag Stress":
73+
key = "DRAG"
74+
6775
f.write(
6876
"*SECTION PRINT, SURFACE=SECTIONFACE{}, NAME=SECTIONPRINT{}\n"
6977
.format(sectionprint_obj.Name, sectionprint_obj.Name)
7078
)
71-
f.write("SOF, SOM, SOAREA\n")
79+
f.write(key + "\n")

src/Mod/Fem/femtaskpanels/task_constraint_sectionprint.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# \ingroup FEM
3030
# \brief task panel for constraint section print object
3131

32+
from PySide import QtCore
3233
from PySide import QtGui
3334

3435
import FreeCAD
@@ -52,6 +53,14 @@ def __init__(self, obj):
5253
FreeCAD.getHomePath() + "Mod/Fem/Resources/ui/ConstraintSectionPrint.ui"
5354
)
5455

56+
self.init_parameter_widget()
57+
58+
QtCore.QObject.connect(
59+
self.parameterWidget.cb_variable,
60+
QtCore.SIGNAL("currentIndexChanged(int)"),
61+
self.variable_changed
62+
)
63+
5564
# geometry selection widget
5665
self.selectionWidget = selection_widgets.GeometryElementsSelection(
5766
obj.References,
@@ -61,15 +70,11 @@ def __init__(self, obj):
6170
)
6271

6372
# form made from param and selection widget
64-
self.form = [self.parameterWidget, self.selectionWidget]
73+
self.form = [self.selectionWidget, self.parameterWidget]
6574

6675
def accept(self):
6776
# check values
6877
items = len(self.selectionWidget.references)
69-
FreeCAD.Console.PrintMessage(
70-
"Task panel: found references: {}\n{}\n"
71-
.format(items, self.selectionWidget.references)
72-
)
7378

7479
if items != 1:
7580
msgBox = QtGui.QMessageBox()
@@ -87,6 +92,8 @@ def accept(self):
8792
return False
8893
elif msgBox.clickedButton() == ignoreButton:
8994
pass
95+
96+
self.obj.Variable = self.variable
9097
self.obj.References = self.selectionWidget.references
9198
self.recompute_and_set_back_all()
9299
return True
@@ -102,3 +109,13 @@ def recompute_and_set_back_all(self):
102109
if self.selectionWidget.sel_server:
103110
FreeCADGui.Selection.removeObserver(self.selectionWidget.sel_server)
104111
doc.resetEdit()
112+
113+
def init_parameter_widget(self):
114+
self.variable = self.obj.Variable
115+
self.variable_enum = self.obj.getEnumerationsOfProperty("Variable")
116+
self.parameterWidget.cb_variable.addItems(self.variable_enum)
117+
index = self.variable_enum.index(self.variable)
118+
self.parameterWidget.cb_variable.setCurrentIndex(index)
119+
120+
def variable_changed(self, index):
121+
self.variable = self.variable_enum[index]

src/Mod/Fem/femviewprovider/view_constraint_sectionprint.py

+10
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@ class VPConstraintSectionPrint(view_base_femconstraint.VPBaseFemConstraint):
3838
A View Provider for the ConstraintSectionPrint object
3939
"""
4040

41+
def __init__(self, vobj):
42+
super().__init__(vobj)
43+
mat = vobj.ShapeAppearance[0]
44+
mat.DiffuseColor = (0.0, 0.165, 1.0, 0.0)
45+
vobj.ShapeAppearance = mat
46+
4147
def setEdit(self, vobj, mode=0):
4248
view_base_femconstraint.VPBaseFemConstraint.setEdit(
4349
self,
4450
vobj,
4551
mode,
4652
task_constraint_sectionprint._TaskPanel
4753
)
54+
55+
def attach(self, vobj):
56+
super().attach(vobj)
57+
vobj.loadSymbol(self.resource_symbol_dir + "ConstraintSectionPrint.iv")

0 commit comments

Comments
 (0)