FEM: extend the C++ fem mesh object to be able make python mesh object childs

This commit is contained in:
Bernd Hahnebach 2016-11-22 19:47:50 +01:00
parent 1c0920d624
commit 9f8a7b8642
7 changed files with 47 additions and 2 deletions

View File

@ -136,6 +136,7 @@ PyMODINIT_FUNC initFem()
Fem::FeaturePython ::init();
Fem::FemMesh ::init();
Fem::FemMeshObject ::init();
Fem::FemMeshObjectPython ::init();
Fem::FemMeshShapeObject ::init();
Fem::FemMeshShapeNetgenObject ::init();
Fem::PropertyFemMesh ::init();

View File

@ -29,6 +29,7 @@
#include "FemMeshObject.h"
#include "FemMesh.h"
#include <App/DocumentObjectPy.h>
#include <App/FeaturePythonPyImp.h>
#include <Base/Placement.h>
using namespace Fem;
@ -70,3 +71,25 @@ void FemMeshObject::onChanged(const Property* prop)
}
}
// Python feature ---------------------------------------------------------
namespace App {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::FemMeshObjectPython, Fem::FemMeshObject)
template<> const char* Fem::FemMeshObjectPython::getViewProviderName(void) const {
return "FemGui::ViewProviderFemMeshPython";
}
template<> PyObject* Fem::FemMeshObjectPython::getPyObject(void) {
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new App::FeaturePythonPyT<App::DocumentObjectPy>(this),true);
}
return Py::new_reference_to(PythonObject);
}
// explicit template instantiation
template class AppFemExport FeaturePythonT<Fem::FemMeshObject>;
}

View File

@ -24,6 +24,7 @@
#ifndef Fem_FemMeshObject_H
#define Fem_FemMeshObject_H
#include <App/FeaturePython.h>
#include <App/GeoFeature.h>
#include <App/PropertyFile.h>
#include <App/PropertyGeo.h>
@ -60,6 +61,9 @@ protected:
virtual void onChanged (const App::Property* prop);
};
typedef App::FeaturePythonT<FemMeshObject> FemMeshObjectPython;
} //namespace Fem

View File

@ -109,6 +109,7 @@ PyMODINIT_FUNC initFemGui()
FemGui::ViewProviderFemAnalysis ::init();
FemGui::ViewProviderFemAnalysisPython ::init();
FemGui::ViewProviderFemMesh ::init();
FemGui::ViewProviderFemMeshPython ::init();
FemGui::ViewProviderFemMeshShape ::init();
FemGui::ViewProviderFemMeshShapeNetgen ::init();
FemGui::ViewProviderSolver ::init();

View File

@ -2464,3 +2464,15 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop,
}
// Python feature -----------------------------------------------------------------------
namespace Gui {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderFemMeshPython, FemGui::ViewProviderFemMesh)
/// @endcond
// explicit template instantiation
template class FemGuiExport ViewProviderPythonFeatureT<ViewProviderFemMesh>;
}

View File

@ -26,6 +26,7 @@
#include <Gui/ViewProviderGeometryObject.h>
#include <Gui/ViewProviderBuilder.h>
#include <Gui/ViewProviderPythonFeature.h>
#include <CXX/Objects.hxx>
@ -163,6 +164,9 @@ private:
class Private;
};
typedef Gui::ViewProviderPythonFeatureT<ViewProviderFemMesh> ViewProviderFemMeshPython;
} //namespace FemGui

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="ViewProviderPy"
Father="ViewProviderDocumentObjectPy"
Name="ViewProviderFemMeshPy"
Twin="ViewProviderFemMesh"
TwinPointer="ViewProviderFemMesh"
Include="Mod/Fem/Gui/ViewProviderFemMesh.h"
Namespace="FemGui"
FatherInclude="Gui/ViewProviderPy.h"
FatherInclude="Gui/ViewProviderDocumentObjectPy.h"
FatherNamespace="Gui"
Constructor="false"
Delete="false">