Part: Rename AttachExtension::Support property to AttachmentSupport, to avoid name conflict with base features. Fixes #7052
This commit is contained in:
committed by
Adrián Insaurralde Avalos
parent
2643902b6b
commit
fbd8767242
@@ -518,7 +518,7 @@ PyObject* AttachEnginePy::readParametersFromFeature(PyObject* args)
|
||||
}
|
||||
Part::AttachExtension* feat = dobj->getExtensionByType<Part::AttachExtension>();
|
||||
AttachEngine &attacher = *(this->getAttachEnginePtr());
|
||||
attacher.setUp(feat->Support,
|
||||
attacher.setUp(feat->AttachmentSupport,
|
||||
eMapMode(feat->MapMode.getValue()),
|
||||
feat->MapReversed.getValue(),
|
||||
feat->MapPathParameter.getValue(),
|
||||
@@ -543,7 +543,7 @@ PyObject* AttachEnginePy::writeParametersToFeature(PyObject* args)
|
||||
Part::AttachExtension* feat = dobj->getExtensionByType<Part::AttachExtension>();
|
||||
const AttachEngine &attacher = *(this->getAttachEnginePtr());
|
||||
AttachEngine::verifyReferencesAreSafe(attacher.references);
|
||||
feat->Support.Paste(attacher.references);
|
||||
feat->AttachmentSupport.Paste(attacher.references);
|
||||
feat->MapMode.setValue(attacher.mapMode);
|
||||
feat->MapReversed.setValue(attacher.mapReverse);
|
||||
feat->MapPathParameter.setValue(attacher.attachParameter);
|
||||
|
||||
@@ -38,7 +38,7 @@ AttachExtension::AttachExtension()
|
||||
EXTENSION_ADD_PROPERTY_TYPE(AttacherType, ("Attacher::AttachEngine3D"), "Attachment",(App::PropertyType)(App::Prop_None),"Class name of attach engine object driving the attachment.");
|
||||
this->AttacherType.setStatus(App::Property::Status::Hidden, true);
|
||||
|
||||
EXTENSION_ADD_PROPERTY_TYPE(Support, (nullptr,nullptr), "Attachment",(App::PropertyType)(App::Prop_None),"Support of the 2D geometry");
|
||||
EXTENSION_ADD_PROPERTY_TYPE(AttachmentSupport, (nullptr,nullptr), "Attachment",(App::PropertyType)(App::Prop_None),"Support of the 2D geometry");
|
||||
|
||||
EXTENSION_ADD_PROPERTY_TYPE(MapMode, (mmDeactivated), "Attachment", App::Prop_None, "Mode of attachment to other object");
|
||||
MapMode.setEditorName("PartGui::PropertyEnumAttacherItem");
|
||||
@@ -165,7 +165,7 @@ App::DocumentObjectExecReturn *AttachExtension::extensionExecute()
|
||||
void AttachExtension::extensionOnChanged(const App::Property* prop)
|
||||
{
|
||||
if(! getExtendedObject()->isRestoring()){
|
||||
if ((prop == &Support
|
||||
if ((prop == &AttachmentSupport
|
||||
|| prop == &MapMode
|
||||
|| prop == &MapPathParameter
|
||||
|| prop == &MapReversed
|
||||
@@ -212,13 +212,32 @@ void AttachExtension::extensionOnChanged(const App::Property* prop)
|
||||
App::DocumentObjectExtension::extensionOnChanged(prop);
|
||||
}
|
||||
|
||||
void AttachExtension::extHandleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName)
|
||||
bool AttachExtension::extensionHandleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char *PropName)
|
||||
{
|
||||
// Was superPlacement
|
||||
// superPlacement -> AttachmentOffset
|
||||
Base::Type type = Base::Type::fromName(TypeName);
|
||||
if (AttachmentOffset.getClassTypeId() == type && strcmp(PropName, "superPlacement") == 0) {
|
||||
if (strcmp(PropName, "superPlacement") == 0 && AttachmentOffset.getClassTypeId() == type) {
|
||||
AttachmentOffset.Restore(reader);
|
||||
return true;
|
||||
}
|
||||
// Support -> AttachmentSupport
|
||||
else if (strcmp(PropName, "Support") == 0) {
|
||||
// At one point, the type of Support changed from PropertyLinkSub to its present type of PropertyLinkSubList.
|
||||
// Later, the property name changed to AttachmentSupport
|
||||
App::PropertyLinkSub tmp;
|
||||
if (0 == strcmp(tmp.getTypeId().getName(),TypeName)) {
|
||||
tmp.setContainer(this->getExtendedContainer());
|
||||
tmp.Restore(reader);
|
||||
AttachmentSupport.setValue(tmp.getValue(), tmp.getSubValues());
|
||||
this->MapMode.setValue(Attacher::mmFlatFace);
|
||||
return true;
|
||||
}
|
||||
else if (AttachmentSupport.getClassTypeId() == type) {
|
||||
AttachmentSupport.Restore(reader);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return App::DocumentObjectExtension::extensionHandleChangedPropertyName(reader, TypeName, PropName);
|
||||
}
|
||||
|
||||
void AttachExtension::onExtendedDocumentRestored()
|
||||
@@ -257,7 +276,7 @@ void AttachExtension::updateAttacherVals()
|
||||
{
|
||||
if (!_attacher)
|
||||
return;
|
||||
_attacher->setUp(this->Support,
|
||||
_attacher->setUp(this->AttachmentSupport,
|
||||
eMapMode(this->MapMode.getValue()),
|
||||
this->MapReversed.getValue(),
|
||||
this->MapPathParameter.getValue(),
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
|
||||
|
||||
App::PropertyString AttacherType;
|
||||
App::PropertyLinkSubList Support;
|
||||
App::PropertyLinkSubList AttachmentSupport;
|
||||
App::PropertyEnumeration MapMode; //see AttachEngine::eMapMode
|
||||
App::PropertyBool MapReversed; //inverts Z and X internal axes
|
||||
App::PropertyPlacement AttachmentOffset;
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
*/
|
||||
App::PropertyFloat MapPathParameter;
|
||||
|
||||
/** calculate and update the Placement property based on the Support, and
|
||||
/** calculate and update the Placement property based on the AttachmentSupport, and
|
||||
* mode. Can throw FreeCAD and OCC exceptions. Returns true if attached,
|
||||
* false if not, throws if attachment failed.
|
||||
*/
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
bool isAttacherActive() const;
|
||||
|
||||
virtual bool isTouched_Mapping()
|
||||
{return true; /*support.isTouched isn't true when linked objects are changed... why?..*/}
|
||||
{return true; /*AttachmentSupport.isTouched isn't true when linked objects are changed... why?..*/}
|
||||
|
||||
short int extensionMustExecute() override;
|
||||
App::DocumentObjectExecReturn *extensionExecute() override;
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
|
||||
protected:
|
||||
void extensionOnChanged(const App::Property* /*prop*/) override;
|
||||
virtual void extHandleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName);
|
||||
virtual bool extensionHandleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override;
|
||||
|
||||
App::PropertyPlacement& getPlacement() const;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</Documentation>
|
||||
<Methode Name="positionBySupport">
|
||||
<Documentation>
|
||||
<UserDocu>positionBySupport(): Reposition object based on Support, MapMode and MapPathParameter properties.
|
||||
<UserDocu>positionBySupport(): Reposition object based on AttachmentSupport, MapMode and MapPathParameter properties.
|
||||
Returns True if attachment calculation was successful, false if object is not attached and Placement wasn't updated,
|
||||
and raises an exception if attachment calculation fails.</UserDocu>
|
||||
</Documentation>
|
||||
|
||||
@@ -144,7 +144,7 @@ enum eRefType {
|
||||
};
|
||||
|
||||
|
||||
using refTypeString = std::vector<eRefType>; //a sequence of ref types, according to Support contents for example
|
||||
using refTypeString = std::vector<eRefType>; //a sequence of ref types, according to AttachmentSupport contents for example
|
||||
using refTypeStringList = std::vector<refTypeString>; //a set of type strings, defines which selection sets are supported by a certain mode
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Datum::~Datum() = default;
|
||||
void Datum::onDocumentRestored()
|
||||
{
|
||||
// This seems to be the only way to make the ViewProvider display the datum feature
|
||||
Support.touch();
|
||||
AttachmentSupport.touch();
|
||||
Part::Feature::onDocumentRestored();
|
||||
}
|
||||
|
||||
@@ -83,8 +83,3 @@ App::DocumentObject *Datum::getSubObject(const char *subname,
|
||||
Base::Vector3d Datum::getBasePoint () const {
|
||||
return Placement.getValue().getPosition();
|
||||
}
|
||||
|
||||
void Datum::handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName)
|
||||
{
|
||||
extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ public:
|
||||
Base::Matrix4D *mat, bool transform, int depth) const override;
|
||||
protected:
|
||||
void onDocumentRestored() override;
|
||||
void handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName) override;
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
@@ -75,7 +75,7 @@ App::DocumentObjectExecReturn *Part2DObject::execute()
|
||||
|
||||
void Part2DObject::transformPlacement(const Base::Placement &transform)
|
||||
{
|
||||
if (!Support.getValues().empty()) {
|
||||
if (!AttachmentSupport.getValues().empty()) {
|
||||
//part->transformPlacement(transform);
|
||||
positionBySupport();
|
||||
} else {
|
||||
@@ -254,33 +254,6 @@ void Part2DObject::Restore(Base::XMLReader &reader)
|
||||
Part::Feature::Restore(reader);
|
||||
}
|
||||
|
||||
void Part2DObject::handleChangedPropertyType(Base::XMLReader &reader,
|
||||
const char * TypeName,
|
||||
App::Property * prop)
|
||||
{
|
||||
//override generic restoration to convert Support property from PropertyLinkSub to PropertyLinkSubList
|
||||
if (prop->isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())) {
|
||||
//reading legacy Support - when the Support could only be a single flat face.
|
||||
App::PropertyLinkSub tmp;
|
||||
if (0 == strcmp(tmp.getTypeId().getName(),TypeName)) {
|
||||
tmp.setContainer(this);
|
||||
tmp.Restore(reader);
|
||||
static_cast<App::PropertyLinkSubList*>(prop)->setValue(tmp.getValue(), tmp.getSubValues());
|
||||
}
|
||||
this->MapMode.setValue(Attacher::mmFlatFace);
|
||||
}
|
||||
else {
|
||||
Part::Feature::handleChangedPropertyType(reader, TypeName, prop);
|
||||
}
|
||||
}
|
||||
|
||||
void Part2DObject::handleChangedPropertyName(Base::XMLReader &reader,
|
||||
const char * TypeName,
|
||||
const char *PropName)
|
||||
{
|
||||
extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
||||
@@ -94,10 +94,6 @@ public:
|
||||
//@}
|
||||
|
||||
void Restore(Base::XMLReader &reader) override;
|
||||
|
||||
protected:
|
||||
void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) override;
|
||||
void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override;
|
||||
};
|
||||
|
||||
using Part2DObjectPython = App::FeaturePythonT<Part2DObject>;
|
||||
|
||||
@@ -116,11 +116,6 @@ void Primitive::Restore(Base::XMLReader &reader)
|
||||
Part::Feature::Restore(reader);
|
||||
}
|
||||
|
||||
void Primitive::handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName)
|
||||
{
|
||||
extHandleChangedPropertyName(reader, TypeName, PropName); // AttachExtension
|
||||
}
|
||||
|
||||
void Primitive::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
|
||||
{
|
||||
// For #0001652 the property types of many primitive features have changed
|
||||
|
||||
@@ -49,7 +49,6 @@ public:
|
||||
protected:
|
||||
void Restore(Base::XMLReader &reader) override;
|
||||
void onChanged (const App::Property* prop) override;
|
||||
void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override;
|
||||
void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop) override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user