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;
|
||||
};
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ const QString makeRefString(const App::DocumentObject* obj, const std::string& s
|
||||
|
||||
void TaskAttacher::makeRefStrings(std::vector<QString>& refstrings, std::vector<std::string>& refnames) {
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->Support.getValues();
|
||||
refnames = pcAttach->Support.getSubValues();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->AttachmentSupport.getValues();
|
||||
refnames = pcAttach->AttachmentSupport.getSubValues();
|
||||
|
||||
for (size_t r = 0; r < 4; r++) {
|
||||
if ((r < refs.size()) && (refs[r])) {
|
||||
@@ -172,7 +172,7 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject *ViewProvider, QWidge
|
||||
|
||||
// Get the feature data
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
std::vector<std::string> refnames = pcAttach->Support.getSubValues();
|
||||
std::vector<std::string> refnames = pcAttach->AttachmentSupport.getSubValues();
|
||||
|
||||
ui->checkBoxFlip->setChecked(pcAttach->MapReversed.getValue());
|
||||
std::vector<QString> refstrings;
|
||||
@@ -203,7 +203,7 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject *ViewProvider, QWidge
|
||||
this->iActiveRef = 0;
|
||||
else
|
||||
this->iActiveRef = -1;
|
||||
if (pcAttach->Support.getSize() == 0){
|
||||
if (pcAttach->AttachmentSupport.getSize() == 0){
|
||||
autoNext = true;
|
||||
} else {
|
||||
autoNext = false;
|
||||
@@ -279,7 +279,7 @@ void TaskAttacher::updateReferencesUI()
|
||||
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->Support.getValues();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->AttachmentSupport.getValues();
|
||||
completed = false;
|
||||
|
||||
// Get hints for further required references...
|
||||
@@ -363,8 +363,8 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
|
||||
// Note: The validity checking has already been done in ReferenceSelection.cpp
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->Support.getValues();
|
||||
std::vector<std::string> refnames = pcAttach->Support.getSubValues();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->AttachmentSupport.getValues();
|
||||
std::vector<std::string> refnames = pcAttach->AttachmentSupport.getSubValues();
|
||||
App::DocumentObject* selObj = ViewProvider->getObject()->getDocument()->getObject(msg.pObjectName);
|
||||
if (!selObj || selObj == ViewProvider->getObject())//prevent self-referencing
|
||||
return;
|
||||
@@ -401,7 +401,7 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
|
||||
//bool error = false;
|
||||
try {
|
||||
pcAttach->Support.setValues(refs, refnames);
|
||||
pcAttach->AttachmentSupport.setValues(refs, refnames);
|
||||
updateListOfModes();
|
||||
eMapMode mmode = getActiveMapMode();//will be mmDeactivated, if selected or if no modes are available
|
||||
if(mmode == mmDeactivated){
|
||||
@@ -572,8 +572,8 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx)
|
||||
// Reference was removed
|
||||
// Update the reference list
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->Support.getValues();
|
||||
std::vector<std::string> refnames = pcAttach->Support.getSubValues();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->AttachmentSupport.getValues();
|
||||
std::vector<std::string> refnames = pcAttach->AttachmentSupport.getSubValues();
|
||||
std::vector<App::DocumentObject*> newrefs;
|
||||
std::vector<std::string> newrefnames;
|
||||
for (size_t r = 0; r < refs.size(); r++) {
|
||||
@@ -582,7 +582,7 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx)
|
||||
newrefnames.push_back(refnames[r]);
|
||||
}
|
||||
}
|
||||
pcAttach->Support.setValues(newrefs, newrefnames);
|
||||
pcAttach->AttachmentSupport.setValues(newrefs, newrefnames);
|
||||
updateListOfModes();
|
||||
pcAttach->MapMode.setValue(getActiveMapMode());
|
||||
selectMapMode(getActiveMapMode());
|
||||
@@ -665,8 +665,8 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx)
|
||||
}
|
||||
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->Support.getValues();
|
||||
std::vector<std::string> refnames = pcAttach->Support.getSubValues();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->AttachmentSupport.getValues();
|
||||
std::vector<std::string> refnames = pcAttach->AttachmentSupport.getSubValues();
|
||||
if (idx < refs.size()) {
|
||||
refs[idx] = obj;
|
||||
refnames[idx] = subElement;
|
||||
@@ -674,7 +674,7 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx)
|
||||
refs.push_back(obj);
|
||||
refnames.emplace_back(subElement);
|
||||
}
|
||||
pcAttach->Support.setValues(refs, refnames);
|
||||
pcAttach->AttachmentSupport.setValues(refs, refnames);
|
||||
updateListOfModes();
|
||||
pcAttach->MapMode.setValue(getActiveMapMode());
|
||||
selectMapMode(getActiveMapMode());
|
||||
@@ -697,7 +697,7 @@ void TaskAttacher::updateRefButton(int idx)
|
||||
}
|
||||
|
||||
Part::AttachExtension* pcAttach = ViewProvider->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->Support.getValues();
|
||||
std::vector<App::DocumentObject*> refs = pcAttach->AttachmentSupport.getValues();
|
||||
|
||||
int numrefs = refs.size();
|
||||
bool enable = true;
|
||||
@@ -792,7 +792,7 @@ void TaskAttacher::updateListOfModes()
|
||||
this->lastSuggestResult.bestFitMode = mmDeactivated;
|
||||
size_t lastValidModeItemIndex = mmDummy_NumberOfModes;
|
||||
|
||||
if (pcAttach->Support.getSize() > 0){
|
||||
if (pcAttach->AttachmentSupport.getSize() > 0){
|
||||
pcAttach->attacher().suggestMapModes(this->lastSuggestResult);
|
||||
modesInList = this->lastSuggestResult.allApplicableModes;
|
||||
modesInList.insert(modesInList.begin(), mmDeactivated); // always have the option to choose Deactivated mode
|
||||
@@ -976,8 +976,8 @@ void TaskAttacher::visibilityAutomation(bool opening_not_closing)
|
||||
"_tv_%4.hide(dep_features)\n"
|
||||
"del(dep_features)\n"
|
||||
"if not tvObj.isDerivedFrom('PartDesign::CoordinateSystem'):\n"
|
||||
"\t\tif len(tvObj.Support) > 0:\n"
|
||||
"\t\t\t_tv_%4.show([lnk[0] for lnk in tvObj.Support])\n"
|
||||
"\t\tif len(tvObj.AttachmentSupport) > 0:\n"
|
||||
"\t\t\t_tv_%4.show([lnk[0] for lnk in tvObj.AttachmentSupport])\n"
|
||||
"del(tvObj)"
|
||||
).arg(
|
||||
QString::fromLatin1(Gui::Command::getObjectCmd(vp->getObject()).c_str()),
|
||||
@@ -1103,7 +1103,7 @@ bool TaskDlgAttacher::accept()
|
||||
|
||||
Gui::cmdAppObjectArgs(obj, "MapReversed = %s", pcAttach->MapReversed.getValue() ? "True" : "False");
|
||||
|
||||
Gui::cmdAppObjectArgs(obj, "Support = %s", pcAttach->Support.getPyReprString().c_str());
|
||||
Gui::cmdAppObjectArgs(obj, "AttachmentSupport = %s", pcAttach->AttachmentSupport.getPyReprString().c_str());
|
||||
|
||||
Gui::cmdAppObjectArgs(obj, "MapPathParameter = %f", pcAttach->MapPathParameter.getValue());
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ void ViewProviderAttachExtension::extensionUpdateData(const App::Property* prop)
|
||||
auto* attach = getExtendedViewProvider()->getObject()->getExtensionByType<Part::AttachExtension>();
|
||||
|
||||
if(attach) {
|
||||
if( prop == &(attach->Support) ||
|
||||
if( prop == &(attach->AttachmentSupport) ||
|
||||
prop == &(attach->MapMode) ||
|
||||
prop == &(attach->MapPathParameter) ||
|
||||
prop == &(attach->MapReversed) ||
|
||||
|
||||
@@ -551,7 +551,7 @@ bool ViewProviderGridExtension::extensionHandleChangedPropertyType(Base::XMLRead
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Gui::ViewProviderExtension::extensionHandleChangedPropertyType(reader, TypeName, prop);
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
|
||||
Reference in New Issue
Block a user