FEM: add ConstraintPython object type
Constraints implemented in python can use this object as their base. That makes it easier to identify them as constraint objects.
This commit is contained in:
committed by
Bernd Hahnebach
parent
b7e8348e85
commit
ef85389cbc
@@ -148,6 +148,7 @@ PyMOD_INIT_FUNC(Fem)
|
||||
Fem::FemSetNodesObject ::init();
|
||||
|
||||
Fem::Constraint ::init();
|
||||
Fem::ConstraintPython ::init();
|
||||
Fem::ConstraintBearing ::init();
|
||||
Fem::ConstraintFixed ::init();
|
||||
Fem::ConstraintForce ::init();
|
||||
|
||||
@@ -54,6 +54,9 @@
|
||||
#include "FemConstraint.h"
|
||||
#include "FemTools.h"
|
||||
|
||||
#include <App/DocumentObjectPy.h>
|
||||
#include <App/FeaturePythonPyImp.h>
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
@@ -391,3 +394,27 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direct
|
||||
|
||||
return Fem::Tools::getDirectionFromShape(sh);
|
||||
}
|
||||
|
||||
// Python feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(Fem::ConstraintPython, Fem::Constraint)
|
||||
template<> const char* Fem::ConstraintPython::getViewProviderName(void) const {
|
||||
return "FemGui::ViewProviderFemConstraintPython";
|
||||
}
|
||||
|
||||
template<> PyObject* Fem::ConstraintPython::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::Constraint>;
|
||||
|
||||
/// @endcond
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define FEM_CONSTRAINT_H
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
#include <App/FeaturePython.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/PropertyLinks.h>
|
||||
#include <App/PropertyGeo.h>
|
||||
@@ -75,6 +76,9 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<Constraint> ConstraintPython;
|
||||
|
||||
|
||||
} //namespace Fem
|
||||
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ PyMOD_INIT_FUNC(FemGui)
|
||||
FemGui::ViewProviderSetFaces ::init();
|
||||
FemGui::ViewProviderSetGeometry ::init();
|
||||
FemGui::ViewProviderFemConstraint ::init();
|
||||
FemGui::ViewProviderFemConstraintPython ::init();
|
||||
FemGui::ViewProviderFemConstraintBearing ::init();
|
||||
FemGui::ViewProviderFemConstraintFixed ::init();
|
||||
FemGui::ViewProviderFemConstraintForce ::init();
|
||||
|
||||
@@ -490,3 +490,15 @@ void ViewProviderFemConstraint::checkForWizard()
|
||||
wizardSubLayout = wiz->findChild<QVBoxLayout*>(QString::fromLatin1("ShaftWizardLayout"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Python feature -----------------------------------------------------------------------
|
||||
|
||||
namespace Gui {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderFemConstraintPython, FemGui::ViewProviderFemConstraint)
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class FemGuiExport ViewProviderPythonFeatureT<ViewProviderFemConstraint>;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define GUI_VIEWPROVIDERFEMCONSTRAINT_H
|
||||
|
||||
#include <Gui/ViewProviderGeometryObject.h>
|
||||
#include <Gui/ViewProviderPythonFeature.h>
|
||||
#include <QObject>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -117,6 +118,9 @@ protected:
|
||||
static QObject* findChildByName(const QObject* parent, const QString& name);
|
||||
};
|
||||
|
||||
typedef Gui::ViewProviderPythonFeatureT<ViewProviderFemConstraint> ViewProviderFemConstraintPython;
|
||||
|
||||
|
||||
} //namespace FemGui
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user