Prefer to use BaseClass's isDerivedFrom<T> over non template or Base::Type's

Regex based changes, manually verified
This commit is contained in:
Benjamin Nauck
2025-01-16 21:27:50 +01:00
parent 6a3eb2ab49
commit 6f535f19fb
166 changed files with 484 additions and 497 deletions

View File

@@ -255,12 +255,12 @@ std::vector<App::DocumentObject*> Body::addObject(App::DocumentObject *feature)
}
if(feature->Visibility.getValue()
&& feature->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
&& feature->isDerivedFrom<PartDesign::Feature>())
{
for(auto obj : Group.getValues()) {
if(obj->Visibility.getValue()
&& obj!=feature
&& obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
&& obj->isDerivedFrom<PartDesign::Feature>())
obj->Visibility.setValue(false);
}
}
@@ -313,7 +313,7 @@ void Body::insertObject(App::DocumentObject* feature, App::DocumentObject* targe
Group.setValues (model);
if(feature->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
if(feature->isDerivedFrom<PartDesign::Feature>())
static_cast<PartDesign::Feature*>(feature)->_Body.setValue(this);
// Set the BaseFeature property
@@ -399,7 +399,7 @@ App::DocumentObjectExecReturn *Body::execute()
Part::TopoShape tipShape;
if ( tip ) {
if ( !tip->getTypeId().isDerivedFrom ( PartDesign::Feature::getClassTypeId() ) ) {
if ( !tip->isDerivedFrom<PartDesign::Feature>() ) {
return new App::DocumentObjectExecReturn (QT_TRANSLATE_NOOP("Exception", "Linked object is not a PartDesign feature" ));
}
@@ -441,7 +441,7 @@ void Body::onChanged(const App::Property* prop) {
if (BaseFeature.getValue()) {
//setup the FeatureBase if needed
if (!first || !first->isDerivedFrom(FeatureBase::getClassTypeId())) {
if (!first || !first->isDerivedFrom<FeatureBase>()) {
bf = static_cast<FeatureBase*>(getDocument()->addObject("PartDesign::FeatureBase", "BaseFeature"));
insertObject(bf, first, false);
@@ -460,7 +460,7 @@ void Body::onChanged(const App::Property* prop) {
else if (prop == &Group) {
//if the FeatureBase was deleted we set the BaseFeature link to nullptr
if (BaseFeature.getValue() &&
(Group.getValues().empty() || !Group.getValues().front()->isDerivedFrom(FeatureBase::getClassTypeId()))) {
(Group.getValues().empty() || !Group.getValues().front()->isDerivedFrom<FeatureBase>())) {
BaseFeature.setValue(nullptr);
}
}
@@ -532,7 +532,7 @@ App::DocumentObject *Body::getSubObject(const char *subname,
const char* secondDot = strchr(firstDot + 1, '.');
if (secondDot) {
auto firstObj = Group.find(std::string(subname, firstDot).c_str());
if (!firstObj || firstObj->isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
if (!firstObj || firstObj->isDerivedFrom<PartDesign::Feature>()) {
auto secondObj = Group.find(std::string(firstDot + 1, secondDot).c_str());
if (secondObj) {
// we support only one level of sibling grouping, so no
@@ -564,7 +564,7 @@ App::DocumentObject *Body::getSubObject(const char *subname,
// We return the shape only if there are feature visible inside
for(auto obj : Group.getValues()) {
if(obj->Visibility.getValue() &&
obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
obj->isDerivedFrom<PartDesign::Feature>())
{
return Part::BodyBase::getSubObject(subname,pyObj,pmat,transform,depth);
}
@@ -578,7 +578,7 @@ App::DocumentObject *Body::getSubObject(const char *subname,
void Body::onDocumentRestored()
{
for(auto obj : Group.getValues()) {
if(obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()))
if(obj->isDerivedFrom<PartDesign::Feature>())
static_cast<PartDesign::Feature*>(obj)->_Body.setValue(this);
}
_GroupTouched.setStatus(App::Property::Output,true);