From 773c701eec0ef33f66ed098af6e1996132c80b9c Mon Sep 17 00:00:00 2001 From: Florian Foinant-Willig Date: Sun, 15 Oct 2023 21:38:48 +0200 Subject: [PATCH] Core: modernize type checking --- src/App/ExtensionPython.h | 2 +- src/App/OriginGroupExtension.cpp | 8 +-- src/App/PropertyGeo.cpp | 2 +- src/App/PropertyLinks.cpp | 8 +-- src/App/PropertyPythonObject.cpp | 2 +- src/App/Transactions.cpp | 2 +- src/Base/Type.h | 6 +- src/Gui/Application.cpp | 6 +- src/Gui/CommandDoc.cpp | 2 +- src/Gui/CommandFeat.cpp | 4 +- src/Gui/CommandStructure.cpp | 2 +- src/Gui/DlgDisplayPropertiesImp.cpp | 6 +- src/Gui/DlgMaterialPropertiesImp.cpp | 12 ++-- src/Gui/Document.cpp | 8 +-- src/Gui/DocumentModel.cpp | 4 +- src/Gui/ExpressionBinding.cpp | 2 +- src/Gui/ManualAlignment.cpp | 6 +- src/Gui/SelectionView.cpp | 4 +- src/Gui/TaskView/TaskAppearance.cpp | 22 +++---- src/Gui/TaskView/TaskImage.cpp | 2 +- src/Gui/TaskView/TaskSelectLinkProperty.cpp | 4 +- src/Gui/Transform.cpp | 6 +- src/Gui/TreeView.cpp | 4 +- src/Gui/View3DInventorViewer.cpp | 2 +- src/Gui/ViewProviderAnnotation.cpp | 14 ++--- src/Gui/ViewProviderDocumentObjectGroup.cpp | 4 +- src/Gui/ViewProviderLink.cpp | 4 +- src/Gui/ViewProviderMeasureDistance.cpp | 2 +- src/Gui/ViewProviderOriginFeature.cpp | 2 +- src/Gui/Workbench.cpp | 2 +- src/Gui/propertyeditor/PropertyItem.cpp | 66 ++++++++++----------- 31 files changed, 110 insertions(+), 110 deletions(-) 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 ce1ceed12f..63a8ed518c 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); @@ -1841,7 +1841,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 d1ed313356..2998517016 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 ee2a800766..e4921d730e 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2403,7 +2403,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); 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())};