Skip to content

Commit

Permalink
+ make FEM beam section and shell thickness ready for drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 19, 2015
1 parent eff2799 commit 861dc86
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Mod/Fem/App/AppFem.cpp
Expand Up @@ -118,6 +118,7 @@ void AppFemExport initFem()

Fem::FemAnalysis ::init();
Fem::FemAnalysisPython ::init();
Fem::FeaturePython ::init();
Fem::FemMesh ::init();
Fem::FemMeshObject ::init();
Fem::FemMeshShapeObject ::init();
Expand Down
23 changes: 22 additions & 1 deletion src/Mod/Fem/App/FemAnalysis.cpp
Expand Up @@ -28,6 +28,7 @@

#include "FemAnalysis.h"
#include <App/DocumentObjectPy.h>
#include <App/FeaturePythonPyImp.h>
#include <Base/Placement.h>
#include <Base/Uuid.h>

Expand Down Expand Up @@ -88,4 +89,24 @@ template<> const char* Fem::FemAnalysisPython::getViewProviderName(void) const {

// explicit template instantiation
template class AppFemExport FeaturePythonT<Fem::FemAnalysis>;
}
}

// ---------------------------------------------------------

namespace App {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(Fem::FeaturePython, App::DocumentObject)
template<> const char* Fem::FeaturePython::getViewProviderName(void) const {
return "Gui::ViewProviderPythonFeature";
}
template<> PyObject* Fem::FeaturePython::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<App::DocumentObject>;
/// @endcond
}
1 change: 1 addition & 0 deletions src/Mod/Fem/App/FemAnalysis.h
Expand Up @@ -65,6 +65,7 @@ class AppFemExport FemAnalysis : public App::DocumentObject
};

typedef App::FeaturePythonT<FemAnalysis> FemAnalysisPython;
typedef App::FeaturePythonT<App::DocumentObject> FeaturePython;


} //namespace Fem
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/FemBeamSection.py
Expand Up @@ -37,7 +37,7 @@

def makeFemBeamSection(width=20.0, height=20.0, name="BeamSection"):
'''makeFemBeamSection([width], [height], [name]): creates an beamsection object to define a cross section'''
obj = FemGui.getActiveAnalysis().Document.addObject("App::FeaturePython", name)
obj = FemGui.getActiveAnalysis().Document.addObject("Fem::FeaturePython", name)
_FemBeamSection(obj)
obj.Width = width
obj.Height = height
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/FemShellThickness.py
Expand Up @@ -37,7 +37,7 @@

def makeFemShellThickness(thickness=20.0, name="ShellThickness"):
'''makeFemShellThickness([thickness], [name]): creates an shellthickness object to define a plate thickness'''
obj = FemGui.getActiveAnalysis().Document.addObject("App::FeaturePython", name)
obj = FemGui.getActiveAnalysis().Document.addObject("Fem::FeaturePython", name)
_FemShellThickness(obj)
obj.Thickness = thickness
if FreeCAD.GuiUp:
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Fem/Gui/ViewProviderAnalysis.cpp
Expand Up @@ -175,6 +175,8 @@ bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject* obj) const
return true;
else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId()))
return true;
else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython")))
return true;
else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId()))
return true;
else
Expand Down

0 comments on commit 861dc86

Please sign in to comment.