diff --git a/src/Gui/DocumentModel.cpp b/src/Gui/DocumentModel.cpp index c8d58d0006..fc04ef65aa 100644 --- a/src/Gui/DocumentModel.cpp +++ b/src/Gui/DocumentModel.cpp @@ -575,15 +575,10 @@ const Document* DocumentModel::getDocument(const QModelIndex& index) const bool DocumentModel::isPropertyLink(const App::Property& prop) const { - if (prop.isDerivedFrom(App::PropertyLink::getClassTypeId())) - return true; - if (prop.isDerivedFrom(App::PropertyLinkSub::getClassTypeId())) - return true; - if (prop.isDerivedFrom(App::PropertyLinkList::getClassTypeId())) - return true; - if (prop.isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())) - return true; - return false; + return prop.isDerivedFrom() + || prop.isDerivedFrom() + || prop.isDerivedFrom() + || prop.isDerivedFrom(); } std::vector diff --git a/src/Gui/ViewProviderDocumentObject.cpp b/src/Gui/ViewProviderDocumentObject.cpp index 3aed6cf9b1..7de7919277 100644 --- a/src/Gui/ViewProviderDocumentObject.cpp +++ b/src/Gui/ViewProviderDocumentObject.cpp @@ -499,12 +499,10 @@ void ViewProviderDocumentObject::setActiveMode() bool ViewProviderDocumentObject::canDelete(App::DocumentObject* obj) const { - Q_UNUSED(obj) - if (getObject()->hasExtension(App::GroupExtension::getExtensionClassTypeId())) - return true; - if (getObject()->isDerivedFrom(App::Origin::getClassTypeId())) - return true; - return false; + Q_UNUSED(obj); + auto* o = getObject(); + return o->hasExtension(App::GroupExtension::getExtensionClassTypeId()) + || o->isDerivedFrom(); } PyObject* ViewProviderDocumentObject::getPyObject() diff --git a/src/Mod/Fem/App/FemPostFilter.cpp b/src/Mod/Fem/App/FemPostFilter.cpp index 6522fcb423..7d0fd60c3b 100644 --- a/src/Mod/Fem/App/FemPostFilter.cpp +++ b/src/Mod/Fem/App/FemPostFilter.cpp @@ -91,8 +91,7 @@ DocumentObjectExecReturn* FemPostFilter::execute() vtkDataObject* FemPostFilter::getInputData() { if (Input.getValue()) { - if (Input.getValue()->getTypeId().isDerivedFrom( - Base::Type::fromName("Fem::FemPostObject"))) { + if (Input.getValue()->isDerivedFrom()) { return Input.getValue()->Data.getValue(); } else { diff --git a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp index 0eb707801a..62b1f59d3d 100644 --- a/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp +++ b/src/Mod/Fem/Gui/ViewProviderAnalysis.cpp @@ -230,38 +230,25 @@ bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject* obj) const if (!obj) { return false; } - if (obj->isDerivedFrom()) { - return true; - } - else if (obj->isDerivedFrom()) { - return true; - } - else if (obj->isDerivedFrom()) { - return true; - } - else if (obj->isDerivedFrom()) { - return true; - } - else if (obj->isDerivedFrom()) { - return true; - } - else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython"))) { - return true; - } - else if (obj->isDerivedFrom()) { - return true; - } - else if (obj->isDerivedFrom()) { + + // clang-format off: keep line breaks for readability + if (obj->isDerivedFrom() + || obj->isDerivedFrom() + || obj->isDerivedFrom() + || obj->isDerivedFrom() + || obj->isDerivedFrom() + || obj->isDerivedFrom(Base::Type::fromName("Fem::FeaturePython")) + || obj->isDerivedFrom() + || obj->isDerivedFrom()) { return true; } + // clang-format on #ifdef FC_USE_VTK else if (obj->isDerivedFrom()) { return true; } #endif - else { - return false; - } + return false; } void ViewProviderFemAnalysis::dragObject(App::DocumentObject* obj) diff --git a/src/Mod/Import/App/SketchExportHelper.cpp b/src/Mod/Import/App/SketchExportHelper.cpp index 0a1072a8dc..08f2305b20 100644 --- a/src/Mod/Import/App/SketchExportHelper.cpp +++ b/src/Mod/Import/App/SketchExportHelper.cpp @@ -73,14 +73,8 @@ TopoDS_Shape SketchExportHelper::projectShape(const TopoDS_Shape& inShape, //! true if obj is a sketch bool SketchExportHelper::isSketch(App::DocumentObject* obj) { - // TODO:: the check for an object being a sketch should be done as in the commented - // if statement below. To do this, we need to include Mod/Sketcher/SketchObject.h, - // but that makes Import dependent on Eigen libraries which we don't use. As a - // workaround we will inspect the object's class name. - // if (obj->isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) { - std::string objTypeName = obj->getTypeId().getName(); - std::string sketcherToken("Sketcher"); - return objTypeName.find(sketcherToken) != std::string::npos; + // Use name to lookup to avoid dependency on Sketcher module + return obj->isDerivedFrom(Base::Type::fromName("Sketcher::SketchObject")); } diff --git a/src/Mod/Measure/Gui/TaskMeasure.cpp b/src/Mod/Measure/Gui/TaskMeasure.cpp index 56d538367a..9ed4d88ec0 100644 --- a/src/Mod/Measure/Gui/TaskMeasure.cpp +++ b/src/Mod/Measure/Gui/TaskMeasure.cpp @@ -369,8 +369,7 @@ void TaskMeasure::ensureGroup(Measure::MeasureBase* measurement) App::DocumentObject* obj = doc->getObject(measurementGroupName); - if (!obj || !obj->isValid() - || !obj->isDerivedFrom(App::DocumentObjectGroup::getClassTypeId())) { + if (!obj || !obj->isValid() || !obj->isDerivedFrom()) { obj = doc->addObject("App::DocumentObjectGroup", measurementGroupName, true, diff --git a/src/Mod/Part/App/MeasureClient.cpp b/src/Mod/Part/App/MeasureClient.cpp index e6f0479420..9b0a0e8290 100644 --- a/src/Mod/Part/App/MeasureClient.cpp +++ b/src/Mod/Part/App/MeasureClient.cpp @@ -139,10 +139,8 @@ App::MeasureElementType PartMeasureTypeCb(App::DocumentObject* ob, const char* s switch (curve.GetType()) { case GeomAbs_Line: { - if (ob->getTypeId().isDerivedFrom(Base::Type::fromName("Part::Datum"))) { - return App::MeasureElementType::LINE; - } - return App::MeasureElementType::LINESEGMENT; + return ob->isDerivedFrom() ? App::MeasureElementType::LINE + : App::MeasureElementType::LINESEGMENT; } case GeomAbs_Circle: { return App::MeasureElementType::CIRCLE; } case GeomAbs_BezierCurve: diff --git a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp index 1690738ba2..83e914a503 100644 --- a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp +++ b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp @@ -376,9 +376,7 @@ void ViewProviderRobotObject::updateData(const App::Property* prop) else if (prop == &robObj->ToolShape) { App::DocumentObject* o = robObj->ToolShape.getValue(); - if (o - && (o->isDerivedFrom(Part::Feature::getClassTypeId()) - || o->isDerivedFrom(App::VRMLObject::getClassTypeId()))) { + if (o && (o->isDerivedFrom() || o->isDerivedFrom())) { // Part::Feature *p = dynamic_cast(o); toolShape = Gui::Application::Instance->getViewProvider(o); toolShape->setTransformation( diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h index 5ad102ec25..604a08ce15 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h @@ -70,7 +70,7 @@ public: if (geom->is() || geom->is() || geom->is() - || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) + || geom->isDerivedFrom() || geom->is()) { return true; } @@ -122,7 +122,7 @@ public: if (geom->is() || geom->is() || geom->is() - || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) + || geom->isDerivedFrom() || geom->is()) { GeoId = curveGeoId; } diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index cfd800dd36..a9e4edd96a 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -924,7 +924,7 @@ void Sheet::recomputeCell(CellAddress p) cellErrors.insert(p); cellUpdated(p); - if (e.isDerivedFrom(Base::AbortException::getClassTypeId())) { + if (e.isDerivedFrom()) { throw; } } diff --git a/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp b/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp index 129b5eba0b..41f73305c6 100644 --- a/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp +++ b/src/Mod/Spreadsheet/Gui/DlgSheetConf.cpp @@ -115,8 +115,7 @@ App::Property* DlgSheetConf::prepare(CellAddress& from, e.ReportException(); FC_THROWM(Base::RuntimeError, "Failed to parse expression for property"); } - if (expr->hasComponent() - || !expr->isDerivedFrom(App::VariableExpression::getClassTypeId())) { + if (expr->hasComponent() || !expr->isDerivedFrom()) { FC_THROWM(Base::RuntimeError, "Invalid property expression: " << expr->toString()); } @@ -196,8 +195,7 @@ void DlgSheetConf::accept() std::string exprTxt(ui->lineEditProp->text().trimmed().toUtf8().constData()); App::ExpressionPtr expr(App::Expression::parse(sheet, exprTxt)); - if (expr->hasComponent() - || !expr->isDerivedFrom(App::VariableExpression::getClassTypeId())) { + if (expr->hasComponent() || !expr->isDerivedFrom()) { FC_THROWM(Base::RuntimeError, "Invalid property expression: " << expr->toString()); } diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index 69ef1a862c..46247e125d 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -398,31 +398,20 @@ bool ShapeExtractor::is2dObject(const App::DocumentObject* obj) bool ShapeExtractor::isEdgeType(const App::DocumentObject* obj) { Base::Type t = obj->getTypeId(); - if (t.isDerivedFrom(Part::Line::getClassTypeId()) ) { - return true; - } else if (t.isDerivedFrom(Part::Circle::getClassTypeId())) { - return true; - } else if (t.isDerivedFrom(Part::Ellipse::getClassTypeId())) { - return true; - } else if (t.isDerivedFrom(Part::RegularPolygon::getClassTypeId())) { - return true; - } - return false; + return t.isDerivedFrom(Part::Line::getClassTypeId()) + || t.isDerivedFrom(Part::Circle::getClassTypeId()) + || t.isDerivedFrom(Part::Ellipse::getClassTypeId()) + || t.isDerivedFrom(Part::RegularPolygon::getClassTypeId()); } bool ShapeExtractor::isPointType(const App::DocumentObject* obj) { - if (obj) { - Base::Type t = obj->getTypeId(); - if (t.isDerivedFrom(Part::Vertex::getClassTypeId())) { - return true; - } else if (isDraftPoint(obj)) { - return true; - } else if (isDatumPoint(obj)) { - return true; - } + if (!obj) { + return false; } - return false; + return obj->isDerivedFrom() + || isDraftPoint(obj) + || isDatumPoint(obj); } bool ShapeExtractor::isDraftPoint(const App::DocumentObject* obj) @@ -486,17 +475,8 @@ TopoDS_Shape ShapeExtractor::getLocatedShape(const App::DocumentObject* docObj) bool ShapeExtractor::isSketchObject(const App::DocumentObject* obj) { -// TODO:: the check for an object being a sketch should be done as in the commented -// if statement below. To do this, we need to include Mod/Sketcher/SketchObject.h, -// but that makes TechDraw dependent on Eigen libraries which we don't use. As a -// workaround we will inspect the object's class name. -// if (obj->isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) { - std::string objTypeName = obj->getTypeId().getName(); - std::string sketcherToken("Sketcher"); - if (objTypeName.find(sketcherToken) != std::string::npos) { - return true; - } - return false; + // Use name to lookup to avoid dependency on Sketcher module + return obj->isDerivedFrom(Base::Type::fromName("Sketcher::SketchObject")); }