From a5262f9cb7255c7797ece8612ca36e990ab95474 Mon Sep 17 00:00:00 2001 From: jriegel Date: Sun, 4 Aug 2013 20:39:08 +0200 Subject: [PATCH] Add python object for the FemMesh ViewProvider for later postprecessing capabilities --- src/Mod/Fem/Gui/CMakeLists.txt | 12 +++++ src/Mod/Fem/Gui/ViewProviderFemMesh.cpp | 9 ++++ src/Mod/Fem/Gui/ViewProviderFemMesh.h | 6 +++ src/Mod/Fem/Gui/ViewProviderFemMeshPy.xml | 30 ++++++++++++ src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp | 51 ++++++++++++++++++++ 5 files changed, 108 insertions(+) create mode 100644 src/Mod/Fem/Gui/ViewProviderFemMeshPy.xml create mode 100644 src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index 823d75c65..8ef615d56 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -24,10 +24,21 @@ include_directories( link_directories(${OCC_LIBRARY_DIR}) + + set(FemGui_LIBS Fem FreeCADGui ) + +generate_from_xml(ViewProviderFemMeshPy) + +SET(Python_SRCS + ViewProviderFemMeshPy.xml + ViewProviderFemMeshPyImp.cpp +) +SOURCE_GROUP("Python" FILES ${Python_SRCS}) + set(FemGui_MOC_HDRS Hypothesis.h @@ -167,6 +178,7 @@ SET(FemGui_SRCS_Module SOURCE_GROUP("Module" FILES ${FemGui_SRCS_Module}) SET(FemGui_SRCS + ${Python_SRCS} ${FemGui_DLG_SRCS} ${FemResource_SRCS} ${FemGui_SRCS_ViewProvider} diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp index 372d05aa3..486300f5a 100755 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp @@ -51,6 +51,7 @@ #endif #include "ViewProviderFemMesh.h" +#include "ViewProviderFemMeshPy.h" #include #include @@ -477,6 +478,14 @@ void ViewProviderFemMesh::resetHighlightNodes(void) pcAnoCoords->point.setNum(0); } +PyObject * ViewProviderFemMesh::getPyObject() +{ + if (PythonObject.is(Py::_None())){ + // ref counter is set to 1 + PythonObject = Py::Object(new ViewProviderFemMeshPy(this),true); + } + return Py::new_reference_to(PythonObject); +} // ---------------------------------------------------------------------------- diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.h b/src/Mod/Fem/Gui/ViewProviderFemMesh.h index 0bdbdd570..5e8d17224 100755 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.h +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.h @@ -27,6 +27,8 @@ #include #include +#include + class SoCoordinate3; class SoDrawStyle; class SoIndexedFaceSet; @@ -95,8 +97,12 @@ public: void setHighlightNodes(const std::set&); void resetHighlightNodes(void); + PyObject *getPyObject(); + private: static App::PropertyFloatConstraint::Constraints floatRange; + + Py::Object PythonObject; protected: /// get called by the container whenever a property has been changed diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshPy.xml b/src/Mod/Fem/Gui/ViewProviderFemMeshPy.xml new file mode 100644 index 000000000..871bfb5f2 --- /dev/null +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshPy.xml @@ -0,0 +1,30 @@ + + + + + + ViewProviderFemMesh class + + + + + + + + + Pose of Axis 1 in degrees + + + + + diff --git a/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp new file mode 100644 index 000000000..dd3b14153 --- /dev/null +++ b/src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp @@ -0,0 +1,51 @@ + +#include "PreCompiled.h" + +#include "Mod/Fem/Gui/ViewProviderFemMesh.h" + +// inclusion of the generated files (generated out of ViewProviderFemMeshPy.xml) +#include "ViewProviderFemMeshPy.h" +#include "ViewProviderFemMeshPy.cpp" + +using namespace FemGui; + +// returns a string which represents the object e.g. when printed in python +std::string ViewProviderFemMeshPy::representation(void) const +{ + return std::string(""); +} + + + +PyObject* ViewProviderFemMeshPy::animate(PyObject * /*args*/) +{ + PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); + return 0; +} + + + + + +Py::List ViewProviderFemMeshPy::getNodeColor(void) const +{ + //return Py::List(); + throw Py::AttributeError("Not yet implemented"); +} + +void ViewProviderFemMeshPy::setNodeColor(Py::List /*arg*/) +{ + throw Py::AttributeError("Not yet implemented"); +} + +PyObject *ViewProviderFemMeshPy::getCustomAttributes(const char* /*attr*/) const +{ + return 0; +} + +int ViewProviderFemMeshPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) +{ + return 0; +} + +