Port Attacher codde to the extension framework
AttachableObjects are desired in multiple occasions, and the current AttachableObject is not flexible enough to handle all cases. Hence the code is portet to an extension, which gives the needed flexibility.
This commit is contained in:
parent
cc6bc1b8d9
commit
d0d4d6bc07
|
@ -82,10 +82,9 @@ DocumentObjectExecReturn *DocumentObject::execute(void)
|
|||
{
|
||||
//call all extensions
|
||||
auto vector = getExtensionsDerivedFromType<App::DocumentObjectExtension>();
|
||||
for(auto ext : vector) {
|
||||
if(ext->extensionMustExecute())
|
||||
ext->extensionExecute();
|
||||
}
|
||||
for(auto ext : vector)
|
||||
ext->extensionExecute();
|
||||
|
||||
return StdReturn;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,13 @@ void * _class_::create(void){\
|
|||
return new _class_ ();\
|
||||
}
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define EXTENSION_TYPESYSTEM_SOURCE_ABSTRACT_P(_class_) \
|
||||
Base::Type _class_::getExtensionClassTypeId(void) { return _class_::classTypeId; } \
|
||||
Base::Type _class_::getExtensionTypeId(void) const { return _class_::classTypeId; } \
|
||||
Base::Type _class_::classTypeId = Base::Type::badType(); \
|
||||
void * _class_::create(void){return 0;}
|
||||
|
||||
/// define to implement a subclass of Base::BaseClass
|
||||
#define EXTENSION_TYPESYSTEM_SOURCE(_class_, _parentclass_) \
|
||||
EXTENSION_TYPESYSTEM_SOURCE_P(_class_);\
|
||||
|
@ -248,7 +255,7 @@ public:
|
|||
|
||||
/** @name TypeHandling */
|
||||
//@{
|
||||
bool isDerivedFrom(const Base::Type type) const {return getExtensionTypeId().isDerivedFrom(type);}
|
||||
bool extensionIsDerivedFrom(const Base::Type type) const {return getExtensionTypeId().isDerivedFrom(type);}
|
||||
protected:
|
||||
static void initExtensionSubclass(Base::Type &toInit,const char* ClassName, const char *ParentName,
|
||||
Base::Type::instantiationMethod method=0);
|
||||
|
|
|
@ -186,14 +186,10 @@ private:
|
|||
|
||||
/// We make sur that the PropertyData of the container is not connected to the one of the extension
|
||||
#define PROPERTY_SOURCE_WITH_EXTENSIONS(_class_, _parentclass_) \
|
||||
TYPESYSTEM_SOURCE_P(_class_);\
|
||||
const App::PropertyData * _class_::getPropertyDataPtr(void){return &propertyData;} \
|
||||
const App::PropertyData & _class_::getPropertyData(void) const{return propertyData;} \
|
||||
App::PropertyData _class_::propertyData; \
|
||||
void _class_::init(void){\
|
||||
initSubclass(_class_::classTypeId, #_class_ , #_parentclass_, &(_class_::create) ); \
|
||||
_class_::propertyData.parentPropertyData = _parentclass_::getPropertyDataPtr();\
|
||||
}
|
||||
PROPERTY_SOURCE(_class_, _parentclass_)
|
||||
|
||||
#define PROPERTY_SOURCE_ABSTRACT_WITH_EXTENSIONS(_class_, _parentclass_) \
|
||||
PROPERTY_SOURCE_ABSTRACT(_class_, _parentclass_)
|
||||
|
||||
} //App
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
#include "PropertyGeometryList.h"
|
||||
#include "DatumFeature.h"
|
||||
#include "Attacher.h"
|
||||
#include "AttachableObject.h"
|
||||
#include "AttachExtension.h"
|
||||
#include "FaceMaker.h"
|
||||
#include "FaceMakerCheese.h"
|
||||
#include "FaceMakerBullseye.h"
|
||||
|
@ -397,11 +397,12 @@ PyMODINIT_FUNC initPart()
|
|||
Attacher::AttachEnginePlane ::init();
|
||||
Attacher::AttachEngineLine ::init();
|
||||
Attacher::AttachEnginePoint ::init();
|
||||
|
||||
Part::AttachExtension ::init();
|
||||
Part::AttachExtensionPython ::init();
|
||||
|
||||
Part::Feature ::init();
|
||||
Part::FeatureExt ::init();
|
||||
Part::AttachableObject ::init();
|
||||
Part::AttachableObjectPython::init();
|
||||
Part::BodyBase ::init();
|
||||
Part::FeaturePython ::init();
|
||||
Part::FeatureGeometrySet ::init();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "Mod/Part/App/Attacher.h"
|
||||
#include <Base/PlacementPy.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
#include "AttachableObjectPy.h"
|
||||
#include "AttachExtensionPy.h"
|
||||
#include "TopoShapePy.h"
|
||||
|
||||
#include "OCCError.h"
|
||||
|
@ -493,12 +493,12 @@ PyObject* AttachEnginePy::readParametersFromFeature(PyObject* args)
|
|||
return NULL; // NULL triggers exception
|
||||
|
||||
try{
|
||||
const App::DocumentObjectPy* dobjpy = static_cast<const App::DocumentObjectPy*>(obj);
|
||||
const App::DocumentObject* dobj = dobjpy->getDocumentObjectPtr();
|
||||
if (! dobj->isDerivedFrom(Part::AttachableObject::getClassTypeId())){
|
||||
throw Py::TypeError("Supplied object isn't Part::AttachableObject");
|
||||
App::DocumentObjectPy* dobjpy = static_cast<App::DocumentObjectPy*>(obj);
|
||||
App::DocumentObject* dobj = dobjpy->getDocumentObjectPtr();
|
||||
if (! dobj->hasExtension(Part::AttachExtension::getExtensionClassTypeId())){
|
||||
throw Py::TypeError("Supplied object has no Part::AttachExtension");
|
||||
}
|
||||
const Part::AttachableObject* feat = static_cast<const Part::AttachableObject*>(dobj);
|
||||
Part::AttachExtension* feat = dobj->getExtensionByType<Part::AttachExtension>();
|
||||
AttachEngine &attacher = *(this->getAttachEnginePtr());
|
||||
attacher.setUp(feat->Support,
|
||||
eMapMode(feat->MapMode.getValue()),
|
||||
|
@ -519,10 +519,10 @@ PyObject* AttachEnginePy::writeParametersToFeature(PyObject* args)
|
|||
try{
|
||||
App::DocumentObjectPy* dobjpy = static_cast<App::DocumentObjectPy*>(obj);
|
||||
App::DocumentObject* dobj = dobjpy->getDocumentObjectPtr();
|
||||
if (! dobj->isDerivedFrom(Part::AttachableObject::getClassTypeId())){
|
||||
throw Py::TypeError("Supplied object isn't Part::AttachableObject");
|
||||
if (! dobj->hasExtension(Part::AttachExtension::getExtensionClassTypeId())){
|
||||
throw Py::TypeError("Supplied object has no Part::AttachExtension");
|
||||
}
|
||||
Part::AttachableObject* feat = static_cast<Part::AttachableObject*>(dobj);
|
||||
Part::AttachExtension* feat = dobj->getExtensionByType<Part::AttachExtension>();
|
||||
const AttachEngine &attacher = *(this->getAttachEnginePtr());
|
||||
AttachEngine::verifyReferencesAreSafe(attacher.references);
|
||||
feat->Support.Paste(attacher.references);
|
||||
|
|
|
@ -25,19 +25,19 @@
|
|||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "AttachableObject.h"
|
||||
#include "AttachExtension.h"
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <App/Application.h>
|
||||
|
||||
#include <App/FeaturePythonPyImp.h>
|
||||
#include "AttachableObjecty.h"
|
||||
#include "AttachExtensionPy.h"
|
||||
|
||||
|
||||
using namespace Part;
|
||||
using namespace Attacher;
|
||||
|
||||
EXTENSION_PROPERTY_SOURCE(Part::AttachExtension, Part::Feature);
|
||||
EXTENSION_PROPERTY_SOURCE(Part::AttachExtension, App::DocumentObjectExtension);
|
||||
|
||||
AttachExtension::AttachExtension()
|
||||
: _attacher(0)
|
||||
|
@ -126,10 +126,17 @@ bool AttachExtension::positionBySupport()
|
|||
};
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *AttachExtension::exttensionExecute()
|
||||
short int AttachExtension::extensionMustExecute(void) {
|
||||
return DocumentObjectExtension::extensionMustExecute();
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObjectExecReturn *AttachExtension::extensionExecute()
|
||||
{
|
||||
Base::Console().Message("Execute Extension");
|
||||
if(this->isTouched_Mapping()) {
|
||||
try{
|
||||
Base::Console().Message("Call position by support");
|
||||
positionBySupport();
|
||||
} catch (Base::Exception &e) {
|
||||
return new App::DocumentObjectExecReturn(e.what());
|
||||
|
@ -153,11 +160,11 @@ void AttachExtension::extensionOnChanged(const App::Property* prop)
|
|||
try{
|
||||
bAttached = positionBySupport();
|
||||
} catch (Base::Exception &e) {
|
||||
this->setError();
|
||||
getExtendedObject()->setStatus(App::Error, true);
|
||||
Base::Console().Error("PositionBySupport: %s",e.what());
|
||||
//set error message - how?
|
||||
} catch (Standard_Failure &e){
|
||||
this->setError();
|
||||
getExtendedObject()->setStatus(App::Error, true);
|
||||
Base::Console().Error("PositionBySupport: %s",e.GetMessageString());
|
||||
}
|
||||
|
||||
|
@ -195,23 +202,22 @@ App::PropertyPlacement& AttachExtension::getPlacement() {
|
|||
return static_cast<App::GeoFeature*>(getExtendedObject())->Placement;
|
||||
}
|
||||
|
||||
PyObject* AttachExtension::getExtensionPyObject(void) {
|
||||
|
||||
if (ExtensionPythonObject.is(Py::_None())){
|
||||
// ref counter is set to 1
|
||||
ExtensionPythonObject = Py::Object(new AttachExtensionPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(ExtensionPythonObject);
|
||||
}
|
||||
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
EXTENSION_PROPERTY_SOURCE_TEMPLATE(Part::AttachExtensionPython, Part::AttachExtension)
|
||||
template<> const char* Part::AttachExtensionPython::getViewProviderName(void) const {
|
||||
return "PartGui::ViewProviderPython";
|
||||
}
|
||||
template<> PyObject* Part::AttachExtensionPython::getPyObject(void) {
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new FeaturePythonPyT<Part::AttachExtensionPy>(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class PartExport FeaturePythonT<Part::AttachExtension>;
|
||||
template class PartExport ExtensionPythonT<Part::AttachExtension>;
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* *
|
||||
***************************************************************************/
|
||||
/**
|
||||
* AttachableObject.h, .cpp contain a class to derive other features from, to make
|
||||
* AttachExtensionh, .cpp contain a extension class to derive other features from, to make
|
||||
* them attachable.
|
||||
*/
|
||||
|
||||
|
@ -100,7 +100,9 @@ public:
|
|||
virtual bool isTouched_Mapping()
|
||||
{return true; /*support.isTouched isn't true when linked objects are changed... why?..*/};
|
||||
|
||||
App::DocumentObjectExecReturn *extensionExecute(void);
|
||||
virtual short int extensionMustExecute(void);
|
||||
virtual App::DocumentObjectExecReturn *extensionExecute(void);
|
||||
virtual PyObject* getExtensionPyObject(void);
|
||||
protected:
|
||||
virtual void extensionOnChanged(const App::Property* /*prop*/);
|
||||
|
|
@ -1,15 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="PartFeaturePy"
|
||||
Name="AttachableObjectPy"
|
||||
PythonName="Part.AttachableObject"
|
||||
Twin="AttachableObject"
|
||||
TwinPointer="AttachableObject"
|
||||
Include="Mod/Part/App/AttachableObject.h"
|
||||
Father="DocumentObjectExtensionPy"
|
||||
Name="AttachExtensionPy"
|
||||
Twin="AttachExtension"
|
||||
TwinPointer="AttachExtension"
|
||||
Include="Mod/Part/App/AttachExtension.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/PartFeaturePy.h"
|
||||
FatherNamespace="Part">
|
||||
FatherInclude="App/DocumentObjectExtensionPy.h"
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="DeepSOIC" EMail="vv.titov@gmail.com" />
|
||||
<UserDocu>This object represents an attachable object with OCC shape.</UserDocu>
|
|
@ -1,30 +1,30 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "Mod/Part/App/AttachableObject.h"
|
||||
#include "Mod/Part/App/AttachExtension.h"
|
||||
#include "OCCError.h"
|
||||
|
||||
#include "AttachEnginePy.h"
|
||||
|
||||
// inclusion of the generated files (generated out of AttachableObjectPy.xml)
|
||||
#include "AttachableObjectPy.h"
|
||||
#include "AttachableObjectPy.cpp"
|
||||
// inclusion of the generated files (generated out of AttachExtensionPy.xml)
|
||||
#include "AttachExtensionPy.h"
|
||||
#include "AttachExtensionPy.cpp"
|
||||
|
||||
using namespace Part;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string AttachableObjectPy::representation(void) const
|
||||
std::string AttachExtensionPy::representation(void) const
|
||||
{
|
||||
return std::string("<Part::AttachableObject>");
|
||||
}
|
||||
|
||||
PyObject* AttachableObjectPy::positionBySupport(PyObject *args)
|
||||
PyObject* AttachExtensionPy::positionBySupport(PyObject *args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return 0;
|
||||
bool bAttached = false;
|
||||
try{
|
||||
bAttached = this->getAttachableObjectPtr()->positionBySupport();
|
||||
bAttached = this->getAttachExtensionPtr()->positionBySupport();
|
||||
} catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
|
@ -36,14 +36,14 @@ PyObject* AttachableObjectPy::positionBySupport(PyObject *args)
|
|||
return Py::new_reference_to(Py::Boolean(bAttached));
|
||||
}
|
||||
|
||||
PyObject* AttachableObjectPy::changeAttacherType(PyObject *args)
|
||||
PyObject* AttachExtensionPy::changeAttacherType(PyObject *args)
|
||||
{
|
||||
const char* typeName;
|
||||
if (!PyArg_ParseTuple(args, "s", &typeName))
|
||||
return 0;
|
||||
bool ret;
|
||||
try{
|
||||
ret = this->getAttachableObjectPtr()->changeAttacherType(typeName);
|
||||
ret = this->getAttachExtensionPtr()->changeAttacherType(typeName);
|
||||
} catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
|
||||
|
@ -55,16 +55,16 @@ PyObject* AttachableObjectPy::changeAttacherType(PyObject *args)
|
|||
return Py::new_reference_to(Py::Boolean(ret));
|
||||
}
|
||||
|
||||
Py::Object AttachableObjectPy::getAttacher(void) const
|
||||
Py::Object AttachExtensionPy::getAttacher(void) const
|
||||
{
|
||||
try {
|
||||
this->getAttachableObjectPtr()->attacher(); //throws if attacher is not set
|
||||
this->getAttachExtensionPtr()->attacher(); //throws if attacher is not set
|
||||
} catch (Base::Exception) {
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
try {
|
||||
return Py::Object( new Attacher::AttachEnginePy(this->getAttachableObjectPtr()->attacher().copy()), true);
|
||||
return Py::Object( new Attacher::AttachEnginePy(this->getAttachExtensionPtr()->attacher().copy()), true);
|
||||
} catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Py::Exception(Part::PartExceptionOCCError, e->GetMessageString());
|
||||
|
@ -74,12 +74,12 @@ Py::Object AttachableObjectPy::getAttacher(void) const
|
|||
|
||||
}
|
||||
|
||||
PyObject *AttachableObjectPy::getCustomAttributes(const char* /*attr*/) const
|
||||
PyObject *AttachExtensionPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AttachableObjectPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
int AttachExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -73,7 +73,7 @@ generate_from_xml(RectangularTrimmedSurfacePy)
|
|||
generate_from_xml(SurfaceOfExtrusionPy)
|
||||
generate_from_xml(SurfaceOfRevolutionPy)
|
||||
generate_from_xml(PartFeaturePy)
|
||||
generate_from_xml(AttachableObjectPy)
|
||||
generate_from_xml(AttachExtensionPy)
|
||||
generate_from_xml(Part2DObjectPy)
|
||||
generate_from_xml(AttachEnginePy)
|
||||
generate_from_xml(TopoShapePy)
|
||||
|
@ -169,8 +169,8 @@ SET(Features_SRCS
|
|||
BodyBase.cpp
|
||||
DatumFeature.cpp
|
||||
DatumFeature.h
|
||||
AttachableObject.h
|
||||
AttachableObject.cpp
|
||||
AttachExtension.h
|
||||
AttachExtension.cpp
|
||||
)
|
||||
SOURCE_GROUP("Features" FILES ${Features_SRCS})
|
||||
|
||||
|
@ -251,8 +251,8 @@ SET(Python_SRCS
|
|||
SurfaceOfRevolutionPyImp.cpp
|
||||
PartFeaturePy.xml
|
||||
PartFeaturePyImp.cpp
|
||||
AttachableObjectPy.xml
|
||||
AttachableObjectPyImp.cpp
|
||||
AttachExtensionPy.xml
|
||||
AttachExtensionPyImp.cpp
|
||||
Part2DObjectPy.xml
|
||||
Part2DObjectPyImp.cpp
|
||||
AttachEnginePy.xml
|
||||
|
|
|
@ -32,10 +32,11 @@
|
|||
using namespace Part;
|
||||
using namespace Attacher;
|
||||
|
||||
PROPERTY_SOURCE_ABSTRACT(Part::Datum, Part::AttachableObject)
|
||||
PROPERTY_SOURCE_ABSTRACT_WITH_EXTENSIONS(Part::Datum, Part::Feature)
|
||||
|
||||
Datum::Datum(void)
|
||||
{
|
||||
AttachExtension::initExtension(this);
|
||||
touch();
|
||||
}
|
||||
|
||||
|
@ -47,7 +48,7 @@ void Datum::onDocumentRestored()
|
|||
{
|
||||
// This seems to be the only way to make the ViewProvider display the datum feature
|
||||
Support.touch();
|
||||
AttachableObject::onDocumentRestored();
|
||||
Part::Feature::onDocumentRestored();
|
||||
}
|
||||
|
||||
TopoDS_Shape Datum::getShape() const
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <App/PropertyLinks.h>
|
||||
|
||||
#include "PartFeature.h"
|
||||
#include "AttachableObject.h"
|
||||
#include "AttachExtension.h"
|
||||
|
||||
namespace Part
|
||||
{
|
||||
|
@ -36,9 +36,9 @@ namespace Part
|
|||
// This generic class is defined here so that the Sketcher module can access datum features
|
||||
// without creating a dependency on PartDesign
|
||||
|
||||
class PartExport Datum : public Part::AttachableObject
|
||||
class PartExport Datum : public Part::Feature, public Part::AttachExtension
|
||||
{
|
||||
PROPERTY_HEADER(Part::Datum);
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::Datum);
|
||||
|
||||
public:
|
||||
Datum();
|
||||
|
|
|
@ -62,18 +62,19 @@ const int Part2DObject::H_Axis = -1;
|
|||
const int Part2DObject::V_Axis = -2;
|
||||
const int Part2DObject::N_Axis = -3;
|
||||
|
||||
PROPERTY_SOURCE(Part::Part2DObject, Part::AttachableObject)
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Part::Part2DObject, Part::Feature)
|
||||
|
||||
|
||||
Part2DObject::Part2DObject()
|
||||
{
|
||||
AttachExtension::initExtension(this);
|
||||
this->setAttacher(new Attacher::AttachEnginePlane);
|
||||
}
|
||||
|
||||
|
||||
App::DocumentObjectExecReturn *Part2DObject::execute(void)
|
||||
{
|
||||
return AttachableObject::execute();
|
||||
return Feature::execute();
|
||||
}
|
||||
|
||||
void Part2DObject::transformPlacement(const Base::Placement &transform)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <Base/Axis.h>
|
||||
|
||||
#include "PartFeature.h"
|
||||
#include "AttachableObject.h"
|
||||
#include "AttachExtension.h"
|
||||
|
||||
class TopoDS_Face;
|
||||
|
||||
|
@ -50,9 +50,9 @@ class Geometry;
|
|||
* geometry as its descend Sketcher::SketchObject .
|
||||
*/
|
||||
|
||||
class PartExport Part2DObject : public Part::AttachableObject
|
||||
class PartExport Part2DObject : public Part::Feature, public Part::AttachExtension
|
||||
{
|
||||
PROPERTY_HEADER(Part::Part2DObject);
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::Part2DObject);
|
||||
|
||||
public:
|
||||
Part2DObject();
|
||||
|
|
|
@ -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="AttachableObjectPy"
|
||||
Father="PartFeaturePy"
|
||||
Name="Part2DObjectPy"
|
||||
Twin="Part2DObject"
|
||||
TwinPointer="Part2DObject"
|
||||
Include="Mod/Part/App/Part2DObject.h"
|
||||
Namespace="Part"
|
||||
FatherInclude="Mod/Part/App/AttachableObjectPy.h"
|
||||
FatherInclude="Mod/Part/App/PartFeaturePy.h"
|
||||
FatherNamespace="Part">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Juergen Riegel" EMail="FreeCAD@juergen-riegel.net" />
|
||||
|
|
|
@ -93,7 +93,7 @@ App::DocumentObjectExecReturn *Feature::recompute(void)
|
|||
App::DocumentObjectExecReturn *Feature::execute(void)
|
||||
{
|
||||
this->Shape.touch();
|
||||
return App::DocumentObject::StdReturn;
|
||||
return GeoFeature::execute();
|
||||
}
|
||||
|
||||
PyObject *Feature::getPyObject(void)
|
||||
|
|
|
@ -84,10 +84,11 @@ namespace Part {
|
|||
using namespace Part;
|
||||
|
||||
|
||||
PROPERTY_SOURCE_ABSTRACT(Part::Primitive, Part::AttachableObject)
|
||||
PROPERTY_SOURCE_ABSTRACT_WITH_EXTENSIONS(Part::Primitive, Part::Feature)
|
||||
|
||||
Primitive::Primitive(void)
|
||||
{
|
||||
AttachExtension::initExtension(this);
|
||||
touch();
|
||||
}
|
||||
|
||||
|
@ -100,6 +101,11 @@ short Primitive::mustExecute(void) const
|
|||
return Feature::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* Primitive::execute(void) {
|
||||
return Part::Feature::execute();
|
||||
}
|
||||
|
||||
|
||||
void Primitive::Restore(Base::XMLReader &reader)
|
||||
{
|
||||
reader.readElement("Properties");
|
||||
|
@ -169,7 +175,7 @@ void Primitive::onChanged(const App::Property* prop)
|
|||
}
|
||||
}
|
||||
}
|
||||
Part::AttachableObject::onChanged(prop);
|
||||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Vertex, Part::Primitive)
|
||||
|
@ -191,7 +197,7 @@ short Vertex::mustExecute() const
|
|||
Y.isTouched() ||
|
||||
Z.isTouched())
|
||||
return 1;
|
||||
return Part::AttachableObject::mustExecute();
|
||||
return Part::Primitive::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Vertex::execute(void)
|
||||
|
@ -205,7 +211,7 @@ App::DocumentObjectExecReturn *Vertex::execute(void)
|
|||
const TopoDS_Vertex& vertex = MakeVertex.Vertex();
|
||||
this->Shape.setValue(vertex);
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
|
||||
|
@ -221,7 +227,7 @@ void Vertex::onChanged(const App::Property* prop)
|
|||
}
|
||||
}
|
||||
}
|
||||
Part::AttachableObject::onChanged(prop);
|
||||
Part::Primitive::onChanged(prop);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Line, Part::Primitive)
|
||||
|
@ -249,7 +255,7 @@ short Line::mustExecute() const
|
|||
Y2.isTouched() ||
|
||||
Z2.isTouched())
|
||||
return 1;
|
||||
return Part::AttachableObject::mustExecute();
|
||||
return Part::Primitive::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Line::execute(void)
|
||||
|
@ -270,7 +276,7 @@ App::DocumentObjectExecReturn *Line::execute(void)
|
|||
const TopoDS_Edge& edge = mkEdge.Edge();
|
||||
this->Shape.setValue(edge);
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
void Line::onChanged(const App::Property* prop)
|
||||
|
@ -285,7 +291,7 @@ void Line::onChanged(const App::Property* prop)
|
|||
}
|
||||
}
|
||||
}
|
||||
Part::AttachableObject::onChanged(prop);
|
||||
Part::Primitive::onChanged(prop);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Plane, Part::Primitive)
|
||||
|
@ -356,7 +362,7 @@ App::DocumentObjectExecReturn *Plane::execute(void)
|
|||
TopoDS_Shape ResultShape = mkFace.Shape();
|
||||
this->Shape.setValue(ResultShape);
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Sphere, Part::Primitive)
|
||||
|
@ -404,7 +410,7 @@ App::DocumentObjectExecReturn *Sphere::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Ellipsoid, Part::Primitive)
|
||||
|
@ -486,7 +492,7 @@ App::DocumentObjectExecReturn *Ellipsoid::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Cylinder, Part::Primitive)
|
||||
|
@ -529,7 +535,7 @@ App::DocumentObjectExecReturn *Cylinder::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
App::PropertyIntegerConstraint::Constraints Prism::polygonRange = {3,INT_MAX,1};
|
||||
|
@ -587,7 +593,7 @@ App::DocumentObjectExecReturn *Prism::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
App::PropertyIntegerConstraint::Constraints RegularPolygon::polygon = {3,INT_MAX,1};
|
||||
|
@ -639,7 +645,7 @@ App::DocumentObjectExecReturn *RegularPolygon::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
|
||||
|
@ -689,7 +695,7 @@ App::DocumentObjectExecReturn *Cone::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Torus, Part::Primitive)
|
||||
|
@ -761,7 +767,7 @@ App::DocumentObjectExecReturn *Torus::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Helix, Part::Primitive)
|
||||
|
@ -798,7 +804,7 @@ void Helix::onChanged(const App::Property* prop)
|
|||
}
|
||||
}
|
||||
}
|
||||
Part::AttachableObject::onChanged(prop);
|
||||
Part::Primitive::onChanged(prop);
|
||||
}
|
||||
|
||||
short Helix::mustExecute() const
|
||||
|
@ -842,7 +848,7 @@ App::DocumentObjectExecReturn *Helix::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Spiral, Part::Primitive)
|
||||
|
@ -869,7 +875,7 @@ void Spiral::onChanged(const App::Property* prop)
|
|||
}
|
||||
}
|
||||
}
|
||||
Part::AttachableObject::onChanged(prop);
|
||||
Part::Primitive::onChanged(prop);
|
||||
}
|
||||
|
||||
short Spiral::mustExecute() const
|
||||
|
@ -933,7 +939,7 @@ App::DocumentObjectExecReturn *Spiral::execute(void)
|
|||
BRepProj_Projection proj(wire, mkFace.Face(), gp::DZ());
|
||||
this->Shape.setValue(proj.Shape());
|
||||
|
||||
AttachableObject::execute();
|
||||
Primitive::execute();
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
|
@ -942,7 +948,7 @@ App::DocumentObjectExecReturn *Spiral::execute(void)
|
|||
|
||||
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Wedge, Part::Primitive)
|
||||
|
@ -1027,7 +1033,7 @@ App::DocumentObjectExecReturn *Wedge::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
void Wedge::onChanged(const App::Property* prop)
|
||||
|
@ -1070,7 +1076,7 @@ short Ellipse::mustExecute() const
|
|||
MajorRadius.isTouched() ||
|
||||
MinorRadius.isTouched())
|
||||
return 1;
|
||||
return Part::AttachableObject::mustExecute();
|
||||
return Part::Primitive::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Ellipse::execute(void)
|
||||
|
@ -1084,7 +1090,7 @@ App::DocumentObjectExecReturn *Ellipse::execute(void)
|
|||
const TopoDS_Edge& edge = clMakeEdge.Edge();
|
||||
this->Shape.setValue(edge);
|
||||
|
||||
return AttachableObject::execute();
|
||||
return Primitive::execute();
|
||||
}
|
||||
|
||||
void Ellipse::onChanged(const App::Property* prop)
|
||||
|
@ -1099,5 +1105,5 @@ void Ellipse::onChanged(const App::Property* prop)
|
|||
}
|
||||
}
|
||||
}
|
||||
Part::AttachableObject::onChanged(prop);
|
||||
Part::Primitive::onChanged(prop);
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include "PartFeature.h"
|
||||
#include "AttachableObject.h"
|
||||
#include "AttachExtension.h"
|
||||
|
||||
namespace Part
|
||||
{
|
||||
|
||||
class PartExport Primitive : public Part::AttachableObject
|
||||
class PartExport Primitive : public Part::Feature, public Part::AttachExtension
|
||||
{
|
||||
PROPERTY_HEADER(Part::Primitive);
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::Primitive);
|
||||
|
||||
public:
|
||||
Primitive();
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
App::DocumentObjectExecReturn *execute(void) = 0;
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
//@}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name)
|
|||
|
||||
//test if current selection fits a mode.
|
||||
if (support.getSize() > 0) {
|
||||
Part::AttachableObject* pcDatum = static_cast<Part::AttachableObject*>(cmd.getDocument()->getObject(FeatName.c_str()));
|
||||
Part::AttachExtension* pcDatum = cmd.getDocument()->getObject(FeatName.c_str())->getExtensionByType<Part::AttachExtension>();
|
||||
pcDatum->attacher().references.Paste(support);
|
||||
SuggestResult sugr;
|
||||
pcDatum->attacher().suggestMapModes(sugr);
|
||||
|
|
|
@ -394,8 +394,8 @@ bool isFeatureMovable(App::DocumentObject* const feat)
|
|||
|
||||
}
|
||||
|
||||
if (feat->getTypeId().isDerivedFrom(Part::AttachableObject::getClassTypeId())) {
|
||||
auto attachable = static_cast<Part::AttachableObject*>(feat);
|
||||
if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) {
|
||||
auto attachable = feat->getExtensionByType<Part::AttachExtension>();
|
||||
App::DocumentObject* support = attachable->Support.getValue();
|
||||
if (support && !support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()))
|
||||
return false;
|
||||
|
@ -460,8 +460,8 @@ std::vector<App::DocumentObject*> collectMovableDependencies(std::vector<App::Do
|
|||
|
||||
void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody)
|
||||
{
|
||||
if (feat->getTypeId().isDerivedFrom(Part::AttachableObject::getClassTypeId())) {
|
||||
auto attachable = static_cast<Part::AttachableObject*>(feat);
|
||||
if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) {
|
||||
auto attachable = feat->getExtensionByType<Part::AttachExtension>();
|
||||
App::DocumentObject* support = attachable->Support.getValue();
|
||||
if (support && support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) {
|
||||
auto originfeat = static_cast<App::OriginFeature*>(support);
|
||||
|
|
Loading…
Reference in New Issue
Block a user