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