[FEM] fix pipeline recompute issue

- 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
This commit is contained in:
Uwe
2022-08-08 02:04:07 +02:00
parent b397633f27
commit ee127273c1
6 changed files with 62 additions and 27 deletions

View File

@@ -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<std::string>&);
@@ -123,7 +125,6 @@ protected:
bool setupPipeline();
void updateVtk();
void setRangeOfColorBar(double min, double max);
void updateMaterial();
SoCoordinate3* m_coordinates;
SoIndexedPointSet* m_markers;

View File

@@ -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());

View File

@@ -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();

View File

@@ -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>

View File

@@ -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;

View File

@@ -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(