Part: modernize type checking

This commit is contained in:
Florian Foinant-Willig
2023-10-15 21:38:52 +02:00
parent 1a83d18a8f
commit eb55f1fe52
22 changed files with 46 additions and 46 deletions

View File

@@ -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<App::OriginFeature>() ||
obj->isDerivedFrom<Part::Datum>())
// 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<App::OriginFeature>() ||
selObj->isDerivedFrom<Part::Datum>())
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<App::Plane>()) {
// 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<App::Line>()) {
// 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<Part::Datum>()) {
subElement.clear();
} else {
// TODO: check validity of the text that was entered: Does subElement actually reference to an element on the obj?