Drawing: modernize type checking

This commit is contained in:
Florian Foinant-Willig
2023-10-15 21:39:01 +02:00
parent 027ac1b456
commit da1dd02ff0
8 changed files with 16 additions and 20 deletions

View File

@@ -117,7 +117,7 @@ App::DocumentObjectExecReturn* FeatureClip::execute(void)
// get through the children and collect all the views
const vector<App::DocumentObject*>& Grp = Group.getValues();
for (vector<App::DocumentObject*>::const_iterator It = Grp.begin(); It != Grp.end(); ++It) {
if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) {
if ((*It)->isDerivedFrom<Drawing::FeatureView>()) {
Drawing::FeatureView* View = static_cast<Drawing::FeatureView*>(*It);
svg << View->ViewResult.getValue() << endl;
}

View File

@@ -181,22 +181,21 @@ App::DocumentObjectExecReturn* FeaturePage::execute(void)
for (std::vector<App::DocumentObject*>::const_iterator It = Grp.begin();
It != Grp.end();
++It) {
if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) {
if ((*It)->isDerivedFrom<Drawing::FeatureView>()) {
Drawing::FeatureView* View = static_cast<Drawing::FeatureView*>(*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>()) {
Drawing::FeatureClip* Clip = static_cast<Drawing::FeatureClip*>(*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<App::DocumentObjectGroup>()) {
// getting children inside subgroups too
App::DocumentObjectGroup* SubGroup =
static_cast<App::DocumentObjectGroup*>(*It);
@@ -204,8 +203,7 @@ App::DocumentObjectExecReturn* FeaturePage::execute(void)
for (std::vector<App::DocumentObject*>::const_iterator Grit = SubGrp.begin();
Grit != SubGrp.end();
++Grit) {
if ((*Grit)->getTypeId().isDerivedFrom(
Drawing::FeatureView::getClassTypeId())) {
if ((*Grit)->isDerivedFrom<Drawing::FeatureView>()) {
Drawing::FeatureView* SView = static_cast<Drawing::FeatureView*>(*Grit);
if (SView->Visible.getValue()) {
ofile << SView->ViewResult.getValue();

View File

@@ -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<Part::Feature>()) {
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
}
const TopoDS_Shape& shape = static_cast<Part::Feature*>(link)->Shape.getShape().getShape();

View File

@@ -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<Part::Feature>()) {
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
}
TopoDS_Shape shape = static_cast<Part::Feature*>(link)->Shape.getShape().getShape();

View File

@@ -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<Spreadsheet::Sheet>()) {
return new App::DocumentObjectExecReturn("The linked object is not a spreadsheet");
}
if ((scellstart.empty()) || (scellend.empty())) {