some fixes in Fem
This commit is contained in:
parent
e34c0f6734
commit
eadc02d65d
|
@ -103,6 +103,7 @@ public:
|
|||
* color or certain elements.
|
||||
*/
|
||||
//@{
|
||||
|
||||
/// set the color for each node
|
||||
void setColorByNodeId(const std::map<long,App::Color> &NodeColorMap);
|
||||
void setColorByNodeId(const std::vector<long> &NodeIds,const std::vector<App::Color> &NodeColors);
|
||||
|
|
|
@ -37,21 +37,29 @@ PyObject* ViewProviderFemMeshPy::animate(PyObject * args)
|
|||
|
||||
App::Color calcColor(double value,double min, double max)
|
||||
{
|
||||
if (max < 0) max = 0;
|
||||
if (min > 0) min = 0;
|
||||
|
||||
if (value < min)
|
||||
return App::Color (0.0,1.0,0.0);
|
||||
return App::Color (0.0,0.0,1.0);
|
||||
if (value > max)
|
||||
return App::Color (1.0,0.0,0.0);
|
||||
if ( value < (min + (max-min)/2.0 ))
|
||||
return App::Color ((value-min) / ((max-min)/2.0),1.0,0.0) ;
|
||||
else
|
||||
return App::Color (1.0,1-((value-min-((max-min)/2.0)) / ((max-min)/2.0)),0.0);
|
||||
if ( value > max/2.0 )
|
||||
return App::Color (1.0,1-((value-(max/2.0)) / (max/2.0)),0.0);
|
||||
if ( value > 0.0 )
|
||||
return App::Color (value/(max/2.0),1.0,0.0) ;
|
||||
if ( value < min/2.0 )
|
||||
return App::Color (0.0,1-((value-(min/2.0)) / (min/2.0)),1.0);
|
||||
if ( value < 0.0 )
|
||||
return App::Color (0.0,1.0,value/(min/2.0)) ;
|
||||
}
|
||||
|
||||
|
||||
PyObject* ViewProviderFemMeshPy::setNodeColorByResult(PyObject *args)
|
||||
{
|
||||
PyObject *object=0;
|
||||
if (PyArg_ParseTuple(args,"O!",&(App::DocumentObjectPy::Type), &object)) {
|
||||
int type = 0;
|
||||
if (PyArg_ParseTuple(args,"O!|i",&(App::DocumentObjectPy::Type), &object, &type)) {
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(object)->getDocumentObjectPtr();
|
||||
if (obj && obj->getTypeId().isDerivedFrom(Fem::FemResultValue::getClassTypeId())){
|
||||
Fem::FemResultValue *result = static_cast<Fem::FemResultValue*>(obj);
|
||||
|
@ -77,14 +85,38 @@ PyObject* ViewProviderFemMeshPy::setNodeColorByResult(PyObject *args)
|
|||
const std::vector<long> & Ids = result->ElementNumbers.getValues() ;
|
||||
const std::vector<Base::Vector3d> & Vecs = result->Values.getValues() ;
|
||||
std::vector<App::Color> NodeColors(Vecs.size());
|
||||
float max = 0.0;
|
||||
for(std::vector<Base::Vector3d>::const_iterator it= Vecs.begin();it!=Vecs.end();++it)
|
||||
if(it->Length() > max)
|
||||
max = it->Length();
|
||||
double max = -1e12;
|
||||
double min = +1e12;
|
||||
for(std::vector<Base::Vector3d>::const_iterator it= Vecs.begin();it!=Vecs.end();++it){
|
||||
double val;
|
||||
if(type == 0)
|
||||
val = it->Length();
|
||||
else if (type == 1)
|
||||
val = it->x;
|
||||
else if (type == 2)
|
||||
val = it->y;
|
||||
else if (type == 3)
|
||||
val = it->z;
|
||||
else
|
||||
val = it->Length();
|
||||
|
||||
if(val > max)
|
||||
max = val;
|
||||
if(val < min)
|
||||
min = val;
|
||||
}
|
||||
// fill up color vector
|
||||
long i=0;
|
||||
for(std::vector<Base::Vector3d>::const_iterator it= Vecs.begin();it!=Vecs.end();++it,i++)
|
||||
if(type == 0)
|
||||
NodeColors[i] = calcColor(it->Length(),0.0,max);
|
||||
else if (type == 1)
|
||||
NodeColors[i] = calcColor(it->x,0.0,max);
|
||||
else if (type == 2)
|
||||
NodeColors[i] = calcColor(it->y,0.0,max);
|
||||
else if (type == 3)
|
||||
NodeColors[i] = calcColor(it->z,0.0,max);
|
||||
else
|
||||
NodeColors[i] = calcColor(it->Length(),0.0,max);
|
||||
|
||||
// set the color to the view-provider
|
||||
|
|
|
@ -130,8 +130,6 @@ class _CommandMechanicalShowResult:
|
|||
return
|
||||
|
||||
taskd = _ResultControlTaskPanel(FemGui.getActiveAnalysis())
|
||||
#taskd.obj = vobj.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
|
||||
|
||||
|
@ -197,8 +195,6 @@ class _ViewProviderFemAnalysis:
|
|||
return True
|
||||
else:
|
||||
taskd = _JobControlTaskPanel(self.Object)
|
||||
taskd.obj = vobj.Object
|
||||
taskd.update()
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
||||
|
||||
|
@ -470,13 +466,10 @@ class _ResultControlTaskPanel:
|
|||
self.formUi.setupUi(self.form)
|
||||
|
||||
#Connect Signals and Slots
|
||||
QtCore.QObject.connect(self.formUi.radioButton_Displacement, QtCore.SIGNAL("clicked(bool)"), self.displacementClicked)
|
||||
QtCore.QObject.connect(self.formUi.radioButton_Stress, QtCore.SIGNAL("clicked(bool)"), self.stressClicked)
|
||||
QtCore.QObject.connect(self.formUi.radioButton_NoColor, QtCore.SIGNAL("clicked(bool)"), self.noColorClicked)
|
||||
QtCore.QObject.connect(self.formUi.comboBox_Type, QtCore.SIGNAL("currentIndexChanged(QString)"), self.typeChanged)
|
||||
|
||||
QtCore.QObject.connect(self.formUi.checkBox_ShowDisplacement, QtCore.SIGNAL("clicked(bool)"), self.showDisplacementClicked)
|
||||
|
||||
QtCore.QObject.connect(self.formUi.verticalScrollBar_Factor, QtCore.SIGNAL("valueChanged(int)"), self.sliderValue)
|
||||
|
||||
QtCore.QObject.connect(self.formUi.spinBox_SliderFactor, QtCore.SIGNAL("valueChanged(double)"), self.sliderMaxValue)
|
||||
QtCore.QObject.connect(self.formUi.spinBox_DisplacementFactor, QtCore.SIGNAL("valueChanged(double)"), self.displacementFactorValue)
|
||||
|
||||
|
@ -490,20 +483,28 @@ class _ResultControlTaskPanel:
|
|||
def getStandardButtons(self):
|
||||
return int(QtGui.QDialogButtonBox.Close)
|
||||
|
||||
def displacementClicked(self,bool):
|
||||
QtGui.qApp.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||
self.setColorDisplacement()
|
||||
QtGui.qApp.restoreOverrideCursor()
|
||||
|
||||
def stressClicked(self,bool):
|
||||
print 'stressClicked()'
|
||||
QtGui.qApp.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||
self.setColorStress()
|
||||
QtGui.qApp.restoreOverrideCursor()
|
||||
|
||||
def noColorClicked(self,bool):
|
||||
def typeChanged(self,typeName):
|
||||
if typeName == "None":
|
||||
self.MeshObject.ViewObject.NodeColor = {}
|
||||
self.MeshObject.ViewObject.ElementColor = {}
|
||||
return
|
||||
|
||||
QtGui.qApp.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||
if typeName[:2] == "Ua" and self.DisplacementObject:
|
||||
values = self.DisplacementObject.Values
|
||||
maxL = 0.0
|
||||
for i in values:
|
||||
if i.Length > maxL:
|
||||
maxL = i.Length
|
||||
|
||||
self.formUi.lineEdit_Max.setText(str(maxL))
|
||||
|
||||
self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject)
|
||||
|
||||
print typeName
|
||||
|
||||
QtGui.qApp.restoreOverrideCursor()
|
||||
|
||||
|
||||
def showDisplacementClicked(self,bool):
|
||||
QtGui.qApp.setOverrideCursor(QtCore.Qt.WaitCursor)
|
||||
|
@ -524,19 +525,6 @@ class _ResultControlTaskPanel:
|
|||
print 'displacementFactorValue()'
|
||||
self.formUi.verticalScrollBar_Factor.setValue(value)
|
||||
|
||||
def setColorDisplacement(self):
|
||||
if self.DisplacementObject:
|
||||
values = self.DisplacementObject.Values
|
||||
maxL = 0.0
|
||||
for i in values:
|
||||
if i.Length > maxL:
|
||||
maxL = i.Length
|
||||
|
||||
self.formUi.lineEdit_Max.setText(str(maxL))
|
||||
self.formUi.doubleSpinBox_MinValueColor.setValue(maxL)
|
||||
|
||||
self.MeshObject.ViewObject.setNodeColorByResult(self.DisplacementObject)
|
||||
|
||||
def setDisplacement(self):
|
||||
if self.DisplacementObject:
|
||||
self.MeshObject.ViewObject.setNodeDisplacementByResult(self.DisplacementObject)
|
||||
|
@ -551,7 +539,7 @@ class _ResultControlTaskPanel:
|
|||
|
||||
def update(self):
|
||||
'fills the widgets'
|
||||
|
||||
print "Update-------------------------------"
|
||||
self.MeshObject = None
|
||||
if FemGui.getActiveAnalysis():
|
||||
for i in FemGui.getActiveAnalysis().Member:
|
||||
|
@ -562,10 +550,15 @@ class _ResultControlTaskPanel:
|
|||
if i.isDerivedFrom("Fem::FemResultVector"):
|
||||
if i.DataType == 'Displacement':
|
||||
self.DisplacementObject = i
|
||||
self.formUi.comboBox_Type.addItem("U1 (Disp. X)")
|
||||
self.formUi.comboBox_Type.addItem("U2 (Disp. Y)")
|
||||
self.formUi.comboBox_Type.addItem("U3 (Disp. z)")
|
||||
self.formUi.comboBox_Type.addItem("Uabs (Disp. abs)")
|
||||
for i in FemGui.getActiveAnalysis().Member:
|
||||
if i.isDerivedFrom("Fem::FemResultValue"):
|
||||
if i.DataType == 'VanMisesStress':
|
||||
self.StressObject = i
|
||||
self.formUi.comboBox_Type.addItem("Sabs (Van Mises Stress)")
|
||||
|
||||
def accept(self):
|
||||
FreeCADGui.Control.closeDialog()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>186</width>
|
||||
<height>416</height>
|
||||
<height>371</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -23,124 +23,60 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_Stress">
|
||||
<widget class="QComboBox" name="comboBox_Type">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Stress</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_Displacement">
|
||||
<property name="text">
|
||||
<string>Displacement</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_NoColor">
|
||||
<property name="text">
|
||||
<string>No color</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_MinValueColor">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_MaxValueColor">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999990.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Statistic</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Max">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Max_3">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Avg:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Max_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Avg">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Max">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Min">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -225,7 +161,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>18</height>
|
||||
<height>240</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
|
Loading…
Reference in New Issue
Block a user