Skip to content

Commit

Permalink
[FEM] fix pipeline recompute issue
Browse files Browse the repository at this point in the history
- after a simulation was run, the pipelines and its childs are recomputed but its shape coloring is not updated.

- also update XML documentation
- also remove comment in tasks.py for now
  • Loading branch information
donovaly committed Aug 8, 2022
1 parent 8b06680 commit d438514
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 27 deletions.
5 changes: 3 additions & 2 deletions src/Mod/Fem/Gui/ViewProviderFemPostObject.h
Expand Up @@ -95,8 +95,10 @@ class FemGuiExport ViewProviderFemPostObject : public Gui::ViewProviderDocumentO

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<std::string>&);
Expand All @@ -123,7 +125,6 @@ class FemGuiExport ViewProviderFemPostObject : public Gui::ViewProviderDocumentO
bool setupPipeline();
void updateVtk();
void setRangeOfColorBar(double min, double max);
void updateMaterial();

SoCoordinate3* m_coordinates;
SoIndexedPointSet* m_markers;
Expand Down
19 changes: 19 additions & 0 deletions src/Mod/Fem/Gui/ViewProviderFemPostPipeline.cpp
Expand Up @@ -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<FemGui::ViewProviderFemPostObject *>(
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<Fem::FemPostPipeline *>(getObject());
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Fem/Gui/ViewProviderFemPostPipeline.h
Expand Up @@ -44,6 +44,7 @@ class FemGuiExport ViewProviderFemPostPipeline : public ViewProviderFemPostObjec
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();
Expand Down
47 changes: 26 additions & 21 deletions src/Mod/Fem/Gui/ViewProviderFemPostPipelinePy.xml
@@ -1,24 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="ViewProviderDocumentObjectPy"
Name="ViewProviderFemPostPipelinePy"
Twin="ViewProviderFemPostPipeline"
TwinPointer="ViewProviderFemPostPipeline"
Include="Mod/Fem/Gui/ViewProviderFemPostPipeline.h"
Namespace="FemGui"
FatherInclude="Gui/ViewProviderDocumentObjectPy.h"
FatherNamespace="Gui"
Constructor="false"
Delete="false">
<Documentation>
<Author Licence="LGPL" Name="Uwe Stöhr" EMail="uwestoehr@lyx.org" />
<UserDocu>ViewProviderFemPostPipeline class</UserDocu>
</Documentation>
<Methode Name="transformField">
<Documentation>
<UserDocu></UserDocu>
</Documentation>
</Methode>
</PythonExport>
<PythonExport
Father="ViewProviderDocumentObjectPy"
Name="ViewProviderFemPostPipelinePy"
Twin="ViewProviderFemPostPipeline"
TwinPointer="ViewProviderFemPostPipeline"
Include="Mod/Fem/Gui/ViewProviderFemPostPipeline.h"
Namespace="FemGui"
FatherInclude="Gui/ViewProviderDocumentObjectPy.h"
FatherNamespace="Gui"
Constructor="false"
Delete="false">
<Documentation>
<Author Licence="LGPL" Name="Uwe Stöhr" EMail="uwestoehr@lyx.org" />
<UserDocu>ViewProviderFemPostPipeline class</UserDocu>
</Documentation>
<Methode Name="transformField">
<Documentation>
<UserDocu>Scales values of given result mesh field by given factor</UserDocu>
</Documentation>
</Methode>
<Methode Name="updateColorBars">
<Documentation>
<UserDocu>Update coloring of pipeline and its childs</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>
10 changes: 10 additions & 0 deletions src/Mod/Fem/Gui/ViewProviderFemPostPipelinePyImp.cpp
Expand Up @@ -40,6 +40,16 @@ std::string ViewProviderFemPostPipelinePy::representation(void) const
return std::string("<ViewProviderFemPostPipeline object>");
}

PyObject *ViewProviderFemPostPipelinePy::updateColorBars(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return nullptr;

this->getViewProviderFemPostPipelinePtr()->updateColorBars();

Py_Return;
}

PyObject *ViewProviderFemPostPipelinePy::transformField(PyObject *args)
{
char *FieldName;
Expand Down
7 changes: 3 additions & 4 deletions src/Mod/Fem/femsolver/elmer/tasks.py
Expand Up @@ -256,12 +256,11 @@ def run(self):
# 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(
Expand Down

0 comments on commit d438514

Please sign in to comment.