diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 35d3a67e3d..a62f55bd53 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -2147,7 +2147,7 @@ void Application::initTypes() App::TextDocument ::init(); App::Placement ::init(); App::PlacementPython ::init(); - App::OriginFeature ::init(); + App::DatumElement ::init(); App::Plane ::init(); App::Line ::init(); App::Part ::init(); diff --git a/src/App/Datums.cpp b/src/App/Datums.cpp index 83020070ae..68511613dc 100644 --- a/src/App/Datums.cpp +++ b/src/App/Datums.cpp @@ -29,11 +29,11 @@ using namespace App; -PROPERTY_SOURCE(App::OriginFeature, App::GeoFeature) -PROPERTY_SOURCE(App::Plane, App::OriginFeature) -PROPERTY_SOURCE(App::Line, App::OriginFeature) +PROPERTY_SOURCE(App::DatumElement, App::GeoFeature) +PROPERTY_SOURCE(App::Plane, App::DatumElement) +PROPERTY_SOURCE(App::Line, App::DatumElement) -OriginFeature::OriginFeature() +DatumElement::DatumElement() { ADD_PROPERTY_TYPE(Role, (""), 0, App::Prop_ReadOnly, "Role of the feature in the Origin"); @@ -41,9 +41,9 @@ OriginFeature::OriginFeature() Placement.setStatus(Property::Hidden, true); } -OriginFeature::~OriginFeature() = default; +DatumElement::~DatumElement() = default; -Origin* OriginFeature::getOrigin() +Origin* DatumElement::getOrigin() { App::Document* doc = getDocument(); auto origins = doc->getObjectsOfType(App::Origin::getClassTypeId()); diff --git a/src/App/Datums.h b/src/App/Datums.h index 6f318497b7..5da3ffd8e6 100644 --- a/src/App/Datums.h +++ b/src/App/Datums.h @@ -33,25 +33,25 @@ class Origin; /** Plane Object * Used to define planar support for all kind of operations in the document space */ -class AppExport OriginFeature: public App::GeoFeature +class AppExport DatumElement: public App::GeoFeature { - PROPERTY_HEADER_WITH_OVERRIDE(App::OriginFeature); + PROPERTY_HEADER_WITH_OVERRIDE(App::DatumElement); public: /// additional information about the feature usage (e.g. "BasePlane-XY" or "Axis-X" in a Origin) PropertyString Role; /// Constructor - OriginFeature(); - ~OriginFeature() override; + DatumElement(); + ~DatumElement() override; /// Finds the origin object this plane belongs to App::Origin* getOrigin(); }; -class AppExport Plane: public App::OriginFeature +class AppExport Plane: public App::DatumElement { - PROPERTY_HEADER_WITH_OVERRIDE(App::OriginFeature); + PROPERTY_HEADER_WITH_OVERRIDE(App::DatumElement); public: const char* getViewProviderName() const override @@ -60,9 +60,9 @@ public: } }; -class AppExport Line: public App::OriginFeature +class AppExport Line: public App::DatumElement { - PROPERTY_HEADER_WITH_OVERRIDE(App::OriginFeature); + PROPERTY_HEADER_WITH_OVERRIDE(App::DatumElement); public: const char* getViewProviderName() const override diff --git a/src/App/GeoFeatureGroupExtension.cpp b/src/App/GeoFeatureGroupExtension.cpp index 9724a14f1a..dc8808adf9 100644 --- a/src/App/GeoFeatureGroupExtension.cpp +++ b/src/App/GeoFeatureGroupExtension.cpp @@ -88,7 +88,7 @@ DocumentObject* GeoFeatureGroupExtension::getGroupOfObject(const DocumentObject* } // we will find origins, but not origin features - if (obj->isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (obj->isDerivedFrom(App::DatumElement::getClassTypeId())) { return OriginGroupExtension::getGroupOfObject(obj); } @@ -305,15 +305,11 @@ void GeoFeatureGroupExtension::getCSOutList(const App::DocumentObject* obj, // expressions, also we only want links with scope Local auto result = getScopedObjectsFromLinks(obj, LinkScope::Local); - // we remove all links to origin features and origins, they belong to a CS too and can't be - // moved - result.erase(std::remove_if(result.begin(), - result.end(), - [](App::DocumentObject* obj) -> bool { - return (obj->isDerivedFrom(App::OriginFeature::getClassTypeId()) - || obj->isDerivedFrom(App::Origin::getClassTypeId())); - }), - result.end()); + //we remove all links to origin features and origins, they belong to a CS too and can't be moved + result.erase(std::remove_if(result.begin(), result.end(), [](App::DocumentObject* obj)->bool { + return (obj->isDerivedFrom(App::DatumElement::getClassTypeId()) || + obj->isDerivedFrom(App::Origin::getClassTypeId())); + }), result.end()); vec.insert(vec.end(), result.begin(), result.end()); diff --git a/src/App/Graphviz.cpp b/src/App/Graphviz.cpp index ec74cf5f68..176339d168 100644 --- a/src/App/Graphviz.cpp +++ b/src/App/Graphviz.cpp @@ -301,7 +301,7 @@ void Document::exportGraphviz(std::ostream& out) const if (!sgraph) { auto group = GeoFeatureGroupExtension::getGroupOfObject(docObj); if (group) { - if (docObj->isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (docObj->isDerivedFrom(App::DatumElement::getClassTypeId())) { sgraph = GraphList[group->getExtensionByType() ->Origin.getValue()]; } @@ -311,8 +311,8 @@ void Document::exportGraphviz(std::ostream& out) const } } if (!sgraph) { - if (docObj->isDerivedFrom(OriginFeature::getClassTypeId())) { - sgraph = GraphList[static_cast(docObj)->getOrigin()]; + if (docObj->isDerivedFrom(DatumElement::getClassTypeId())) { + sgraph = GraphList[static_cast(docObj)->getOrigin()]; } } } diff --git a/src/App/Origin.cpp b/src/App/Origin.cpp index afc3c13492..fe8254bd92 100644 --- a/src/App/Origin.cpp +++ b/src/App/Origin.cpp @@ -32,7 +32,7 @@ #include #include "Origin.h" -#include "OriginFeature.h" +#include "Datums.h" #ifndef M_PI @@ -60,15 +60,15 @@ Origin::Origin() Origin::~Origin() = default; -App::OriginFeature* Origin::getOriginFeature(const char* role) const +App::DatumElement* Origin::getOriginFeature(const char* role) const { const auto& features = OriginFeatures.getValues(); auto featIt = std::find_if(features.begin(), features.end(), [role](App::DocumentObject* obj) { - return obj->isDerivedFrom(App::OriginFeature::getClassTypeId()) - && strcmp(static_cast(obj)->Role.getValue(), role) == 0; + return obj->isDerivedFrom(App::DatumElement::getClassTypeId()) + && strcmp(static_cast(obj)->Role.getValue(), role) == 0; }); if (featIt != features.end()) { - return static_cast(*featIt); + return static_cast(*featIt); } else { @@ -81,7 +81,7 @@ App::OriginFeature* Origin::getOriginFeature(const char* role) const App::Line* Origin::getAxis(const char* role) const { - App::OriginFeature* feat = getOriginFeature(role); + App::DatumElement* feat = getOriginFeature(role); if (feat->isDerivedFrom(App::Line::getClassTypeId())) { return static_cast(feat); } @@ -95,7 +95,7 @@ App::Line* Origin::getAxis(const char* role) const App::Plane* Origin::getPlane(const char* role) const { - App::OriginFeature* feat = getOriginFeature(role); + App::DatumElement* feat = getOriginFeature(role); if (feat->isDerivedFrom(App::Plane::getClassTypeId())) { return static_cast(feat); } @@ -171,12 +171,12 @@ void Origin::setupObject() std::string objName = doc->getUniqueObjectName(data.role); App::DocumentObject* featureObj = doc->addObject(data.type.getName(), objName.c_str()); - assert(featureObj && featureObj->isDerivedFrom(App::OriginFeature::getClassTypeId())); + assert(featureObj && featureObj->isDerivedFrom(App::DatumElement::getClassTypeId())); QByteArray byteArray = data.label.toUtf8(); featureObj->Label.setValue(byteArray.constData()); - App::OriginFeature* feature = static_cast(featureObj); + App::DatumElement* feature = static_cast(featureObj); feature->Placement.setValue(Base::Placement(Base::Vector3d(), data.rot)); feature->Role.setValue(data.role); diff --git a/src/App/Origin.h b/src/App/Origin.h index f45e889898..68aeca6a4c 100644 --- a/src/App/Origin.h +++ b/src/App/Origin.h @@ -101,13 +101,13 @@ public: } /// Returns all controlled objects (both planes and axis) to iterate on them - std::vector baseObjects() const + std::vector baseObjects() const { return {getX(), getY(), getZ(), getXY(), getXZ(), getYZ()}; } /// Returns an axis by it's name - App::OriginFeature* getOriginFeature(const char* role) const; + App::DatumElement* getOriginFeature(const char* role) const; /// Returns an axis by it's name App::Line* getAxis(const char* role) const; diff --git a/src/App/OriginGroupExtension.cpp b/src/App/OriginGroupExtension.cpp index ed7ad3547b..9dabd2475e 100644 --- a/src/App/OriginGroupExtension.cpp +++ b/src/App/OriginGroupExtension.cpp @@ -114,7 +114,7 @@ App::DocumentObject* OriginGroupExtension::getGroupOfObject(const DocumentObject return nullptr; } - bool isOriginFeature = obj->isDerivedFrom(App::OriginFeature::getClassTypeId()); + bool isOriginFeature = obj->isDerivedFrom(App::DatumElement::getClassTypeId()); auto list = obj->getInList(); for (auto o : list) { @@ -226,12 +226,12 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) auto p = static_cast(prop); if (!p->getValue() - || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId())) { + || !p->getValue()->isDerivedFrom(App::DatumElement::getClassTypeId())) { continue; } p->setValue(getOrigin()->getOriginFeature( - static_cast(p->getValue())->Role.getValue())); + static_cast(p->getValue())->Role.getValue())); } else if (prop->isDerivedFrom()) { auto p = static_cast(prop); @@ -239,12 +239,12 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) std::vector result; bool changed = false; for (App::DocumentObject* o : vec) { - if (!o || !o->isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (!o || !o->isDerivedFrom(App::DatumElement::getClassTypeId())) { result.push_back(o); } else { result.push_back(getOrigin()->getOriginFeature( - static_cast(o)->Role.getValue())); + static_cast(o)->Role.getValue())); changed = true; } } @@ -255,13 +255,13 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) else if (prop->isDerivedFrom()) { auto p = static_cast(prop); if (!p->getValue() - || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId())) { + || !p->getValue()->isDerivedFrom(App::DatumElement::getClassTypeId())) { continue; } std::vector subValues = p->getSubValues(); p->setValue(getOrigin()->getOriginFeature( - static_cast(p->getValue())->Role.getValue()), + static_cast(p->getValue())->Role.getValue()), subValues); } else if (prop->isDerivedFrom()) { @@ -269,9 +269,9 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) auto vec = p->getSubListValues(); bool changed = false; for (auto& v : vec) { - if (v.first && v.first->isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (v.first && v.first->isDerivedFrom(App::DatumElement::getClassTypeId())) { v.first = getOrigin()->getOriginFeature( - static_cast(v.first)->Role.getValue()); + static_cast(v.first)->Role.getValue()); changed = true; } } diff --git a/src/Gui/ViewProviderOriginFeature.cpp b/src/Gui/ViewProviderOriginFeature.cpp index 66f3a2b2c8..a6d3b66b3c 100644 --- a/src/Gui/ViewProviderOriginFeature.cpp +++ b/src/Gui/ViewProviderOriginFeature.cpp @@ -192,7 +192,7 @@ void ViewProviderOriginFeature::setDisplayMode (const char* ModeName) } bool ViewProviderOriginFeature::onDelete(const std::vector &) { - auto feat = static_cast ( getObject() ); + auto feat = static_cast (getObject()); // Forbid deletion if there is an origin this feature belongs to if ( feat->getOrigin () ) { diff --git a/src/Mod/Part/Gui/TaskAttacher.cpp b/src/Mod/Part/Gui/TaskAttacher.cpp index 3abf4bf323..d46ad0a4a8 100644 --- a/src/Mod/Part/Gui/TaskAttacher.cpp +++ b/src/Mod/Part/Gui/TaskAttacher.cpp @@ -65,7 +65,7 @@ const QString makeRefString(const App::DocumentObject* obj, const std::string& s if (!obj) return QObject::tr("No reference selected"); - if (obj->isDerivedFrom() || + if (obj->isDerivedFrom() || obj->isDerivedFrom()) // App::Plane, Line or Datum feature return QString::fromLatin1(obj->getNameInDocument()); @@ -374,7 +374,7 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg) std::string subname = msg.pSubName; // Remove subname for planes and datum features - if (selObj->isDerivedFrom() || + if (selObj->isDerivedFrom() || selObj->isDerivedFrom()) subname = ""; diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index e59f119949..94164d59a8 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -350,7 +350,7 @@ PyObject* Feature::getPyObject() bool Feature::isDatum(const App::DocumentObject* feature) { - return feature->isDerivedFrom() || + return feature->isDerivedFrom() || feature->isDerivedFrom(); } diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index 729bb7a1b1..70f6817951 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -68,7 +68,7 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c } // Enable selection from origin of current part/ - if (pObj->isDerivedFrom()) { + if (pObj->isDerivedFrom()) { return allowOrigin(body, originGroup, pObj); } @@ -301,7 +301,7 @@ bool getReferencedSelection(const App::DocumentObject* thisObj, const Gui::Selec //of course only if thisObj is in a body, as otherwise the old workflow would not //be supported PartDesign::Body* body = PartDesignGui::getBodyFor(thisObj, false); - bool originfeature = selObj->isDerivedFrom(App::OriginFeature::getClassTypeId()); + bool originfeature = selObj->isDerivedFrom(App::DatumElement::getClassTypeId()); if (!originfeature && body) { PartDesign::Body* selBody = PartDesignGui::getBodyFor(selObj, false); if (!selBody || body != selBody) { diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 2e5c53bbc3..c72fb4fe53 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -139,9 +139,9 @@ TaskFeaturePick::TaskFeaturePick(std::vector& objects, } // check if we need to set any origin in temporary visibility mode - if (*statusIt != invalidShape - && (*objIt)->isDerivedFrom(App::OriginFeature::getClassTypeId())) { - App::Origin* origin = static_cast(*objIt)->getOrigin(); + auto* datum = dynamic_cast(*objIt); + if (*statusIt != invalidShape && datum) { + App::Origin* origin = dynamic_cast(datum->getLCS()); if (origin) { if ((*objIt)->isDerivedFrom(App::Plane::getClassTypeId())) { originVisStatus[origin].set(planeBit, true); diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 7572b3119a..1a047dc4ae 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -514,7 +514,7 @@ bool isFeatureMovable(App::DocumentObject* const feat) if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { auto attachable = feat->getExtensionByType(); App::DocumentObject* support = attachable->AttachmentSupport.getValue(); - if (support && !support->isDerivedFrom()) { + if (support && !support->isDerivedFrom()) { return false; } } @@ -545,19 +545,19 @@ std::vector collectMovableDependencies(std::vector(prim->getPropertyByName("ReferenceAxis"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->isDerivedFrom()){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } if (auto prop = dynamic_cast(prim->getPropertyByName("Spine"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->isDerivedFrom()){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } if (auto prop = dynamic_cast(prim->getPropertyByName("AuxillerySpine"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->isDerivedFrom()){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } @@ -576,9 +576,9 @@ void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody) if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { auto attachable = feat->getExtensionByType(); App::DocumentObject* support = attachable->AttachmentSupport.getValue(); - if (support && support->isDerivedFrom()) { - auto originfeat = static_cast(support); - App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue()); + if (support && support->isDerivedFrom()) { + auto originfeat = static_cast(support); + App::DatumElement* targetOriginFeature = targetbody->getOrigin()->getDatumElement(originfeat->Role.getValue()); if (targetOriginFeature) { attachable->AttachmentSupport.setValue(static_cast(targetOriginFeature), ""); } @@ -588,9 +588,9 @@ void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody) auto prim = static_cast(feat); if (auto prop = static_cast(prim->getPropertyByName("ReferenceAxis"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && axis->isDerivedFrom()){ - auto originfeat = static_cast(axis); - App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue()); + if (axis && axis->isDerivedFrom()){ + auto originfeat = static_cast(axis); + App::DatumElement* targetOriginFeature = targetbody->getOrigin()->getDatumElement(originfeat->Role.getValue()); if (targetOriginFeature) { prop->setValue(static_cast(targetOriginFeature), std::vector(0)); }