From eb55f1fe520cdff24c09d5c6ef1e4e4ceb131ab8 Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Sun, 15 Oct 2023 21:38:52 +0200 Subject: [PATCH] Part: modernize type checking --- src/Mod/Part/App/AppPartPy.cpp | 2 +- src/Mod/Part/App/Attacher.cpp | 2 +- .../Part/App/GeomPlate/CurveConstraintPyImp.cpp | 4 ++-- src/Mod/Part/App/Part2DObject.cpp | 2 +- src/Mod/Part/App/PrimitiveFeature.cpp | 2 +- src/Mod/Part/App/TopoShape.cpp | 4 ++-- src/Mod/Part/Gui/DlgBooleanOperation.cpp | 6 +++--- src/Mod/Part/Gui/DlgFilletEdges.cpp | 2 +- src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp | 4 ++-- src/Mod/Part/Gui/TaskAttacher.cpp | 14 +++++++------- src/Mod/Part/Gui/TaskFaceColors.cpp | 2 +- src/Mod/Part/Gui/TaskShapeBuilder.cpp | 2 +- src/Mod/Part/Gui/ViewProvider2DObject.cpp | 4 ++-- src/Mod/Part/Gui/ViewProviderBoolean.cpp | 12 ++++++------ src/Mod/Part/Gui/ViewProviderCompound.cpp | 8 ++++---- src/Mod/Part/Gui/ViewProviderCurveNet.cpp | 2 +- src/Mod/Part/Gui/ViewProviderExt.cpp | 2 +- src/Mod/Part/Gui/ViewProviderGridExtension.cpp | 4 ++-- src/Mod/Part/Gui/ViewProviderMirror.cpp | 4 ++-- src/Mod/Part/Gui/ViewProviderPython.cpp | 4 ++-- src/Mod/Part/Gui/ViewProviderRuledSurface.cpp | 2 +- src/Mod/Part/Gui/ViewProviderSpline.cpp | 4 ++-- 22 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 293893862b..1ab082d699 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -805,7 +805,7 @@ private: PyObject* item = (*it).ptr(); if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) { App::DocumentObject* obj = static_cast(item)->getDocumentObjectPtr(); - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { Part::Feature* part = static_cast(obj); const TopoDS_Shape& shape = part->Shape.getValue(); if (!shape.IsNull()) diff --git a/src/Mod/Part/App/Attacher.cpp b/src/Mod/Part/App/Attacher.cpp index c102396cd6..74f04f5326 100644 --- a/src/Mod/Part/App/Attacher.cpp +++ b/src/Mod/Part/App/Attacher.cpp @@ -765,7 +765,7 @@ void AttachEngine::readLinks(const App::PropertyLinkSubList &references, shapes.resize(objs.size()); types.resize(objs.size()); for (std::size_t i = 0; i < objs.size(); i++) { - if (!objs[i]->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (!objs[i]->isDerivedFrom()) { throw AttachEngineException("AttachEngine3D: link points to something that is not App::GeoFeature"); } App::GeoFeature* geof = static_cast(objs[i]); diff --git a/src/Mod/Part/App/GeomPlate/CurveConstraintPyImp.cpp b/src/Mod/Part/App/GeomPlate/CurveConstraintPyImp.cpp index 55d1a364f7..f173085a05 100644 --- a/src/Mod/Part/App/GeomPlate/CurveConstraintPyImp.cpp +++ b/src/Mod/Part/App/GeomPlate/CurveConstraintPyImp.cpp @@ -82,7 +82,7 @@ int CurveConstraintPy::PyInit(PyObject* args, PyObject* kwds) #if OCC_VERSION_HEX >= 0x070600 Handle(Adaptor3d_Curve) hCurve; - if (curve->getTypeId().isDerivedFrom(GeomTrimmedCurve::getClassTypeId())) { + if (curve->isDerivedFrom()) { GeomTrimmedCurve* trim = static_cast(curve); hCurve = new GeomAdaptor_Curve(handle, trim->getFirstParameter(), trim->getLastParameter()); } @@ -91,7 +91,7 @@ int CurveConstraintPy::PyInit(PyObject* args, PyObject* kwds) } #else Handle(Adaptor3d_HCurve) hCurve; - if (curve->getTypeId().isDerivedFrom(GeomTrimmedCurve::getClassTypeId())) { + if (curve->isDerivedFrom()) { GeomTrimmedCurve* trim = static_cast(curve); GeomAdaptor_Curve adapt(handle, trim->getFirstParameter(), trim->getLastParameter()); hCurve = new GeomAdaptor_HCurve(adapt); diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index d98daa2126..75dccb8d3d 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -157,7 +157,7 @@ bool Part2DObject::seekTrimPoints(const std::vector &geomlist, // this is just a work-around until that bug is fixed. // https://www.freecad.org/tracker/view.php?id=2463 // https://tracker.dev.opencascade.org/view.php?id=30217 - if (geomlist[id]->getTypeId().isDerivedFrom(Part::GeomBoundedCurve::getClassTypeId())) { + if (geomlist[id]->isDerivedFrom()) { Part::GeomBoundedCurve * bcurve = static_cast(geomlist[id]); diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index 28348e1b36..3d9b9c38fe 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -128,7 +128,7 @@ void Primitive::handleChangedPropertyType(Base::XMLReader &reader, const char * // types don't match if both inherit from PropertyFloat because all derived // classes do not re-implement the Save/Restore methods. Base::Type inputType = Base::Type::fromName(TypeName); - if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && + if (prop->isDerivedFrom() && inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { // Do not directly call the property's Restore method in case the implementation // has changed. So, create a temporary PropertyFloat object and assign the value. diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index e6e63a0840..a503d5ff66 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -3771,7 +3771,7 @@ void TopoShape::getLinesFromSubElement(const Data::Segment* element, std::vector &vertices, std::vector &lines) const { - if (element->getTypeId() == ShapeSegment::getClassTypeId()) { + if (element->is()) { const TopoDS_Shape& shape = static_cast(element)->Shape; if (shape.IsNull()) return; @@ -3785,7 +3785,7 @@ void TopoShape::getFacesFromSubElement(const Data::Segment* element, std::vector &pointNormals, std::vector &faces) const { - if (element->getTypeId() == ShapeSegment::getClassTypeId()) { + if (element->is()) { const TopoDS_Shape& shape = static_cast(element)->Shape; if (shape.IsNull() || shape.ShapeType() != TopAbs_FACE) return; diff --git a/src/Mod/Part/Gui/DlgBooleanOperation.cpp b/src/Mod/Part/Gui/DlgBooleanOperation.cpp index af53f9cc5e..e75ad18086 100644 --- a/src/Mod/Part/Gui/DlgBooleanOperation.cpp +++ b/src/Mod/Part/Gui/DlgBooleanOperation.cpp @@ -126,7 +126,7 @@ void DlgBooleanOperation::slotCreatedObject(const App::DocumentObject& obj) if (!activeDoc) return; App::Document* doc = obj.getDocument(); - if (activeDoc == doc && obj.getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (activeDoc == doc && obj.isDerivedFrom()) { observe.push_back(&obj); } } @@ -136,7 +136,7 @@ void DlgBooleanOperation::slotChangedObject(const App::DocumentObject& obj, { std::list::iterator it; it = std::find(observe.begin(), observe.end(), &obj); - if (it != observe.end() && prop.getTypeId() == Part::PropertyPartShape::getClassTypeId()) { + if (it != observe.end() && prop.is()) { const TopoDS_Shape& shape = static_cast(prop).getValue(); if (!shape.IsNull()) { Gui::Document* activeGui = Gui::Application::Instance->getDocument(obj.getDocument()); @@ -198,7 +198,7 @@ void DlgBooleanOperation::slotChangedObject(const App::DocumentObject& obj, bool DlgBooleanOperation::hasSolids(const App::DocumentObject* obj) const { - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { const TopoDS_Shape& shape = static_cast(obj)->Shape.getValue(); TopExp_Explorer anExp (shape, TopAbs_SOLID); if (anExp.More()) { diff --git a/src/Mod/Part/Gui/DlgFilletEdges.cpp b/src/Mod/Part/Gui/DlgFilletEdges.cpp index 2bd0ba12bb..28971ff8df 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.cpp +++ b/src/Mod/Part/Gui/DlgFilletEdges.cpp @@ -732,7 +732,7 @@ void DlgFilletEdges::onShapeObjectActivated(int itemPos) if (!doc) return; App::DocumentObject* part = doc->getObject((const char*)name); - if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (part && part->isDerivedFrom()) { d->object = part; TopoDS_Shape myShape = static_cast(part)->Shape.getValue(); diff --git a/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp b/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp index 28bb8cd924..ba8d38b0b3 100644 --- a/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp +++ b/src/Mod/Part/Gui/PropertyEnumAttacherItem.cpp @@ -79,11 +79,11 @@ void PropertyEnumAttacherItem::openTask() if (prop) { App::PropertyContainer* parent = prop->getContainer(); - if (parent->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())) { + if (parent->isDerivedFrom()) { App::DocumentObject* obj = static_cast(parent); Gui::ViewProvider* view = Gui::Application::Instance->getViewProvider(obj); - if (view->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { + if (view->isDerivedFrom()) { task = new TaskDlgAttacher(static_cast(view)); } } diff --git a/src/Mod/Part/Gui/TaskAttacher.cpp b/src/Mod/Part/Gui/TaskAttacher.cpp index 904f67056f..31e695e995 100644 --- a/src/Mod/Part/Gui/TaskAttacher.cpp +++ b/src/Mod/Part/Gui/TaskAttacher.cpp @@ -65,8 +65,8 @@ const QString makeRefString(const App::DocumentObject* obj, const std::string& s if (!obj) return QObject::tr("No reference selected"); - if (obj->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) || - obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) + if (obj->isDerivedFrom() || + obj->isDerivedFrom()) // App::Plane, Line or Datum feature return QString::fromLatin1(obj->getNameInDocument()); @@ -372,8 +372,8 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg) std::string subname = msg.pSubName; // Remove subname for planes and datum features - if (selObj->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) || - selObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) + if (selObj->isDerivedFrom() || + selObj->isDerivedFrom()) subname = ""; // eliminate duplicate selections @@ -614,13 +614,13 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx) std::string subElement; - if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + if (obj->isDerivedFrom()) { // everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree) subElement.clear(); - } else if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + } else if (obj->isDerivedFrom()) { // everything is OK (we assume a Part can only have exactly 3 App::Line objects located at the base of the feature tree) subElement.clear(); - } else if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + } else if (obj->isDerivedFrom()) { subElement.clear(); } else { // TODO: check validity of the text that was entered: Does subElement actually reference to an element on the obj? diff --git a/src/Mod/Part/Gui/TaskFaceColors.cpp b/src/Mod/Part/Gui/TaskFaceColors.cpp index 0b088f898a..1ee5a12433 100644 --- a/src/Mod/Part/Gui/TaskFaceColors.cpp +++ b/src/Mod/Part/Gui/TaskFaceColors.cpp @@ -222,7 +222,7 @@ public: FaceColors* self = static_cast(ud); self->d->view = nullptr; - if (self->d->obj && self->d->obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (self->d->obj && self->d->obj->isDerivedFrom()) { cb->setHandled(); const TopoDS_Shape& shape = static_cast(self->d->obj)->Shape.getValue(); self->d->boxSelection = true; diff --git a/src/Mod/Part/Gui/TaskShapeBuilder.cpp b/src/Mod/Part/Gui/TaskShapeBuilder.cpp index fb1df53db1..8ca6050cb2 100644 --- a/src/Mod/Part/Gui/TaskShapeBuilder.cpp +++ b/src/Mod/Part/Gui/TaskShapeBuilder.cpp @@ -152,7 +152,7 @@ void ShapeBuilderWidget::onSelectionChanged(const Gui::SelectionChanges& msg) bool blocked = blockSelection(true); App::Document* doc = App::GetApplication().getDocument(msg.pDocName); App::DocumentObject* obj = doc->getObject(msg.pObjectName); - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { TopoDS_Shape myShape = static_cast(obj)->Shape.getValue(); TopTools_IndexedMapOfShape all_faces; TopExp::MapShapes(myShape, TopAbs_FACE, all_faces); diff --git a/src/Mod/Part/Gui/ViewProvider2DObject.cpp b/src/Mod/Part/Gui/ViewProvider2DObject.cpp index 2e17597a53..7dd81a5fd2 100644 --- a/src/Mod/Part/Gui/ViewProvider2DObject.cpp +++ b/src/Mod/Part/Gui/ViewProvider2DObject.cpp @@ -210,7 +210,7 @@ void ViewProvider2DObjectGrid::updateData(const App::Property* prop) { ViewProvider2DObject::updateData(prop); - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) { + if (prop->is()) { if (GridAutoSize.getValue()) { Base::BoundBox3d bbox = static_cast(prop)->getBoundingBox(); if (!bbox.IsValid()) @@ -263,7 +263,7 @@ void ViewProvider2DObjectGrid::handleChangedPropertyType(Base::XMLReader &reader App::Property * prop) { Base::Type inputType = Base::Type::fromName(TypeName); - if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && + if (prop->isDerivedFrom() && inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { // Do not directly call the property's Restore method in case the implementation // has changed. So, create a temporary PropertyFloat object and assign the value. diff --git a/src/Mod/Part/Gui/ViewProviderBoolean.cpp b/src/Mod/Part/Gui/ViewProviderBoolean.cpp index aed6079f3e..63df4c898d 100644 --- a/src/Mod/Part/Gui/ViewProviderBoolean.cpp +++ b/src/Mod/Part/Gui/ViewProviderBoolean.cpp @@ -73,7 +73,7 @@ QIcon ViewProviderBoolean::getIcon() const void ViewProviderBoolean::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { + if (prop->is()) { const std::vector& hist = static_cast (prop)->getValues(); if (hist.size() != 2) @@ -133,7 +133,7 @@ void ViewProviderBoolean::updateData(const App::Property* prop) } } } - else if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { + else if (prop->isDerivedFrom()) { App::DocumentObject *pBase = static_cast(prop)->getValue(); if (pBase) Gui::Application::Instance->hideViewProvider(pBase); @@ -174,7 +174,7 @@ QIcon ViewProviderMultiFuse::getIcon() const void ViewProviderMultiFuse::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { + if (prop->is()) { const std::vector& hist = static_cast (prop)->getValues(); Part::MultiFuse* objBool = static_cast(getObject()); @@ -221,7 +221,7 @@ void ViewProviderMultiFuse::updateData(const App::Property* prop) this->DiffuseColor.setValues(colBool); } - else if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { + else if (prop->isDerivedFrom()) { std::vector pShapes = static_cast(prop)->getValues(); for (auto it : pShapes) { if (it) { @@ -309,7 +309,7 @@ QIcon ViewProviderMultiCommon::getIcon() const void ViewProviderMultiCommon::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { + if (prop->is()) { const std::vector& hist = static_cast (prop)->getValues(); Part::MultiCommon* objBool = static_cast(getObject()); @@ -356,7 +356,7 @@ void ViewProviderMultiCommon::updateData(const App::Property* prop) this->DiffuseColor.setValues(colBool); } - else if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { + else if (prop->isDerivedFrom()) { std::vector pShapes = static_cast(prop)->getValues(); for (auto it : pShapes) { if (it) { diff --git a/src/Mod/Part/Gui/ViewProviderCompound.cpp b/src/Mod/Part/Gui/ViewProviderCompound.cpp index 362dd4dcad..37bac27534 100644 --- a/src/Mod/Part/Gui/ViewProviderCompound.cpp +++ b/src/Mod/Part/Gui/ViewProviderCompound.cpp @@ -65,7 +65,7 @@ bool ViewProviderCompound::onDelete(const std::vector &) void ViewProviderCompound::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { + if (prop->is()) { const std::vector& hist = static_cast (prop)->getValues(); Part::Compound* objComp = static_cast(getObject()); @@ -131,7 +131,7 @@ void ViewProviderCompound::updateData(const App::Property* prop) this->DiffuseColor.setValues(compCol); } - else if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { + else if (prop->isDerivedFrom()) { const std::vector& pBases = static_cast(prop)->getValues(); for (auto pBase : pBases) { if (pBase) Gui::Application::Instance->hideViewProvider(pBase); @@ -146,7 +146,7 @@ bool ViewProviderCompound::canDragObjects() const bool ViewProviderCompound::canDragObject(App::DocumentObject* obj) const { - return obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()); + return obj->isDerivedFrom(); } void ViewProviderCompound::dragObject(App::DocumentObject* obj) @@ -169,7 +169,7 @@ bool ViewProviderCompound::canDropObjects() const bool ViewProviderCompound::canDropObject(App::DocumentObject* obj) const { - return obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()); + return obj->isDerivedFrom(); } void ViewProviderCompound::dropObject(App::DocumentObject* obj) diff --git a/src/Mod/Part/Gui/ViewProviderCurveNet.cpp b/src/Mod/Part/Gui/ViewProviderCurveNet.cpp index 3b472b64e4..7209a0008d 100644 --- a/src/Mod/Part/Gui/ViewProviderCurveNet.cpp +++ b/src/Mod/Part/Gui/ViewProviderCurveNet.cpp @@ -99,7 +99,7 @@ void ViewProviderCurveNet::attach(App::DocumentObject *pcFeat) void ViewProviderCurveNet::updateData(const App::Property* prop) { Gui::ViewProviderGeometryObject::updateData(prop); // clazy:exclude=skipped-base-method - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) { + if (prop->is()) { TopoDS_Shape cShape = static_cast(prop)->getValue(); if (cShape.IsNull()) return; diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 04be9a3022..aa58bf5bb3 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -377,7 +377,7 @@ void ViewProviderPartExt::onChanged(const App::Property* prop) bool ViewProviderPartExt::allowOverride(const App::DocumentObject &) const { // Many derived view providers still uses static_cast to get object // pointer, so check for exact type here. - return getTypeId() == ViewProviderPartExt::getClassTypeId(); + return is(); } void ViewProviderPartExt::attach(App::DocumentObject *pcFeat) diff --git a/src/Mod/Part/Gui/ViewProviderGridExtension.cpp b/src/Mod/Part/Gui/ViewProviderGridExtension.cpp index ed298adff3..4179e651bf 100644 --- a/src/Mod/Part/Gui/ViewProviderGridExtension.cpp +++ b/src/Mod/Part/Gui/ViewProviderGridExtension.cpp @@ -468,7 +468,7 @@ void ViewProviderGridExtension::getClosestGridPoint(double &x, double &y) const void ViewProviderGridExtension::extensionUpdateData(const App::Property* prop) { if(pImpl->getEnabled()) { - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) { + if (prop->is()) { pImpl->drawGrid(); } } @@ -539,7 +539,7 @@ bool ViewProviderGridExtension::extensionHandleChangedPropertyType(Base::XMLRead { Base::Type inputType = Base::Type::fromName(TypeName); - if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && + if (prop->isDerivedFrom() && inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { // Do not directly call the property's Restore method in case the implementation // has changed. So, create a temporary PropertyFloat object and assign the value. diff --git a/src/Mod/Part/Gui/ViewProviderMirror.cpp b/src/Mod/Part/Gui/ViewProviderMirror.cpp index 164316a4c7..b3f6dde3c2 100644 --- a/src/Mod/Part/Gui/ViewProviderMirror.cpp +++ b/src/Mod/Part/Gui/ViewProviderMirror.cpp @@ -231,7 +231,7 @@ ViewProviderFillet::~ViewProviderFillet() = default; void ViewProviderFillet::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { + if (prop->is()) { const std::vector& hist = static_cast (prop)->getValues(); if (hist.size() != 1) @@ -341,7 +341,7 @@ ViewProviderChamfer::~ViewProviderChamfer() = default; void ViewProviderChamfer::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { + if (prop->is()) { const std::vector& hist = static_cast (prop)->getValues(); if (hist.size() != 1) diff --git a/src/Mod/Part/Gui/ViewProviderPython.cpp b/src/Mod/Part/Gui/ViewProviderPython.cpp index f689589cd3..6991f29efb 100644 --- a/src/Mod/Part/Gui/ViewProviderPython.cpp +++ b/src/Mod/Part/Gui/ViewProviderPython.cpp @@ -57,12 +57,12 @@ void ViewProviderCustom::onChanged(const App::Property* prop) void ViewProviderCustom::updateData(const App::Property* prop) { - if (prop->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) { + if (prop->isDerivedFrom()) { std::map::iterator it = propView.find(prop); if (it == propView.end()) { Gui::ViewProvider* view = Gui::ViewProviderBuilder::create(prop->getTypeId()); if (view) { - if (view->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { + if (view->isDerivedFrom()) { static_cast(view)->attach(this->getObject()); static_cast(view)->setDisplayMode(this->getActiveDisplayMode().c_str()); } diff --git a/src/Mod/Part/Gui/ViewProviderRuledSurface.cpp b/src/Mod/Part/Gui/ViewProviderRuledSurface.cpp index 3d76ed99bf..d320142c77 100644 --- a/src/Mod/Part/Gui/ViewProviderRuledSurface.cpp +++ b/src/Mod/Part/Gui/ViewProviderRuledSurface.cpp @@ -59,7 +59,7 @@ std::vector ViewProviderRuledSurface::claimChildren() cons void ViewProviderRuledSurface::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { + if (prop->is()) { //const std::vector& hist = static_cast // (prop)->getValues(); } diff --git a/src/Mod/Part/Gui/ViewProviderSpline.cpp b/src/Mod/Part/Gui/ViewProviderSpline.cpp index 9c875334e6..362f745b2c 100644 --- a/src/Mod/Part/Gui/ViewProviderSpline.cpp +++ b/src/Mod/Part/Gui/ViewProviderSpline.cpp @@ -102,7 +102,7 @@ void ViewProviderSplineExtension::extensionSetupContextMenu(QMenu* menu, QObject void ViewProviderSplineExtension::extensionUpdateData(const App::Property* prop) { Gui::ViewProviderExtension::extensionUpdateData(prop); - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && strcmp(prop->getName(), "Shape") == 0) { + if (prop->is() && strcmp(prop->getName(), "Shape") == 0) { // update control points if there if (pcControlPoints) { Gui::coinRemoveAllChildren(pcControlPoints); @@ -139,7 +139,7 @@ void ViewProviderSplineExtension::showControlPoints(bool show, const App::Proper return; // ask for the property we are interested in - if (prop && prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) { + if (prop && prop->is()) { const TopoDS_Shape& shape = static_cast(prop)->getValue(); if (shape.IsNull()) return; // empty shape