diff --git a/src/App/ExtensionPython.h b/src/App/ExtensionPython.h index c49635afbc..b6672f15d7 100644 --- a/src/App/ExtensionPython.h +++ b/src/App/ExtensionPython.h @@ -62,7 +62,7 @@ using ExtensionPython = ExtensionPythonT; Py::Object result;\ try {\ Property* proxy = this->getExtendedContainer()->getPropertyByName("Proxy");\ - if (proxy && proxy->getTypeId() == PropertyPythonObject::getClassTypeId()) {\ + if (proxy && proxy->is()) {\ Py::Object feature = static_cast(proxy)->getValue();\ if (feature.hasAttr(std::string("function"))) {\ if (feature.hasAttr("__object__")) {\ diff --git a/src/App/OriginGroupExtension.cpp b/src/App/OriginGroupExtension.cpp index 2fef321dc6..4b15f9ffdc 100644 --- a/src/App/OriginGroupExtension.cpp +++ b/src/App/OriginGroupExtension.cpp @@ -189,7 +189,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) std::vector list; obj->getPropertyList(list); for(App::Property* prop : list) { - if(prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { + if(prop->isDerivedFrom()) { auto p = static_cast(prop); if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId())) @@ -197,7 +197,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) p->setValue(getOrigin()->getOriginFeature(static_cast(p->getValue())->Role.getValue())); } - else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { + else if(prop->isDerivedFrom()) { auto p = static_cast(prop); auto vec = p->getValues(); std::vector result; @@ -213,7 +213,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) if(changed) static_cast(prop)->setValues(result); } - else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) { + else if(prop->isDerivedFrom()) { auto p = static_cast(prop); if(!p->getValue() || !p->getValue()->isDerivedFrom(App::OriginFeature::getClassTypeId())) continue; @@ -221,7 +221,7 @@ void OriginGroupExtension::relinkToOrigin(App::DocumentObject* obj) std::vector subValues = p->getSubValues(); p->setValue(getOrigin()->getOriginFeature(static_cast(p->getValue())->Role.getValue()), subValues); } - else if(prop->getTypeId().isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())) { + else if(prop->isDerivedFrom()) { auto p = static_cast(prop); auto vec = p->getSubListValues(); bool changed = false; diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index a72364f265..247079691c 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -998,7 +998,7 @@ PropertyPlacementLink::~PropertyPlacementLink() = default; App::Placement * PropertyPlacementLink::getPlacementObject() const { - if (_pcLink->getTypeId().isDerivedFrom(App::Placement::getClassTypeId())) + if (_pcLink->isDerivedFrom()) return dynamic_cast(_pcLink); else return nullptr; diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 8b7325d3c3..b90f1d4bcb 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -478,7 +478,7 @@ void PropertyLink::Restore(Base::XMLReader &reader) std::string name = reader.getName(reader.getAttribute("value")); // Property not in a DocumentObject! - assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId()) ); + assert(getContainer()->isDerivedFrom() ); if (!name.empty()) { DocumentObject* parent = static_cast(getContainer()); @@ -729,7 +729,7 @@ void PropertyLinkList::Restore(Base::XMLReader &reader) App::PropertyContainer* container = getContainer(); if (!container) throw Base::RuntimeError("Property is not part of a container"); - if (!container->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())) { + if (!container->isDerivedFrom()) { std::stringstream str; str << "Container is not a document object (" << container->getTypeId().getName() << ")"; @@ -1330,7 +1330,7 @@ void PropertyLinkSub::Restore(Base::XMLReader &reader) int count = reader.getAttributeAsInteger("count"); // Property not in a DocumentObject! - assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId()) ); + assert(getContainer()->isDerivedFrom() ); App::Document* document = static_cast(getContainer())->getDocument(); DocumentObject *pcObject = nullptr; @@ -3339,7 +3339,7 @@ void PropertyXLink::Restore(Base::XMLReader &reader) else name = reader.getAttribute("name"); - assert(getContainer()->getTypeId().isDerivedFrom(App::DocumentObject::getClassTypeId())); + assert(getContainer()->isDerivedFrom()); DocumentObject *object = nullptr; if(!name.empty() && file.empty()) { DocumentObject* parent = static_cast(getContainer()); diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index 0efc797efb..6ed1cf4abd 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -432,7 +432,7 @@ Property *PropertyPythonObject::Copy() const void PropertyPythonObject::Paste(const Property &from) { - if (from.getTypeId() == PropertyPythonObject::getClassTypeId()) { + if (from.is()) { Base::PyGILStateLocker lock; aboutToSetValue(); this->object = static_cast(from).object; diff --git a/src/App/Transactions.cpp b/src/App/Transactions.cpp index 7061381de3..5100c3992c 100644 --- a/src/App/Transactions.cpp +++ b/src/App/Transactions.cpp @@ -76,7 +76,7 @@ Transaction::~Transaction() // of an object is not undone or when an addition is undone. if (!It.first->isAttachedToDocument()) { - if (It.first->getTypeId().isDerivedFrom(DocumentObject::getClassTypeId())) { + if (It.first->isDerivedFrom()) { // #0003323: Crash when clearing transaction list // It can happen that when clearing the transaction list several objects // are destroyed with dependencies which can lead to dangling pointers. diff --git a/src/Base/Type.h b/src/Base/Type.h index 23e5d1c233..3cc85eadee 100644 --- a/src/Base/Type.h +++ b/src/Base/Type.h @@ -54,12 +54,12 @@ struct TypeData; \code void getRightFeature(Base::Base * anode) { - assert(anode->getTypeId().isDerivedFrom(App::Feature::getClassTypeId())); + assert(anode->isDerivedFrom()); - if (anode->getTypeId() == Mesh::MeshFeature::getClassTypeId()) { + if (anode->is()) { // do something.. } - else if (anode->getTypeId() == Part::PartFeature::getClassTypeId()) { + else if (anode->is()) { // do something.. } else { diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index baa00927cd..512b259772 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -222,7 +222,7 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args) auto base = static_cast(Base::Type::createInstanceByName(vp.c_str(), true)); if (base - && base->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { + && base->isDerivedFrom()) { std::unique_ptr vp( static_cast(base)); std::map Map; @@ -231,7 +231,7 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args) // this is needed to initialize Python-based view providers App::Property* pyproxy = vp->getPropertyByName("Proxy"); - if (pyproxy && pyproxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) { + if (pyproxy && pyproxy->is()) { static_cast(pyproxy)->setValue(Py::Long(1)); } @@ -1702,7 +1702,7 @@ void Application::setupContextMenu(const char* recipient, MenuItem* items) const if (actWb) { // when populating the context-menu of a Python workbench invoke the method // 'ContextMenu' of the handler object - if (actWb->getTypeId().isDerivedFrom(PythonWorkbench::getClassTypeId())) { + if (actWb->isDerivedFrom()) { static_cast(actWb)->clearContextMenu(); Base::PyGILStateLocker lock; PyObject* pWorkbench = nullptr; diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index feea11b077..0479fb975d 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1549,7 +1549,7 @@ void StdCmdPlacement::activated(int iMsg) auto plm = new Gui::Dialog::TaskPlacement(); if (!sel.empty()) { App::Property* prop = sel.front()->getPropertyByName("Placement"); - if (prop && prop->getTypeId() == App::PropertyPlacement::getClassTypeId()) { + if (prop && prop->is()) { plm->setPlacement(static_cast(prop)->getValue()); std::vector selection; diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index d8b5cf1543..c197fc5f36 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -160,7 +160,7 @@ void StdCmdSendToPythonConsole::activated(int iMsg) cmd = QString::fromLatin1("doc = App.getDocument(\"%1\")").arg(docname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); //support links - if (obj->getTypeId().isDerivedFrom(App::Link::getClassTypeId())) { + if (obj->isDerivedFrom()) { cmd = QString::fromLatin1("lnk = doc.getObject(\"%1\")").arg(objname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); cmd = QString::fromLatin1("obj = lnk.getLinkedObject()"); @@ -171,7 +171,7 @@ void StdCmdSendToPythonConsole::activated(int iMsg) cmd = QString::fromLatin1("obj = doc.getObject(\"%1\")").arg(objname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); } - if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (obj->isDerivedFrom()) { const auto geoObj = static_cast(obj); const App::PropertyGeometry* geo = geoObj->getPropertyOfGeometry(); if (geo){ diff --git a/src/Gui/CommandStructure.cpp b/src/Gui/CommandStructure.cpp index 4c0c597f8b..d586d909ae 100644 --- a/src/Gui/CommandStructure.cpp +++ b/src/Gui/CommandStructure.cpp @@ -125,7 +125,7 @@ void StdCmdGroup::activated(int iMsg) Gui::Document* gui = Application::Instance->activeDocument(); App::Document* app = gui->getDocument(); ViewProvider* vp = gui->getViewProvider(app->getActiveObject()); - if (vp && vp->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) + if (vp && vp->isDerivedFrom()) gui->signalScrollToObject(*static_cast(vp)); } diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 07957396e1..c9ec85996c 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -242,7 +242,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj, if (!name) return; std::string prop_name = name; - if (prop.getTypeId() == App::PropertyColor::getClassTypeId()) { + if (prop.is()) { App::Color value = static_cast(prop).getValue(); if (prop_name == "ShapeColor") { bool blocked = d->ui.buttonColor->blockSignals(true); @@ -266,7 +266,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj, d->ui.buttonPointColor->blockSignals(blocked); } } - else if (prop.getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { + else if (prop.isDerivedFrom()) { long value = static_cast(prop).getValue(); if (prop_name == "Transparency") { bool blocked = d->ui.spinTransparency->blockSignals(true); @@ -285,7 +285,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj, d->ui.sliderLineTransparency->blockSignals(blocked); } } - else if (prop.getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + else if (prop.isDerivedFrom()) { double value = static_cast(prop).getValue(); if (prop_name == "PointSize") { bool blocked = d->ui.spinPointSize->blockSignals(true); diff --git a/src/Gui/DlgMaterialPropertiesImp.cpp b/src/Gui/DlgMaterialPropertiesImp.cpp index 27448e50c1..20e4bcb5a7 100644 --- a/src/Gui/DlgMaterialPropertiesImp.cpp +++ b/src/Gui/DlgMaterialPropertiesImp.cpp @@ -98,7 +98,7 @@ void DlgMaterialPropertiesImp::onAmbientColorChanged() for (std::vector::iterator it= Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.ambientColor = ambient; @@ -120,7 +120,7 @@ void DlgMaterialPropertiesImp::onDiffuseColorChanged() for (std::vector::iterator it = Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.diffuseColor = diffuse; @@ -142,7 +142,7 @@ void DlgMaterialPropertiesImp::onEmissiveColorChanged() for (std::vector::iterator it = Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.emissiveColor = emissive; @@ -164,7 +164,7 @@ void DlgMaterialPropertiesImp::onSpecularColorChanged() for (std::vector::iterator it = Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.specularColor = specular; @@ -181,7 +181,7 @@ void DlgMaterialPropertiesImp::onShininessValueChanged(int sh) float shininess = (float)sh / 100.0f; for (std::vector::iterator it = Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); mat.shininess = shininess; @@ -199,7 +199,7 @@ void DlgMaterialPropertiesImp::setViewProviders(const std::vector::iterator it = Objects.begin(); it != Objects.end(); ++it) { App::Property* prop = (*it)->getPropertyByName(material.c_str()); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto ShapeMaterial = static_cast(prop); App::Material mat = ShapeMaterial->getValue(); int r = int(mat.ambientColor.r * 255.0f); diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index 87a63ea398..a4f7925575 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -627,7 +627,7 @@ void Document::setShow(const char* name) { ViewProvider* pcProv = getViewProviderByName(name); - if (pcProv && pcProv->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { + if (pcProv && pcProv->isDerivedFrom()) { static_cast(pcProv)->Visibility.setValue(true); } } @@ -637,7 +637,7 @@ void Document::setHide(const char* name) { ViewProvider* pcProv = getViewProviderByName(name); - if (pcProv && pcProv->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { + if (pcProv && pcProv->isDerivedFrom()) { static_cast(pcProv)->Visibility.setValue(false); } } @@ -1383,7 +1383,7 @@ void Document::Save (Base::Writer &writer) const size = Base::clamp(size, 64, 512); std::list mdi = getMDIViews(); for (const auto & it : mdi) { - if (it->getTypeId().isDerivedFrom(View3DInventor::getClassTypeId())) { + if (it->isDerivedFrom()) { View3DInventorViewer* view = static_cast(it)->getViewer(); d->thumb.setFileName(d->_pcDocument->FileName.getValue()); d->thumb.setSize(size); @@ -1840,7 +1840,7 @@ Gui::MDIView* Document::cloneView(Gui::MDIView* oldview) if (!oldview) return nullptr; - if (oldview->getTypeId() == View3DInventor::getClassTypeId()) { + if (oldview->is()) { auto view3D = new View3DInventor(this, getMainWindow()); auto firstView = static_cast(oldview); diff --git a/src/Gui/DocumentModel.cpp b/src/Gui/DocumentModel.cpp index 57308e4a8b..b2ae6e6a98 100644 --- a/src/Gui/DocumentModel.cpp +++ b/src/Gui/DocumentModel.cpp @@ -565,7 +565,7 @@ const Document* DocumentModel::getDocument(const QModelIndex& index) const return nullptr; Base::BaseClass* item = nullptr; item = static_cast(index.internalPointer()); - if (item->getTypeId() == DocumentIndex::getClassTypeId()) { + if (item->is()) { const Gui::Document& d = static_cast(item)->d; return (&d); } @@ -593,7 +593,7 @@ DocumentModel::claimChildren(const Gui::Document& doc, const ViewProviderDocumen std::vector childs = obj.claimChildren(); for (const auto & child : childs) { ViewProvider* view = doc.getViewProvider(child); - if (view && view->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) + if (view && view->isDerivedFrom()) views.push_back(static_cast(view)); } diff --git a/src/Gui/ExpressionBinding.cpp b/src/Gui/ExpressionBinding.cpp index 2906ccec03..3e0af0264f 100644 --- a/src/Gui/ExpressionBinding.cpp +++ b/src/Gui/ExpressionBinding.cpp @@ -172,7 +172,7 @@ bool ExpressionBinding::assignToProperty(const std::string & propName, double va if (prop && prop->isReadOnly()) return true; - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { std::string p = path.getSubPathStr(); if (p == ".Rotation.Angle") { value = Base::toRadians(value); diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 5f82f4a58b..4a243fc49b 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -1087,7 +1087,7 @@ bool ManualAlignment::computeAlignment(const std::vector& movPts, */ void ManualAlignment::alignObject(App::DocumentObject *obj) { - if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (obj->isDerivedFrom()) { auto geom = static_cast(obj); geom->transformPlacement(this->myTransform); } @@ -1137,7 +1137,7 @@ void ManualAlignment::slotDeletedDocument(const Gui::Document& Doc) void ManualAlignment::slotDeletedObject(const Gui::ViewProvider& Obj) { // remove the view provider either from the left or the right view - if (Obj.getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { + if (Obj.isDerivedFrom()) { // remove the view provider immediately from the split window bool found = false; auto vp = const_cast @@ -1214,7 +1214,7 @@ void ManualAlignment::probePickedCallback(void * ud, SoEventCallback * n) const SoPickedPoint * point = view->getPickedPoint(n); if (point) { auto vp = static_cast(view->getViewProviderByPath(point->getPath())); - if (vp && vp->getTypeId().isDerivedFrom(Gui::ViewProviderDocumentObject::getClassTypeId())) { + if (vp && vp->isDerivedFrom()) { auto that = static_cast(vp); if (self->applyPickedProbe(that, point)) { const SbVec3f& vec = point->getPoint(); diff --git a/src/Gui/SelectionView.cpp b/src/Gui/SelectionView.cpp index 7cedfe0314..df5e17b018 100644 --- a/src/Gui/SelectionView.cpp +++ b/src/Gui/SelectionView.cpp @@ -548,7 +548,7 @@ QString SelectionView::getModule(const char* type) const QString SelectionView::getProperty(App::DocumentObject* obj) const { QString property; - if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (obj->isDerivedFrom()) { App::GeoFeature* geo = static_cast(obj); const App::PropertyComplexGeoData* data = geo->getPropertyOfGeometry(); const char* name = data ? data->getName() : nullptr; @@ -562,7 +562,7 @@ QString SelectionView::getProperty(App::DocumentObject* obj) const bool SelectionView::supportPart(App::DocumentObject* obj, const QString& part) const { - if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (obj->isDerivedFrom()) { App::GeoFeature* geo = static_cast(obj); const App::PropertyComplexGeoData* data = geo->getPropertyOfGeometry(); if (data) { diff --git a/src/Gui/TaskView/TaskAppearance.cpp b/src/Gui/TaskView/TaskAppearance.cpp index cecbcb8af4..6acbef72e4 100644 --- a/src/Gui/TaskView/TaskAppearance.cpp +++ b/src/Gui/TaskView/TaskAppearance.cpp @@ -127,7 +127,7 @@ void TaskAppearance::slotChangedObject(const Gui::ViewProvider& obj, if (vp != Provider.end()) { std::string prop_name = obj.getPropertyName(&prop); - if (prop.getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { + if (prop.isDerivedFrom()) { long value = static_cast(prop).getValue(); if (prop_name == "Transparency") { bool blocked = ui->spinTransparency->blockSignals(true); @@ -138,7 +138,7 @@ void TaskAppearance::slotChangedObject(const Gui::ViewProvider& obj, ui->horizontalSlider->blockSignals(blocked); } } - else if (prop.getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + else if (prop.isDerivedFrom()) { float value = static_cast(prop).getValue(); if (prop_name == "PointSize") { bool blocked = ui->spinPointSize->blockSignals(true); @@ -163,7 +163,7 @@ void TaskAppearance::onChangeModeActivated(const QString& s) std::vector Provider = getSelection(); for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("DisplayMode"); - if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { + if (prop && prop->is()) { auto Display = static_cast(prop); Display->setValue((const char*)s.toLatin1()); } @@ -183,7 +183,7 @@ void TaskAppearance::onTransparencyValueChanged(int transparency) std::vector Provider = getSelection(); for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("Transparency"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto Transparency = static_cast(prop); Transparency->setValue(transparency); } @@ -198,7 +198,7 @@ void TaskAppearance::onPointSizeValueChanged(int pointsize) std::vector Provider = getSelection(); for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("PointSize"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto PointSize = static_cast(prop); PointSize->setValue(static_cast(pointsize)); } @@ -213,7 +213,7 @@ void TaskAppearance::onLineWidthValueChanged(int linewidth) std::vector Provider = getSelection(); for (const auto & It : Provider) { App::Property* prop = It->getPropertyByName("LineWidth"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto LineWidth = static_cast(prop); LineWidth->setValue(static_cast(linewidth)); } @@ -225,7 +225,7 @@ void TaskAppearance::setDisplayModes(const std::vector& view QStringList commonModes, modes; for (auto it = views.begin(); it != views.end(); ++it) { App::Property* prop = (*it)->getPropertyByName("DisplayMode"); - if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { + if (prop && prop->is()) { auto display = static_cast(prop); if (!display->hasEnums()) return; @@ -253,7 +253,7 @@ void TaskAppearance::setDisplayModes(const std::vector& view // find the display mode to activate for (const auto view : views) { App::Property* prop = view->getPropertyByName("DisplayMode"); - if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { + if (prop && prop->is()) { auto display = static_cast(prop); QString activeMode = QString::fromLatin1(display->getValueAsString()); int index = ui->changeMode->findText(activeMode); @@ -270,7 +270,7 @@ void TaskAppearance::setPointSize(const std::vector& views) bool pointSize = false; for (const auto & view : views) { App::Property* prop = view->getPropertyByName("PointSize"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { bool blocked = ui->spinPointSize->blockSignals(true); ui->spinPointSize->setValue((int)static_cast(prop)->getValue()); ui->spinPointSize->blockSignals(blocked); @@ -287,7 +287,7 @@ void TaskAppearance::setLineWidth(const std::vector& views) bool lineWidth = false; for (const auto & view : views) { App::Property* prop = view->getPropertyByName("LineWidth"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { bool blocked = ui->spinLineWidth->blockSignals(true); ui->spinLineWidth->setValue((int)static_cast(prop)->getValue()); ui->spinLineWidth->blockSignals(blocked); @@ -304,7 +304,7 @@ void TaskAppearance::setTransparency(const std::vector& view bool transparency = false; for (const auto & view : views) { App::Property* prop = view->getPropertyByName("Transparency"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { bool blocked = ui->spinTransparency->blockSignals(true); ui->spinTransparency->setValue(static_cast(prop)->getValue()); ui->spinTransparency->blockSignals(blocked); diff --git a/src/Gui/TaskView/TaskImage.cpp b/src/Gui/TaskView/TaskImage.cpp index 672832c3e0..e0fec1ecbc 100644 --- a/src/Gui/TaskView/TaskImage.cpp +++ b/src/Gui/TaskView/TaskImage.cpp @@ -125,7 +125,7 @@ void TaskImage::initialiseTransparency() // NOLINTBEGIN auto vp = Application::Instance->getViewProvider(feature.get()); App::Property* prop = vp->getPropertyByName("Transparency"); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { auto Transparency = static_cast(prop); ui->spinBoxTransparency->setValue(Transparency->getValue()); ui->sliderTransparency->setValue(Transparency->getValue()); diff --git a/src/Gui/TaskView/TaskSelectLinkProperty.cpp b/src/Gui/TaskView/TaskSelectLinkProperty.cpp index 1bb20c6fcf..7c0ade2819 100644 --- a/src/Gui/TaskView/TaskSelectLinkProperty.cpp +++ b/src/Gui/TaskView/TaskSelectLinkProperty.cpp @@ -63,10 +63,10 @@ TaskSelectLinkProperty::TaskSelectLinkProperty(const char *sFilter,App::Property // property have to be set! assert(prop); StartObject = nullptr; - if (prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) { + if (prop->isDerivedFrom()) { LinkSub = dynamic_cast(prop); } - else if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { + else if (prop->isDerivedFrom()) { LinkList = dynamic_cast(prop); } else { diff --git a/src/Gui/Transform.cpp b/src/Gui/Transform.cpp index be98701d83..ce2eeb02b8 100644 --- a/src/Gui/Transform.cpp +++ b/src/Gui/Transform.cpp @@ -72,7 +72,7 @@ Base::Vector3d TransformStrategy::getRotationCenter() const Base::BoundBox3d bbox; bool first=true; for (const auto & object : objects) { - if (object->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (object->isDerivedFrom()) { // search for a data property const App::PropertyGeometry* geo = static_cast(object)->getPropertyOfGeometry(); if (geo) { @@ -126,7 +126,7 @@ void TransformStrategy::acceptDataTransform(const Base::Matrix4D& mat, App::Docu } // Apply the transformation - if (obj->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (obj->isDerivedFrom()) { // search for a data property const App::PropertyGeometry* geo = static_cast(obj)->getPropertyOfGeometry(); if (geo) { @@ -225,7 +225,7 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m std::vector sel = Gui::Selection().getObjectsOfType (App::DocumentObject::getClassTypeId()); for (const auto & it : sel) { - if (it->getTypeId().isDerivedFrom(App::GeoFeature::getClassTypeId())) { + if (it->isDerivedFrom()) { // search for a data property const App::PropertyGeometry* geo = static_cast(it)->getPropertyOfGeometry(); if (geo) { diff --git a/src/Gui/TreeView.cpp b/src/Gui/TreeView.cpp index 39a056a05e..91f7a054ac 100644 --- a/src/Gui/TreeView.cpp +++ b/src/Gui/TreeView.cpp @@ -59,7 +59,7 @@ void TreeView::mouseDoubleClickEvent (QMouseEvent * event) return; Base::BaseClass* item = nullptr; item = static_cast(index.internalPointer()); - if (item->getTypeId() == Document::getClassTypeId()) { + if (item->is()) { QTreeView::mouseDoubleClickEvent(event); const Gui::Document* doc = static_cast(item); MDIView *view = doc->getActiveView(); @@ -67,7 +67,7 @@ void TreeView::mouseDoubleClickEvent (QMouseEvent * event) return; getMainWindow()->setActiveWindow(view); } - else if (item->getTypeId().isDerivedFrom(ViewProvider::getClassTypeId())) { + else if (item->isDerivedFrom()) { if (!static_cast(item)->doubleClicked()) QTreeView::mouseDoubleClickEvent(event); } diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 7343f1cefe..eec7834161 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2504,7 +2504,7 @@ void View3DInventorViewer::selectAll() std::vector objs; for (auto it : _ViewProviderSet) { - if (it->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) { + if (it->isDerivedFrom()) { auto vp = static_cast(it); // NOLINT App::DocumentObject* obj = vp->getObject(); diff --git a/src/Gui/ViewProviderAnnotation.cpp b/src/Gui/ViewProviderAnnotation.cpp index 94dbc9c2da..457036dae5 100644 --- a/src/Gui/ViewProviderAnnotation.cpp +++ b/src/Gui/ViewProviderAnnotation.cpp @@ -239,7 +239,7 @@ void ViewProviderAnnotation::attach(App::DocumentObject* f) void ViewProviderAnnotation::updateData(const App::Property* prop) { - if (prop->getTypeId() == App::PropertyStringList::getClassTypeId() && + if (prop->is() && strcmp(prop->getName(),"LabelText") == 0) { const std::vector lines = static_cast(prop)->getValues(); int index=0; @@ -261,7 +261,7 @@ void ViewProviderAnnotation::updateData(const App::Property* prop) index++; } } - else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() && + else if (prop->is() && strcmp(prop->getName(),"Position") == 0) { Base::Vector3d v = static_cast(prop)->getValue(); pTranslation->translation.setValue(v.x,v.y,v.z); @@ -324,7 +324,7 @@ void ViewProviderAnnotationLabel::onChanged(const App::Property* prop) prop == &FontName || prop == &Frame) { if (getObject()) { App::Property* label = getObject()->getPropertyByName("LabelText"); - if (label && label->getTypeId() == App::PropertyStringList::getClassTypeId()) + if (label && label->is()) drawImage(static_cast(label)->getValues()); } } @@ -380,16 +380,16 @@ void ViewProviderAnnotationLabel::attach(App::DocumentObject* f) void ViewProviderAnnotationLabel::updateData(const App::Property* prop) { - if (prop->getTypeId() == App::PropertyStringList::getClassTypeId() && + if (prop->is() && strcmp(prop->getName(),"LabelText") == 0) { drawImage(static_cast(prop)->getValues()); } - else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() && + else if (prop->is() && strcmp(prop->getName(),"BasePosition") == 0) { Base::Vector3d v = static_cast(prop)->getValue(); pBaseTranslation->translation.setValue(v.x,v.y,v.z); } - else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() && + else if (prop->is() && strcmp(prop->getName(),"TextPosition") == 0) { Base::Vector3d v = static_cast(prop)->getValue(); pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z)); @@ -427,7 +427,7 @@ void ViewProviderAnnotationLabel::dragMotionCallback(void *data, SoDragger *drag auto that = static_cast(data); const SbMatrix& mat = drag->getMotionMatrix(); App::DocumentObject* obj = that->getObject(); - if (obj && obj->getTypeId() == App::AnnotationLabel::getClassTypeId()) { + if (obj && obj->is()) { static_cast(obj)->TextPosition.setValue(mat[3][0],mat[3][1],mat[3][2]); } } diff --git a/src/Gui/ViewProviderDocumentObjectGroup.cpp b/src/Gui/ViewProviderDocumentObjectGroup.cpp index 84f9b02dee..0fcf0ad108 100644 --- a/src/Gui/ViewProviderDocumentObjectGroup.cpp +++ b/src/Gui/ViewProviderDocumentObjectGroup.cpp @@ -70,13 +70,13 @@ QIcon ViewProviderDocumentObjectGroup::getIcon() const void ViewProviderDocumentObjectGroup::getViewProviders(std::vector& vp) const { App::DocumentObject* doc = getObject(); - if (doc->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) { + if (doc->isDerivedFrom()) { Gui::Document* gd = Application::Instance->getDocument(doc->getDocument()); auto grp = static_cast(doc); std::vector obj = grp->getObjects(); for (const auto & it : obj) { ViewProvider* v = gd->getViewProvider(it); - if (v && v->getTypeId().isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) + if (v && v->isDerivedFrom()) vp.push_back(static_cast(v)); } } diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 234f67245f..d67c933efc 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -2620,7 +2620,7 @@ bool ViewProviderLink::initDraggingPlacement() { Base::PyGILStateLocker lock; try { auto* proxy = getPropertyByName("Proxy"); - if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) { + if (proxy && proxy->is()) { Py::Object feature = static_cast(proxy)->getValue(); const char *fname = "initDraggingPlacement"; if (feature.hasAttr(fname)) { @@ -2940,7 +2940,7 @@ bool ViewProviderLink::callDraggerProxy(const char *fname, bool update) { Base::PyGILStateLocker lock; try { auto* proxy = getPropertyByName("Proxy"); - if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) { + if (proxy && proxy->is()) { Py::Object feature = static_cast(proxy)->getValue(); if (feature.hasAttr(fname)) { Py::Callable method(feature.getAttr(fname)); diff --git a/src/Gui/ViewProviderMeasureDistance.cpp b/src/Gui/ViewProviderMeasureDistance.cpp index 4475005363..84766d4954 100644 --- a/src/Gui/ViewProviderMeasureDistance.cpp +++ b/src/Gui/ViewProviderMeasureDistance.cpp @@ -196,7 +196,7 @@ void ViewProviderMeasureDistance::attach(App::DocumentObject* pcObject) void ViewProviderMeasureDistance::updateData(const App::Property* prop) { - if (prop->getTypeId() == App::PropertyVector::getClassTypeId() || + if (prop->is() || prop == &Mirror || prop == &DistFactor) { if (strcmp(prop->getName(),"P1") == 0) { Base::Vector3d v = static_cast(prop)->getValue(); diff --git a/src/Gui/ViewProviderOriginFeature.cpp b/src/Gui/ViewProviderOriginFeature.cpp index 1693e8948c..6e360c06dd 100644 --- a/src/Gui/ViewProviderOriginFeature.cpp +++ b/src/Gui/ViewProviderOriginFeature.cpp @@ -100,7 +100,7 @@ void ViewProviderOriginFeature::attach(App::DocumentObject* pcObject) // Setup font size auto font = new SoFont (); float fontRatio = 10.0f; - if ( pcObject->getTypeId() == App::Line::getClassTypeId() ) { + if ( pcObject->is() ) { // keep font size on axes equal to font size on planes fontRatio *= ViewProviderOrigin::axesScaling; const char* axisName = pcObject->getNameInDocument(); diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index 81d5d3c8fd..5c26c5a977 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -236,7 +236,7 @@ void Workbench::setupCustomToolbars(ToolBarItem* root, const char* toolbar) cons } // for this workbench global toolbars are not allowed - if (getTypeId() == NoneWorkbench::getClassTypeId()) { + if (is()) { return; } diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 4e00b1dbda..9a530d1efd 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -746,7 +746,7 @@ PropertyStringItem::PropertyStringItem() = default; QVariant PropertyStringItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyString::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); std::string value = static_cast(prop)->getValue(); return {QString::fromUtf8(value.c_str())}; @@ -798,7 +798,7 @@ PropertyFontItem::PropertyFontItem() = default; QVariant PropertyFontItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFont::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); std::string value = static_cast(prop)->getValue(); return {QString::fromUtf8(value.c_str())}; @@ -861,7 +861,7 @@ PropertyIntegerItem::PropertyIntegerItem() = default; QVariant PropertyIntegerItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); int value = (int)static_cast(prop)->getValue(); return {value}; @@ -926,7 +926,7 @@ PropertyIntegerConstraintItem::PropertyIntegerConstraintItem() = default; QVariant PropertyIntegerConstraintItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyIntegerConstraint::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); int value = (int)static_cast(prop)->getValue(); return {value}; @@ -1018,7 +1018,7 @@ QVariant PropertyFloatItem::toString(const QVariant& prop) const QVariant PropertyFloatItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); double value = static_cast(prop)->getValue(); return {value}; @@ -1084,7 +1084,7 @@ QVariant PropertyUnitItem::toString(const QVariant& prop) const QVariant PropertyUnitItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); Base::Quantity value = static_cast(prop)->getQuantityValue(); return QVariant::fromValue(value); @@ -1187,7 +1187,7 @@ QVariant PropertyFloatConstraintItem::toString(const QVariant& prop) const QVariant PropertyFloatConstraintItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloatConstraint::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); double value = static_cast(prop)->getValue(); return {value}; @@ -1284,7 +1284,7 @@ PropertyBoolItem::PropertyBoolItem() = default; QVariant PropertyBoolItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyBool::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); bool value = static_cast(prop)->getValue(); return {value}; @@ -1391,7 +1391,7 @@ QVariant PropertyVectorItem::toString(const QVariant& prop) const QVariant PropertyVectorItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVector::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Vector3d& value = static_cast(prop)->getValue(); return QVariant::fromValue(value); @@ -1604,7 +1604,7 @@ QVariant PropertyVectorListItem::toString(const QVariant& prop) const QVariant PropertyVectorListItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVectorList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const std::vector& value = static_cast(prop)->getValue(); QList list; @@ -1685,7 +1685,7 @@ QVariant PropertyVectorDistanceItem::toString(const QVariant& prop) const QVariant PropertyVectorDistanceItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVector::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Vector3d& value = static_cast(prop)->getValue(); return QVariant::fromValue(value); @@ -1894,7 +1894,7 @@ QVariant PropertyMatrixItem::toString(const QVariant& prop) const QVariant PropertyMatrixItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMatrix::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Matrix4D& value = static_cast(prop)->getValue(); return QVariant::fromValue(value); @@ -1902,7 +1902,7 @@ QVariant PropertyMatrixItem::value(const App::Property* prop) const QVariant PropertyMatrixItem::toolTip(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMatrix::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Matrix4D& value = static_cast(prop)->getValue(); return {QString::fromStdString(value.analyse())}; @@ -2294,7 +2294,7 @@ void PropertyRotationItem::assignProperty(const App::Property* prop) // Choose an adaptive epsilon to avoid changing the axis when they are considered to // be equal. See https://forum.freecad.org/viewtopic.php?f=10&t=24662&start=10 double eps = std::pow(10.0, -2*(decimals()+1)); - if (prop->getTypeId().isDerivedFrom(App::PropertyRotation::getClassTypeId())) { + if (prop->isDerivedFrom()) { const Base::Rotation& value = static_cast(prop)->getValue(); h.assignProperty(value, eps); } @@ -2302,7 +2302,7 @@ void PropertyRotationItem::assignProperty(const App::Property* prop) QVariant PropertyRotationItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyRotation::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Rotation& value = static_cast(prop)->getValue(); double angle; @@ -2339,7 +2339,7 @@ QVariant PropertyRotationItem::value(const App::Property* prop) const QVariant PropertyRotationItem::toolTip(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyRotation::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Rotation& p = static_cast(prop)->getValue(); double angle; @@ -2586,7 +2586,7 @@ void PropertyPlacementItem::assignProperty(const App::Property* prop) // Choose an adaptive epsilon to avoid changing the axis when they are considered to // be equal. See https://forum.freecad.org/viewtopic.php?f=10&t=24662&start=10 double eps = std::pow(10.0, -2*(decimals()+1)); - if (prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) { + if (prop->isDerivedFrom()) { const Base::Placement& value = static_cast(prop)->getValue(); h.assignProperty(value.getRotation(), eps); } @@ -2594,7 +2594,7 @@ void PropertyPlacementItem::assignProperty(const App::Property* prop) QVariant PropertyPlacementItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Placement& value = static_cast(prop)->getValue(); double angle; @@ -2631,7 +2631,7 @@ QVariant PropertyPlacementItem::value(const App::Property* prop) const QVariant PropertyPlacementItem::toolTip(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const Base::Placement& p = static_cast(prop)->getValue(); double angle; @@ -2769,7 +2769,7 @@ QStringList PropertyEnumItem::getEnum() const { QStringList res; auto prop = getFirstProperty(); - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyEnumeration::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { const auto prop_enum = static_cast(prop); std::vector enums = prop_enum->getEnumVector(); for (const auto& it : enums) @@ -2780,7 +2780,7 @@ QStringList PropertyEnumItem::getEnum() const QVariant PropertyEnumItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyEnumeration::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const auto prop_enum = static_cast(prop); if(!prop_enum->isValid()) @@ -2857,7 +2857,7 @@ QWidget* PropertyEnumItem::createEditor(QWidget* parent, const QObject* receiver QStringList commonModes, modes; for (auto it = items.begin(); it != items.end(); ++it) { - if ((*it)->getTypeId() == App::PropertyEnumeration::getClassTypeId()) { + if ((*it)->is()) { auto prop = static_cast(*it); if (!prop->hasEnums()) { commonModes.clear(); @@ -3012,7 +3012,7 @@ QVariant PropertyStringListItem::toString(const QVariant& prop) const QVariant PropertyStringListItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyStringList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); QStringList list; const std::vector& value = (static_cast(prop))->getValues(); for (const auto & jt : value) { @@ -3088,7 +3088,7 @@ QVariant PropertyFloatListItem::toString(const QVariant& prop) const QVariant PropertyFloatListItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFloatList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); QStringList list; const std::vector& value = static_cast(prop)->getValues(); @@ -3161,7 +3161,7 @@ QVariant PropertyIntegerListItem::toString(const QVariant& prop) const QVariant PropertyIntegerListItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyIntegerList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); QStringList list; const std::vector& value = static_cast(prop)->getValues(); @@ -3216,7 +3216,7 @@ QVariant PropertyColorItem::toString(const QVariant& prop) const QVariant PropertyColorItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyColor::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); App::Color value = static_cast(prop)->getValue(); return QVariant(value.asValue()); @@ -3467,7 +3467,7 @@ QVariant PropertyMaterialItem::toString(const QVariant& prop) const QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const App::Material& value = static_cast(prop)->getValue(); auto dc = value.diffuseColor.asValue(); @@ -3496,7 +3496,7 @@ QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const QVariant PropertyMaterialItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterial::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const App::Material& value = static_cast(prop)->getValue(); Material mat; @@ -3888,7 +3888,7 @@ QVariant PropertyMaterialListItem::toString(const QVariant& prop) const QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterialList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const std::vector& values = static_cast(prop)->getValues(); if (values.empty()) @@ -3921,7 +3921,7 @@ QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const QVariant PropertyMaterialListItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyMaterialList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); const std::vector& value = static_cast(prop)->getValues(); QVariantList variantList; @@ -4054,7 +4054,7 @@ PropertyFileItem::PropertyFileItem() = default; QVariant PropertyFileItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFile::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); std::string value = static_cast(prop)->getValue(); return {QString::fromUtf8(value.c_str())}; @@ -4111,7 +4111,7 @@ PropertyPathItem::PropertyPathItem() = default; QVariant PropertyPathItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyPath::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); std::string value = static_cast(prop)->getValue().string(); return {QString::fromUtf8(value.c_str())}; @@ -4161,7 +4161,7 @@ PropertyTransientFileItem::PropertyTransientFileItem() = default; QVariant PropertyTransientFileItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyFileIncluded::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); std::string value = static_cast(prop)->getValue(); return {QString::fromUtf8(value.c_str())}; diff --git a/src/Mod/Drawing/App/FeatureClip.cpp b/src/Mod/Drawing/App/FeatureClip.cpp index df4515ad58..86ce1da8a9 100644 --- a/src/Mod/Drawing/App/FeatureClip.cpp +++ b/src/Mod/Drawing/App/FeatureClip.cpp @@ -117,7 +117,7 @@ App::DocumentObjectExecReturn* FeatureClip::execute(void) // get through the children and collect all the views const vector& Grp = Group.getValues(); for (vector::const_iterator It = Grp.begin(); It != Grp.end(); ++It) { - if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) { + if ((*It)->isDerivedFrom()) { Drawing::FeatureView* View = static_cast(*It); svg << View->ViewResult.getValue() << endl; } diff --git a/src/Mod/Drawing/App/FeaturePage.cpp b/src/Mod/Drawing/App/FeaturePage.cpp index 2ea63d9eaa..d4cc5473cd 100644 --- a/src/Mod/Drawing/App/FeaturePage.cpp +++ b/src/Mod/Drawing/App/FeaturePage.cpp @@ -181,22 +181,21 @@ App::DocumentObjectExecReturn* FeaturePage::execute(void) for (std::vector::const_iterator It = Grp.begin(); It != Grp.end(); ++It) { - if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) { + if ((*It)->isDerivedFrom()) { Drawing::FeatureView* View = static_cast(*It); if (View->Visible.getValue()) { ofile << View->ViewResult.getValue(); ofile << tempendl << tempendl << tempendl; } } - else if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId())) { + else if ((*It)->isDerivedFrom()) { Drawing::FeatureClip* Clip = static_cast(*It); if (Clip->Visible.getValue()) { ofile << Clip->ViewResult.getValue(); ofile << tempendl << tempendl << tempendl; } } - else if ((*It)->getTypeId().isDerivedFrom( - App::DocumentObjectGroup::getClassTypeId())) { + else if ((*It)->isDerivedFrom()) { // getting children inside subgroups too App::DocumentObjectGroup* SubGroup = static_cast(*It); @@ -204,8 +203,7 @@ App::DocumentObjectExecReturn* FeaturePage::execute(void) for (std::vector::const_iterator Grit = SubGrp.begin(); Grit != SubGrp.end(); ++Grit) { - if ((*Grit)->getTypeId().isDerivedFrom( - Drawing::FeatureView::getClassTypeId())) { + if ((*Grit)->isDerivedFrom()) { Drawing::FeatureView* SView = static_cast(*Grit); if (SView->Visible.getValue()) { ofile << SView->ViewResult.getValue(); diff --git a/src/Mod/Drawing/App/FeatureProjection.cpp b/src/Mod/Drawing/App/FeatureProjection.cpp index 39d7a6d3d5..22d18c9938 100644 --- a/src/Mod/Drawing/App/FeatureProjection.cpp +++ b/src/Mod/Drawing/App/FeatureProjection.cpp @@ -67,7 +67,7 @@ App::DocumentObjectExecReturn* FeatureProjection::execute(void) if (!link) { return new App::DocumentObjectExecReturn("No object linked"); } - if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!link->isDerivedFrom()) { return new App::DocumentObjectExecReturn("Linked object is not a Part object"); } const TopoDS_Shape& shape = static_cast(link)->Shape.getShape().getShape(); diff --git a/src/Mod/Drawing/App/FeatureViewPart.cpp b/src/Mod/Drawing/App/FeatureViewPart.cpp index 4bab836cdc..5724c1f529 100644 --- a/src/Mod/Drawing/App/FeatureViewPart.cpp +++ b/src/Mod/Drawing/App/FeatureViewPart.cpp @@ -87,7 +87,7 @@ App::DocumentObjectExecReturn* FeatureViewPart::execute(void) if (!link) { return new App::DocumentObjectExecReturn("No object linked"); } - if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!link->isDerivedFrom()) { return new App::DocumentObjectExecReturn("Linked object is not a Part object"); } TopoDS_Shape shape = static_cast(link)->Shape.getShape().getShape(); diff --git a/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp b/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp index 718d23adc1..024bc0889b 100644 --- a/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp +++ b/src/Mod/Drawing/App/FeatureViewSpreadsheet.cpp @@ -81,7 +81,7 @@ App::DocumentObjectExecReturn* FeatureViewSpreadsheet::execute(void) if (!link) { return new App::DocumentObjectExecReturn("No spreadsheet linked"); } - if (!link->getTypeId().isDerivedFrom(Spreadsheet::Sheet::getClassTypeId())) { + if (!link->isDerivedFrom()) { return new App::DocumentObjectExecReturn("The linked object is not a spreadsheet"); } if ((scellstart.empty()) || (scellend.empty())) { diff --git a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp index 894c08140c..0baeca6f95 100644 --- a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp +++ b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp @@ -146,7 +146,7 @@ private: if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) { App::DocumentObject* obj = static_cast(item)->getDocumentObjectPtr(); - if (obj->getTypeId().isDerivedFrom(Drawing::FeaturePage::getClassTypeId())) { + if (obj->isDerivedFrom()) { Base::FileInfo fi_out(EncodedName.c_str()); Base::ofstream str_out(fi_out, std::ios::out | std::ios::binary); if (!str_out) { @@ -176,16 +176,14 @@ private: for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom( - Drawing::FeatureViewPart::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { Drawing::FeatureViewPart* view = static_cast(*it); App::DocumentObject* link = view->Source.getValue(); if (!link) { throw Py::ValueError("No object linked"); } - if (!link->getTypeId().isDerivedFrom( - Part::Feature::getClassTypeId())) { + if (!link->isDerivedFrom()) { throw Py::TypeError("Linked object is not a Part object"); } TopoDS_Shape shape = diff --git a/src/Mod/Drawing/Gui/ViewProviderPage.cpp b/src/Mod/Drawing/Gui/ViewProviderPage.cpp index f8ddd3930e..04d1fd2951 100644 --- a/src/Mod/Drawing/Gui/ViewProviderPage.cpp +++ b/src/Mod/Drawing/Gui/ViewProviderPage.cpp @@ -104,7 +104,7 @@ void ViewProviderDrawingPage::hide(void) void ViewProviderDrawingPage::updateData(const App::Property* prop) { Gui::ViewProviderDocumentObjectGroup::updateData(prop); - if (prop->getTypeId() == App::PropertyFileIncluded::getClassTypeId()) { + if (prop->is()) { if (std::string(getPageObject()->PageResult.getValue()) != "") { if (view) { view->load(QString::fromUtf8(getPageObject()->PageResult.getValue())); diff --git a/src/Mod/Drawing/Gui/ViewProviderView.cpp b/src/Mod/Drawing/Gui/ViewProviderView.cpp index 6df5c0c8d4..445844e160 100644 --- a/src/Mod/Drawing/Gui/ViewProviderView.cpp +++ b/src/Mod/Drawing/Gui/ViewProviderView.cpp @@ -69,7 +69,7 @@ void ViewProviderDrawingView::show(void) if (!obj || obj->isRestoring()) { return; } - if (obj->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) { + if (obj->isDerivedFrom()) { // The 'Visible' property is marked as 'Output'. To update the drawing on recompute // the parent page object is touched. static_cast(obj)->Visible.setValue(true); @@ -88,7 +88,7 @@ void ViewProviderDrawingView::hide(void) if (!obj || obj->isRestoring()) { return; } - if (obj->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) { + if (obj->isDerivedFrom()) { // The 'Visible' property is marked as 'Output'. To update the drawing on recompute // the parent page object is touched. static_cast(obj)->Visible.setValue(false); @@ -172,7 +172,7 @@ void ViewProviderDrawingClip::show(void) if (!obj || obj->isRestoring()) { return; } - if (obj->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId())) { + if (obj->isDerivedFrom()) { // The 'Visible' property is marked as 'Output'. To update the drawing on recompute // the parent page object is touched. static_cast(obj)->Visible.setValue(true); @@ -191,7 +191,7 @@ void ViewProviderDrawingClip::hide(void) if (!obj || obj->isRestoring()) { return; } - if (obj->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId())) { + if (obj->isDerivedFrom()) { // The 'Visible' property is marked as 'Output'. To update the drawing on recompute // the parent page object is touched. static_cast(obj)->Visible.setValue(false); diff --git a/src/Mod/Fem/App/FemConstraint.cpp b/src/Mod/Fem/App/FemConstraint.cpp index 84f5fb3477..16a61d26fa 100644 --- a/src/Mod/Fem/App/FemConstraint.cpp +++ b/src/Mod/Fem/App/FemConstraint.cpp @@ -462,19 +462,19 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub& direct return Base::Vector3d(0, 0, 0); } - if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + if (obj->isDerivedFrom()) { Base::Vector3d vec(1.0, 0.0, 0.0); static_cast(obj)->Placement.getValue().multVec(vec, vec); return vec; } - if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + if (obj->isDerivedFrom()) { Base::Vector3d vec(0.0, 0.0, 1.0); static_cast(obj)->Placement.getValue().multVec(vec, vec); return vec; } - if (!obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!obj->isDerivedFrom()) { std::stringstream str; str << "Type is not a line, plane or Part object"; throw Base::TypeError(str.str()); diff --git a/src/Mod/Fem/App/FemPostPipelinePyImp.cpp b/src/Mod/Fem/App/FemPostPipelinePyImp.cpp index 485ee6e6ce..69e650e72e 100644 --- a/src/Mod/Fem/App/FemPostPipelinePyImp.cpp +++ b/src/Mod/Fem/App/FemPostPipelinePyImp.cpp @@ -71,7 +71,7 @@ PyObject* FemPostPipelinePy::load(PyObject* args) } App::DocumentObject* obj = static_cast(py)->getDocumentObjectPtr(); - if (!obj->getTypeId().isDerivedFrom(FemResultObject::getClassTypeId())) { + if (!obj->isDerivedFrom()) { PyErr_SetString(PyExc_TypeError, "object is not a result object"); return nullptr; } @@ -111,7 +111,7 @@ PyObject* FemPostPipelinePy::holdsPostObject(PyObject* args) } App::DocumentObject* obj = static_cast(py)->getDocumentObjectPtr(); - if (!obj->getTypeId().isDerivedFrom(FemPostObject::getClassTypeId())) { + if (!obj->isDerivedFrom()) { PyErr_SetString(PyExc_TypeError, "object is not a post-processing object"); return nullptr; } diff --git a/src/Mod/Fem/App/FemVTKTools.cpp b/src/Mod/Fem/App/FemVTKTools.cpp index 49ff9f0d39..e3d8432398 100644 --- a/src/Mod/Fem/App/FemVTKTools.cpp +++ b/src/Mod/Fem/App/FemVTKTools.cpp @@ -603,7 +603,7 @@ App::DocumentObject* getObjectByType(const Base::Type type) if (obj->getTypeId() == type) { return obj; } - if (obj->getTypeId() == FemAnalysis::getClassTypeId()) { + if (obj->is()) { std::vector fem = (static_cast(obj))->Group.getValues(); for (const auto& it : fem) { if (it->getTypeId().isDerivedFrom(type)) { @@ -624,7 +624,7 @@ App::DocumentObject* createObjectByType(const Base::Type type) } App::DocumentObject* obj = pcDoc->getActiveObject(); - if (obj->getTypeId() == FemAnalysis::getClassTypeId()) { + if (obj->is()) { App::DocumentObject* newobj = pcDoc->addObject(type.getName()); static_cast(obj)->addObject(newobj); return newobj; diff --git a/src/Mod/Fem/Gui/AppFemGuiPy.cpp b/src/Mod/Fem/Gui/AppFemGuiPy.cpp index 045f222064..04ee5bd2c3 100644 --- a/src/Mod/Fem/Gui/AppFemGuiPy.cpp +++ b/src/Mod/Fem/Gui/AppFemGuiPy.cpp @@ -87,7 +87,7 @@ private: && object) { App::DocumentObject* obj = static_cast(object)->getDocumentObjectPtr(); - if (!obj || !obj->getTypeId().isDerivedFrom(Fem::FemAnalysis::getClassTypeId())) { + if (!obj || !obj->isDerivedFrom()) { throw Py::Exception(Base::PyExc_FC_GeneralError, "Active Analysis object have to be of type Fem::FemAnalysis!"); } diff --git a/src/Mod/Fem/Gui/Command.cpp b/src/Mod/Fem/Gui/Command.cpp index d759b4cb05..8d423da5ba 100644 --- a/src/Mod/Fem/Gui/Command.cpp +++ b/src/Mod/Fem/Gui/Command.cpp @@ -1091,7 +1091,7 @@ void CmdFemDefineNodesSet::activated(int) if (it == docObj.begin()) { Gui::Document* doc = getActiveGuiDocument(); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); viewer->startSelection(Gui::View3DInventorViewer::Clip); diff --git a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp index 1cd9a2af14..22c8e6dec5 100644 --- a/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp +++ b/src/Mod/Fem/Gui/TaskCreateNodeSet.cpp @@ -91,7 +91,7 @@ void TaskCreateNodeSet::Poly() { Gui::Document* doc = Gui::Application::Instance->activeDocument(); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); viewer->startSelection(Gui::View3DInventorViewer::Clip); diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index 8caed56810..58fc8bc491 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -226,7 +226,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( if (pcAnalysis) { std::vector fem = pcAnalysis->Group.getValues(); for (auto it : fem) { - if (it->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) { + if (it->isDerivedFrom()) { pcMesh = static_cast(it); } } @@ -238,7 +238,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( } if (pcMesh) { App::Property* prop = pcMesh->getPropertyByName("Shape"); // PropertyLink - if (prop && prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { + if (prop && prop->isDerivedFrom()) { App::PropertyLink* pcLink = static_cast(prop); Part::Feature* pcPart = dynamic_cast(pcLink->getValue()); if (pcPart) { // deduct dimension from part_obj.Shape.ShapeType @@ -267,7 +267,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary( if (pcAnalysis) { std::vector fem = pcAnalysis->Group.getValues(); for (auto it : fem) { - if (it->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) { + if (it->isDerivedFrom()) { pcSolver = static_cast(it); } } diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 4695b8ee15..f19453608a 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -1332,8 +1332,7 @@ void TaskPostClip::collectImplicitFunctions() if (!pipelines.empty()) { Fem::FemPostPipeline* pipeline = pipelines.front(); if (pipeline->Functions.getValue() - && pipeline->Functions.getValue()->getTypeId() - == Fem::FemPostFunctionProvider::getClassTypeId()) { + && pipeline->Functions.getValue()->is()) { ui->FunctionBox->clear(); QStringList items; @@ -1383,8 +1382,7 @@ void TaskPostClip::onFunctionBoxCurrentIndexChanged(int idx) if (!pipelines.empty()) { Fem::FemPostPipeline* pipeline = pipelines.front(); if (pipeline->Functions.getValue() - && pipeline->Functions.getValue()->getTypeId() - == Fem::FemPostFunctionProvider::getClassTypeId()) { + && pipeline->Functions.getValue()->is()) { const std::vector& funcs = static_cast(pipeline->Functions.getValue()) @@ -1617,8 +1615,7 @@ void TaskPostCut::collectImplicitFunctions() if (!pipelines.empty()) { Fem::FemPostPipeline* pipeline = pipelines.front(); if (pipeline->Functions.getValue() - && pipeline->Functions.getValue()->getTypeId() - == Fem::FemPostFunctionProvider::getClassTypeId()) { + && pipeline->Functions.getValue()->is()) { ui->FunctionBox->clear(); QStringList items; @@ -1668,8 +1665,7 @@ void TaskPostCut::onFunctionBoxCurrentIndexChanged(int idx) if (!pipelines.empty()) { Fem::FemPostPipeline* pipeline = pipelines.front(); if (pipeline->Functions.getValue() - && pipeline->Functions.getValue()->getTypeId() - == Fem::FemPostFunctionProvider::getClassTypeId()) { + && pipeline->Functions.getValue()->is()) { const std::vector& funcs = static_cast(pipeline->Functions.getValue()) diff --git a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp index b1b9c051e2..6eff36df47 100644 --- a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp +++ b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp @@ -223,32 +223,32 @@ bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject* obj) const if (!obj) { return false; } - if (obj->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) { + if (obj->isDerivedFrom()) { return true; } - else if (obj->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) { + else if (obj->isDerivedFrom()) { return true; } - else if (obj->getTypeId().isDerivedFrom(Fem::FemResultObject::getClassTypeId())) { + else if (obj->isDerivedFrom()) { return true; } - else if (obj->getTypeId().isDerivedFrom(Fem::Constraint::getClassTypeId())) { + else if (obj->isDerivedFrom()) { return true; } - else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId())) { + else if (obj->isDerivedFrom()) { return true; } else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython"))) { return true; } - else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId())) { + else if (obj->isDerivedFrom()) { return true; } - else if (obj->getTypeId().isDerivedFrom(App::TextDocument::getClassTypeId())) { + else if (obj->isDerivedFrom()) { return true; } #ifdef FC_USE_VTK - else if (obj->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + else if (obj->isDerivedFrom()) { return true; } #endif diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp index 98046c3f77..d1e8b0711e 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp @@ -930,7 +930,7 @@ void ViewProviderFemPostObject::hide() App::DocumentObject* firstVisiblePostObject = nullptr; // step through the objects for (auto it : ObjectsList) { - if (it->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) { + if (it->isDerivedFrom()) { if (!firstVisiblePostObject && it->Visibility.getValue() && !it->isDerivedFrom(Fem::FemPostDataAtPointFilter::getClassTypeId())) { firstVisiblePostObject = it; diff --git a/src/Mod/Import/App/ExportOCAF.cpp b/src/Mod/Import/App/ExportOCAF.cpp index adf65a1176..6b73a08ff2 100644 --- a/src/Mod/Import/App/ExportOCAF.cpp +++ b/src/Mod/Import/App/ExportOCAF.cpp @@ -162,7 +162,7 @@ int ExportOCAF::exportObject(App::DocumentObject* obj, int root_id; int return_label = -1; - if (obj->getTypeId().isDerivedFrom(App::Part::getClassTypeId())) { + if (obj->isDerivedFrom()) { App::Part* part = static_cast(obj); // I shall recursively select the elements and call back std::vector entries = part->Group.getValues(); @@ -188,7 +188,7 @@ int ExportOCAF::exportObject(App::DocumentObject* obj, return_label = root_id; } - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { Part::Feature* part = static_cast(obj); std::vector colors; findColors(part, colors); diff --git a/src/Mod/Inspection/App/InspectionFeature.cpp b/src/Mod/Inspection/App/InspectionFeature.cpp index 46a77575a7..b1cbfda5a1 100644 --- a/src/Mod/Inspection/App/InspectionFeature.cpp +++ b/src/Mod/Inspection/App/InspectionFeature.cpp @@ -805,15 +805,15 @@ App::DocumentObjectExecReturn* Feature::execute() } InspectActualGeometry* actual = nullptr; - if (pcActual->getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { + if (pcActual->isDerivedFrom()) { Mesh::Feature* mesh = static_cast(pcActual); actual = new InspectActualMesh(mesh->Mesh.getValue()); } - else if (pcActual->getTypeId().isDerivedFrom(Points::Feature::getClassTypeId())) { + else if (pcActual->isDerivedFrom()) { Points::Feature* pts = static_cast(pcActual); actual = new InspectActualPoints(pts->Points.getValue()); } - else if (pcActual->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (pcActual->isDerivedFrom()) { useMultithreading = false; Part::Feature* part = static_cast(pcActual); actual = new InspectActualShape(part->Shape.getShape()); @@ -828,15 +828,15 @@ App::DocumentObjectExecReturn* Feature::execute() const std::vector& nominals = Nominals.getValues(); for (auto it : nominals) { InspectNominalGeometry* nominal = nullptr; - if (it->getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { + if (it->isDerivedFrom()) { Mesh::Feature* mesh = static_cast(it); nominal = new InspectNominalMesh(mesh->Mesh.getValue(), this->SearchRadius.getValue()); } - else if (it->getTypeId().isDerivedFrom(Points::Feature::getClassTypeId())) { + else if (it->isDerivedFrom()) { Points::Feature* pts = static_cast(it); nominal = new InspectNominalPoints(pts->Points.getValue(), this->SearchRadius.getValue()); } - else if (it->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (it->isDerivedFrom()) { useMultithreading = false; Part::Feature* part = static_cast(it); nominal = new InspectNominalShape(part->Shape.getValue(), this->SearchRadius.getValue()); diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index b5d363f6ff..bb02d337dc 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -247,8 +247,7 @@ bool ViewProviderInspection::setupPoints(const Data::ComplexGeoData* data, // If getPoints() doesn't deliver normals check a second property if (normals.empty() && container) { App::Property* propN = container->getPropertyByName("Normal"); - if (propN - && propN->getTypeId().isDerivedFrom(Points::PropertyNormalList::getClassTypeId())) { + if (propN && propN->isDerivedFrom()) { normals = static_cast(propN)->getValues(); } } @@ -327,7 +326,7 @@ void ViewProviderInspection::setupFaceIndexes(const std::vectorgetTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { + if (prop->isDerivedFrom()) { App::GeoFeature* object = static_cast(prop)->getValue(); const App::PropertyComplexGeoData* propData = @@ -343,7 +342,7 @@ void ViewProviderInspection::updateData(const App::Property* prop) } } } - else if (prop->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) { + else if (prop->is()) { // force an update of the Inventor data nodes if (this->pcObject) { App::Property* link = this->pcObject->getPropertyByName("Actual"); @@ -353,7 +352,7 @@ void ViewProviderInspection::updateData(const App::Property* prop) setDistances(); } } - else if (prop->getTypeId() == App::PropertyFloat::getClassTypeId()) { + else if (prop->is()) { if (strcmp(prop->getName(), "SearchRadius") == 0) { float fSearchRadius = ((App::PropertyFloat*)prop)->getValue(); this->search_radius = fSearchRadius; @@ -427,7 +426,7 @@ QIcon ViewProviderInspection::getIcon() const // Get the icon of the view provider to the associated feature QIcon px = inherited::getIcon(); App::Property* pActual = pcObject->getPropertyByName("Actual"); - if (pActual && pActual->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { + if (pActual && pActual->isDerivedFrom()) { App::DocumentObject* docobj = ((App::PropertyLink*)pActual)->getValue(); if (docobj) { Gui::Document* doc = Gui::Application::Instance->getDocument(docobj->getDocument()); @@ -572,7 +571,7 @@ void ViewProviderInspection::inspectCallback(void* ud, SoEventCallback* n) // check if we have picked one a node of the view provider we are insterested in Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath()); - if (vp && vp->getTypeId().isDerivedFrom(ViewProviderInspection::getClassTypeId())) { + if (vp && vp->isDerivedFrom()) { ViewProviderInspection* that = static_cast(vp); QString info = that->inspectDistance(point); Gui::getMainWindow()->setPaneText(1, info); @@ -594,9 +593,7 @@ void ViewProviderInspection::inspectCallback(void* ud, SoEventCallback* n) for (int i = 0; i < pps.getLength(); ++i) { const SoPickedPoint* point = pps[i]; vp = view->getViewProviderByPathFromTail(point->getPath()); - if (vp - && vp->getTypeId().isDerivedFrom( - ViewProviderInspection::getClassTypeId())) { + if (vp && vp->isDerivedFrom()) { ViewProviderInspection* self = static_cast(vp); QString info = self->inspectDistance(point); Gui::getMainWindow()->setPaneText(1, info); @@ -661,8 +658,7 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const // get the distances of the three points of the picked facet const SoFaceDetail* facedetail = static_cast(detail); App::Property* pDistance = this->pcObject->getPropertyByName("Distances"); - if (pDistance - && pDistance->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) { + if (pDistance && pDistance->is()) { Inspection::PropertyDistanceList* dist = static_cast(pDistance); int index1 = facedetail->getPoint(0)->getCoordinateIndex(); @@ -673,8 +669,7 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const float fVal3 = (*dist)[index3]; App::Property* pActual = this->pcObject->getPropertyByName("Actual"); - if (pActual - && pActual->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { + if (pActual && pActual->isDerivedFrom()) { float fSearchRadius = this->search_radius; if (fVal1 > fSearchRadius || fVal2 > fSearchRadius || fVal3 > fSearchRadius) { info = QObject::tr("Distance: > %1").arg(fSearchRadius); @@ -714,7 +709,7 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const // get the distance of the picked point int index = pointdetail->getCoordinateIndex(); App::Property* prop = this->pcObject->getPropertyByName("Distances"); - if (prop && prop->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) { + if (prop && prop->is()) { Inspection::PropertyDistanceList* dist = static_cast(prop); float fVal = (*dist)[index]; diff --git a/src/Mod/Mesh/App/FeatureMeshDefects.cpp b/src/Mod/Mesh/App/FeatureMeshDefects.cpp index 68a95abad0..fa00cd59cf 100644 --- a/src/Mod/Mesh/App/FeatureMeshDefects.cpp +++ b/src/Mod/Mesh/App/FeatureMeshDefects.cpp @@ -70,7 +70,7 @@ App::DocumentObjectExecReturn* HarmonizeNormals::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -94,7 +94,7 @@ App::DocumentObjectExecReturn* FlipNormals::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -118,7 +118,7 @@ App::DocumentObjectExecReturn* FixNonManifolds::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -142,7 +142,7 @@ App::DocumentObjectExecReturn* FixDuplicatedFaces::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -166,7 +166,7 @@ App::DocumentObjectExecReturn* FixDuplicatedPoints::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -190,7 +190,7 @@ App::DocumentObjectExecReturn* FixDegenerations::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -217,7 +217,7 @@ App::DocumentObjectExecReturn* FixDeformations::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -242,7 +242,7 @@ App::DocumentObjectExecReturn* FixIndices::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -270,7 +270,7 @@ App::DocumentObjectExecReturn* FillHoles::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); @@ -299,7 +299,7 @@ App::DocumentObjectExecReturn* RemoveComponents::execute() return new App::DocumentObjectExecReturn("No mesh linked"); } App::Property* prop = link->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::unique_ptr mesh(new MeshObject); *mesh = kernel->getValue(); diff --git a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp index 5df89ecef7..814bf51fd5 100644 --- a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp +++ b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp @@ -64,7 +64,7 @@ App::DocumentObjectExecReturn* SegmentByMesh::execute() App::DocumentObject* mesh = Source.getValue(); if (mesh) { App::Property* prop = mesh->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { kernel = static_cast(prop); } } @@ -79,7 +79,7 @@ App::DocumentObjectExecReturn* SegmentByMesh::execute() App::DocumentObject* tool = Tool.getValue(); if (tool) { App::Property* prop = tool->getPropertyByName("Mesh"); - if (prop && prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop && prop->is()) { toolmesh = static_cast(prop); } } diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index 6c3df65f05..1de8503d77 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -141,7 +141,7 @@ void MeshObject::getFacesFromSubElement(const Data::Segment* element, std::vector& /*pointNormals*/, std::vector& faces) const { - if (element && element->getTypeId() == MeshSegment::getClassTypeId()) { + if (element && element->is()) { const MeshSegment* segm = static_cast(element); if (segm->segment) { Base::Reference submesh( diff --git a/src/Mod/Mesh/Gui/Command.cpp b/src/Mod/Mesh/Gui/Command.cpp index 87a8d4f19b..b5a4dc3b96 100644 --- a/src/Mod/Mesh/Gui/Command.cpp +++ b/src/Mod/Mesh/Gui/Command.cpp @@ -483,15 +483,14 @@ void CmdMeshFromGeometry::activated(int) std::vector geo = Gui::Selection().getObjectsOfType(App::GeoFeature::getClassTypeId()); for (auto it : geo) { - if (!it->getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { + if (!it->isDerivedFrom()) { // exclude meshes std::map Map; it->getPropertyMap(Map); Mesh::MeshObject mesh; for (const auto& jt : Map) { if (jt.first == "Shape" - && jt.second->getTypeId().isDerivedFrom( - App::PropertyComplexGeoData::getClassTypeId())) { + && jt.second->isDerivedFrom()) { std::vector aPoints; std::vector aTopo; const Data::ComplexGeoData* data = @@ -675,7 +674,7 @@ void CmdMeshPolySegm::activated(int) if (it == docObj.begin()) { Gui::Document* doc = getActiveGuiDocument(); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); viewer->startSelection(Gui::View3DInventorViewer::Clip); @@ -732,7 +731,7 @@ void CmdMeshAddFacet::activated(int) for (auto it : docObj) { Gui::Document* doc = Gui::Application::Instance->getDocument(it->getDocument()); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { MeshGui::MeshFaceAddition* edit = new MeshGui::MeshFaceAddition(static_cast(view)); edit->startEditing(static_cast( @@ -783,7 +782,7 @@ void CmdMeshPolyCut::activated(int) if (it == docObj.begin()) { Gui::Document* doc = getActiveGuiDocument(); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); @@ -848,7 +847,7 @@ void CmdMeshPolyTrim::activated(int) if (it == docObj.begin()) { Gui::Document* doc = getActiveGuiDocument(); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); @@ -1001,7 +1000,7 @@ void CmdMeshPolySplit::activated(int) if (it == docObj.begin()) { Gui::Document* doc = getActiveGuiDocument(); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); viewer->startSelection(Gui::View3DInventorViewer::Clip); diff --git a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp index 24ef560230..89046e0d55 100644 --- a/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp +++ b/src/Mod/Mesh/Gui/DlgEvaluateMeshImp.cpp @@ -258,7 +258,7 @@ void DlgEvaluateMeshImp::changeEvent(QEvent* e) void DlgEvaluateMeshImp::slotCreatedObject(const App::DocumentObject& Obj) { // add new mesh object to the list - if (Obj.getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { + if (Obj.isDerivedFrom()) { QString label = QString::fromUtf8(Obj.Label.getValue()); QString name = QString::fromLatin1(Obj.getNameInDocument()); d->ui.meshNameButton->addItem(label, name); @@ -268,7 +268,7 @@ void DlgEvaluateMeshImp::slotCreatedObject(const App::DocumentObject& Obj) void DlgEvaluateMeshImp::slotDeletedObject(const App::DocumentObject& Obj) { // remove mesh objects from the list - if (Obj.getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { + if (Obj.isDerivedFrom()) { int index = d->ui.meshNameButton->findData(QString::fromLatin1(Obj.getNameInDocument())); if (index > 0) { d->ui.meshNameButton->removeItem(index); @@ -290,16 +290,15 @@ void DlgEvaluateMeshImp::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) { // if the current mesh object was modified update everything - if (&Obj == d->meshFeature && Prop.getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (&Obj == d->meshFeature && Prop.is()) { removeViewProviders(); cleanInformation(); showInformation(); d->self_intersections.clear(); } - else if (Obj.getTypeId().isDerivedFrom(Mesh::Feature::getClassTypeId())) { + else if (Obj.isDerivedFrom()) { // if the label has changed update the entry in the list - if (Prop.getTypeId() == App::PropertyString::getClassTypeId() - && strcmp(Prop.getName(), "Label") == 0) { + if (Prop.is() && strcmp(Prop.getName(), "Label") == 0) { QString label = QString::fromUtf8(Obj.Label.getValue()); QString name = QString::fromLatin1(Obj.getNameInDocument()); int index = d->ui.meshNameButton->findData(name); @@ -353,7 +352,7 @@ void DlgEvaluateMeshImp::addViewProvider(const char* name, if (d->view) { ViewProviderMeshDefects* vp = static_cast(Base::Type::createInstanceByName(name)); - assert(vp->getTypeId().isDerivedFrom(Gui::ViewProvider::getClassTypeId())); + assert(vp->isDerivedFrom()); vp->attach(d->meshFeature); d->view->getViewer()->addViewProvider(vp); vp->showDefects(indices); diff --git a/src/Mod/Mesh/Gui/MeshSelection.cpp b/src/Mod/Mesh/Gui/MeshSelection.cpp index ee54fc9eb6..2c34abd3a6 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.cpp +++ b/src/Mod/Mesh/Gui/MeshSelection.cpp @@ -162,7 +162,7 @@ Gui::View3DInventorViewer* MeshSelection::getViewer() const return nullptr; } Gui::MDIView* view = doc->getActiveView(); - if (view && view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view && view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer(); return viewer; } @@ -561,7 +561,7 @@ void MeshSelection::pickFaceCallback(void* ud, SoEventCallback* n) // By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is // really from the mesh we render and not from any other geometry Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath()); - if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId())) { + if (!vp || !vp->isDerivedFrom()) { return; } ViewProviderMesh* mesh = static_cast(vp); diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index e1759373f3..d24dc4cc7b 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -506,10 +506,10 @@ void ViewProviderMesh::updateData(const App::Property* prop) { Gui::ViewProviderGeometryObject::updateData(prop); - if (prop->getTypeId() == App::PropertyColorList::getClassTypeId()) { + if (prop->is()) { Coloring.setStatus(App::Property::Hidden, false); } - else if (prop->getTypeId() == Mesh::PropertyMaterial::getClassTypeId()) { + else if (prop->is()) { Coloring.setStatus(App::Property::Hidden, false); } } @@ -1708,7 +1708,7 @@ void ViewProviderMesh::faceInfoCallback(void* ud, SoEventCallback* n) // By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is // really from the mesh we render and not from any other geometry Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath()); - if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId())) { + if (!vp || !vp->isDerivedFrom()) { return; } @@ -1791,7 +1791,7 @@ void ViewProviderMesh::fillHoleCallback(void* ud, SoEventCallback* n) // By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is // really from the mesh we render and not from any other geometry Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath()); - if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId())) { + if (!vp || !vp->isDerivedFrom()) { return; } ViewProviderMesh* that = static_cast(vp); @@ -1868,7 +1868,7 @@ void ViewProviderMesh::markPartCallback(void* ud, SoEventCallback* n) // By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is // really from the mesh we render and not from any other geometry Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath()); - if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId())) { + if (!vp || !vp->isDerivedFrom()) { return; } ViewProviderMesh* that = static_cast(vp); @@ -2501,7 +2501,7 @@ void ViewProviderIndexedFaceSet::attach(App::DocumentObject* pcFeat) void ViewProviderIndexedFaceSet::updateData(const App::Property* prop) { ViewProviderMesh::updateData(prop); - if (prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop->is()) { ViewProviderMeshBuilder builder; builder.createMesh(prop, pcMeshCoord, pcMeshFaces); showOpenEdges(OpenEdges.getValue()); @@ -2592,7 +2592,7 @@ void ViewProviderMeshObject::attach(App::DocumentObject* pcFeat) void ViewProviderMeshObject::updateData(const App::Property* prop) { ViewProviderMesh::updateData(prop); - if (prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop->is()) { const Mesh::PropertyMeshKernel* mesh = static_cast(prop); this->pcMeshNode->mesh.setValue( Base::Reference(mesh->getValuePtr())); diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp index 6e1f35104d..ec0a778f1a 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp @@ -289,7 +289,7 @@ void ViewProviderMeshCurvature::attach(App::DocumentObject* pcFeat) void ViewProviderMeshCurvature::updateData(const App::Property* prop) { // set to the expected size - if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) { + if (prop->isDerivedFrom()) { Mesh::Feature* object = static_cast(prop)->getValue(); Gui::coinRemoveAllChildren(this->pcLinkRoot); @@ -309,7 +309,7 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop) ViewProviderMesh::updateTransform(p, pcTransform); } } - else if (prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) { + else if (prop->is()) { const Mesh::PropertyCurvatureList* curv = static_cast(prop); if (curv->getSize() < 3) { // invalid array @@ -545,8 +545,7 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void* ud, SoEventCallback* // By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is // really from the mesh we render and not from any other geometry Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath()); - if (!vp - || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId())) { + if (!vp || !vp->isDerivedFrom()) { return; } ViewProviderMeshCurvature* self = static_cast(vp); @@ -582,7 +581,7 @@ void ViewProviderMeshCurvature::curvatureInfoCallback(void* ud, SoEventCallback* // By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is // really from the mesh we render and not from any other geometry Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(point->getPath()); - if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMeshCurvature::getClassTypeId())) { + if (!vp || !vp->isDerivedFrom()) { return; } ViewProviderMeshCurvature* that = static_cast(vp); @@ -605,7 +604,7 @@ ViewProviderMeshCurvature::curvatureInfo(bool detail, int index1, int index2, in // get the curvature info of the three points of the picked facet App::Property* prop = pcObject->getPropertyByName("CurvInfo"); std::stringstream str; - if (prop && prop->getTypeId() == Mesh::PropertyCurvatureList::getClassTypeId()) { + if (prop && prop->is()) { Mesh::PropertyCurvatureList* curv = static_cast(prop); const Mesh::CurvatureInfo& cVal1 = (*curv)[index1]; const Mesh::CurvatureInfo& cVal2 = (*curv)[index2]; diff --git a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp index 7ddb233844..49a95431be 100644 --- a/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderMeshFaceSet.cpp @@ -100,7 +100,7 @@ void ViewProviderMeshFaceSet::attach(App::DocumentObject* pcFeat) void ViewProviderMeshFaceSet::updateData(const App::Property* prop) { ViewProviderMesh::updateData(prop); - if (prop->getTypeId() == Mesh::PropertyMeshKernel::getClassTypeId()) { + if (prop->is()) { const Mesh::MeshObject* mesh = static_cast(prop)->getValuePtr(); diff --git a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp index f4b9e194a3..7ae0b1c3b4 100644 --- a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp +++ b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp @@ -609,9 +609,7 @@ void CurveOnMeshHandler::Private::vertexCallback(void* ud, SoEventCallback* cb) CurveOnMeshHandler* self = static_cast(ud); if (!self->d_ptr->wireClosed) { Gui::ViewProvider* vp = view->getViewProviderByPathFromTail(pp->getPath()); - if (vp - && vp->getTypeId().isDerivedFrom( - MeshGui::ViewProviderMesh::getClassTypeId())) { + if (vp && vp->isDerivedFrom()) { MeshGui::ViewProviderMesh* mesh = static_cast(vp); const SoDetail* detail = pp->getDetail(); @@ -653,9 +651,7 @@ void CurveOnMeshHandler::Private::vertexCallback(void* ud, SoEventCallback* cb) } } // try to 'complete' the curve - else if (vp - && vp->getTypeId().isDerivedFrom( - ViewProviderCurveOnMesh::getClassTypeId())) { + else if (vp && vp->isDerivedFrom()) { const SbVec3f& p = pp->getPoint(); if (self->tryCloseWire(p)) { self->closeWire(); diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index d4ae32a2b8..6e219af4e9 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 diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index b2b38323ce..0e41160ca7 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -189,7 +189,7 @@ bool Body::isMemberOfMultiTransform(const App::DocumentObject* obj) // to auto set it when the originals are not null. See: // App::DocumentObjectExecReturn *Transformed::execute(void) // - return (obj->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) && + return (obj->isDerivedFrom() && static_cast(obj)->Originals.getValues().empty()); } @@ -198,7 +198,7 @@ bool Body::isSolidFeature(const App::DocumentObject *obj) if (!obj) return false; - if (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) && + if (obj->isDerivedFrom() && !PartDesign::Feature::isDatum(obj)) { // Transformed Features inside a MultiTransform are not solid features return !isMemberOfMultiTransform(obj); @@ -212,15 +212,15 @@ bool Body::isAllowed(const App::DocumentObject *obj) return false; // TODO: Should we introduce a PartDesign::FeaturePython class? This should then also return true for isSolidFeature() - return (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) || - obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) || + return (obj->isDerivedFrom() || + obj->isDerivedFrom() || // TODO Shouldn't we replace it with Sketcher::SketchObject? (2015-08-13, Fat-Zer) - obj->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()) || - obj->getTypeId().isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) || - obj->getTypeId().isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId()) + obj->isDerivedFrom() || + obj->isDerivedFrom() || + obj->isDerivedFrom() // TODO Why this lines was here? why should we allow anything of those? (2015-08-13, Fat-Zer) - //obj->getTypeId().isDerivedFrom(Part::FeaturePython::getClassTypeId()) // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython... - //obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()) + //obj->isDerivedFrom() // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython... + //obj->isDerivedFrom() ); } diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 2c52f40578..681da9f60f 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -116,7 +116,7 @@ Part::Feature* Feature::getBaseObject(bool silent) const { const char *err = nullptr; if (BaseLink) { - if (BaseLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (BaseLink->isDerivedFrom()) { BaseObject = static_cast(BaseLink); } if (!BaseObject) { @@ -191,8 +191,8 @@ PyObject* Feature::getPyObject() bool Feature::isDatum(const App::DocumentObject* feature) { - return feature->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) || - feature->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()); + return feature->isDerivedFrom() || + feature->isDerivedFrom(); } gp_Pln Feature::makePlnFromPlane(const App::DocumentObject* obj) diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index 143aac8209..821e37689b 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -125,11 +125,11 @@ App::DocumentObjectExecReturn *Draft::execute() gp_Dir pullDirection; App::DocumentObject* refDirection = PullDirection.getValue(); if (refDirection) { - if (refDirection->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + if (refDirection->isDerivedFrom()) { PartDesign::Line* line = static_cast(refDirection); Base::Vector3d d = line->getDirection(); pullDirection = gp_Dir(d.x, d.y, d.z); - } else if (refDirection->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refDirection->isDerivedFrom()) { std::vector subStrings = PullDirection.getSubValues(); if (subStrings.empty() || subStrings[0].empty()) throw Base::ValueError("No pull direction reference specified"); @@ -209,14 +209,14 @@ App::DocumentObjectExecReturn *Draft::execute() if (!found) throw Base::RuntimeError("No neutral plane specified and none can be guessed"); } else { - if (refPlane->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + if (refPlane->isDerivedFrom()) { PartDesign::Plane* plane = static_cast(refPlane); Base::Vector3d b = plane->getBasePoint(); Base::Vector3d n = plane->getNormal(); neutralPlane = gp_Pln(gp_Pnt(b.x, b.y, b.z), gp_Dir(n.x, n.y, n.z)); - } else if (refPlane->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + } else if (refPlane->isDerivedFrom()) { neutralPlane = Feature::makePlnFromPlane(refPlane); - } else if (refPlane->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refPlane->isDerivedFrom()) { std::vector subStrings = NeutralPlane.getSubValues(); if (subStrings.empty() || subStrings[0].empty()) throw Base::ValueError("No neutral plane reference specified"); diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index 5d8bd8a21e..c77e5c67d8 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -66,7 +66,7 @@ short DressUp::mustExecute() const void DressUp::positionByBaseFeature() { Part::Feature *base = static_cast(BaseFeature.getValue()); - if (base && base->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (base && base->isDerivedFrom()) this->Placement.setValue(base->Placement.getValue()); } diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index d34233ef42..256ea7d29b 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -110,7 +110,7 @@ const std::list LinearPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (refObject->isDerivedFrom()) { Part::Part2DObject* refSketch = static_cast(refObject); Base::Axis axis; if (subStrings[0] == "H_Axis") { @@ -151,21 +151,21 @@ const std::list LinearPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Plane* plane = static_cast(refObject); Base::Vector3d d = plane->getNormal(); dir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Line* line = static_cast(refObject); Base::Vector3d d = line->getDirection(); dir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { App::Line* line = static_cast(refObject); Base::Rotation rot = line->Placement.getValue().getRotation(); Base::Vector3d d(1,0,0); rot.multVec(d, d); dir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { if (subStrings[0].empty()) throw Base::ValueError("No direction reference specified"); Part::Feature* refFeature = static_cast(refObject); diff --git a/src/Mod/PartDesign/App/FeatureMirrored.cpp b/src/Mod/PartDesign/App/FeatureMirrored.cpp index 0379b1d36c..90ace67654 100644 --- a/src/Mod/PartDesign/App/FeatureMirrored.cpp +++ b/src/Mod/PartDesign/App/FeatureMirrored.cpp @@ -68,7 +68,7 @@ const std::list Mirrored::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (refObject->isDerivedFrom()) { Part::Part2DObject* refSketch = static_cast(refObject); Base::Axis axis; if (subStrings[0] == "H_Axis") @@ -88,13 +88,13 @@ const std::list Mirrored::getTransformations(const std::vectorPlacement.getValue(); axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); - } else if (refObject->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Plane* plane = static_cast(refObject); Base::Vector3d base = plane->getBasePoint(); axbase = gp_Pnt(base.x, base.y, base.z); Base::Vector3d dir = plane->getNormal(); axdir = gp_Dir(dir.x, dir.y, dir.z); - } else if (refObject->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { App::Plane* plane = static_cast(refObject); Base::Vector3d base = plane->Placement.getValue().getPosition(); axbase = gp_Pnt(base.x, base.y, base.z); @@ -102,7 +102,7 @@ const std::list Mirrored::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { if (subStrings[0].empty()) throw Base::ValueError("No direction reference specified"); Part::TopoShape baseShape = static_cast(refObject)->Shape.getShape(); diff --git a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp index be59aba392..b4ac76d554 100644 --- a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp +++ b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp @@ -51,7 +51,7 @@ void MultiTransform::positionBySupport() PartDesign::Transformed::positionBySupport(); std::vector transFeatures = Transformations.getValues(); for (auto f : transFeatures) { - if (!(f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) + if (!(f->isDerivedFrom())) throw Base::TypeError("Transformation features must be subclasses of Transformed"); PartDesign::Transformed* transFeature = static_cast(f); transFeature->Placement.setValue(this->Placement.getValue()); @@ -80,7 +80,7 @@ const std::list MultiTransform::getTransformations(const std::vector(originals.front()); TopoDS_Shape original; - if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + if (originalFeature->isDerivedFrom()) { PartDesign::FeatureAddSub* addFeature = static_cast(originalFeature); //if (addFeature->getAddSubType() == FeatureAddSub::Additive) // original = addFeature->AddSubShape.getShape().getShape(); @@ -97,7 +97,7 @@ const std::list MultiTransform::getTransformations(const std::vector::const_iterator f; for (f = transFeatures.begin(); f != transFeatures.end(); ++f) { - if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) + if (!((*f)->isDerivedFrom())) throw Base::TypeError("Transformation features must be subclasses of Transformed"); PartDesign::Transformed* transFeature = static_cast(*f); std::list newTransformations = transFeature->getTransformations(originals); @@ -116,7 +116,7 @@ const std::list MultiTransform::getTransformations(const std::vector oldCogs; cogs.swap(oldCogs); // empty cogs to receive new cogs - if ((*f)->getTypeId() == PartDesign::Scaled::getClassTypeId()) { + if ((*f)->is()) { // Diagonal method // Multiply every element in the old transformations' slices with the corresponding // element in the newTransformations. Example: diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index 00e833f7b8..032fca9dfe 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -173,7 +173,7 @@ App::DocumentObjectExecReturn *Pipe::execute() // build the paths App::DocumentObject* spine = Spine.getValue(); - if (!(spine && spine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) + if (!(spine && spine->isDerivedFrom())) return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No spine linked")); std::vector subedge = Spine.getSubValues(); @@ -186,7 +186,7 @@ App::DocumentObjectExecReturn *Pipe::execute() TopoDS_Shape auxpath; if (Mode.getValue() == 3) { App::DocumentObject* auxspine = AuxillerySpine.getValue(); - if (!(auxspine && auxspine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) + if (!(auxspine && auxspine->isDerivedFrom())) return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No auxiliary spine linked.")); std::vector auxsubedge = AuxillerySpine.getSubValues(); diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp index c8436fc896..26df30d606 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp @@ -104,7 +104,7 @@ const std::list PolarPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (refObject->isDerivedFrom()) { Part::Part2DObject* refSketch = static_cast(refObject); Base::Axis axis; if (subStrings[0] == "H_Axis") @@ -121,19 +121,19 @@ const std::list PolarPattern::getTransformations(const std::vectorPlacement.getValue(); axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); - } else if (refObject->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Line* line = static_cast(refObject); Base::Vector3d base = line->getBasePoint(); axbase = gp_Pnt(base.x, base.y, base.z); Base::Vector3d dir = line->getDirection(); axdir = gp_Dir(dir.x, dir.y, dir.z); - } else if (refObject->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { App::Line* line = static_cast(refObject); Base::Rotation rot = line->Placement.getValue().getRotation(); Base::Vector3d d(1,0,0); rot.multVec(d, d); axdir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { if (subStrings[0].empty()) throw Base::ValueError("No axis reference specified"); Part::Feature* refFeature = static_cast(refObject); diff --git a/src/Mod/PartDesign/App/FeatureScaled.cpp b/src/Mod/PartDesign/App/FeatureScaled.cpp index dddef82df3..7cc1717e89 100644 --- a/src/Mod/PartDesign/App/FeatureScaled.cpp +++ b/src/Mod/PartDesign/App/FeatureScaled.cpp @@ -69,7 +69,7 @@ const std::list Scaled::getTransformations(const std::vector(originals.front()); TopoDS_Shape original; - if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + if (originalFeature->isDerivedFrom()) { PartDesign::FeatureAddSub* Feature = static_cast(originalFeature); //if(Feature->getAddSubType() == FeatureAddSub::Additive) // original = Feature->AddSubShape.getShape().getShape(); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 5df0ebe35e..f42506297a 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -130,7 +130,7 @@ Part::Part2DObject* ProfileBased::getVerifiedSketch(bool silent) const { err = "No profile linked at all"; } else { - if (!result->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (!result->isDerivedFrom()) { err = "Linked object is not a Sketch or Part2DObject"; result = nullptr; } @@ -152,7 +152,7 @@ Part::Feature* ProfileBased::getVerifiedObject(bool silent) const { err = "No object linked"; } else { - if (!result->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!result->isDerivedFrom()) err = "Linked object is not a Sketch, Part2DObject or Feature"; } @@ -213,12 +213,12 @@ TopoDS_Shape ProfileBased::getVerifiedFace(bool silent) const { } } else { - if (result->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (result->isDerivedFrom()) { auto wires = getProfileWires(); return Part::FaceMakerCheese::makeFace(wires); } - else if (result->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (result->isDerivedFrom()) { if (Profile.getSubValues().empty()) err = "Linked object has no subshape specified"; else { @@ -424,17 +424,17 @@ void ProfileBased::getFaceFromLinkSub(TopoDS_Face& upToFace, const App::Property if (!ref) throw Base::ValueError("SketchBased: No face selected"); - if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + if (ref->isDerivedFrom()) { upToFace = TopoDS::Face(makeShapeFromPlane(ref)); return; } - else if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + else if (ref->isDerivedFrom()) { Part::Datum* datum = static_cast(ref); upToFace = TopoDS::Face(datum->getShape()); return; } - if (!ref->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!ref->isDerivedFrom()) throw Base::TypeError("SketchBased: Must be face of a feature"); Part::TopoShape baseShape = static_cast(ref)->Shape.getShape(); @@ -1008,7 +1008,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st App::DocumentObject* profile = Profile.getValue(); gp_Pln sketchplane; - if (profile->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (profile->isDerivedFrom()) { Part::Part2DObject* sketch = getVerifiedSketch(); Base::Placement SketchPlm = sketch->Placement.getValue(); Base::Vector3d SketchVector = Base::Vector3d(0, 0, 1); @@ -1048,7 +1048,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st } } - else if (profile->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (profile->isDerivedFrom()) { Base::Placement SketchPlm = getVerifiedObject()->Placement.getValue(); Base::Vector3d SketchVector = getProfileNormal(); Base::Vector3d SketchPos = SketchPlm.getPosition(); @@ -1056,7 +1056,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st } // get reference axis - if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + if (pcReferenceAxis->isDerivedFrom()) { const PartDesign::Line* line = static_cast(pcReferenceAxis); base = line->getBasePoint(); dir = line->getDirection(); @@ -1065,7 +1065,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st return; } - if (pcReferenceAxis->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + if (pcReferenceAxis->isDerivedFrom()) { const App::Line* line = static_cast(pcReferenceAxis); base = Base::Vector3d(0, 0, 0); line->Placement.getValue().multVec(Base::Vector3d(1, 0, 0), dir); @@ -1074,7 +1074,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st return; } - if (pcReferenceAxis->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (pcReferenceAxis->isDerivedFrom()) { if (subReferenceAxis.empty()) throw Base::ValueError("No rotation axis reference specified"); const Part::Feature* refFeature = static_cast(pcReferenceAxis); diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index fb97ef0732..3e0788dae7 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -107,23 +107,23 @@ Part::Feature* Transformed::getBaseObject(bool silent) const { App::DocumentObject* Transformed::getSketchObject() const { std::vector originals = Originals.getValues(); - if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (!originals.empty() && originals.front()->isDerivedFrom()) { return (static_cast(originals.front()))->getVerifiedSketch(true); } - else if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + else if (!originals.empty() && originals.front()->isDerivedFrom()) { return nullptr; } - else if (this->getTypeId().isDerivedFrom(LinearPattern::getClassTypeId())) { + else if (this->isDerivedFrom()) { // if Originals is empty then try the linear pattern's Direction property const LinearPattern* pattern = static_cast(this); return pattern->Direction.getValue(); } - else if (this->getTypeId().isDerivedFrom(PolarPattern::getClassTypeId())) { + else if (this->isDerivedFrom()) { // if Originals is empty then try the polar pattern's Axis property const PolarPattern* pattern = static_cast(this); return pattern->Axis.getValue(); } - else if (this->getTypeId().isDerivedFrom(Mirrored::getClassTypeId())) { + else if (this->isDerivedFrom()) { // if Originals is empty then try the mirror pattern's MirrorPlane property const Mirrored* pattern = static_cast(this); return pattern->MirrorPlane.getValue(); @@ -143,7 +143,7 @@ void Transformed::handleChangedPropertyType(Base::XMLReader &reader, const char // The property 'Angle' of PolarPattern has changed from PropertyFloat // to PropertyAngle and the property 'Length' has changed to PropertyLength. 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. @@ -254,7 +254,7 @@ App::DocumentObjectExecReturn *Transformed::execute() Part::TopoShape fuseShape; Part::TopoShape cutShape; - if (original->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + if (original->isDerivedFrom()) { PartDesign::FeatureAddSub* feature = static_cast(original); feature->getAddSubShape(fuseShape, cutShape); if (fuseShape.isNull() && cutShape.isNull()) diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index b7e2325cc3..1339f3650b 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -151,7 +151,7 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, //we only allow one part feature, so get the first one we find size_t index = 0; for (auto* it : objs) { - if (it && it->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (it && it->isDerivedFrom()) { obj = static_cast(it); break; } @@ -182,11 +182,11 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, else { // search for Origin features for (auto* it : objs) { - if (it && it->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + if (it && it->isDerivedFrom()) { obj = static_cast(it); break; } - else if (it && it->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + else if (it && it->isDerivedFrom()) { obj = static_cast(it); break; } @@ -199,7 +199,7 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std: if (!obj) return TopoDS_Shape(); - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { Part::Feature* part = static_cast(obj); if (subs.empty()) return part->Shape.getValue(); @@ -224,14 +224,14 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std: return cmp; } } - else if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + else if (obj->isDerivedFrom()) { gp_Lin line; BRepBuilderAPI_MakeEdge mkEdge(line); Part::TopoShape shape(mkEdge.Shape()); shape.setPlacement(obj->Placement.getValue()); return shape; } - else if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + else if (obj->isDerivedFrom()) { gp_Pln plane; BRepBuilderAPI_MakeFace mkFace(plane); Part::TopoShape shape(mkFace.Shape()); @@ -273,7 +273,7 @@ void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::P return; if (!TraceSupport.getValue()) return; - if (!Prop.getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) + if (!Prop.isDerivedFrom()) return; App::GeoFeature* obj = nullptr; diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 2bef4dddeb..f79aa94a09 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -617,9 +617,9 @@ unsigned validateSketches(std::vector& sketches, std::vector::iterator o = inList.begin(); while (o != inList.end()) { //Base::Console().Error("Inlist: %s\n", (*o)->getNameInDocument()); - if ((*o)->getTypeId().isDerivedFrom(PartDesign::Body::getClassTypeId())) + if ((*o)->isDerivedFrom()) o = inList.erase(o); //ignore bodies - else if (!( (*o)->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) )) + else if (!( (*o)->isDerivedFrom() )) o = inList.erase(o); //ignore non-partDesign else ++o; @@ -2244,7 +2244,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg) if (!features.empty()) { // Throw out MultiTransform features, we don't want to nest them for (std::vector::iterator f = features.begin(); f != features.end(); ) { - if ((*f)->getTypeId().isDerivedFrom(PartDesign::MultiTransform::getClassTypeId())) + if ((*f)->isDerivedFrom()) f = features.erase(f); else f++; diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index 65014d6960..e5f49d5bad 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -231,7 +231,7 @@ void CmdPartDesignBody::activated(int iMsg) if (body) { std::vector links = body->Group.getValues(); for (auto it : links) { - if (it->getTypeId().isDerivedFrom(PartDesign::FeatureBase::getClassTypeId())) { + if (it->isDerivedFrom()) { PartDesign::FeatureBase* base = static_cast(it); if (base && base->BaseFeature.getValue() == baseFeature) { Gui::Application::Instance->hideViewProvider(baseFeature); @@ -797,7 +797,7 @@ void CmdPartDesignMoveFeature::activated(int iMsg) } // Fix sketch support - if (feat->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) { + if (feat->isDerivedFrom()) { Sketcher::SketchObject *sketch = static_cast(feat); try { PartDesignGui::fixSketchSupport(sketch); diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index cc821b1ff3..a36d29d056 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -68,11 +68,11 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c } // Enable selection from origin of current part/ - if (pObj->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (pObj->isDerivedFrom()) { return allowOrigin(body, originGroup, pObj); } - if (pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (pObj->isDerivedFrom()) { return allowDatum(body, pObj); } @@ -90,11 +90,11 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c return type.testFlag(AllowSelection::WHOLE); // resolve links if needed - if (!pObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!pObj->isDerivedFrom()) { pObj = Part::Feature::getShapeOwner(pObj, sSubName); } - if (pObj && pObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (pObj && pObj->isDerivedFrom()) { return allowPartFeature(pObj, sSubName); } @@ -138,10 +138,10 @@ App::OriginGroupExtension* ReferenceSelection::getOriginGroupExtension(PartDesig bool ReferenceSelection::allowOrigin(PartDesign::Body *body, App::OriginGroupExtension* originGroup, App::DocumentObject* pObj) const { bool fits = false; - if (type.testFlag(AllowSelection::FACE) && pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + if (type.testFlag(AllowSelection::FACE) && pObj->isDerivedFrom()) { fits = true; } - else if (type.testFlag(AllowSelection::EDGE) && pObj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + else if (type.testFlag(AllowSelection::EDGE) && pObj->isDerivedFrom()) { fits = true; } @@ -173,11 +173,11 @@ bool ReferenceSelection::allowDatum(PartDesign::Body *body, App::DocumentObject* return false; } - if (type.testFlag(AllowSelection::FACE) && (pObj->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId()))) + if (type.testFlag(AllowSelection::FACE) && (pObj->isDerivedFrom())) return true; - if (type.testFlag(AllowSelection::EDGE) && (pObj->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId()))) + if (type.testFlag(AllowSelection::EDGE) && (pObj->isDerivedFrom())) return true; - if (type.testFlag(AllowSelection::POINT) && (pObj->getTypeId().isDerivedFrom(PartDesign::Point::getClassTypeId()))) + if (type.testFlag(AllowSelection::POINT) && (pObj->isDerivedFrom())) return true; return false; diff --git a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp index 07c7774828..7bfc3a2150 100644 --- a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp @@ -111,7 +111,7 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg) return; // if the selected object is not a body then get the body it is part of - if (!pcBody->getTypeId().isDerivedFrom(PartDesign::Body::getClassTypeId())) { + if (!pcBody->isDerivedFrom()) { pcBody = PartDesign::Body::findBodyOf(pcBody); if (!pcBody) return; diff --git a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp index 986d52c84c..3179cf20b7 100644 --- a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp @@ -100,7 +100,7 @@ bool TaskDlgFeatureParameters::accept() { } // Make sure the feature is what we are expecting // Should be fine but you never know... - if ( !feature->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) { + if ( !feature->isDerivedFrom() ) { throw Base::TypeError("Bad object processed in the feature dialog."); } diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index d5c0649120..d6d2a8da7c 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -263,7 +263,7 @@ std::vector TaskFeaturePick::buildFeatures() else if (status == notInBody) { activeBody->addObject(copy); // doesn't supposed to get here anything but sketch but to be on the safe side better to check - if (copy->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) { + if (copy->isDerivedFrom()) { Sketcher::SketchObject *sketch = static_cast(copy); PartDesignGui::fixSketchSupport(sketch); } @@ -325,10 +325,10 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st //independent copies don't have links and are not attached if(independent && ( - prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId()) || - prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId()) || - prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId()) || - prop->getTypeId().isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())|| + prop->isDerivedFrom() || + prop->isDerivedFrom() || + prop->isDerivedFrom() || + prop->isDerivedFrom()|| ( prop->getGroup() && strcmp(prop->getGroup(),"Attachment")==0) )) { ++it; @@ -378,13 +378,13 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st long int mode = mmDeactivated; Part::Datum *datumCopy = static_cast(copy); - if(obj->getTypeId() == PartDesign::Point::getClassTypeId()) { + if(obj->is()) { mode = mm0Vertex; } - else if(obj->getTypeId() == PartDesign::Line::getClassTypeId()) { + else if(obj->is()) { mode = mm1TwoPoints; } - else if(obj->getTypeId() == PartDesign::Plane::getClassTypeId()) { + else if(obj->is()) { mode = mmFlatFace; } else @@ -401,7 +401,7 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st datumCopy->Shape.setValue(static_cast(obj)->Shape.getValue()); } } - else if(obj->getTypeId() == PartDesign::ShapeBinder::getClassTypeId() || + else if(obj->is() || obj->isDerivedFrom(Part::Feature::getClassTypeId())) { copy = App::GetApplication().getActiveDocument()->addObject("PartDesign::ShapeBinder", name.c_str()); diff --git a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp index 62ee1b697b..bc7b385c87 100644 --- a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp @@ -260,13 +260,13 @@ void TaskMultiTransformParameters::onTransformEdit() std::vector transformFeatures = pcMultiTransform->Transformations.getValues(); subFeature = static_cast(transformFeatures[row]); - if (transformFeatures[row]->getTypeId() == PartDesign::Mirrored::getClassTypeId()) + if (transformFeatures[row]->is()) subTask = new TaskMirroredParameters(this, ui->verticalLayout); - else if (transformFeatures[row]->getTypeId() == PartDesign::LinearPattern::getClassTypeId()) + else if (transformFeatures[row]->is()) subTask = new TaskLinearPatternParameters(this, ui->verticalLayout); - else if (transformFeatures[row]->getTypeId() == PartDesign::PolarPattern::getClassTypeId()) + else if (transformFeatures[row]->is()) subTask = new TaskPolarPatternParameters(this, ui->verticalLayout); - else if (transformFeatures[row]->getTypeId() == PartDesign::Scaled::getClassTypeId()) + else if (transformFeatures[row]->is()) subTask = new TaskScaledParameters(this, ui->verticalLayout); else return; // TODO: Show an error? diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index 5cf5eb65e4..4bf845c716 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -146,11 +146,11 @@ QVariant TaskSketchBasedParameters::setUpToFace(const QString& text) if (!obj) return {}; - 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) return {}; } - else if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + else if (obj->isDerivedFrom()) { // it's up to the document to check that the datum plane is in the same body return {}; } @@ -256,7 +256,7 @@ bool TaskDlgSketchBasedParameters::accept() { // Make sure the feature is what we are expecting // Should be fine but you never know... - if (!feature->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (!feature->isDerivedFrom()) { throw Base::TypeError("Bad object processed in the sketch based dialog."); } diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 158caaf9ae..f52009f8fa 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -457,14 +457,14 @@ bool isFeatureMovable(App::DocumentObject* const feat) if (!feat) return false; - if (feat->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) { + if (feat->isDerivedFrom()) { auto prim = static_cast(feat); App::DocumentObject* bf = prim->BaseFeature.getValue(); if (bf) return false; } - if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (feat->isDerivedFrom()) { auto prim = static_cast(feat); auto sk = prim->getVerifiedSketch(true); @@ -501,7 +501,7 @@ bool isFeatureMovable(App::DocumentObject* const feat) if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { auto attachable = feat->getExtensionByType(); App::DocumentObject* support = attachable->Support.getValue(); - if (support && !support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) + if (support && !support->isDerivedFrom()) return false; } @@ -516,7 +516,7 @@ std::vector collectMovableDependencies(std::vectorgetTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (feat->isDerivedFrom()) { auto prim = static_cast(feat); Part::Part2DObject* sk = prim->getVerifiedSketch(true); if (sk) { @@ -529,19 +529,19 @@ std::vector collectMovableDependencies(std::vector(prim->getPropertyByName("ReferenceAxis"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } if (auto prop = static_cast(prim->getPropertyByName("Spine"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } if (auto prop = static_cast(prim->getPropertyByName("AuxillerySpine"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } @@ -560,7 +560,7 @@ void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody) if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { auto attachable = feat->getExtensionByType(); App::DocumentObject* support = attachable->Support.getValue(); - if (support && support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (support && support->isDerivedFrom()) { auto originfeat = static_cast(support); App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue()); if (targetOriginFeature) { @@ -568,11 +568,11 @@ void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody) } } } - else if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + else if (feat->isDerivedFrom()) { auto prim = static_cast(feat); if (auto prop = static_cast(prim->getPropertyByName("ReferenceAxis"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && axis->isDerivedFrom()){ auto originfeat = static_cast(axis); App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue()); if (targetOriginFeature) { diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 94b314d5f6..14874a71fc 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -161,7 +161,7 @@ void ViewProvider::unsetEdit(int ModNum) void ViewProvider::updateData(const App::Property* prop) { // TODO What's that? (2015-07-24, Fat-Zer) - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && + if (prop->is() && strcmp(prop->getName(),"AddSubShape") == 0) { return; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 19313c0003..fac6d815b0 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -490,7 +490,7 @@ bool ViewProviderBody::canDropObject(App::DocumentObject* obj) const void ViewProviderBody::dropObject(App::DocumentObject* obj) { PartDesign::Body* body = static_cast(getObject()); - if (obj->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (obj->isDerivedFrom()) { body->addObject(obj); } else if (PartDesign::Body::isAllowed(obj) && PartDesignGui::isFeatureMovable(obj)) { @@ -519,7 +519,7 @@ void ViewProviderBody::dropObject(App::DocumentObject* obj) // check if a proxy object has been created for the base feature std::vector links = body->Group.getValues(); for (auto it : links) { - if (it->getTypeId().isDerivedFrom(PartDesign::FeatureBase::getClassTypeId())) { + if (it->isDerivedFrom()) { PartDesign::FeatureBase* base = static_cast(it); if (base && base->BaseFeature.getValue() == obj) { Gui::Application::Instance->hideViewProvider(obj); diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index 7c84e38206..13676e04e0 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -105,22 +105,22 @@ void ViewProviderDatum::attach(App::DocumentObject *obj) // TODO remove this field (2015-09-08, Fat-Zer) App::DocumentObject* o = getObject(); - if (o->getTypeId() == PartDesign::Plane::getClassTypeId()) { + if (o->is()) { datumType = QString::fromLatin1("Plane"); datumText = QObject::tr("Plane"); datumMenuText = tr("Datum Plane parameters"); } - else if (o->getTypeId() == PartDesign::Line::getClassTypeId()) { + else if (o->is()) { datumType = QString::fromLatin1("Line"); datumText = QObject::tr("Line"); datumMenuText = tr("Datum Line parameters"); } - else if (o->getTypeId() == PartDesign::Point::getClassTypeId()) { + else if (o->is()) { datumType = QString::fromLatin1("Point"); datumText = QObject::tr("Point"); datumMenuText = tr("Datum Point parameters"); } - else if (o->getTypeId() == PartDesign::CoordinateSystem::getClassTypeId()) { + else if (o->is()) { datumType = QString::fromLatin1("CoordinateSystem"); datumText = QObject::tr("Coordinate System"); datumMenuText = tr("Local Coordinate System parameters"); diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index c931cd31dc..e34c811f4f 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -136,7 +136,7 @@ void ViewProviderShapeBinder::highlightReferences(bool on) return; // stop if not a Part feature was found - if (!obj || !obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!obj || !obj->isDerivedFrom()) return; PartGui::ViewProviderPart* svp = dynamic_cast( diff --git a/src/Mod/Path/App/FeaturePathCompound.cpp b/src/Mod/Path/App/FeaturePathCompound.cpp index f93bc21572..9b70b6f133 100644 --- a/src/Mod/Path/App/FeaturePathCompound.cpp +++ b/src/Mod/Path/App/FeaturePathCompound.cpp @@ -49,7 +49,7 @@ App::DocumentObjectExecReturn *FeatureCompound::execute() Path::Toolpath result; for (std::vector::const_iterator it= Paths.begin();it!=Paths.end();++it) { - if ((*it)->getTypeId().isDerivedFrom(Path::Feature::getClassTypeId())){ + if ((*it)->isDerivedFrom()){ const std::vector &cmds = static_cast(*it)->Path.getValue().getCommands(); const Base::Placement pl = static_cast(*it)->Placement.getValue(); for (std::vector::const_iterator it2= cmds.begin();it2!=cmds.end();++it2) { diff --git a/src/Mod/Path/App/FeaturePathCompoundPyImp.cpp b/src/Mod/Path/App/FeaturePathCompoundPyImp.cpp index 5d62b84258..0d87b1a00c 100644 --- a/src/Mod/Path/App/FeaturePathCompoundPyImp.cpp +++ b/src/Mod/Path/App/FeaturePathCompoundPyImp.cpp @@ -58,10 +58,10 @@ PyObject* FeaturePathCompoundPy::addObject(PyObject *args) FeatureCompound* comp = getFeaturePathCompoundPtr(); - if (comp->getTypeId().isDerivedFrom(Path::FeatureCompoundPython::getClassTypeId())) { + if (comp->isDerivedFrom()) { FeatureCompoundPython* comppy = static_cast(comp); App::Property* proxy = comppy->getPropertyByName("Proxy"); - if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) { + if (proxy && proxy->is()) { Py::Object vp = static_cast(proxy)->getValue(); if (vp.hasAttr(std::string("addObject"))) { Py::Callable method(vp.getAttr(std::string("addObject"))); @@ -99,10 +99,10 @@ PyObject* FeaturePathCompoundPy::removeObject(PyObject *args) FeatureCompound* comp = getFeaturePathCompoundPtr(); - if (comp->getTypeId().isDerivedFrom(Path::FeatureCompoundPython::getClassTypeId())) { + if (comp->isDerivedFrom()) { FeatureCompoundPython* comppy = static_cast(comp); App::Property* proxy = comppy->getPropertyByName("Proxy"); - if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) { + if (proxy && proxy->is()) { Py::Object vp = static_cast(proxy)->getValue(); if (vp.hasAttr(std::string("removeObject"))) { Py::Callable method(vp.getAttr(std::string("removeObject"))); diff --git a/src/Mod/Path/Gui/Command.cpp b/src/Mod/Path/Gui/Command.cpp index 0d817c5c74..0af7ec5ef9 100644 --- a/src/Mod/Path/Gui/Command.cpp +++ b/src/Mod/Path/Gui/Command.cpp @@ -66,7 +66,7 @@ void CmdPathArea::activated(int iMsg) if(addView && !areaName.empty()) addView = false; if(subnames.empty()) { - if(addView && pcObj->getTypeId().isDerivedFrom(Path::FeatureArea::getClassTypeId())) + if(addView && pcObj->isDerivedFrom()) areaName = pcObj->getNameInDocument(); sources << "FreeCAD.activeDocument()." << pcObj->getNameInDocument() << ","; continue; @@ -151,7 +151,7 @@ void CmdPathAreaWorkplane::activated(int iMsg) } const Part::Feature *pcObj = static_cast(selObj.getObject()); if(subnames.empty()) { - if(pcObj->getTypeId().isDerivedFrom(Path::FeatureArea::getClassTypeId())) { + if(pcObj->isDerivedFrom()) { if(!areaName.empty()){ Base::Console().Error("Please select one FeatureArea only\n"); return; @@ -232,7 +232,7 @@ void CmdPathCompound::activated(int iMsg) cmd << "["; Path::Feature *pcPathObject; for (std::vector::const_iterator it=Sel.begin();it!=Sel.end();++it) { - if ((*it).pObject->getTypeId().isDerivedFrom(Path::Feature::getClassTypeId())) { + if ((*it).pObject->isDerivedFrom()) { pcPathObject = static_cast((*it).pObject); cmd << "FreeCAD.activeDocument()." << pcPathObject->getNameInDocument() << ","; } else { diff --git a/src/Mod/Path/Gui/ViewProviderArea.cpp b/src/Mod/Path/Gui/ViewProviderArea.cpp index 8a2cca3282..40d0f6588a 100644 --- a/src/Mod/Path/Gui/ViewProviderArea.cpp +++ b/src/Mod/Path/Gui/ViewProviderArea.cpp @@ -54,7 +54,7 @@ bool ViewProviderArea::canDragObjects() const bool ViewProviderArea::canDragObject(App::DocumentObject* obj) const { - return obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()); + return obj && obj->isDerivedFrom(); } void ViewProviderArea::dragObject(App::DocumentObject* obj) @@ -91,7 +91,7 @@ void ViewProviderArea::dropObject(App::DocumentObject* obj) void ViewProviderArea::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); - if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { + if (prop->isDerivedFrom()) { std::vector pShapes = static_cast(prop)->getValues(); for (std::vector::iterator it = pShapes.begin(); it != pShapes.end(); ++it) { if (*it) @@ -141,7 +141,7 @@ bool ViewProviderAreaView::canDragObjects() const bool ViewProviderAreaView::canDragObject(App::DocumentObject* obj) const { - return obj && obj->getTypeId().isDerivedFrom(Path::FeatureArea::getClassTypeId()); + return obj && obj->isDerivedFrom(); } void ViewProviderAreaView::dragObject(App::DocumentObject* ) @@ -169,7 +169,7 @@ void ViewProviderAreaView::dropObject(App::DocumentObject* obj) void ViewProviderAreaView::updateData(const App::Property* prop) { PartGui::ViewProviderPlaneParametric::updateData(prop); - if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) + if (prop->isDerivedFrom()) Gui::Application::Instance->hideViewProvider( static_cast(prop)->getValue()); } diff --git a/src/Mod/Path/Gui/ViewProviderPathShape.cpp b/src/Mod/Path/Gui/ViewProviderPathShape.cpp index cb0b45cdf3..f8e559695d 100644 --- a/src/Mod/Path/Gui/ViewProviderPathShape.cpp +++ b/src/Mod/Path/Gui/ViewProviderPathShape.cpp @@ -52,7 +52,7 @@ bool ViewProviderPathShape::canDragObjects() const bool ViewProviderPathShape::canDragObject(App::DocumentObject* obj) const { - return obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()); + return obj && obj->isDerivedFrom(); } void ViewProviderPathShape::dragObject(App::DocumentObject* obj) @@ -89,7 +89,7 @@ void ViewProviderPathShape::dropObject(App::DocumentObject* obj) void ViewProviderPathShape::updateData(const App::Property* prop) { PathGui::ViewProviderPath::updateData(prop); - if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) { + if (prop->isDerivedFrom()) { std::vector pShapes = static_cast(prop)->getValues(); for (std::vector::iterator it = pShapes.begin(); it != pShapes.end(); ++it) { if (*it) diff --git a/src/Mod/Points/Gui/Command.cpp b/src/Mod/Points/Gui/Command.cpp index 07e2a3ba3b..016f1d8e35 100644 --- a/src/Mod/Points/Gui/Command.cpp +++ b/src/Mod/Points/Gui/Command.cpp @@ -310,7 +310,7 @@ void CmdPointsPolyCut::activated(int iMsg) if (it == docObj.begin()) { Gui::Document* doc = getActiveGuiDocument(); Gui::MDIView* view = doc->getActiveView(); - if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { + if (view->isDerivedFrom()) { Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer(); viewer->setEditing(true); viewer->startSelection(Gui::View3DInventorViewer::Lasso); @@ -427,7 +427,7 @@ void CmdPointsStructure::activated(int iMsg) output->Label.setValue(name); // Already sorted, so just make a copy - if (it->getTypeId().isDerivedFrom(Points::Structured::getClassTypeId())) { + if (it->isDerivedFrom()) { Points::Structured* input = static_cast(it); Points::PointKernel* kernel = output->Points.startEditing(); diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index 4f6fc004e6..b90e8fe7f0 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -426,20 +426,20 @@ void ViewProviderScattered::attach(App::DocumentObject* pcObj) void ViewProviderScattered::updateData(const App::Property* prop) { ViewProviderPoints::updateData(prop); - if (prop->getTypeId() == Points::PropertyPointKernel::getClassTypeId()) { + if (prop->is()) { ViewProviderPointsBuilder builder; builder.createPoints(prop, pcPointsCoord, pcPoints); // The number of points might have changed, so force also a resize of the Inventor internals setActiveMode(); } - else if (prop->getTypeId() == Points::PropertyNormalList::getClassTypeId()) { + else if (prop->is()) { setActiveMode(); } - else if (prop->getTypeId() == Points::PropertyGreyValueList::getClassTypeId()) { + else if (prop->is()) { setActiveMode(); } - else if (prop->getTypeId() == App::PropertyColorList::getClassTypeId()) { + else if (prop->is()) { setActiveMode(); } } @@ -598,7 +598,7 @@ void ViewProviderStructured::attach(App::DocumentObject* pcObj) void ViewProviderStructured::updateData(const App::Property* prop) { ViewProviderPoints::updateData(prop); - if (prop->getTypeId() == Points::PropertyPointKernel::getClassTypeId()) { + if (prop->is()) { ViewProviderPointsBuilder builder; builder.createPoints(prop, pcPointsCoord, pcPoints); diff --git a/src/Mod/ReverseEngineering/Gui/Command.cpp b/src/Mod/ReverseEngineering/Gui/Command.cpp index b4cacdcd97..0e92fe819f 100644 --- a/src/Mod/ReverseEngineering/Gui/Command.cpp +++ b/src/Mod/ReverseEngineering/Gui/Command.cpp @@ -120,7 +120,7 @@ void CmdApproxPlane::activated(int) std::vector List; it->getPropertyList(List); for (const auto& jt : List) { - if (jt->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) { + if (jt->isDerivedFrom()) { const Data::ComplexGeoData* data = static_cast(jt)->getComplexData(); if (data) { diff --git a/src/Mod/Robot/App/Edge2TracObject.cpp b/src/Mod/Robot/App/Edge2TracObject.cpp index 4c8543bbcf..24636dc027 100644 --- a/src/Mod/Robot/App/Edge2TracObject.cpp +++ b/src/Mod/Robot/App/Edge2TracObject.cpp @@ -67,7 +67,7 @@ App::DocumentObjectExecReturn* Edge2TracObject::execute() if (!link) { return new App::DocumentObjectExecReturn("No object linked"); } - if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!link->isDerivedFrom()) { return new App::DocumentObjectExecReturn("Linked object is not a Part object"); } Part::Feature* base = static_cast(Source.getValue()); diff --git a/src/Mod/Robot/App/TrajectoryCompound.cpp b/src/Mod/Robot/App/TrajectoryCompound.cpp index 7e4ce7b341..d6c6811582 100644 --- a/src/Mod/Robot/App/TrajectoryCompound.cpp +++ b/src/Mod/Robot/App/TrajectoryCompound.cpp @@ -44,7 +44,7 @@ App::DocumentObjectExecReturn* TrajectoryCompound::execute() Robot::Trajectory result; for (auto it : Tracs) { - if (it->getTypeId().isDerivedFrom(Robot::TrajectoryObject::getClassTypeId())) { + if (it->isDerivedFrom()) { const std::vector& wps = static_cast(it)->Trajectory.getValue().getWaypoints(); for (auto wp : wps) { diff --git a/src/Mod/Robot/App/TrajectoryDressUpObject.cpp b/src/Mod/Robot/App/TrajectoryDressUpObject.cpp index 6961f4a36a..54d6a4906f 100644 --- a/src/Mod/Robot/App/TrajectoryDressUpObject.cpp +++ b/src/Mod/Robot/App/TrajectoryDressUpObject.cpp @@ -81,7 +81,7 @@ App::DocumentObjectExecReturn* TrajectoryDressUpObject::execute() if (!link) { return new App::DocumentObjectExecReturn("No object linked"); } - if (!link->getTypeId().isDerivedFrom(Robot::TrajectoryObject::getClassTypeId())) { + if (!link->isDerivedFrom()) { return new App::DocumentObjectExecReturn("Linked object is not a Trajectory object"); } diff --git a/src/Mod/Robot/Gui/CommandExport.cpp b/src/Mod/Robot/Gui/CommandExport.cpp index bbd390529c..304d154f53 100644 --- a/src/Mod/Robot/Gui/CommandExport.cpp +++ b/src/Mod/Robot/Gui/CommandExport.cpp @@ -68,19 +68,19 @@ void CmdRobotExportKukaCompact::activated(int) Robot::RobotObject* pcRobotObject = nullptr; - if (Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { + if (Sel[0].pObject->is()) { pcRobotObject = static_cast(Sel[0].pObject); } - else if (Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { + else if (Sel[1].pObject->is()) { pcRobotObject = static_cast(Sel[1].pObject); } std::string RoboName = pcRobotObject->getNameInDocument(); Robot::TrajectoryObject* pcTrajectoryObject = nullptr; - if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { + if (Sel[0].pObject->is()) { pcTrajectoryObject = static_cast(Sel[0].pObject); } - else if (Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { + else if (Sel[1].pObject->is()) { pcTrajectoryObject = static_cast(Sel[1].pObject); } // std::string TrakName = pcTrajectoryObject->getNameInDocument(); @@ -143,19 +143,19 @@ void CmdRobotExportKukaFull::activated(int) Robot::RobotObject* pcRobotObject = nullptr; - if (Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { + if (Sel[0].pObject->is()) { pcRobotObject = static_cast(Sel[0].pObject); } - else if (Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { + else if (Sel[1].pObject->is()) { pcRobotObject = static_cast(Sel[1].pObject); } // std::string RoboName = pcRobotObject->getNameInDocument(); Robot::TrajectoryObject* pcTrajectoryObject = nullptr; - if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { + if (Sel[0].pObject->is()) { pcTrajectoryObject = static_cast(Sel[0].pObject); } - else if (Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { + else if (Sel[1].pObject->is()) { pcTrajectoryObject = static_cast(Sel[1].pObject); } // std::string TrakName = pcTrajectoryObject->getNameInDocument(); diff --git a/src/Mod/Robot/Gui/CommandTrajectory.cpp b/src/Mod/Robot/Gui/CommandTrajectory.cpp index f87604e4fa..e55457e62a 100644 --- a/src/Mod/Robot/Gui/CommandTrajectory.cpp +++ b/src/Mod/Robot/Gui/CommandTrajectory.cpp @@ -111,19 +111,19 @@ void CmdRobotInsertWaypoint::activated(int) std::vector Sel = getSelection().getSelection(); Robot::RobotObject* pcRobotObject = nullptr; - if (Sel[0].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { + if (Sel[0].pObject->is()) { pcRobotObject = static_cast(Sel[0].pObject); } - else if (Sel[1].pObject->getTypeId() == Robot::RobotObject::getClassTypeId()) { + else if (Sel[1].pObject->is()) { pcRobotObject = static_cast(Sel[1].pObject); } std::string RoboName = pcRobotObject->getNameInDocument(); Robot::TrajectoryObject* pcTrajectoryObject = nullptr; - if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { + if (Sel[0].pObject->is()) { pcTrajectoryObject = static_cast(Sel[0].pObject); } - else if (Sel[1].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { + else if (Sel[1].pObject->is()) { pcTrajectoryObject = static_cast(Sel[1].pObject); } std::string TrakName = pcTrajectoryObject->getNameInDocument(); @@ -184,7 +184,7 @@ void CmdRobotInsertWaypointPreselect::activated(int) Robot::TrajectoryObject* pcTrajectoryObject; - if (Sel[0].pObject->getTypeId() == Robot::TrajectoryObject::getClassTypeId()) { + if (Sel[0].pObject->is()) { pcTrajectoryObject = static_cast(Sel[0].pObject); } else { diff --git a/src/Mod/Sandbox/Gui/AppSandboxGui.cpp b/src/Mod/Sandbox/Gui/AppSandboxGui.cpp index 14664b6ae9..3fe70ad212 100644 --- a/src/Mod/Sandbox/Gui/AppSandboxGui.cpp +++ b/src/Mod/Sandbox/Gui/AppSandboxGui.cpp @@ -67,7 +67,7 @@ private: void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) { #ifdef HAVE_PART - if (object == &Obj && Prop.getTypeId() == Part::PropertyGeometryList::getClassTypeId()) { + if (object == &Obj && Prop.is()) { const Part::PropertyGeometryList& geom = static_cast(Prop); const std::vector& items = geom.getValues(); if (items.size() != 2) diff --git a/src/Mod/Sketcher/App/GeoList.cpp b/src/Mod/Sketcher/App/GeoList.cpp index 33fd95a054..d477d6cb12 100644 --- a/src/Mod/Sketcher/App/GeoList.cpp +++ b/src/Mod/Sketcher/App/GeoList.cpp @@ -171,13 +171,13 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po { using namespace Sketcher; - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo->is()) { const Part::GeomPoint* p = static_cast(geo); if (pos == PointPos::start || pos == PointPos::mid || pos == PointPos::end) { return p->getPoint(); } } - else if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); if (pos == PointPos::start) { return lineSeg->getStartPoint(); @@ -186,19 +186,19 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return lineSeg->getEndPoint(); } } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); if (pos == PointPos::mid) { return circle->getCenter(); } } - else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomEllipse* ellipse = static_cast(geo); if (pos == PointPos::mid) { return ellipse->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* aoc = static_cast(geo); if (pos == PointPos::start) { return aoc->getStartPoint(/*emulateCCW=*/true); @@ -210,7 +210,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aoc->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfEllipse* aoc = static_cast(geo); if (pos == PointPos::start) { return aoc->getStartPoint(/*emulateCCW=*/true); @@ -222,7 +222,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aoc->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo); if (pos == PointPos::start) { return aoh->getStartPoint(); @@ -234,7 +234,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aoh->getCenter(); } } - else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo); if (pos == PointPos::start) { return aop->getStartPoint(); @@ -246,7 +246,7 @@ Base::Vector3d GeoListModel::getPoint(const Part::Geometry* geo, Sketcher::Po return aop->getCenter(); } } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); if (pos == PointPos::start) { return bsp->getStartPoint(); diff --git a/src/Mod/Sketcher/App/GeometryFacade.h b/src/Mod/Sketcher/App/GeometryFacade.h index b7aab2ee34..8e8f513bbe 100644 --- a/src/Mod/Sketcher/App/GeometryFacade.h +++ b/src/Mod/Sketcher/App/GeometryFacade.h @@ -82,7 +82,7 @@ class GeometryFacadePy; * Examples getting and setting the construction stations without creating a Facade: * * if ((*geo) && GeometryFacade::getConstruction(*geo) && - * (*geo)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) + * (*geo)->is()) * count++; * * Part::Geometry* copy = v->copy(); diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index bab148ca46..71560d5ce2 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -682,48 +682,48 @@ const char* nameByType(Sketch::GeoType type) int Sketch::addGeometry(const Part::Geometry* geo, bool fixed) { - if (geo->getTypeId() == GeomPoint::getClassTypeId()) { // add a point + if (geo->is()) { // add a point const GeomPoint* point = static_cast(geo); auto pointf = GeometryFacade::getFacade(point); // create the definition struct for that geom return addPoint(*point, fixed); } - else if (geo->getTypeId() == GeomLineSegment::getClassTypeId()) { // add a line + else if (geo->is()) { // add a line const GeomLineSegment* lineSeg = static_cast(geo); // create the definition struct for that geom return addLineSegment(*lineSeg, fixed); } - else if (geo->getTypeId() == GeomCircle::getClassTypeId()) { // add a circle + else if (geo->is()) { // add a circle const GeomCircle* circle = static_cast(geo); // create the definition struct for that geom return addCircle(*circle, fixed); } - else if (geo->getTypeId() == GeomEllipse::getClassTypeId()) { // add a ellipse + else if (geo->is()) { // add a ellipse const GeomEllipse* ellipse = static_cast(geo); // create the definition struct for that geom return addEllipse(*ellipse, fixed); } - else if (geo->getTypeId() == GeomArcOfCircle::getClassTypeId()) { // add an arc + else if (geo->is()) { // add an arc const GeomArcOfCircle* aoc = static_cast(geo); // create the definition struct for that geom return addArc(*aoc, fixed); } - else if (geo->getTypeId() == GeomArcOfEllipse::getClassTypeId()) { // add an arc + else if (geo->is()) { // add an arc const GeomArcOfEllipse* aoe = static_cast(geo); // create the definition struct for that geom return addArcOfEllipse(*aoe, fixed); } - else if (geo->getTypeId() == GeomArcOfHyperbola::getClassTypeId()) { // add an arc of hyperbola + else if (geo->is()) { // add an arc of hyperbola const GeomArcOfHyperbola* aoh = static_cast(geo); // create the definition struct for that geom return addArcOfHyperbola(*aoh, fixed); } - else if (geo->getTypeId() == GeomArcOfParabola::getClassTypeId()) { // add an arc of parabola + else if (geo->is()) { // add an arc of parabola const GeomArcOfParabola* aop = static_cast(geo); // create the definition struct for that geom return addArcOfParabola(*aop, fixed); } - else if (geo->getTypeId() == GeomBSplineCurve::getClassTypeId()) { // add a bspline + else if (geo->is()) { // add a bspline const GeomBSplineCurve* bsp = static_cast(geo); // Current B-Spline implementation relies on OCCT calculations, so a second solve diff --git a/src/Mod/Sketcher/App/SketchAnalysis.cpp b/src/Mod/Sketcher/App/SketchAnalysis.cpp index b778660929..c51e6db205 100644 --- a/src/Mod/Sketcher/App/SketchAnalysis.cpp +++ b/src/Mod/Sketcher/App/SketchAnalysis.cpp @@ -165,7 +165,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, continue; } - if (gf->getGeometry()->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (gf->getGeometry()->is()) { const Part::GeomLineSegment* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -178,7 +178,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfCircle* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -191,7 +191,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(/*emulateCCW=*/true); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfEllipse* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -204,7 +204,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(/*emulateCCW=*/true); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfHyperbola* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -217,7 +217,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomArcOfParabola* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -230,7 +230,7 @@ int SketchAnalysis::detectMissingPointOnPointConstraints(double precision, id.v = segm->getEndPoint(); vertexIds.push_back(id); } - else if (gf->getGeometry()->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (gf->getGeometry()->is()) { const Part::GeomBSplineCurve* segm = static_cast(gf->getGeometry()); VertexIds id; @@ -402,8 +402,7 @@ void SketchAnalysis::analyseMissingPointOnPointCoincident(double angleprecision) if (curve1 && curve2) { - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() && geo2->is()) { const Part::GeomLineSegment* segm1 = static_cast(geo1); @@ -508,7 +507,7 @@ int SketchAnalysis::detectMissingVerticalHorizontalConstraints(double anglepreci for (std::size_t i = 0; i < geom.size(); i++) { Part::Geometry* g = geom[i]; - if (g->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (g->is()) { const Part::GeomLineSegment* segm = static_cast(g); Base::Vector3d dir = segm->getEndPoint() - segm->getStartPoint(); @@ -606,21 +605,21 @@ int SketchAnalysis::detectMissingEqualityConstraints(double precision) for (std::size_t i = 0; i < geom.size(); i++) { Part::Geometry* g = geom[i]; - if (g->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (g->is()) { const Part::GeomLineSegment* segm = static_cast(g); EdgeIds id; id.GeoId = (int)i; id.l = (segm->getEndPoint() - segm->getStartPoint()).Length(); lineedgeIds.push_back(id); } - else if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (g->is()) { const Part::GeomArcOfCircle* segm = static_cast(g); EdgeIds id; id.GeoId = (int)i; id.l = segm->getRadius(); radiusedgeIds.push_back(id); } - else if (g->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (g->is()) { const Part::GeomCircle* segm = static_cast(g); EdgeIds id; id.GeoId = (int)i; @@ -988,7 +987,7 @@ int SketchAnalysis::detectDegeneratedGeometries(double tolerance) continue; } - if (gf->getGeometry()->getTypeId().isDerivedFrom(Part::GeomCurve::getClassTypeId())) { + if (gf->getGeometry()->isDerivedFrom()) { Part::GeomCurve* curve = static_cast(gf->getGeometry()); double len = curve->length(curve->getFirstParameter(), curve->getLastParameter()); if (len < tolerance) { @@ -1011,7 +1010,7 @@ int SketchAnalysis::removeDegeneratedGeometries(double tolerance) continue; } - if (gf->getGeometry()->getTypeId().isDerivedFrom(Part::GeomCurve::getClassTypeId())) { + if (gf->getGeometry()->isDerivedFrom()) { Part::GeomCurve* curve = static_cast(gf->getGeometry()); double len = curve->length(curve->getFirstParameter(), curve->getLastParameter()); if (len < tolerance) { diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 3773396bc2..fca1a0abf9 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -918,25 +918,25 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) const Part::GeomPoint *p = static_cast(geo); if (PosId == PointPos::start || PosId == PointPos::mid || PosId == PointPos::end) return p->getPoint(); - } else if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomLineSegment *lineSeg = static_cast(geo); if (PosId == PointPos::start) return lineSeg->getStartPoint(); else if (PosId == PointPos::end) return lineSeg->getEndPoint(); - } else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomCircle *circle = static_cast(geo); auto pt = circle->getCenter(); if(PosId != PointPos::mid) pt.x += circle->getRadius(); return pt; - } else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomEllipse *ellipse = static_cast(geo); auto pt = ellipse->getCenter(); if(PosId != PointPos::mid) pt += ellipse->getMajorAxisDir()*ellipse->getMajorRadius(); return pt; - } else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfCircle *aoc = static_cast(geo); if (PosId == PointPos::start) return aoc->getStartPoint(/*emulateCCW=*/true); @@ -944,7 +944,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aoc->getEndPoint(/*emulateCCW=*/true); else if (PosId == PointPos::mid) return aoc->getCenter(); - } else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfEllipse *aoc = static_cast(geo); if (PosId == PointPos::start) return aoc->getStartPoint(/*emulateCCW=*/true); @@ -952,7 +952,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aoc->getEndPoint(/*emulateCCW=*/true); else if (PosId == PointPos::mid) return aoc->getCenter(); - } else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfHyperbola *aoh = static_cast(geo); if (PosId == PointPos::start) return aoh->getStartPoint(); @@ -960,7 +960,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aoh->getEndPoint(); else if (PosId == PointPos::mid) return aoh->getCenter(); - } else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomArcOfParabola *aop = static_cast(geo); if (PosId == PointPos::start) return aop->getStartPoint(); @@ -968,7 +968,7 @@ Base::Vector3d SketchObject::getPoint(const Part::Geometry *geo, PointPos PosId) return aop->getEndPoint(); else if (PosId == PointPos::mid) return aop->getCenter(); - } else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + } else if (geo->is()) { const Part::GeomBSplineCurve *bsp = static_cast(geo); if (PosId == PointPos::start) return bsp->getStartPoint(); @@ -994,7 +994,7 @@ int SketchObject::getAxisCount() const int count = 0; for (std::vector::const_iterator geo = vals.begin(); geo != vals.end(); geo++) if ((*geo) && GeometryFacade::getConstruction(*geo) - && (*geo)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) + && (*geo)->is()) count++; return count; @@ -1009,7 +1009,7 @@ Base::Axis SketchObject::getAxis(int axId) const int count = 0; for (std::vector::const_iterator geo = vals.begin(); geo != vals.end(); geo++) if ((*geo) && GeometryFacade::getConstruction(*geo) - && (*geo)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + && (*geo)->is()) { if (count == axId) { Part::GeomLineSegment* lineSeg = static_cast(*geo); Base::Vector3d start = lineSeg->getStartPoint(); @@ -1030,18 +1030,18 @@ void SketchObject::acceptGeometry() bool SketchObject::isSupportedGeometry(const Part::Geometry* geo) const { - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() - || geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is()) { return true; } - if (geo->getTypeId() == Part::GeomTrimmedCurve::getClassTypeId()) { + if (geo->is()) { Handle(Geom_TrimmedCurve) trim = Handle(Geom_TrimmedCurve)::DownCast(geo->handle()); Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(trim->BasisCurve()); Handle(Geom_Ellipse) ellipse = Handle(Geom_Ellipse)::DownCast(trim->BasisCurve()); @@ -1081,7 +1081,7 @@ int SketchObject::addGeometry(const std::vector& geoList, for (auto& v : geoList) { Part::Geometry* copy = v->copy(); - if (copy->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (copy->is()) { // creation mode for points is always construction not to // break legacy code GeometryFacade::setConstruction(copy, true); @@ -1119,7 +1119,7 @@ int SketchObject::addGeometry(std::unique_ptr newgeo, bool const auto* geoNew = newgeo.release(); - if (geoNew->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geoNew->is()) { // creation mode for points is always construction not to // break legacy code GeometryFacade::setConstruction(geoNew, true); @@ -1149,11 +1149,11 @@ int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo) if (deleteinternalgeo) { const Part::Geometry* geo = getGeometry(GeoId); // Only for supported types - if ((geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId())) { + if ((geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is())) { this->deleteUnusedInternalGeometry(GeoId, true); @@ -1997,8 +1997,8 @@ int SketchObject::fillet(int GeoId, PointPos PosId, double radius, bool trim, bo if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) { const Part::Geometry* geo1 = getGeometry(GeoIdList[0]); const Part::Geometry* geo2 = getGeometry(GeoIdList[1]); - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() + && geo2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); const Part::GeomLineSegment* lineSeg2 = static_cast(geo2); @@ -2025,8 +2025,8 @@ int SketchObject::fillet(int GeoId1, int GeoId2, const Base::Vector3d& refPnt1, trim = false; } - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() + && geo2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); const Part::GeomLineSegment* lineSeg2 = static_cast(geo2); @@ -2629,7 +2629,7 @@ int SketchObject::extend(int GeoId, double increment, PointPos endpoint) const std::vector& geomList = getInternalGeometry(); Part::Geometry* geom = geomList[GeoId]; int retcode = -1; - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { Part::GeomLineSegment* seg = static_cast(geom); Base::Vector3d startVec = seg->getStartPoint(); Base::Vector3d endVec = seg->getEndPoint(); @@ -2650,7 +2650,7 @@ int SketchObject::extend(int GeoId, double increment, PointPos endpoint) retcode = movePoint(GeoId, Sketcher::PointPos::end, newPoint, false, true); } } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { Part::GeomArcOfCircle* arc = static_cast(geom); double startArc, endArc; arc->getRange(startArc, endArc, true); @@ -2867,7 +2867,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point) // Removes all internal geometry of a BSplineCurve and updates the GeoId index after removal auto ifBSplineRemoveInternalAlignmentGeometry = [this](int& GeoId) { const Part::Geometry* geo = getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { // We need to remove the internal geometry of the BSpline, as BSplines change in number // of poles and knots We save the tags of the relevant geometry to retrieve the new // GeoIds later on. @@ -2936,15 +2936,15 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point) // Trimmed B-Spline internal geometry cannot be reused geo = getGeometry(GeoId); - auto isBSpline = geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId(); + auto isBSpline = geo->is(); auto isPeriodicBSpline = isBSpline && static_cast(geo)->isPeriodic(); auto isNonPeriodicBSpline = isBSpline && !static_cast(geo)->isPeriodic(); - auto isLineSegment = geo->getTypeId() == Part::GeomLineSegment::getClassTypeId(); + auto isLineSegment = geo->is(); auto isDerivedFromTrimmedCurve = geo->isDerivedFrom(Part::GeomTrimmedCurve::getClassTypeId()); - auto isCircle = geo->getTypeId() == Part::GeomCircle::getClassTypeId(); - auto isEllipse = geo->getTypeId() == Part::GeomEllipse::getClassTypeId(); + auto isCircle = geo->is(); + auto isEllipse = geo->is(); if (isBSpline) { @@ -3459,7 +3459,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) }; bool ok = false; - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { ok = createGeosFromNonPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3481,7 +3481,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::end, newId1, PointPos::end); }); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { ok = createGeosFromPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3494,7 +3494,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::mid, newId, PointPos::mid); }); } - else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo->is()) { ok = createGeosFromPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3507,7 +3507,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::mid, newId, PointPos::mid); }); } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { ok = createGeosFromNonPeriodic( static_cast(geo), [](const Part::GeomCurve* curve, double startParam, double endParam) { @@ -3564,7 +3564,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) transferConstraints(GeoId, PointPos::end, newId1, PointPos::end, true); }); } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); // what to do for periodic b-splines? @@ -3638,7 +3638,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) case Horizontal: case Vertical: case Parallel: { - transferToAll = geo->getTypeId() == Part::GeomLineSegment::getClassTypeId(); + transferToAll = geo->is(); break; } case Tangent: @@ -3697,7 +3697,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) int targetId = newIds[0]; // for non-periodic curves, see if second curve is more appropriate - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { Base::Vector3d projPoint( conPoint.Perpendicular(startPoint, endPoint - startPoint)); Base::Vector3d splitDir = splitPoint - startPoint; @@ -3721,8 +3721,8 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point) case Radius: case Diameter: case Equal: { - transferToAll = geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId(); + transferToAll = geo->is() + || geo->is(); break; } default: @@ -4156,7 +4156,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, } // Handle Geometry - if (geosym->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geosym->is()) { Part::GeomLineSegment* geosymline = static_cast(geosym); Base::Vector3d sp = geosymline->getStartPoint(); Base::Vector3d ep = geosymline->getEndPoint(); @@ -4166,7 +4166,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, ep + 2.0 * (ep.Perpendicular(refGeoLine->getStartPoint(), vectline) - ep)); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomCircle* geosymcircle = static_cast(geosym); Base::Vector3d cp = geosymcircle->getCenter(); @@ -4174,7 +4174,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, cp + 2.0 * (cp.Perpendicular(refGeoLine->getStartPoint(), vectline) - cp)); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfCircle* geoaoc = static_cast(geosym); Base::Vector3d sp = geoaoc->getStartPoint(true); Base::Vector3d ep = geoaoc->getEndPoint(true); @@ -4194,7 +4194,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geoaoc->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomEllipse* geosymellipse = static_cast(geosym); Base::Vector3d cp = geosymellipse->getCenter(); @@ -4214,7 +4214,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymellipse->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfEllipse* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4246,7 +4246,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfHyperbola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4275,7 +4275,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfParabola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4299,7 +4299,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, true)); } - else if (geosym->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geosym->is()) { Part::GeomBSplineCurve* geosymbsp = static_cast(geosym); std::vector poles = geosymbsp->getPoles(); @@ -4316,7 +4316,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomPoint::getClassTypeId()) { + else if (geosym->is()) { Part::GeomPoint* geosympoint = static_cast(geosym); Base::Vector3d cp = geosympoint->getPoint(); @@ -4339,7 +4339,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, Vector3d refpoint; const Part::Geometry* georef = getGeometry(refGeoId); - if (georef->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (georef->is()) { refpoint = static_cast(georef)->getPoint(); } else if (refGeoId == -1 && refPosId == Sketcher::PointPos::start) { @@ -4348,96 +4348,96 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, else { switch (refPosId) { case Sketcher::PointPos::start: - if (georef->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (georef->is()) { const Part::GeomLineSegment* geosymline = static_cast(georef); refpoint = geosymline->getStartPoint(); } - else if (georef->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfCircle* geoaoc = static_cast(georef); refpoint = geoaoc->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfEllipse* geosymaoe = static_cast(georef); refpoint = geosymaoe->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfHyperbola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfParabola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getStartPoint(true); } - else if (georef->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (georef->is()) { const Part::GeomBSplineCurve* geosymbsp = static_cast(georef); refpoint = geosymbsp->getStartPoint(); } break; case Sketcher::PointPos::end: - if (georef->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (georef->is()) { const Part::GeomLineSegment* geosymline = static_cast(georef); refpoint = geosymline->getEndPoint(); } - else if (georef->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfCircle* geoaoc = static_cast(georef); refpoint = geoaoc->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfEllipse* geosymaoe = static_cast(georef); refpoint = geosymaoe->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfHyperbola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfParabola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getEndPoint(true); } - else if (georef->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (georef->is()) { const Part::GeomBSplineCurve* geosymbsp = static_cast(georef); refpoint = geosymbsp->getEndPoint(); } break; case Sketcher::PointPos::mid: - if (georef->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (georef->is()) { const Part::GeomCircle* geosymcircle = static_cast(georef); refpoint = geosymcircle->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfCircle* geoaoc = static_cast(georef); refpoint = geoaoc->getCenter(); } - else if (georef->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomEllipse* geosymellipse = static_cast(georef); refpoint = geosymellipse->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfEllipse* geosymaoe = static_cast(georef); refpoint = geosymaoe->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfHyperbola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getCenter(); } - else if (georef->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (georef->is()) { const Part::GeomArcOfParabola* geosymaoe = static_cast(georef); refpoint = geosymaoe->getCenter(); @@ -4481,7 +4481,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, } // Handle Geometry - if (geosym->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geosym->is()) { Part::GeomLineSegment* geosymline = static_cast(geosym); Base::Vector3d sp = geosymline->getStartPoint(); Base::Vector3d ep = geosymline->getEndPoint(); @@ -4491,14 +4491,14 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymline->setPoints(ssp, sep); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomCircle* geosymcircle = static_cast(geosym); Base::Vector3d cp = geosymcircle->getCenter(); geosymcircle->setCenter(cp + 2.0 * (refpoint - cp)); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfCircle* geoaoc = static_cast(geosym); Base::Vector3d sp = geoaoc->getStartPoint(true); Base::Vector3d ep = geoaoc->getEndPoint(true); @@ -4515,7 +4515,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geoaoc->setRange(theta1, theta2, true); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomEllipse* geosymellipse = static_cast(geosym); Base::Vector3d cp = geosymellipse->getCenter(); @@ -4533,7 +4533,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymellipse->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfEllipse* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4551,7 +4551,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfHyperbola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4570,7 +4570,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, geosymaoe->setCenter(scp); isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geosym->is()) { Part::GeomArcOfParabola* geosymaoe = static_cast(geosym); Base::Vector3d cp = geosymaoe->getCenter(); @@ -4585,7 +4585,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geosym->is()) { Part::GeomBSplineCurve* geosymbsp = static_cast(geosym); std::vector poles = geosymbsp->getPoles(); @@ -4599,7 +4599,7 @@ int SketchObject::addSymmetric(const std::vector& geoIdList, int refGeoId, // isStartEndInverted.insert(std::make_pair(*it, false)); } - else if (geosym->getTypeId() == Part::GeomPoint::getClassTypeId()) { + else if (geosym->is()) { Part::GeomPoint* geosympoint = static_cast(geosym); Base::Vector3d cp = geosympoint->getPoint(); @@ -4828,8 +4828,8 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 refgeoid = *(newgeoIdList.begin()); currentrowfirstgeoid = refgeoid; iterfirstgeoid = refgeoid; - if (geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (geo->is() + || geo->is()) { refposId = Sketcher::PointPos::mid; } else @@ -4886,7 +4886,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 geocopy = newgeoVals[*it]; // Handle Geometry - if (geocopy->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geocopy->is()) { Part::GeomLineSegment* geosymline = static_cast(geocopy); Base::Vector3d ep = geosymline->getEndPoint(); @@ -4899,7 +4899,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = ssp; } - else if (geocopy->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomCircle* geosymcircle = static_cast(geocopy); Base::Vector3d cp = geosymcircle->getCenter(); Base::Vector3d scp = @@ -4910,7 +4910,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = scp; } - else if (geocopy->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfCircle* geoaoc = static_cast(geocopy); Base::Vector3d cp = geoaoc->getCenter(); Base::Vector3d scp = @@ -4921,7 +4921,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoc->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomEllipse* geosymellipse = static_cast(geocopy); Base::Vector3d cp = geosymellipse->getCenter(); Base::Vector3d scp = @@ -4932,7 +4932,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = scp; } - else if (geocopy->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfEllipse* geoaoe = static_cast(geocopy); Base::Vector3d cp = geoaoe->getCenter(); Base::Vector3d scp = @@ -4943,7 +4943,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoe->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfHyperbola* geoaoe = static_cast(geocopy); Base::Vector3d cp = geoaoe->getCenter(); @@ -4955,7 +4955,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoe->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomArcOfParabola* geoaoe = static_cast(geocopy); Base::Vector3d cp = geoaoe->getCenter(); @@ -4967,7 +4967,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geoaoe->getStartPoint(true); } - else if (geocopy->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomBSplineCurve* geobsp = static_cast(geocopy); std::vector poles = geobsp->getPoles(); @@ -4985,7 +4985,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 if (it == newgeoIdList.begin()) iterfirstpoint = geobsp->getStartPoint(); } - else if (geocopy->getTypeId() == Part::GeomPoint::getClassTypeId()) { + else if (geocopy->is()) { Part::GeomPoint* geopoint = static_cast(geocopy); Base::Vector3d cp = geopoint->getPoint(); Base::Vector3d scp = @@ -5040,8 +5040,7 @@ int SketchObject::addCopy(const std::vector& geoIdList, const Base::Vector3 newconstrVals.push_back(constNew); } else if ((*it)->Type == Sketcher::Angle && clone) { - if (getGeometry((*it)->First)->getTypeId() - == Part::GeomLineSegment::getClassTypeId()) { + if (getGeometry((*it)->First)->is()) { // Angles on a single Element are mapped to parallel // constraints in clone mode Constraint* constNew = (*it)->copy(); @@ -5426,8 +5425,8 @@ int SketchObject::exposeInternalGeometry(int GeoId) const Part::Geometry* geo = getGeometry(GeoId); // Only for supported types - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + if (geo->is() + || geo->is()) { // First we search what has to be restored bool major = false; bool minor = false; @@ -5469,7 +5468,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) std::vector igeo; std::vector icon; - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (geo->is()) { const Part::GeomEllipse* ellipse = static_cast(geo); center = ellipse->getCenter(); @@ -5577,7 +5576,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) return incrgeo;// number of added elements } - else if (geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo->is()) { // First we search what has to be restored bool major = false; bool minor = false; @@ -5692,7 +5691,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) return incrgeo;// number of added elements } - else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { // First we search what has to be restored bool focus = false; bool focus_to_vertex = false; @@ -5779,7 +5778,7 @@ int SketchObject::exposeInternalGeometry(int GeoId) return incrgeo;// number of added elements } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); // First we search what has to be restored @@ -5965,9 +5964,9 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) const Part::Geometry* geo = getGeometry(GeoId); // Only for supported types - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + if (geo->is() + || geo->is() + || geo->is()) { int majorelementindex = -1; int minorelementindex = -1; @@ -6059,7 +6058,7 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) return ndeleted;// number of deleted elements } - else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { // if the focus-to-vertex line is constrained, then never delete the focus // if the line is unconstrained, then the line may be deleted, // in this case the focus may be deleted if unconstrained. @@ -6130,7 +6129,7 @@ int SketchObject::deleteUnusedInternalGeometry(int GeoId, bool delgeoid) return ndeleted;// number of deleted elements } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); @@ -6265,7 +6264,7 @@ bool SketchObject::convertToNURBS(int GeoId) const Part::Geometry* geo = getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) + if (geo->is()) return false; const Part::GeomCurve* geo1 = static_cast(geo); @@ -7295,7 +7294,7 @@ bool SketchObject::evaluateSupport() { // returns false if the shape is broken, null or non-planar App::DocumentObject* link = Support.getValue(); - if (!link || !link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!link || !link->isDerivedFrom()) return false; return true; } @@ -7316,7 +7315,7 @@ void SketchObject::validateExternalLinks() TopoDS_Shape refSubShape; try { - if (Obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (Obj->isDerivedFrom()) { const Part::Datum* datum = static_cast(Obj); refSubShape = datum->getShape(); } @@ -7421,11 +7420,11 @@ void SketchObject::rebuildExternalGeometry() TopoDS_Shape refSubShape; - if (Obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (Obj->isDerivedFrom()) { const Part::Datum* datum = static_cast(Obj); refSubShape = datum->getShape(); } - else if (Obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (Obj->isDerivedFrom()) { try { const Part::Feature* refObj = static_cast(Obj); const Part::TopoShape& refShape = refObj->Shape.getShape(); @@ -7435,7 +7434,7 @@ void SketchObject::rebuildExternalGeometry() throw Base::CADKernelError(e.GetMessageString()); } } - else if (Obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + else if (Obj->isDerivedFrom()) { const App::Plane* pl = static_cast(Obj); Base::Placement plm = pl->Placement.getValue(); Base::Vector3d base = plm.getPosition(); @@ -8039,25 +8038,25 @@ void SketchObject::rebuildVertexIndex() ++it, i++) { if (i > imax) i = -getExternalGeometryCount(); - if ((*it)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); } - else if ((*it)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::end); } - else if ((*it)->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8065,7 +8064,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8073,7 +8072,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8081,7 +8080,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8089,7 +8088,7 @@ void SketchObject::rebuildVertexIndex() VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::mid); } - else if ((*it)->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if ((*it)->is()) { VertexId2GeoId.push_back(i); VertexId2PosId.push_back(PointPos::start); VertexId2GeoId.push_back(i); @@ -8970,7 +8969,7 @@ void SketchObject::migrateSketch() bool oldconstr = ext->getConstruction(); - if (g->getTypeId() == Part::GeomPoint::getClassTypeId() + if (g->is() && !gf->isInternalAligned()) oldconstr = true; @@ -8986,8 +8985,8 @@ void SketchObject::migrateSketch() auto constraints = Constraints.getValues(); auto geometries = getInternalGeometry(); - auto parabolafound = std::find_if(geometries.begin(), geometries.end(), [](auto g) { - return g->getTypeId() == Part::GeomArcOfParabola::getClassTypeId(); + auto parabolafound = std::find_if(geometries.begin(), geometries.end(), [](Part::Geometry* g) { + return g->is(); }); if (parabolafound != geometries.end()) { @@ -9219,7 +9218,7 @@ int SketchObject::port_reversedExternalArcs(bool justAnalyze) && (posId == Sketcher::PointPos::start || posId == Sketcher::PointPos::end)) { // we are dealing with a link to an endpoint of external geom Part::Geometry* g = this->ExternalGeo[-geoId - 1]; - if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (g->is()) { const Part::GeomArcOfCircle* segm = static_cast(g); if (segm->isReversed()) { diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index a91c05fb82..79f814ce43 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -87,7 +87,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) Part::Geometry* geo = static_cast(pcObj)->getGeometryPtr(); int ret; // An arc created with Part.Arc will be converted into a Part.ArcOfCircle - if (geo->getTypeId() == Part::GeomTrimmedCurve::getClassTypeId()) { + if (geo->is()) { Handle(Geom_TrimmedCurve) trim = Handle(Geom_TrimmedCurve)::DownCast(geo->handle()); Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(trim->BasisCurve()); Handle(Geom_Ellipse) ellipse = Handle(Geom_Ellipse)::DownCast(trim->BasisCurve()); @@ -110,15 +110,11 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) return nullptr; } } - else if (geo->getTypeId() == Part::GeomPoint::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() - || geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is()) { ret = this->getSketchObjectPtr()->addGeometry(geo, isConstruction); } else { @@ -139,7 +135,7 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) Part::Geometry* geo = static_cast((*it).ptr())->getGeometryPtr(); // An arc created with Part.Arc will be converted into a Part.ArcOfCircle - if (geo->getTypeId() == Part::GeomTrimmedCurve::getClassTypeId()) { + if (geo->is()) { Handle(Geom_TrimmedCurve) trim = Handle(Geom_TrimmedCurve)::DownCast(geo->handle()); Handle(Geom_Circle) circle = Handle(Geom_Circle)::DownCast(trim->BasisCurve()); @@ -166,15 +162,11 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args) return nullptr; } } - else if (geo->getTypeId() == Part::GeomPoint::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() - || geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is() || geo->is() + || geo->is()) { geoList.push_back(geo); } else { diff --git a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp index 38e1053232..b5844654e5 100644 --- a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp +++ b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp @@ -197,7 +197,7 @@ void CmdSketcherToggleConstruction::activated(int iMsg) auto geo = Obj->getGeometry(geoId); - if (geo && geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo && geo->is()) { // issue the actual commands to toggle Gui::cmdAppObjectArgs(selection[0].getObject(), "toggleConstruction(%d) ", diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 1078587904..1077a9e330 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -238,8 +238,8 @@ bool SketcherGui::calculateAngle(Sketcher::SketchObject* Obj, int& GeoId1, int& const Part::Geometry* geom1 = Obj->getGeometry(GeoId1); const Part::Geometry* geom2 = Obj->getGeometry(GeoId2); - if (!(geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) || - !(geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId())) { + if (!(geom1->is()) || + !(geom2->is())) { return false; } @@ -787,8 +787,7 @@ int SketchSelection::setUp() // only one sketch with its subelements are allowed to be selected if (selection.size() == 1) { // if one selectetd, only sketch allowed. should be done by activity of command - if (!selection[0].getObject()->getTypeId().isDerivedFrom( - Sketcher::SketchObject::getClassTypeId())) { + if (!selection[0].getObject()->isDerivedFrom()) { ErrorMsg = QObject::tr("Only sketch and its support are allowed to be selected."); return -1; } @@ -796,8 +795,7 @@ int SketchSelection::setUp() SketchSubNames = selection[0].getSubNames(); } else if (selection.size() == 2) { - if (selection[0].getObject()->getTypeId().isDerivedFrom( - Sketcher::SketchObject::getClassTypeId())) { + if (selection[0].getObject()->isDerivedFrom()) { SketchObj = static_cast(selection[0].getObject()); // check if the none sketch object is the support of the sketch if (selection[1].getObject() != SketchObj->Support.getValue()) { @@ -805,13 +803,11 @@ int SketchSelection::setUp() return -1; } // assume always a Part::Feature derived object as support - assert(selection[1].getObject()->getTypeId().isDerivedFrom( - Part::Feature::getClassTypeId())); + assert(selection[1].getObject()->isDerivedFrom()); SketchSubNames = selection[0].getSubNames(); SupportSubNames = selection[1].getSubNames(); } - else if (selection[1].getObject()->getTypeId().isDerivedFrom( - Sketcher::SketchObject::getClassTypeId())) { + else if (selection[1].getObject()->isDerivedFrom()) { SketchObj = static_cast(selection[1].getObject()); // check if the none sketch object is the support of the sketch if (selection[0].getObject() != SketchObj->Support.getValue()) { @@ -819,8 +815,7 @@ int SketchSelection::setUp() return -1; } // assume always a Part::Feature derived object as support - assert(selection[0].getObject()->getTypeId().isDerivedFrom( - Part::Feature::getClassTypeId())); + assert(selection[0].getObject()->isDerivedFrom()); SketchSubNames = selection[1].getSubNames(); SupportSubNames = selection[0].getSubNames(); } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index e16b1448ef..3fa34fcbed 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -84,7 +84,7 @@ bool findBSplineAndKnotIndex(Sketcher::SketchObject* Obj, // TODO: what to do if multiple splines have the same first/last point? const Part::Geometry* geo = Obj->getGeometry(knotGeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { splineGeoId = knotGeoId; switch (knotPosId) { case Sketcher::PointPos::start: @@ -224,7 +224,7 @@ void CmdSketcherIncreaseDegree::activated(int iMsg) int GeoId = std::atoi(SubNames[i].substr(4, 4000).c_str()) - 1; const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { Gui::cmdAppObjectArgs(selection[0].getObject(), "increaseBSplineDegree(%d) ", GeoId); @@ -303,7 +303,7 @@ void CmdSketcherDecreaseDegree::activated(int iMsg) int GeoId = std::atoi(SubNames[i].substr(4, 4000).c_str()) - 1; const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { Gui::cmdAppObjectArgs(selection[0].getObject(), "decreaseBSplineDegree(%d) ", GeoId); @@ -928,7 +928,7 @@ void CmdSketcherInsertKnot::activated(int iMsg) int GeoId = std::atoi(SubNames[0].substr(4, 4000).c_str()) - 1; const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { ActivateBSplineHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineInsertKnot(Obj, GeoId)); } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index e305473887..f0c5e983c1 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -796,11 +796,11 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) auto noInternalGeo = [&Obj](const auto& GeoId) { const Part::Geometry* geo = Obj->getGeometry(GeoId); bool hasInternalGeo = geo - && (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()); + && (geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is()); return !hasInternalGeo;// so it's removed }; @@ -932,7 +932,7 @@ void CmdSketcherSymmetry::activated(int iMsg) // reference can be external or non-external LastGeo = Obj->getGeometry(LastGeoId); // Only for supported types - if (LastGeo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) + if (LastGeo->is()) lastgeotype = line; else lastgeotype = invalid; @@ -950,7 +950,7 @@ void CmdSketcherSymmetry::activated(int iMsg) Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; LastPointPos = Sketcher::PointPos::start; lastgeotype = point; @@ -1316,7 +1316,7 @@ void SketcherCopy::activate(SketcherCopy::Op op) int GeoId; Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; LastPointPos = Sketcher::PointPos::start; // points to copy @@ -1361,8 +1361,8 @@ void SketcherCopy::activate(SketcherCopy::Op op) // then make the start point of the last element the copy reference (if it exists, if not the // center point) if (LastPointPos == Sketcher::PointPos::none) { - if (LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() - || LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (LastGeo->is() + || LastGeo->is()) { LastPointPos = Sketcher::PointPos::mid; } else { @@ -1919,7 +1919,7 @@ void CmdSketcherRectangularArray::activated(int iMsg) int GeoId; Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; LastPointPos = Sketcher::PointPos::start; // points to copy @@ -1964,8 +1964,8 @@ void CmdSketcherRectangularArray::activated(int iMsg) // then make the start point of the last element the copy reference (if it exists, if not the // center point) if (LastPointPos == Sketcher::PointPos::none) { - if (LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() - || LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (LastGeo->is() + || LastGeo->is()) { LastPointPos = Sketcher::PointPos::mid; } else { @@ -2207,7 +2207,7 @@ void CmdSketcherRemoveAxesAlignment::activated(int iMsg) int GeoId; Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); - if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (Obj->getGeometry(GeoId)->is()) { LastGeoId = GeoId; // points to copy if (LastGeoId >= 0) { diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index a7ded46a2c..d5ac7d55f4 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -648,7 +648,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested // ensure geom exists in case object was called before preselection is updated if (geom) { GeoId = preSelCrv; - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* line = static_cast(geom); hitShapeDir = line->getEndPoint() - line->getStartPoint(); } @@ -768,7 +768,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested for (std::vector::const_iterator it = geomlist.begin(); it != geomlist.end(); ++it, i++) { - if ((*it)->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if ((*it)->is()) { const Part::GeomCircle* circle = static_cast((*it)); Base::Vector3d center = circle->getCenter(); @@ -790,7 +790,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested tangDeviation = projDist; } } - else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomEllipse* ellipse = static_cast((*it)); @@ -819,7 +819,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested tangDeviation = error; } } - else if ((*it)->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomArcOfCircle* arc = static_cast((*it)); Base::Vector3d center = arc->getCenter(); @@ -850,7 +850,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector& suggested } } } - else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomArcOfEllipse* aoe = static_cast((*it)); Base::Vector3d center = aoe->getCenter(); @@ -993,8 +993,7 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& // ellipse tangency support using construction elements (lines) if (geom1 && geom2 - && (geom1->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomEllipse::getClassTypeId())) { + && (geom1->is() || geom2->is())) { if (geom1->getTypeId() != Part::GeomEllipse::getClassTypeId()) { std::swap(geoId1, geoId2); @@ -1004,10 +1003,9 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& geom1 = Obj->getGeometry(geoId1); geom2 = Obj->getGeometry(geoId2); - if (geom2->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom2->is() || geom2->is() + || geom2->is() + || geom2->is()) { // in all these cases an intermediate element is needed makeTangentToEllipseviaNewPoint( Obj, @@ -1021,8 +1019,8 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& // arc of ellipse tangency support using external elements if (geom1 && geom2 - && (geom1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId())) { + && (geom1->is() + || geom2->is())) { if (geom1->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId()) { std::swap(geoId1, geoId2); @@ -1032,9 +1030,8 @@ void DrawSketchHandler::createAutoConstraints(const std::vector& geom1 = Obj->getGeometry(geoId1); geom2 = Obj->getGeometry(geoId2); - if (geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geom2->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom2->is() || geom2->is() + || geom2->is()) { // in all these cases an intermediate element is needed makeTangentToArcOfEllipseviaNewPoint( Obj, diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h index 073b206fae..9121079636 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerCarbonCopy.h @@ -160,7 +160,7 @@ public: throw Base::ValueError("Sketcher: Carbon Copy: Invalid object in selection"); } - if (obj->getTypeId() == Sketcher::SketchObject::getClassTypeId()) { + if (obj->is()) { try { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create a carbon copy")); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h index 4d1560f70a..98d774d28d 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerExtend.h @@ -68,8 +68,7 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is() || geom->is()) { return true; } } @@ -113,7 +112,7 @@ public: Q_UNUSED(onSketchPos); if (Mode == STATUS_SEEK_Second) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(BaseGeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geom); // project point to the existing curve @@ -159,7 +158,7 @@ public: } drawEdit(EditCurve); } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { const Part::GeomArcOfCircle* arc = static_cast(geom); Base::Vector3d center = arc->getCenter(); double radius = arc->getRadius(); @@ -254,7 +253,7 @@ public: BaseGeoId = getPreselectCurve(); if (BaseGeoId > -1) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(BaseGeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* seg = static_cast(geom); Base::Vector3d start3d = seg->getStartPoint(); @@ -266,7 +265,7 @@ public: ExtendFromStart = SavedExtendFromStart; Mode = STATUS_SEEK_Second; } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { const Part::GeomArcOfCircle* arc = static_cast(geom); double start, end; diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h index 0f9dfcca3a..3048b68246 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerExternal.h @@ -106,8 +106,7 @@ public: || (element.size() > 4 && element.substr(0, 4) == "Face")) { return true; } - if (pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) - || pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (pObj->isDerivedFrom() || pObj->isDerivedFrom()) { return true; } return false; @@ -156,8 +155,7 @@ public: throw Base::ValueError("Sketcher: External geometry: Invalid object in selection"); } std::string subName(msg.pSubName); - if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId()) - || obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) + if (obj->isDerivedFrom() || obj->isDerivedFrom() || (subName.size() > 4 && subName.substr(0, 4) == "Edge") || (subName.size() > 6 && subName.substr(0, 6) == "Vertex") || (subName.size() > 4 && subName.substr(0, 4) == "Face")) { diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h index c479169914..ed2685a507 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerFillet.h @@ -63,7 +63,7 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomBoundedCurve::getClassTypeId())) { + if (geom->isDerivedFrom()) { return true; } } @@ -76,8 +76,7 @@ public: if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) { const Part::Geometry* geom1 = Sketch->getGeometry(GeoIdList[0]); const Part::Geometry* geom2 = Sketch->getGeometry(GeoIdList[1]); - if (geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom1->is() && geom2->is()) { return true; } } @@ -132,7 +131,7 @@ public: Sketcher::PointPos PosId = Sketcher::PointPos::none; sketchgui->getSketchObject()->getGeoVertexIndex(VtId, GeoId, PosId); const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() + if (geom->is() && (PosId == Sketcher::PointPos::start || PosId == Sketcher::PointPos::end)) { // guess fillet radius @@ -150,8 +149,7 @@ public: sketchgui->getSketchObject()->getGeometry(GeoIdList[1]); construction = Sketcher::GeometryFacade::getConstruction(geom1) && Sketcher::GeometryFacade::getConstruction(geom2); - if (geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geom2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom1->is() && geom2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geom1); const Part::GeomLineSegment* lineSeg2 = @@ -212,7 +210,7 @@ public: int GeoId = getPreselectCurve(); if (GeoId > -1) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomBoundedCurve::getClassTypeId())) { + if (geom->isDerivedFrom()) { if (Mode == STATUS_SEEK_First) { firstCurve = GeoId; firstPos = onSketchPos; @@ -240,8 +238,7 @@ public: double radius = 0; - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geom1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is() && geom1->is()) { // guess fillet radius const Part::GeomLineSegment* lineSeg1 = static_cast( diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h index 1adf4a1895..299f196d96 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerLineSet.h @@ -126,8 +126,7 @@ public: if (SegmentMode == SEGMENT_MODE_Line) { switch (TransitionMode) { case TRANSITION_MODE_Free: - if (geom->getTypeId() - == Part::GeomArcOfCircle::getClassTypeId()) { // 3rd mode + if (geom->is()) { // 3rd mode SegmentMode = SEGMENT_MODE_Arc; TransitionMode = TRANSITION_MODE_Tangent; } @@ -136,7 +135,7 @@ public: } break; case TRANSITION_MODE_Perpendicular_L: // 2nd mode - if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is()) { TransitionMode = TRANSITION_MODE_Free; } else { @@ -144,8 +143,7 @@ public: } break; case TRANSITION_MODE_Tangent: - if (geom->getTypeId() - == Part::GeomArcOfCircle::getClassTypeId()) { // 1st mode + if (geom->is()) { // 1st mode TransitionMode = TRANSITION_MODE_Perpendicular_L; } else { // 3rd mode @@ -168,7 +166,7 @@ public: break; default: // 6th mode (Perpendicular_R) + unexpected mode SegmentMode = SEGMENT_MODE_Line; - if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is()) { TransitionMode = TRANSITION_MODE_Tangent; } else { @@ -351,15 +349,14 @@ public: if (sugConstr1[i].Type == Sketcher::Coincident) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(sugConstr1[i].GeoId); - if ((geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) + if ((geom->is() || geom->is()) && (sugConstr1[i].PosId == Sketcher::PointPos::start || sugConstr1[i].PosId == Sketcher::PointPos::end)) { previousCurve = sugConstr1[i].GeoId; previousPosId = sugConstr1[i].PosId; updateTransitionData(previousCurve, previousPosId); // -> dirVec, EditCurve[0] - if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geom->is()) { TransitionMode = TRANSITION_MODE_Tangent; SnapMode = SNAP_MODE_Free; } @@ -794,7 +791,7 @@ protected: // Use updated startPoint/endPoint as autoconstraints can modify the position const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geom->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geom); dirVec.Set(lineSeg->getEndPoint().x - lineSeg->getStartPoint().x, lineSeg->getEndPoint().y - lineSeg->getStartPoint().y, @@ -808,7 +805,7 @@ protected: EditCurve[0] = Base::Vector2d(lineSeg->getEndPoint().x, lineSeg->getEndPoint().y); } } - else if (geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geom->is()) { const Part::GeomArcOfCircle* arcSeg = static_cast(geom); if (PosId == Sketcher::PointPos::start) { EditCurve[0] = Base::Vector2d(arcSeg->getStartPoint(/*emulateCCW=*/true).x, diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h index 77572ab080..46c82dd7c1 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h @@ -65,11 +65,10 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() + if (geom->is() || geom->is() + || geom->is() || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + || geom->is()) { return true; } } @@ -115,11 +114,10 @@ public: int curveGeoId = getPreselectCurve(); if (curveGeoId >= 0) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(curveGeoId); - if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() + if (geom->is() || geom->is() + || geom->is() || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + || geom->is()) { GeoId = curveGeoId; } } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h index 041215bb35..7ee7a490d5 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerTrimming.h @@ -67,10 +67,8 @@ public: int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1; Sketcher::SketchObject* Sketch = static_cast(object); const Part::Geometry* geom = Sketch->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomTrimmedCurve::getClassTypeId()) - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geom->isDerivedFrom() || geom->is() + || geom->is() || geom->is()) { // We do not trim internal geometry of complex geometries if (Sketcher::GeometryFacade::isInternalType(geom, Sketcher::InternalType::None)) { return true; @@ -146,10 +144,8 @@ public: int GeoId = getPreselectCurve(); if (GeoId > -1) { const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(GeoId); - if (geom->getTypeId().isDerivedFrom(Part::GeomTrimmedCurve::getClassTypeId()) - || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geom->isDerivedFrom() || geom->is() + || geom->is() || geom->is()) { try { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Trim edge")); Gui::cmdAppObjectArgs(sketchgui->getObject(), diff --git a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp index 8445600800..68b5bc2b8c 100644 --- a/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp +++ b/src/Mod/Sketcher/Gui/EditModeConstraintCoinManager.cpp @@ -217,7 +217,7 @@ Restart: Base::Vector3d dir; Base::Vector3d norm; - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); @@ -229,7 +229,7 @@ Restart: norm = Base::Vector3d(-dir.y, dir.x, 0); } - else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if (geo->is()) { const Part::GeomBSplineCurve* bsp = static_cast(geo); midpos = Base::Vector3d(0, 0, 0); @@ -258,14 +258,14 @@ Restart: double angle, angleplus = 0.; // angle = rotation of object as a whole; angleplus // = arc angle (t parameter for ellipses). - if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); ra = circle->getRadius(); angle = M_PI / 4; midpos = circle->getCenter(); } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); ra = arc->getRadius(); @@ -274,7 +274,7 @@ Restart: angle = (startangle + endangle) / 2; midpos = arc->getCenter(); } - else if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomEllipse* ellipse = static_cast(geo); ra = ellipse->getMajorRadius(); @@ -284,7 +284,7 @@ Restart: angleplus = M_PI / 4; midpos = ellipse->getCenter(); } - else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfEllipse* aoe = static_cast(geo); ra = aoe->getMajorRadius(); @@ -296,8 +296,7 @@ Restart: angleplus = (startangle + endangle) / 2; midpos = aoe->getCenter(); } - else if (geo->getTypeId() - == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo); ra = aoh->getMajorRadius(); @@ -309,8 +308,7 @@ Restart: angleplus = (startangle + endangle) / 2; midpos = aoh->getCenter(); } - else if (geo->getTypeId() - == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo); ra = aop->getFocal(); @@ -325,9 +323,8 @@ Restart: break; } - if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + if (geo->is() || geo->is() + || geo->is()) { Base::Vector3d majDir, minDir, rvec; majDir = Base::Vector3d(cos(angle), @@ -467,7 +464,7 @@ Restart: } else if (Constr->FirstPos == Sketcher::PointPos::none) { - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); midpos1 = ((lineSeg1->getEndPoint() + lineSeg1->getStartPoint()) / 2); @@ -475,7 +472,7 @@ Restart: (lineSeg1->getEndPoint() - lineSeg1->getStartPoint()).Normalize(); norm1 = Base::Vector3d(-dir1.y, dir1.x, 0.); } - else if (geo1->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo1); double startangle, endangle, midangle; @@ -485,7 +482,7 @@ Restart: dir1 = Base::Vector3d(-norm1.y, norm1.x, 0); midpos1 = arc->getCenter() + arc->getRadius() * norm1; } - else if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomCircle* circle = static_cast(geo1); norm1 = Base::Vector3d(cos(M_PI / 4), sin(M_PI / 4), 0); @@ -496,7 +493,7 @@ Restart: break; } - if (geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo2->is()) { const Part::GeomLineSegment* lineSeg2 = static_cast(geo2); midpos2 = ((lineSeg2->getEndPoint() + lineSeg2->getStartPoint()) / 2); @@ -504,7 +501,7 @@ Restart: (lineSeg2->getEndPoint() - lineSeg2->getStartPoint()).Normalize(); norm2 = Base::Vector3d(-dir2.y, dir2.x, 0.); } - else if (geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo2); double startangle, endangle, midangle; @@ -514,7 +511,7 @@ Restart: dir2 = Base::Vector3d(-norm2.y, norm2.x, 0); midpos2 = arc->getCenter() + arc->getRadius() * norm2; } - else if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomCircle* circle = static_cast(geo2); norm2 = Base::Vector3d(cos(M_PI / 4), sin(M_PI / 4), 0); @@ -576,14 +573,14 @@ Restart: angle2plus = 0.; // angle1 = rotation of object as a whole; angle1plus = arc // angle (t parameter for ellipses). - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo1->is()) { const Part::GeomCircle* circle = static_cast(geo1); r1a = circle->getRadius(); angle1 = M_PI / 4; midpos1 = circle->getCenter(); } - else if (geo1->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo1); r1a = arc->getRadius(); @@ -592,7 +589,7 @@ Restart: angle1 = (startangle + endangle) / 2; midpos1 = arc->getCenter(); } - else if (geo1->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomEllipse* ellipse = static_cast(geo1); r1a = ellipse->getMajorRadius(); @@ -602,8 +599,7 @@ Restart: angle1plus = M_PI / 4; midpos1 = ellipse->getCenter(); } - else if (geo1->getTypeId() - == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfEllipse* aoe = static_cast(geo1); r1a = aoe->getMajorRadius(); @@ -615,8 +611,7 @@ Restart: angle1plus = (startangle + endangle) / 2; midpos1 = aoe->getCenter(); } - else if (geo1->getTypeId() - == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo1); r1a = aoh->getMajorRadius(); @@ -628,8 +623,7 @@ Restart: angle1plus = (startangle + endangle) / 2; midpos1 = aoh->getCenter(); } - else if (geo1->getTypeId() - == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo1->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo1); r1a = aop->getFocal(); @@ -644,14 +638,14 @@ Restart: break; } - if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo2->is()) { const Part::GeomCircle* circle = static_cast(geo2); r2a = circle->getRadius(); angle2 = M_PI / 4; midpos2 = circle->getCenter(); } - else if (geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo2); r2a = arc->getRadius(); @@ -660,7 +654,7 @@ Restart: angle2 = (startangle + endangle) / 2; midpos2 = arc->getCenter(); } - else if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomEllipse* ellipse = static_cast(geo2); r2a = ellipse->getMajorRadius(); @@ -670,8 +664,7 @@ Restart: angle2plus = M_PI / 4; midpos2 = ellipse->getCenter(); } - else if (geo2->getTypeId() - == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfEllipse* aoe = static_cast(geo2); r2a = aoe->getMajorRadius(); @@ -683,8 +676,7 @@ Restart: angle2plus = (startangle + endangle) / 2; midpos2 = aoe->getCenter(); } - else if (geo2->getTypeId() - == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfHyperbola* aoh = static_cast(geo2); r2a = aoh->getMajorRadius(); @@ -696,8 +688,7 @@ Restart: angle2plus = (startangle + endangle) / 2; midpos2 = aoh->getCenter(); } - else if (geo2->getTypeId() - == Part::GeomArcOfParabola::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfParabola* aop = static_cast(geo2); r2a = aop->getFocal(); @@ -712,8 +703,7 @@ Restart: break; } - if (geo1->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() + if (geo1->is() || geo1->is() || geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { @@ -741,8 +731,7 @@ Restart: } - if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() + if (geo2->is() || geo2->is() || geo2->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { @@ -833,7 +822,7 @@ Restart: else if (Constr->Second != GeoEnum::GeoUndef) { const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->Second); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); Base::Vector3d l2p1 = lineSeg->getStartPoint(); @@ -848,9 +837,8 @@ Restart: else { const Part::Geometry* geo1 = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo1->getTypeId() - == Part::GeomCircle::getClassTypeId()) { // circle to line - // distance + if (geo1->is()) { // circle to line + // distance const Part::GeomCircle* circleSeg = static_cast(geo1); Base::Vector3d ct = circleSeg->getCenter(); @@ -865,12 +853,11 @@ Restart: } } } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::Geometry* geo1 = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo1->getTypeId() - == Part::GeomCircle::getClassTypeId()) { // circle to circle - // distance + if (geo1->is()) { // circle to circle + // distance const Part::GeomCircle* circleSeg1 = static_cast(geo1); auto circleSeg2 = static_cast(geo); @@ -895,8 +882,7 @@ Restart: else if (Constr->First != GeoEnum::GeoUndef) { const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() - == Part::GeomLineSegment::getClassTypeId()) { // segment distance + if (geo->is()) { // segment distance const Part::GeomLineSegment* lineSeg = static_cast(geo); pnt1 = lineSeg->getStartPoint(); @@ -1009,8 +995,8 @@ Restart: const Part::Geometry* geo2 = geolistfacade.getGeometryFromGeoId(Constr->Second); - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is() + && geo2->is()) { const Part::GeomLineSegment* lineSeg1 = static_cast(geo1); const Part::GeomLineSegment* lineSeg2 = @@ -1059,17 +1045,17 @@ Restart: break; } - else if (geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo2->is()) { std::swap(geo1, geo2); } - if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo1); Base::Vector3d dir = (lineSeg->getEndPoint() - lineSeg->getStartPoint()).Normalize(); Base::Vector3d norm(-dir.y, dir.x, 0); - if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo2->is()) { const Part::GeomCircle* circle = static_cast(geo2); // tangency between a line and a circle @@ -1079,12 +1065,11 @@ Restart: pos = lineSeg->getStartPoint() + dir * length; relPos = norm * 1; // TODO Huh? } - else if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo2->getTypeId() - == Part::GeomArcOfEllipse::getClassTypeId()) { + else if (geo2->is() + || geo2->is()) { Base::Vector3d center; - if (geo2->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + if (geo2->is()) { const Part::GeomEllipse* ellipse = static_cast(geo2); center = ellipse->getCenter(); @@ -1101,7 +1086,7 @@ Restart: pos = lineSeg->getStartPoint() + dir * length; relPos = norm * 1; } - else if (geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo2->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo2); // tangency between a line and an arc @@ -1112,8 +1097,7 @@ Restart: } } - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId() - && geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo1->is() && geo2->is()) { const Part::GeomCircle* circle1 = static_cast(geo1); const Part::GeomCircle* circle2 = @@ -1124,12 +1108,11 @@ Restart: pos = circle1->getCenter() + dir * circle1->getRadius(); relPos = dir * 1; } - else if (geo2->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo2->is()) { std::swap(geo1, geo2); } - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId() - && geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo1->is() && geo2->is()) { const Part::GeomCircle* circle = static_cast(geo1); const Part::GeomArcOfCircle* arc = @@ -1140,8 +1123,8 @@ Restart: pos = circle->getCenter() + dir * circle->getRadius(); relPos = dir * 1; } - else if (geo1->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - && geo2->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo1->is() + && geo2->is()) { const Part::GeomArcOfCircle* arc1 = static_cast(geo1); const Part::GeomArcOfCircle* arc2 = @@ -1282,7 +1265,7 @@ Restart: else if (Constr->First != GeoEnum::GeoUndef) { const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); p0 = Base::convertTo( @@ -1292,7 +1275,7 @@ Restart: startangle = 0.; range = atan2(dir.y, dir.x); } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); p0 = Base::convertTo(arc->getCenter()); @@ -1334,7 +1317,7 @@ Restart: const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); double radius = arc->getRadius(); @@ -1348,7 +1331,7 @@ Restart: pnt1 = center - radius * Base::Vector3d(cos(angle), sin(angle), 0.); pnt2 = center + radius * Base::Vector3d(cos(angle), sin(angle), 0.); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); double radius = circle->getRadius(); @@ -1400,7 +1383,7 @@ Restart: const Part::Geometry* geo = geolistfacade.getGeometryFromGeoId(Constr->First); - if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); double radius = arc->getRadius(); @@ -1413,7 +1396,7 @@ Restart: pnt1 = arc->getCenter(); pnt2 = pnt1 + radius * Base::Vector3d(cos(angle), sin(angle), 0.); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); auto gf = GeometryFacade::getFacade(geo); @@ -1862,8 +1845,8 @@ void EditModeConstraintCoinManager::rebuildConstraintNodes( "EditModeConstraintCoinManager", "Tangent constraint references non-existing geometry\n"); } - else if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if (geo1->is() + && geo2->is()) { // #define CONSTRAINT_SEPARATOR_INDEX_SECOND_TRANSLATION 4 sep->addChild(new SoZoomTranslation()); // #define CONSTRAINT_SEPARATOR_INDEX_SECOND_ICON 5 @@ -2215,8 +2198,8 @@ void EditModeConstraintCoinManager::drawConstraintIcons(const GeoListFacade& geo case Tangent: { // second icon is available only for colinear line segments const Part::Geometry* geo1 = geolistfacade.getGeometryFromGeoId(constraint->First); const Part::Geometry* geo2 = geolistfacade.getGeometryFromGeoId(constraint->Second); - if (geo1 && geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() && geo2 - && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo1 && geo1->is() && geo2 + && geo2->is()) { multipleIcons = true; } } break; diff --git a/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp b/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp index 263cc4c423..9b106e45b8 100644 --- a/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp +++ b/src/Mod/Sketcher/Gui/EditModeInformationOverlayCoinConverter.cpp @@ -60,7 +60,7 @@ EditModeInformationOverlayCoinConverter::EditModeInformationOverlayCoinConverter void EditModeInformationOverlayCoinConverter::convert(const Part::Geometry* geometry, int geoid) { - if (geometry->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geometry->is()) { // at this point all calculations relate to BSplineCurves calculate(geometry, geoid); calculate(geometry, geoid); @@ -74,7 +74,7 @@ void EditModeInformationOverlayCoinConverter::convert(const Part::Geometry* geom addUpdateNode(knotMultiplicity); addUpdateNode(poleWeights); } - else if (geometry->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geometry->is()) { // at this point all calculations relate to ArcOfCircle calculate(geometry, geoid); addUpdateNode(circleHelper); diff --git a/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp b/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp index d2179d90d1..ba9a1ebca0 100644 --- a/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp +++ b/src/Mod/Sketcher/Gui/PropertyConstraintListItem.cpp @@ -147,7 +147,7 @@ void PropertyConstraintListItem::assignProperty(const App::Property* prop) // Hint: When renaming a constraint that was unnamed before then it can happen that // a constraint appears twice in the property editor, one time in this group and a // second time inside the Unnamed group - if (!prop->getTypeId().isDerivedFrom(Sketcher::PropertyConstraintList::getClassTypeId())) { + if (!prop->isDerivedFrom()) { return; } @@ -240,8 +240,7 @@ void PropertyConstraintListItem::assignProperty(const App::Property* prop) QVariant PropertyConstraintListItem::value(const App::Property* prop) const { - assert(prop - && prop->getTypeId().isDerivedFrom(Sketcher::PropertyConstraintList::getClassTypeId())); + assert(prop && prop->isDerivedFrom()); PropertyConstraintListItem* self = const_cast(this); diff --git a/src/Mod/Sketcher/Gui/SnapManager.cpp b/src/Mod/Sketcher/Gui/SnapManager.cpp index 02c3a6cc55..399688add4 100644 --- a/src/Mod/Sketcher/Gui/SnapManager.cpp +++ b/src/Mod/Sketcher/Gui/SnapManager.cpp @@ -283,13 +283,13 @@ bool SnapManager::snapToObject(double& x, double& y) } // If it is a line, then we check if we need to snap to the middle. - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* line = static_cast(geo); snapToLineMiddle(pointToOverride, line); } // If it is an arc, then we check if we need to snap to the middle (not the center). - if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); snapToArcMiddle(pointToOverride, arc); } diff --git a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp index 0db1bb55d6..4718f260af 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherValidation.cpp @@ -281,7 +281,7 @@ void SketcherValidation::onFindReversedClicked() Part::Geometry* g = geom[i]; // only arcs of circles need to be repaired. Arcs of ellipse were so broken there should be // nothing to repair from. - if (g->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + if (g->is()) { const Part::GeomArcOfCircle* segm = static_cast(g); if (segm->isReversed()) { points.push_back(segm->getStartPoint(/*emulateCCW=*/true)); diff --git a/src/Mod/Sketcher/Gui/Utils.cpp b/src/Mod/Sketcher/Gui/Utils.cpp index 8f8bfb0c77..c6f24d716c 100644 --- a/src/Mod/Sketcher/Gui/Utils.cpp +++ b/src/Mod/Sketcher/Gui/Utils.cpp @@ -50,47 +50,47 @@ using namespace Sketcher; bool Sketcher::isCircle(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomCircle::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfCircle(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfCircle::getClassTypeId(); + return geom.is(); } bool Sketcher::isEllipse(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomEllipse::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfEllipse(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfEllipse::getClassTypeId(); + return geom.is(); } bool Sketcher::isLineSegment(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomLineSegment::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfHyperbola(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId(); + return geom.is(); } bool Sketcher::isArcOfParabola(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomArcOfParabola::getClassTypeId(); + return geom.is(); } bool Sketcher::isBSplineCurve(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomBSplineCurve::getClassTypeId(); + return geom.is(); } bool Sketcher::isPoint(const Part::Geometry& geom) { - return geom.getTypeId() == Part::GeomPoint::getClassTypeId(); + return geom.is(); } bool SketcherGui::tryAutoRecompute(Sketcher::SketchObject* obj, bool& autoremoveredundants) @@ -219,7 +219,7 @@ std::vector SketcherGui::getGeoIdsOfEdgesFromNames(const Sketcher::SketchOb Sketcher::PointPos PosId; Obj->getGeoVertexIndex(VtId, GeoId, PosId); const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo->is()) { geoids.push_back(GeoId); } } @@ -295,7 +295,7 @@ bool SketcherGui::isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, P return true; } const Part::Geometry* geo = Obj->getGeometry(GeoId); - if (geo->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if (geo->is()) { return true; } else if (PosId == Sketcher::PointPos::mid) { @@ -323,7 +323,7 @@ bool SketcherGui::isBsplineKnotOrEndPoint(const Sketcher::SketchObject* Obj, const Part::Geometry* geo = Obj->getGeometry(GeoId); // end points of B-Splines are also knots - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId() + if (geo->is() && (PosId == Sketcher::PointPos::start || PosId == Sketcher::PointPos::end)) { return true; } @@ -349,7 +349,7 @@ bool SketcherGui::IsPointAlreadyOnCurve(int GeoIdCurve, // implemented. (Ajinkya) if (isBsplineKnot(Obj, GeoIdPoint)) { const Part::Geometry* geoCurve = Obj->getGeometry(GeoIdCurve); - if (geoCurve->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geoCurve->is()) { const std::vector& constraints = Obj->Constraints.getValues(); for (const auto& constraint : constraints) { if (constraint->Type == Sketcher::ConstraintType::InternalAlignment diff --git a/src/Mod/Sketcher/Gui/ViewProviderPython.cpp b/src/Mod/Sketcher/Gui/ViewProviderPython.cpp index 1200c73cfc..1e9cb8c0ef 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderPython.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderPython.cpp @@ -58,13 +58,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/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 8712ff1489..d0910a8f58 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -1056,14 +1056,14 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe case STATUS_SKETCH_DragCurve: if (drag.isDragCurveValid()) { const Part::Geometry* geo = getSketchObject()->getGeometry(drag.DragCurve); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomCircle::getClassTypeId() - || geo->getTypeId() == Part::GeomEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() - || geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is() + || geo->is()) { getDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Drag Curve")); auto geo = getSketchObject()->getGeometry(drag.DragCurve); @@ -1492,8 +1492,8 @@ bool ViewProviderSketch::mouseMove(const SbVec2s& cursorPos, Gui::View3DInventor } } - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId() - || geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is() + || geo->is()) { drag.relative = true; // Since the cursor moved from where it was clicked, and this is a relative @@ -1508,7 +1508,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s& cursorPos, Gui::View3DInventor drag.resetVector(); } - if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + if (geo->is()) { getSketchObject()->initTemporaryBSplinePieceMove( drag.DragCurve, Sketcher::PointPos::none, @@ -1662,7 +1662,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo else if (Constr->Second != GeoEnum::GeoUndef) { p1 = getSolvedSketch().getPoint(Constr->First, Constr->FirstPos); const Part::Geometry* geo = GeoList::getGeometryFromGeoId(geomlist, Constr->Second); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); Base::Vector3d l2p1 = lineSeg->getStartPoint(); @@ -1686,10 +1686,9 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo p2 = ct + dir * radius; } } - else if (geo->getTypeId() - == Part::GeomCircle::getClassTypeId()) {// circle to circle distance + else if (geo->is()) {// circle to circle distance const Part::Geometry* geo1 = GeoList::getGeometryFromGeoId(geomlist, Constr->First); - if (geo1->getTypeId() == Part::GeomCircle::getClassTypeId()) { + if (geo1->is()) { const Part::GeomCircle* circleSeg1 = static_cast(geo1); const Part::GeomCircle* circleSeg2 = static_cast(geo); GetCirclesMinimalDistance(circleSeg1, circleSeg2, p1, p2); @@ -1709,13 +1708,13 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo } else if (Constr->First != GeoEnum::GeoUndef) { const Part::Geometry* geo = GeoList::getGeometryFromGeoId(geomlist, Constr->First); - if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + if (geo->is()) { const Part::GeomLineSegment* lineSeg = static_cast(geo); p1 = lineSeg->getStartPoint(); p2 = lineSeg->getEndPoint(); } - else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomArcOfCircle* arc = static_cast(geo); double radius = arc->getRadius(); Base::Vector3d center = arc->getCenter(); @@ -1737,7 +1736,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d& toPo p2 = center + radius * Base::Vector3d(cos(angle), sin(angle), 0.); } - else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if (geo->is()) { const Part::GeomCircle* circle = static_cast(geo); double radius = circle->getRadius(); Base::Vector3d center = circle->getCenter(); @@ -2318,7 +2317,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& if (GeoId >= intGeoCount) GeoId = -extGeoCount; - if ((*it)->getTypeId() == Part::GeomPoint::getClassTypeId()) { + if ((*it)->is()) { // ----- Check if single point lies inside box selection -----/ const Part::GeomPoint* point = static_cast(*it); Plm.multVec(point->getPoint(), pnt0); @@ -2331,7 +2330,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& addSelection2(ss.str()); } } - else if ((*it)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + else if ((*it)->is()) { // ----- Check if line segment lies inside box selection -----/ const Part::GeomLineSegment* lineSeg = static_cast(*it); Plm.multVec(lineSeg->getStartPoint(), pnt1); @@ -2373,7 +2372,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomCircle::getClassTypeId()) { + else if ((*it)->is()) { // ----- Check if circle lies inside box selection -----/ /// TODO: Make it impossible to miss the circle if it's big and the selection pretty /// thin. @@ -2425,7 +2424,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + else if ((*it)->is()) { // ----- Check if ellipse lies inside box selection -----/ const Part::GeomEllipse* ellipse = static_cast(*it); pnt0 = ellipse->getCenter(); @@ -2477,7 +2476,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfCircle* aoc = static_cast(*it); @@ -2556,7 +2555,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& addSelection2(ss.str()); } } - else if ((*it)->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfEllipse* aoe = static_cast(*it); @@ -2638,7 +2637,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& addSelection2(ss.str()); } } - else if ((*it)->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfHyperbola* aoh = static_cast(*it); pnt0 = aoh->getStartPoint(); @@ -2723,7 +2722,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { + else if ((*it)->is()) { // Check if arc lies inside box selection const Part::GeomArcOfParabola* aop = static_cast(*it); @@ -2809,7 +2808,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s& startPos, const SbVec2s& } } } - else if ((*it)->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { + else if ((*it)->is()) { const Part::GeomBSplineCurve* spline = static_cast(*it); // std::vector poles = spline->getPoles(); VertexId += 2; @@ -2916,7 +2915,7 @@ void ViewProviderSketch::scaleBSplinePoleCirclesAndUpdateSolverAndSketchObjectGe if (GeoId >= geolistfacade.getInternalCount()) GeoId = -geolistfacade.getExternalCount(); - if ((*it)->getGeometry()->getTypeId() == Part::GeomCircle::getClassTypeId()) {// circle + if ((*it)->getGeometry()->is()) {// circle const Part::GeomCircle* circle = static_cast((*it)->getGeometry()); auto& gf = (*it); @@ -3770,8 +3769,7 @@ bool ViewProviderSketch::onDelete(const std::vector& subList) int GeoId; Sketcher::PointPos PosId; getSketchObject()->getGeoVertexIndex(VtId, GeoId, PosId); - if (getSketchObject()->getGeometry(GeoId)->getTypeId() - == Part::GeomPoint::getClassTypeId()) { + if (getSketchObject()->getGeometry(GeoId)->is()) { if (GeoId >= 0) delInternalGeometries.insert(GeoId); else diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index cfa099f8c1..a7b459e2b2 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -363,8 +363,7 @@ void Cell::setContent(const char* value) // check for units in denomainator const auto uDenom = freecad_dynamic_cast(fraction->getRight()); - const bool isUnitDenom = - uDenom && uDenom->getTypeId() == UnitExpression::getClassTypeId(); + const bool isUnitDenom = uDenom && uDenom->is(); const bool isNomValid = isNumberNom || isQuantityNom; const bool isDenomValid = diff --git a/src/Mod/Surface/App/FeatureCut.cpp b/src/Mod/Surface/App/FeatureCut.cpp index c2de5a202c..e39a0cadce 100644 --- a/src/Mod/Surface/App/FeatureCut.cpp +++ b/src/Mod/Surface/App/FeatureCut.cpp @@ -63,7 +63,7 @@ App::DocumentObjectExecReturn* Cut::execute() Part::TopoShape ts2; // Get first toposhape - if (shapes[0]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (shapes[0]->isDerivedFrom()) { ts1 = static_cast(shapes[0])->Shape.getShape(); // Part::TopoShape 1 } else { @@ -71,7 +71,7 @@ App::DocumentObjectExecReturn* Cut::execute() } // Get second toposhape - if (shapes[1]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (shapes[1]->isDerivedFrom()) { ts2 = static_cast(shapes[1])->Shape.getShape(); } else { diff --git a/src/Mod/Surface/App/FeatureExtend.cpp b/src/Mod/Surface/App/FeatureExtend.cpp index a887d36733..83701ba824 100644 --- a/src/Mod/Surface/App/FeatureExtend.cpp +++ b/src/Mod/Surface/App/FeatureExtend.cpp @@ -95,7 +95,7 @@ short Extend::mustExecute() const App::DocumentObjectExecReturn* Extend::execute() { App::DocumentObject* part = Face.getValue(); - if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!part || !part->isDerivedFrom()) { return new App::DocumentObjectExecReturn("No shape linked."); } const auto& faces = Face.getSubValues(); diff --git a/src/Mod/Surface/App/FeatureFilling.cpp b/src/Mod/Surface/App/FeatureFilling.cpp index e5791c761f..68a1a68887 100644 --- a/src/Mod/Surface/App/FeatureFilling.cpp +++ b/src/Mod/Surface/App/FeatureFilling.cpp @@ -141,7 +141,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, App::DocumentObject* obj = edge_obj[index]; const std::string& sub = edge_sub[index]; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { // get the sub-edge of the part's shape const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(sub.c_str()); @@ -217,7 +217,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, for (std::size_t index = 0; index < face_obj.size(); index++) { App::DocumentObject* obj = face_obj[index]; const std::string& sub = face_sub[index]; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape face = shape.getSubShape(sub.c_str()); if (!face.IsNull() && face.ShapeType() == TopAbs_FACE) { @@ -241,7 +241,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, const App::PropertyLinkS for (const auto& it : points) { App::DocumentObject* obj = it.first; std::vector sub = it.second; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); for (const auto& jt : sub) { TopoDS_Shape subShape = shape.getSubShape(jt.c_str()); @@ -287,7 +287,7 @@ App::DocumentObjectExecReturn* Filling::execute() // Load the initial surface if set App::DocumentObject* initFace = InitialFace.getValue(); - if (initFace && initFace->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (initFace && initFace->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(initFace)->Shape.getShape(); std::vector subNames = InitialFace.getSubValues(); for (const auto& it : subNames) { diff --git a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp index 798bf03678..8f63df3194 100644 --- a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp +++ b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp @@ -215,7 +215,7 @@ bool GeomFillSurface::getWire(TopoDS_Wire& aWire) ShapeValidator validator; for (const auto& set : boundary) { - if (set.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (set.first->isDerivedFrom()) { for (const auto& jt : set.second) { const Part::TopoShape& ts = static_cast(set.first)->Shape.getShape(); diff --git a/src/Mod/Surface/App/FeatureSections.cpp b/src/Mod/Surface/App/FeatureSections.cpp index c7333ed376..cd18b80eb8 100644 --- a/src/Mod/Surface/App/FeatureSections.cpp +++ b/src/Mod/Surface/App/FeatureSections.cpp @@ -56,7 +56,7 @@ App::DocumentObjectExecReturn* Sections::execute() // get the part object App::DocumentObject* obj = edge_obj[index]; const std::string& sub = edge_sub[index]; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { // get the sub-edge of the part's shape const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(sub.c_str()); diff --git a/src/Mod/Surface/App/FeatureSewing.cpp b/src/Mod/Surface/App/FeatureSewing.cpp index d81836f1a2..2c821b9fb3 100644 --- a/src/Mod/Surface/App/FeatureSewing.cpp +++ b/src/Mod/Surface/App/FeatureSewing.cpp @@ -81,7 +81,7 @@ App::DocumentObjectExecReturn* Sewing::execute() for (const auto& it : subset) { // the subset has the documentobject and the element name which belongs to it, // in our case for example the cube object and the "Edge1" string - if (it.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (it.first->isDerivedFrom()) { // we get the shape of the document object which resemble the whole box Part::TopoShape ts = static_cast(it.first)->Shape.getShape(); diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp index 678bd7db2b..ee39f7f32e 100644 --- a/src/Mod/Surface/Gui/Command.cpp +++ b/src/Mod/Surface/Gui/Command.cpp @@ -75,7 +75,7 @@ void CmdSurfaceCut::activated(int iMsg) bool askUser = false; for (std::vector::iterator it = Sel.begin(); it != Sel.end(); ++it) { App::DocumentObject* obj = it->getObject(); - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { const TopoDS_Shape& shape = static_cast(obj)->Shape.getValue(); if (!PartGui::checkForSolids(shape) && !askUser) { int ret = QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Non-solids diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 07fbbddce0..bddbfd5c06 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -584,7 +584,7 @@ void FillingPanel::onListBoundaryItemDoubleClicked(QListWidgetItem* item) try { App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray()); diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.cpp b/src/Mod/Surface/Gui/TaskFillingEdge.cpp index e820cb44e6..fefa88cb3a 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.cpp +++ b/src/Mod/Surface/Gui/TaskFillingEdge.cpp @@ -368,7 +368,7 @@ void FillingEdgePanel::onListUnboundItemDoubleClicked(QListWidgetItem* item) try { App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr; - if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj && obj->isDerivedFrom()) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray()); diff --git a/src/Mod/TechDraw/App/DrawComplexSection.cpp b/src/Mod/TechDraw/App/DrawComplexSection.cpp index ebcfb76901..6fde6bec10 100644 --- a/src/Mod/TechDraw/App/DrawComplexSection.cpp +++ b/src/Mod/TechDraw/App/DrawComplexSection.cpp @@ -877,8 +877,7 @@ gp_Ax2 DrawComplexSection::getCSFromBase(const std::string sectionName) const // Base::Console().Message("DCS::getCSFromBase()\n"); App::DocumentObject* base = BaseView.getValue(); if (!base - || !base->getTypeId().isDerivedFrom( - TechDraw::DrawViewPart::getClassTypeId())) {//is second clause necessary? + || !base->isDerivedFrom()) {//is second clause necessary? //if this DCS does not have a baseView, we must use the existing SectionCS return getSectionCS(); } @@ -966,7 +965,7 @@ bool DrawComplexSection::isBaseValid() const //complex section is not based on an existing DVP return true; } - if (!base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { + if (!base->isDerivedFrom()) { //this is probably an error somewhere. the valid options are base = a DVP, //or no base return false; diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index f331a4dbd6..17755f4ea8 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -183,7 +183,7 @@ DrawProjGroup* DrawProjGroupItem::getPGroup() const { std::vector parent = getInList(); for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawProjGroup::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { DrawProjGroup* result = dynamic_cast(*it); return result; } diff --git a/src/Mod/TechDraw/App/DrawTemplate.cpp b/src/Mod/TechDraw/App/DrawTemplate.cpp index c8faadd5d7..35709cd26e 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawTemplate.cpp @@ -86,7 +86,7 @@ DrawPage* DrawTemplate::getParentPage() const TechDraw::DrawPage* page(nullptr); std::vector parents = getInList(); for (auto& obj : parents) { - if (obj->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) { + if (obj->isDerivedFrom()) { page = static_cast(obj); break; } diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index 99a0e2eecb..fd7d6545ab 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -303,7 +303,7 @@ int DrawView::countParentPages() const parentAll.erase(last, parentAll.end()); for (auto& parent : parentAll) { - if (parent->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) { + if (parent->isDerivedFrom()) { count++; } } @@ -320,9 +320,9 @@ DrawPage* DrawView::findParentPage() const DrawViewCollection *collection = nullptr; std::vector parentsAll = getInList(); for (auto& parent : parentsAll) { - if (parent->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) { + if (parent->isDerivedFrom()) { page = static_cast(parent); - } else if (parent->getTypeId().isDerivedFrom(DrawViewCollection::getClassTypeId())) { + } else if (parent->isDerivedFrom()) { collection = static_cast(parent); page = collection->findParentPage(); } @@ -344,9 +344,9 @@ std::vector DrawView::findAllParentPages() const std::vector parentsAll = getInList(); for (auto& parent : parentsAll) { - if (parent->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) { + if (parent->isDerivedFrom()) { page = static_cast(parent); - } else if (parent->getTypeId().isDerivedFrom(DrawViewCollection::getClassTypeId())) { + } else if (parent->isDerivedFrom()) { collection = static_cast(parent); page = collection->findParentPage(); } @@ -368,7 +368,7 @@ bool DrawView::isInClip() { std::vector parent = getInList(); for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawViewClip::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { return true; } } @@ -380,7 +380,7 @@ DrawViewClip* DrawView::getClipGroup() std::vector parent = getInList(); App::DocumentObject* obj = nullptr; for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawViewClip::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { obj = (*it); DrawViewClip* result = dynamic_cast(obj); return result; @@ -486,7 +486,7 @@ std::vector DrawView::getLeaders() const std::vector result; std::vector children = getInList(); for (std::vector::iterator it = children.begin(); it != children.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawLeaderLine::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { TechDraw::DrawLeaderLine* lead = dynamic_cast(*it); result.push_back(lead); } diff --git a/src/Mod/TechDraw/App/DrawViewClip.cpp b/src/Mod/TechDraw/App/DrawViewClip.cpp index d489c0c13d..4596b8f228 100644 --- a/src/Mod/TechDraw/App/DrawViewClip.cpp +++ b/src/Mod/TechDraw/App/DrawViewClip.cpp @@ -113,7 +113,7 @@ App::DocumentObjectExecReturn *DrawViewClip::execute() std::vector children = Views.getValues(); for (std::vector::iterator it = children.begin(); it != children.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { TechDraw::DrawView *view = static_cast(*it); view->requestPaint(); } @@ -142,7 +142,7 @@ std::vector DrawViewClip::getChildViewNames() std::vector childNames; std::vector children = Views.getValues(); for (std::vector::iterator it = children.begin(); it != children.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { std::string name = (*it)->getNameInDocument(); childNames.push_back(name); } diff --git a/src/Mod/TechDraw/App/DrawViewCollection.cpp b/src/Mod/TechDraw/App/DrawViewCollection.cpp index 314cb24aa5..e90160e95a 100644 --- a/src/Mod/TechDraw/App/DrawViewCollection.cpp +++ b/src/Mod/TechDraw/App/DrawViewCollection.cpp @@ -114,7 +114,7 @@ void DrawViewCollection::rebuildViewList() std::vector newViews; std::vector children = getOutList(); for (std::vector::iterator it = children.begin(); it != children.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { bool found = false; for (auto& v:currViews) { if (v == (*it)) { @@ -140,7 +140,7 @@ int DrawViewCollection::countChildren() const std::vector &views = Views.getValues(); for(std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - if((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewCollection::getClassTypeId())) { + if((*it)->isDerivedFrom()) { TechDraw::DrawViewCollection *viewCollection = static_cast(*it); numChildren += viewCollection->countChildren() + 1; } else { diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 5f5cab16a3..56308c31fd 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -141,7 +141,7 @@ App::DocumentObjectExecReturn* DrawViewDetail::execute() return DrawView::execute(); } - if (!baseObj->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { + if (!baseObj->isDerivedFrom()) { //this can only happen via scripting? return DrawView::execute(); } diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index c0cd5402ca..17b605da75 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -723,7 +723,7 @@ std::vector DrawViewPart::getHatches() const std::vector result; std::vector children = getInList(); for (auto& child : children) { - if (child->getTypeId().isDerivedFrom(DrawHatch::getClassTypeId()) && !child->isRemoving()) { + if (child->isDerivedFrom() && !child->isRemoving()) { TechDraw::DrawHatch* hatch = dynamic_cast(child); result.push_back(hatch); } @@ -737,7 +737,7 @@ std::vector DrawViewPart::getGeomHatches() const std::vector result; std::vector children = getInList(); for (auto& child : children) { - if (child->getTypeId().isDerivedFrom(DrawGeomHatch::getClassTypeId()) + if (child->isDerivedFrom() && !child->isRemoving()) { TechDraw::DrawGeomHatch* geom = dynamic_cast(child); result.push_back(geom); @@ -757,7 +757,7 @@ std::vector DrawViewPart::getDimensions() const std::vector::iterator newEnd = std::unique(children.begin(), children.end()); for (std::vector::iterator it = children.begin(); it != newEnd; ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawViewDimension::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { TechDraw::DrawViewDimension* dim = dynamic_cast(*it); result.push_back(dim); } @@ -773,7 +773,7 @@ std::vector DrawViewPart::getBalloons() const std::vector::iterator newEnd = std::unique(children.begin(), children.end()); for (std::vector::iterator it = children.begin(); it != newEnd; ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawViewBalloon::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { TechDraw::DrawViewBalloon* balloon = dynamic_cast(*it); result.push_back(balloon); } @@ -1164,7 +1164,7 @@ std::vector DrawViewPart::getSectionRefs() const std::vector result; std::vector inObjs = getInList(); for (auto& o : inObjs) { - if (o->getTypeId().isDerivedFrom(DrawViewSection::getClassTypeId())) { + if (o->isDerivedFrom()) { result.push_back(static_cast(o)); } } @@ -1176,7 +1176,7 @@ std::vector DrawViewPart::getDetailRefs() const std::vector result; std::vector inObjs = getInList(); for (auto& o : inObjs) { - if (o->getTypeId().isDerivedFrom(DrawViewDetail::getClassTypeId())) { + if (o->isDerivedFrom()) { if (!o->isRemoving()) { result.push_back(static_cast(o)); } diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index cb72d0d190..2d35be7d8c 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -319,8 +319,7 @@ void DrawViewSection::onChanged(const App::Property* prop) else if (prop == &BaseView) { // if the BaseView is a Section, then the option of using UsePreviousCut is // valid. - if (BaseView.getValue() && BaseView.getValue()->getTypeId().isDerivedFrom( - TechDraw::DrawViewSection::getClassTypeId())) { + if (BaseView.getValue() && BaseView.getValue()->isDerivedFrom()) { UsePreviousCut.setStatus(App::Property::ReadOnly, false); } else { @@ -346,18 +345,18 @@ TopoDS_Shape DrawViewSection::getShapeToCut() } TopoDS_Shape shapeToCut; - if (base->getTypeId().isDerivedFrom(TechDraw::DrawViewSection::getClassTypeId())) { + if (base->isDerivedFrom()) { dvs = static_cast(base); shapeToCut = dvs->getShapeToCut(); if (UsePreviousCut.getValue()) { shapeToCut = dvs->getCutShapeRaw(); } } - else if (base->getTypeId().isDerivedFrom(TechDraw::DrawViewDetail::getClassTypeId())) { + else if (base->isDerivedFrom()) { dvd = static_cast(base); shapeToCut = dvd->getDetailShape(); } - else if (base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { + else if (base->isDerivedFrom()) { dvp = static_cast(base); shapeToCut = dvp->getSourceShape(); if (FuseBeforeCut.getValue()) { @@ -430,7 +429,7 @@ App::DocumentObjectExecReturn* DrawViewSection::execute() bool DrawViewSection::isBaseValid() const { App::DocumentObject* base = BaseView.getValue(); - if (base && base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { + if (base && base->isDerivedFrom()) { return true; } return false; @@ -683,7 +682,7 @@ void DrawViewSection::postSectionCutTasks() // Base::Console().Message("DVS::postSectionCutTasks()\n"); std::vector children = getInList(); for (auto& c : children) { - if (c->getTypeId().isDerivedFrom(DrawViewPart::getClassTypeId())) { + if (c->isDerivedFrom()) { // details or sections of this need cut shape c->recomputeFeature(); } @@ -1191,7 +1190,7 @@ TopoDS_Face DrawViewSection::getSectionTopoDSFace(int i) TechDraw::DrawViewPart* DrawViewSection::getBaseDVP() const { App::DocumentObject* base = BaseView.getValue(); - if (base && base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { + if (base && base->isDerivedFrom()) { TechDraw::DrawViewPart* baseDVP = static_cast(base); return baseDVP; } diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp index 2671a8df98..328d9512fd 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp @@ -100,7 +100,7 @@ App::DocumentObjectExecReturn *DrawViewSpreadsheet::execute() std::string scellend = CellEnd.getValue(); if (!link) return new App::DocumentObjectExecReturn("No spreadsheet linked"); - if (!link->getTypeId().isDerivedFrom(Spreadsheet::Sheet::getClassTypeId())) + if (!link->isDerivedFrom()) return new App::DocumentObjectExecReturn("The linked object is not a spreadsheet"); if (scellstart.empty() || scellend.empty()) return new App::DocumentObjectExecReturn("Empty cell value"); diff --git a/src/Mod/TechDraw/App/DrawWeldSymbol.cpp b/src/Mod/TechDraw/App/DrawWeldSymbol.cpp index f172875ca0..05b17e800d 100644 --- a/src/Mod/TechDraw/App/DrawWeldSymbol.cpp +++ b/src/Mod/TechDraw/App/DrawWeldSymbol.cpp @@ -127,7 +127,7 @@ std::vector DrawWeldSymbol::getTiles() const } for(std::vector::iterator it = tiles.begin(); it != tiles.end(); it++) { - if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawTileWeld::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { App::DocumentObject* doTemp = (*it); DrawTileWeld* temp = static_cast(doTemp); result.push_back(temp); diff --git a/src/Mod/TechDraw/App/FeatureProjection.cpp b/src/Mod/TechDraw/App/FeatureProjection.cpp index 139bce3691..41d0a7a019 100644 --- a/src/Mod/TechDraw/App/FeatureProjection.cpp +++ b/src/Mod/TechDraw/App/FeatureProjection.cpp @@ -67,7 +67,7 @@ App::DocumentObjectExecReturn *FeatureProjection::execute() App::DocumentObject* link = Source.getValue(); if (!link) return new App::DocumentObjectExecReturn("No object linked"); - if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!link->isDerivedFrom()) return new App::DocumentObjectExecReturn("Linked object is not a Part object"); const TopoDS_Shape& shape = static_cast(link)->Shape.getShape().getShape(); if (shape.IsNull()) diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index 51595262eb..b71765cfac 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -68,14 +68,14 @@ std::vector ShapeExtractor::getShapes2d(const std::vector objs = gex->Group.getValues(); for (auto& d: objs) { if (is2dObject(d)) { - if (d->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (d->isDerivedFrom()) { shapes2d.push_back(getLocatedShape(d)); } } } } else { if (is2dObject(l)) { - if (l->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (l->isDerivedFrom()) { shapes2d.push_back(getLocatedShape(l)); } // other 2d objects would go here - Draft objects? } @@ -95,7 +95,7 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector l if (is2dObject(l) && !include2d) { continue; } - if (l->getTypeId().isDerivedFrom(App::Link::getClassTypeId())) { + if (l->isDerivedFrom()) { App::Link* xLink = dynamic_cast(l); std::vector xShapes = getXShapes(xLink); if (!xShapes.empty()) { @@ -170,7 +170,7 @@ std::vector ShapeExtractor::getXShapes(const App::Link* xLink) bool childNeedsTransform = false; Base::Placement childPlm; Base::Matrix4D childScale; - if (l->getTypeId().isDerivedFrom(App::LinkElement::getClassTypeId())) { + if (l->isDerivedFrom()) { App::LinkElement* cLinkElem = static_cast(l); if (cLinkElem->hasPlacement()) { childPlm = cLinkElem->getLinkPlacementProperty()->getValue(); @@ -254,7 +254,7 @@ std::vector ShapeExtractor::getShapesFromObject(const App::Documen const App::GroupExtension* gex = dynamic_cast(docObj); App::Property* gProp = docObj->getPropertyByName("Group"); App::Property* sProp = docObj->getPropertyByName("Shape"); - if (docObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (docObj->isDerivedFrom()) { result.push_back(getLocatedShape(docObj)); } else if (gex) { //is a group extension std::vector objs = gex->Group.getValues(); diff --git a/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp b/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp index 2d84b30700..ca183898b1 100644 --- a/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp +++ b/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp @@ -132,7 +132,7 @@ private: PyObject* item = (*it).ptr(); if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) { App::DocumentObject* obj = static_cast(item)->getDocumentObjectPtr(); - if (obj->getTypeId().isDerivedFrom(TechDraw::DrawPage::getClassTypeId())) { + if (obj->isDerivedFrom()) { page = static_cast(obj); Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument()); Gui::ViewProvider* vp = activeGui->getViewProvider(obj); diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp index 474e5c1f63..e3e5f7aabc 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp @@ -98,7 +98,7 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val QGIView* gView = dynamic_cast(childItem); if(gView) { TechDraw::DrawView *fView = gView->getViewObject(); - if(fView->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { + if(fView->isDerivedFrom()) { TechDraw::DrawProjGroupItem *projItemPtr = static_cast(fView); QString type = QString::fromLatin1(projItemPtr->Type.getValueAsString()); diff --git a/src/Mod/TechDraw/Gui/QGSPage.cpp b/src/Mod/TechDraw/Gui/QGSPage.cpp index c2b0391ed2..d788a2086f 100644 --- a/src/Mod/TechDraw/Gui/QGSPage.cpp +++ b/src/Mod/TechDraw/Gui/QGSPage.cpp @@ -910,7 +910,7 @@ void QGSPage::findMissingViews(const std::vector& list, if (!hasQView(*it)) missing.push_back(*it); - if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewCollection::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { std::vector missingChildViews; TechDraw::DrawViewCollection* collection = dynamic_cast(*it); diff --git a/src/Mod/TechDraw/Gui/ViewProviderAnnotation.cpp b/src/Mod/TechDraw/Gui/ViewProviderAnnotation.cpp index 0a7790b96a..9d05f13b7a 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderAnnotation.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderAnnotation.cpp @@ -69,10 +69,10 @@ std::vector ViewProviderAnnotation::claimChildren() const try { for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { temp.push_back((*it)); } - else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) { + else if ((*it)->isDerivedFrom()) { temp.push_back((*it)); } } diff --git a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp index ca43f23f5f..a5d8f8639a 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp @@ -135,7 +135,7 @@ void ViewProviderDrawingView::show() if (!obj || obj->isRestoring()) return; - if (obj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { + if (obj->isDerivedFrom()) { QGIView* qView = getQView(); if (qView) { qView->draw(); @@ -151,7 +151,7 @@ void ViewProviderDrawingView::hide() if (!obj || obj->isRestoring()) return; - if (obj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { + if (obj->isDerivedFrom()) { QGIView* qView = getQView(); if (qView) { //note: hiding an item in the scene clears its selection status diff --git a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp index b499ce78b3..f3cad5c2ee 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp @@ -142,9 +142,9 @@ std::vector ViewProviderLeader::claimChildren() const const std::vector &views = getFeature()->getInList(); try { for(std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { temp.push_back((*it)); - } else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId())) { + } else if ((*it)->isDerivedFrom()) { temp.push_back((*it)); } } diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp index fef98af60c..af7b8513b0 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp @@ -64,7 +64,7 @@ void ViewProviderViewClip::show() App::DocumentObject* obj = getObject(); if (!obj || obj->isRestoring()) return; - if (obj->getTypeId().isDerivedFrom(TechDraw::DrawViewClip::getClassTypeId())) { + if (obj->isDerivedFrom()) { std::vector inp = obj->getInList(); for (std::vector::iterator it = inp.begin(); it != inp.end(); ++it) (*it)->touch(); @@ -79,7 +79,7 @@ void ViewProviderViewClip::hide() App::DocumentObject* obj = getObject(); if (!obj || obj->isRestoring()) return; - if (obj->getTypeId().isDerivedFrom(TechDraw::DrawViewClip::getClassTypeId())) { + if (obj->isDerivedFrom()) { std::vector inp = obj->getInList(); for (std::vector::iterator it = inp.begin(); it != inp.end(); ++it) (*it)->touch(); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index 847d07edb9..1cb8c28ce9 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -199,7 +199,7 @@ std::vector ViewProviderViewPart::claimChildren() const const std::vector &views = getViewPart()->getInList(); try { for(std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - if((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) { + if((*it)->isDerivedFrom()) { //TODO: make a list, then prune it. should be faster? bool skip = false; std::string dimName = (*it)->getNameInDocument(); @@ -213,15 +213,15 @@ std::vector ViewProviderViewPart::claimChildren() const if (!skip) { temp.push_back(*it); } - } else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawHatch::getClassTypeId())) { + } else if ((*it)->isDerivedFrom()) { temp.push_back((*it)); - } else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawGeomHatch::getClassTypeId())) { + } else if ((*it)->isDerivedFrom()) { temp.push_back((*it)); - } else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())) { + } else if ((*it)->isDerivedFrom()) { temp.push_back((*it)); - } else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) { + } else if ((*it)->isDerivedFrom()) { temp.push_back((*it)); - } else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) { + } else if ((*it)->isDerivedFrom()) { temp.push_back((*it)); } } diff --git a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp index 9002e12f20..8b046d7f2b 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp @@ -82,7 +82,7 @@ std::vector ViewProviderWeld::claimChildren() const const std::vector &tiles = getFeature()->getInList(); try { for(std::vector::const_iterator it = tiles.begin(); it != tiles.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawTile::getClassTypeId())) { + if ((*it)->isDerivedFrom()) { temp.push_back((*it)); } }