diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h index fb4cf7843f..f1fd646a12 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.h @@ -95,8 +95,10 @@ public: virtual SoSeparator* getFrontRoot(void) const; - //observer for the color bar + // observer for the color bar virtual void OnChange(Base::Subject< int >& rCaller, int rcReason); + // update color bar + void updateMaterial(); // handling when object is deleted virtual bool onDelete(const std::vector&); @@ -123,7 +125,6 @@ protected: bool setupPipeline(); void updateVtk(); void setRangeOfColorBar(double min, double max); - void updateMaterial(); SoCoordinate3* m_coordinates; SoIndexedPointSet* m_markers; diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp index e166f60375..ca90cffdd2 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp @@ -129,6 +129,25 @@ void ViewProviderFemPostPipeline::onSelectionChanged(const Gui::SelectionChanges } } +void ViewProviderFemPostPipeline::updateColorBars() +{ + + // take all visible childs and update its shape coloring + auto children = claimChildren(); + for (auto& child : children) { + if (child->Visibility.getValue()) { + auto vpObject = dynamic_cast( + Gui::Application::Instance->getViewProvider(child)); + if (vpObject) + vpObject->updateMaterial(); + } + } + + // if pipeline is visible, update it + if (this->isVisible()) + updateMaterial(); +} + void ViewProviderFemPostPipeline::transformField(char *FieldName, double FieldFactor) { Fem::FemPostPipeline *obj = static_cast(getObject()); diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h index cea1b1efef..be7eff2ddd 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h @@ -44,6 +44,7 @@ public: virtual std::vector< App::DocumentObject* > claimChildren3D(void) const; virtual void updateData(const App::Property* prop); virtual void onSelectionChanged(const Gui::SelectionChanges &sel); + void updateColorBars(); void transformField(char *FieldName, double FieldFactor); void scaleField(vtkDataSet *dset, vtkDataArray *pdata, double FieldFactor); PyObject *getPyObject(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePy.xml b/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePy.xml index 72c305b6c0..ad42ced3c4 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePy.xml +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePy.xml @@ -1,24 +1,29 @@ - - - - ViewProviderFemPostPipeline class - - - - - - - + + + + ViewProviderFemPostPipeline class + + + + Scales values of given result mesh field by given factor + + + + + Update coloring of pipeline and its childs + + + diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp index 25e74fbec1..17e7f5e16f 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp @@ -40,6 +40,16 @@ std::string ViewProviderFemPostPipelinePy::representation(void) const return std::string(""); } +PyObject *ViewProviderFemPostPipelinePy::updateColorBars(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + this->getViewProviderFemPostPipelinePtr()->updateColorBars(); + + Py_Return; +} + PyObject *ViewProviderFemPostPipelinePy::transformField(PyObject *args) { char *FieldName; diff --git a/src/Mod/Fem/femsolver/elmer/tasks.py b/src/Mod/Fem/femsolver/elmer/tasks.py index 7f982c94be..5fb9603aca 100644 --- a/src/Mod/Fem/femsolver/elmer/tasks.py +++ b/src/Mod/Fem/femsolver/elmer/tasks.py @@ -256,12 +256,11 @@ class Results(run.Results): # this might be changed in future, therefore leave this # self.solver.ElmerResult.scale(1000) - # it might be necessary to scale some result fields - # this would be done by this call: - # self.solver.ElmerResult.ViewObject.transformField("displacement EigenMode1", 0.001) - self.solver.ElmerResult.recomputeChildren() self.solver.Document.recompute() + # recompute() updated the result mesh data + # but not the shape and bar coloring + self.solver.ElmerResult.ViewObject.updateColorBars() def _createResults(self): self.solver.ElmerResult = self.analysis.Document.addObject(