diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index b2b38323ce..0e41160ca7 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -189,7 +189,7 @@ bool Body::isMemberOfMultiTransform(const App::DocumentObject* obj) // to auto set it when the originals are not null. See: // App::DocumentObjectExecReturn *Transformed::execute(void) // - return (obj->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) && + return (obj->isDerivedFrom() && static_cast(obj)->Originals.getValues().empty()); } @@ -198,7 +198,7 @@ bool Body::isSolidFeature(const App::DocumentObject *obj) if (!obj) return false; - if (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) && + if (obj->isDerivedFrom() && !PartDesign::Feature::isDatum(obj)) { // Transformed Features inside a MultiTransform are not solid features return !isMemberOfMultiTransform(obj); @@ -212,15 +212,15 @@ bool Body::isAllowed(const App::DocumentObject *obj) return false; // TODO: Should we introduce a PartDesign::FeaturePython class? This should then also return true for isSolidFeature() - return (obj->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) || - obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()) || + return (obj->isDerivedFrom() || + obj->isDerivedFrom() || // TODO Shouldn't we replace it with Sketcher::SketchObject? (2015-08-13, Fat-Zer) - obj->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()) || - obj->getTypeId().isDerivedFrom(PartDesign::ShapeBinder::getClassTypeId()) || - obj->getTypeId().isDerivedFrom(PartDesign::SubShapeBinder::getClassTypeId()) + obj->isDerivedFrom() || + obj->isDerivedFrom() || + obj->isDerivedFrom() // TODO Why this lines was here? why should we allow anything of those? (2015-08-13, Fat-Zer) - //obj->getTypeId().isDerivedFrom(Part::FeaturePython::getClassTypeId()) // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython... - //obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()) + //obj->isDerivedFrom() // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython... + //obj->isDerivedFrom() ); } diff --git a/src/Mod/PartDesign/App/Feature.cpp b/src/Mod/PartDesign/App/Feature.cpp index 2c52f40578..681da9f60f 100644 --- a/src/Mod/PartDesign/App/Feature.cpp +++ b/src/Mod/PartDesign/App/Feature.cpp @@ -116,7 +116,7 @@ Part::Feature* Feature::getBaseObject(bool silent) const { const char *err = nullptr; if (BaseLink) { - if (BaseLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (BaseLink->isDerivedFrom()) { BaseObject = static_cast(BaseLink); } if (!BaseObject) { @@ -191,8 +191,8 @@ PyObject* Feature::getPyObject() bool Feature::isDatum(const App::DocumentObject* feature) { - return feature->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId()) || - feature->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId()); + return feature->isDerivedFrom() || + feature->isDerivedFrom(); } gp_Pln Feature::makePlnFromPlane(const App::DocumentObject* obj) diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index 143aac8209..821e37689b 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -125,11 +125,11 @@ App::DocumentObjectExecReturn *Draft::execute() gp_Dir pullDirection; App::DocumentObject* refDirection = PullDirection.getValue(); if (refDirection) { - if (refDirection->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + if (refDirection->isDerivedFrom()) { PartDesign::Line* line = static_cast(refDirection); Base::Vector3d d = line->getDirection(); pullDirection = gp_Dir(d.x, d.y, d.z); - } else if (refDirection->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refDirection->isDerivedFrom()) { std::vector subStrings = PullDirection.getSubValues(); if (subStrings.empty() || subStrings[0].empty()) throw Base::ValueError("No pull direction reference specified"); @@ -209,14 +209,14 @@ App::DocumentObjectExecReturn *Draft::execute() if (!found) throw Base::RuntimeError("No neutral plane specified and none can be guessed"); } else { - if (refPlane->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + if (refPlane->isDerivedFrom()) { PartDesign::Plane* plane = static_cast(refPlane); Base::Vector3d b = plane->getBasePoint(); Base::Vector3d n = plane->getNormal(); neutralPlane = gp_Pln(gp_Pnt(b.x, b.y, b.z), gp_Dir(n.x, n.y, n.z)); - } else if (refPlane->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + } else if (refPlane->isDerivedFrom()) { neutralPlane = Feature::makePlnFromPlane(refPlane); - } else if (refPlane->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refPlane->isDerivedFrom()) { std::vector subStrings = NeutralPlane.getSubValues(); if (subStrings.empty() || subStrings[0].empty()) throw Base::ValueError("No neutral plane reference specified"); diff --git a/src/Mod/PartDesign/App/FeatureDressUp.cpp b/src/Mod/PartDesign/App/FeatureDressUp.cpp index 5d8bd8a21e..c77e5c67d8 100644 --- a/src/Mod/PartDesign/App/FeatureDressUp.cpp +++ b/src/Mod/PartDesign/App/FeatureDressUp.cpp @@ -66,7 +66,7 @@ short DressUp::mustExecute() const void DressUp::positionByBaseFeature() { Part::Feature *base = static_cast(BaseFeature.getValue()); - if (base && base->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (base && base->isDerivedFrom()) this->Placement.setValue(base->Placement.getValue()); } diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index d34233ef42..256ea7d29b 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -110,7 +110,7 @@ const std::list LinearPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (refObject->isDerivedFrom()) { Part::Part2DObject* refSketch = static_cast(refObject); Base::Axis axis; if (subStrings[0] == "H_Axis") { @@ -151,21 +151,21 @@ const std::list LinearPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Plane* plane = static_cast(refObject); Base::Vector3d d = plane->getNormal(); dir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Line* line = static_cast(refObject); Base::Vector3d d = line->getDirection(); dir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { App::Line* line = static_cast(refObject); Base::Rotation rot = line->Placement.getValue().getRotation(); Base::Vector3d d(1,0,0); rot.multVec(d, d); dir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { if (subStrings[0].empty()) throw Base::ValueError("No direction reference specified"); Part::Feature* refFeature = static_cast(refObject); diff --git a/src/Mod/PartDesign/App/FeatureMirrored.cpp b/src/Mod/PartDesign/App/FeatureMirrored.cpp index 0379b1d36c..90ace67654 100644 --- a/src/Mod/PartDesign/App/FeatureMirrored.cpp +++ b/src/Mod/PartDesign/App/FeatureMirrored.cpp @@ -68,7 +68,7 @@ const std::list Mirrored::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (refObject->isDerivedFrom()) { Part::Part2DObject* refSketch = static_cast(refObject); Base::Axis axis; if (subStrings[0] == "H_Axis") @@ -88,13 +88,13 @@ const std::list Mirrored::getTransformations(const std::vectorPlacement.getValue(); axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); - } else if (refObject->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Plane* plane = static_cast(refObject); Base::Vector3d base = plane->getBasePoint(); axbase = gp_Pnt(base.x, base.y, base.z); Base::Vector3d dir = plane->getNormal(); axdir = gp_Dir(dir.x, dir.y, dir.z); - } else if (refObject->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { App::Plane* plane = static_cast(refObject); Base::Vector3d base = plane->Placement.getValue().getPosition(); axbase = gp_Pnt(base.x, base.y, base.z); @@ -102,7 +102,7 @@ const std::list Mirrored::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { if (subStrings[0].empty()) throw Base::ValueError("No direction reference specified"); Part::TopoShape baseShape = static_cast(refObject)->Shape.getShape(); diff --git a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp index be59aba392..b4ac76d554 100644 --- a/src/Mod/PartDesign/App/FeatureMultiTransform.cpp +++ b/src/Mod/PartDesign/App/FeatureMultiTransform.cpp @@ -51,7 +51,7 @@ void MultiTransform::positionBySupport() PartDesign::Transformed::positionBySupport(); std::vector transFeatures = Transformations.getValues(); for (auto f : transFeatures) { - if (!(f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) + if (!(f->isDerivedFrom())) throw Base::TypeError("Transformation features must be subclasses of Transformed"); PartDesign::Transformed* transFeature = static_cast(f); transFeature->Placement.setValue(this->Placement.getValue()); @@ -80,7 +80,7 @@ const std::list MultiTransform::getTransformations(const std::vector(originals.front()); TopoDS_Shape original; - if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + if (originalFeature->isDerivedFrom()) { PartDesign::FeatureAddSub* addFeature = static_cast(originalFeature); //if (addFeature->getAddSubType() == FeatureAddSub::Additive) // original = addFeature->AddSubShape.getShape().getShape(); @@ -97,7 +97,7 @@ const std::list MultiTransform::getTransformations(const std::vector::const_iterator f; for (f = transFeatures.begin(); f != transFeatures.end(); ++f) { - if (!((*f)->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()))) + if (!((*f)->isDerivedFrom())) throw Base::TypeError("Transformation features must be subclasses of Transformed"); PartDesign::Transformed* transFeature = static_cast(*f); std::list newTransformations = transFeature->getTransformations(originals); @@ -116,7 +116,7 @@ const std::list MultiTransform::getTransformations(const std::vector oldCogs; cogs.swap(oldCogs); // empty cogs to receive new cogs - if ((*f)->getTypeId() == PartDesign::Scaled::getClassTypeId()) { + if ((*f)->is()) { // Diagonal method // Multiply every element in the old transformations' slices with the corresponding // element in the newTransformations. Example: diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index 00e833f7b8..032fca9dfe 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -173,7 +173,7 @@ App::DocumentObjectExecReturn *Pipe::execute() // build the paths App::DocumentObject* spine = Spine.getValue(); - if (!(spine && spine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) + if (!(spine && spine->isDerivedFrom())) return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No spine linked")); std::vector subedge = Spine.getSubValues(); @@ -186,7 +186,7 @@ App::DocumentObjectExecReturn *Pipe::execute() TopoDS_Shape auxpath; if (Mode.getValue() == 3) { App::DocumentObject* auxspine = AuxillerySpine.getValue(); - if (!(auxspine && auxspine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) + if (!(auxspine && auxspine->isDerivedFrom())) return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No auxiliary spine linked.")); std::vector auxsubedge = AuxillerySpine.getSubValues(); diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp index c8436fc896..26df30d606 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp @@ -104,7 +104,7 @@ const std::list PolarPattern::getTransformations(const std::vectorgetTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (refObject->isDerivedFrom()) { Part::Part2DObject* refSketch = static_cast(refObject); Base::Axis axis; if (subStrings[0] == "H_Axis") @@ -121,19 +121,19 @@ const std::list PolarPattern::getTransformations(const std::vectorPlacement.getValue(); axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); - } else if (refObject->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { PartDesign::Line* line = static_cast(refObject); Base::Vector3d base = line->getBasePoint(); axbase = gp_Pnt(base.x, base.y, base.z); Base::Vector3d dir = line->getDirection(); axdir = gp_Dir(dir.x, dir.y, dir.z); - } else if (refObject->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { App::Line* line = static_cast(refObject); Base::Rotation rot = line->Placement.getValue().getRotation(); Base::Vector3d d(1,0,0); rot.multVec(d, d); axdir = gp_Dir(d.x, d.y, d.z); - } else if (refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + } else if (refObject->isDerivedFrom()) { if (subStrings[0].empty()) throw Base::ValueError("No axis reference specified"); Part::Feature* refFeature = static_cast(refObject); diff --git a/src/Mod/PartDesign/App/FeatureScaled.cpp b/src/Mod/PartDesign/App/FeatureScaled.cpp index dddef82df3..7cc1717e89 100644 --- a/src/Mod/PartDesign/App/FeatureScaled.cpp +++ b/src/Mod/PartDesign/App/FeatureScaled.cpp @@ -69,7 +69,7 @@ const std::list Scaled::getTransformations(const std::vector(originals.front()); TopoDS_Shape original; - if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + if (originalFeature->isDerivedFrom()) { PartDesign::FeatureAddSub* Feature = static_cast(originalFeature); //if(Feature->getAddSubType() == FeatureAddSub::Additive) // original = Feature->AddSubShape.getShape().getShape(); diff --git a/src/Mod/PartDesign/App/FeatureSketchBased.cpp b/src/Mod/PartDesign/App/FeatureSketchBased.cpp index 5df0ebe35e..f42506297a 100644 --- a/src/Mod/PartDesign/App/FeatureSketchBased.cpp +++ b/src/Mod/PartDesign/App/FeatureSketchBased.cpp @@ -130,7 +130,7 @@ Part::Part2DObject* ProfileBased::getVerifiedSketch(bool silent) const { err = "No profile linked at all"; } else { - if (!result->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (!result->isDerivedFrom()) { err = "Linked object is not a Sketch or Part2DObject"; result = nullptr; } @@ -152,7 +152,7 @@ Part::Feature* ProfileBased::getVerifiedObject(bool silent) const { err = "No object linked"; } else { - if (!result->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!result->isDerivedFrom()) err = "Linked object is not a Sketch, Part2DObject or Feature"; } @@ -213,12 +213,12 @@ TopoDS_Shape ProfileBased::getVerifiedFace(bool silent) const { } } else { - if (result->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (result->isDerivedFrom()) { auto wires = getProfileWires(); return Part::FaceMakerCheese::makeFace(wires); } - else if (result->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (result->isDerivedFrom()) { if (Profile.getSubValues().empty()) err = "Linked object has no subshape specified"; else { @@ -424,17 +424,17 @@ void ProfileBased::getFaceFromLinkSub(TopoDS_Face& upToFace, const App::Property if (!ref) throw Base::ValueError("SketchBased: No face selected"); - if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + if (ref->isDerivedFrom()) { upToFace = TopoDS::Face(makeShapeFromPlane(ref)); return; } - else if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) { + else if (ref->isDerivedFrom()) { Part::Datum* datum = static_cast(ref); upToFace = TopoDS::Face(datum->getShape()); return; } - if (!ref->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!ref->isDerivedFrom()) throw Base::TypeError("SketchBased: Must be face of a feature"); Part::TopoShape baseShape = static_cast(ref)->Shape.getShape(); @@ -1008,7 +1008,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st App::DocumentObject* profile = Profile.getValue(); gp_Pln sketchplane; - if (profile->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (profile->isDerivedFrom()) { Part::Part2DObject* sketch = getVerifiedSketch(); Base::Placement SketchPlm = sketch->Placement.getValue(); Base::Vector3d SketchVector = Base::Vector3d(0, 0, 1); @@ -1048,7 +1048,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st } } - else if (profile->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + else if (profile->isDerivedFrom()) { Base::Placement SketchPlm = getVerifiedObject()->Placement.getValue(); Base::Vector3d SketchVector = getProfileNormal(); Base::Vector3d SketchPos = SketchPlm.getPosition(); @@ -1056,7 +1056,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st } // get reference axis - if (pcReferenceAxis->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) { + if (pcReferenceAxis->isDerivedFrom()) { const PartDesign::Line* line = static_cast(pcReferenceAxis); base = line->getBasePoint(); dir = line->getDirection(); @@ -1065,7 +1065,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st return; } - if (pcReferenceAxis->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + if (pcReferenceAxis->isDerivedFrom()) { const App::Line* line = static_cast(pcReferenceAxis); base = Base::Vector3d(0, 0, 0); line->Placement.getValue().multVec(Base::Vector3d(1, 0, 0), dir); @@ -1074,7 +1074,7 @@ void ProfileBased::getAxis(const App::DocumentObject * pcReferenceAxis, const st return; } - if (pcReferenceAxis->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (pcReferenceAxis->isDerivedFrom()) { if (subReferenceAxis.empty()) throw Base::ValueError("No rotation axis reference specified"); const Part::Feature* refFeature = static_cast(pcReferenceAxis); diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index fb97ef0732..3e0788dae7 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -107,23 +107,23 @@ Part::Feature* Transformed::getBaseObject(bool silent) const { App::DocumentObject* Transformed::getSketchObject() const { std::vector originals = Originals.getValues(); - if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (!originals.empty() && originals.front()->isDerivedFrom()) { return (static_cast(originals.front()))->getVerifiedSketch(true); } - else if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + else if (!originals.empty() && originals.front()->isDerivedFrom()) { return nullptr; } - else if (this->getTypeId().isDerivedFrom(LinearPattern::getClassTypeId())) { + else if (this->isDerivedFrom()) { // if Originals is empty then try the linear pattern's Direction property const LinearPattern* pattern = static_cast(this); return pattern->Direction.getValue(); } - else if (this->getTypeId().isDerivedFrom(PolarPattern::getClassTypeId())) { + else if (this->isDerivedFrom()) { // if Originals is empty then try the polar pattern's Axis property const PolarPattern* pattern = static_cast(this); return pattern->Axis.getValue(); } - else if (this->getTypeId().isDerivedFrom(Mirrored::getClassTypeId())) { + else if (this->isDerivedFrom()) { // if Originals is empty then try the mirror pattern's MirrorPlane property const Mirrored* pattern = static_cast(this); return pattern->MirrorPlane.getValue(); @@ -143,7 +143,7 @@ void Transformed::handleChangedPropertyType(Base::XMLReader &reader, const char // The property 'Angle' of PolarPattern has changed from PropertyFloat // to PropertyAngle and the property 'Length' has changed to PropertyLength. Base::Type inputType = Base::Type::fromName(TypeName); - if (prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId()) && + if (prop->isDerivedFrom() && inputType.isDerivedFrom(App::PropertyFloat::getClassTypeId())) { // Do not directly call the property's Restore method in case the implementation // has changed. So, create a temporary PropertyFloat object and assign the value. @@ -254,7 +254,7 @@ App::DocumentObjectExecReturn *Transformed::execute() Part::TopoShape fuseShape; Part::TopoShape cutShape; - if (original->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) { + if (original->isDerivedFrom()) { PartDesign::FeatureAddSub* feature = static_cast(original); feature->getAddSubShape(fuseShape, cutShape); if (fuseShape.isNull() && cutShape.isNull()) diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index b7e2325cc3..1339f3650b 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -151,7 +151,7 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, //we only allow one part feature, so get the first one we find size_t index = 0; for (auto* it : objs) { - if (it && it->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (it && it->isDerivedFrom()) { obj = static_cast(it); break; } @@ -182,11 +182,11 @@ void ShapeBinder::getFilteredReferences(const App::PropertyLinkSubList* prop, else { // search for Origin features for (auto* it : objs) { - if (it && it->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + if (it && it->isDerivedFrom()) { obj = static_cast(it); break; } - else if (it && it->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + else if (it && it->isDerivedFrom()) { obj = static_cast(it); break; } @@ -199,7 +199,7 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std: if (!obj) return TopoDS_Shape(); - if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (obj->isDerivedFrom()) { Part::Feature* part = static_cast(obj); if (subs.empty()) return part->Shape.getValue(); @@ -224,14 +224,14 @@ Part::TopoShape ShapeBinder::buildShapeFromReferences(App::GeoFeature* obj, std: return cmp; } } - else if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + else if (obj->isDerivedFrom()) { gp_Lin line; BRepBuilderAPI_MakeEdge mkEdge(line); Part::TopoShape shape(mkEdge.Shape()); shape.setPlacement(obj->Placement.getValue()); return shape; } - else if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + else if (obj->isDerivedFrom()) { gp_Pln plane; BRepBuilderAPI_MakeFace mkFace(plane); Part::TopoShape shape(mkFace.Shape()); @@ -273,7 +273,7 @@ void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::P return; if (!TraceSupport.getValue()) return; - if (!Prop.getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) + if (!Prop.isDerivedFrom()) return; App::GeoFeature* obj = nullptr; diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 2bef4dddeb..f79aa94a09 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -617,9 +617,9 @@ unsigned validateSketches(std::vector& sketches, std::vector::iterator o = inList.begin(); while (o != inList.end()) { //Base::Console().Error("Inlist: %s\n", (*o)->getNameInDocument()); - if ((*o)->getTypeId().isDerivedFrom(PartDesign::Body::getClassTypeId())) + if ((*o)->isDerivedFrom()) o = inList.erase(o); //ignore bodies - else if (!( (*o)->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) )) + else if (!( (*o)->isDerivedFrom() )) o = inList.erase(o); //ignore non-partDesign else ++o; @@ -2244,7 +2244,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg) if (!features.empty()) { // Throw out MultiTransform features, we don't want to nest them for (std::vector::iterator f = features.begin(); f != features.end(); ) { - if ((*f)->getTypeId().isDerivedFrom(PartDesign::MultiTransform::getClassTypeId())) + if ((*f)->isDerivedFrom()) f = features.erase(f); else f++; diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index 65014d6960..e5f49d5bad 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -231,7 +231,7 @@ void CmdPartDesignBody::activated(int iMsg) if (body) { std::vector links = body->Group.getValues(); for (auto it : links) { - if (it->getTypeId().isDerivedFrom(PartDesign::FeatureBase::getClassTypeId())) { + if (it->isDerivedFrom()) { PartDesign::FeatureBase* base = static_cast(it); if (base && base->BaseFeature.getValue() == baseFeature) { Gui::Application::Instance->hideViewProvider(baseFeature); @@ -797,7 +797,7 @@ void CmdPartDesignMoveFeature::activated(int iMsg) } // Fix sketch support - if (feat->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) { + if (feat->isDerivedFrom()) { Sketcher::SketchObject *sketch = static_cast(feat); try { PartDesignGui::fixSketchSupport(sketch); diff --git a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp index cc821b1ff3..a36d29d056 100644 --- a/src/Mod/PartDesign/Gui/ReferenceSelection.cpp +++ b/src/Mod/PartDesign/Gui/ReferenceSelection.cpp @@ -68,11 +68,11 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c } // Enable selection from origin of current part/ - if (pObj->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (pObj->isDerivedFrom()) { return allowOrigin(body, originGroup, pObj); } - if (pObj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + if (pObj->isDerivedFrom()) { return allowDatum(body, pObj); } @@ -90,11 +90,11 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c return type.testFlag(AllowSelection::WHOLE); // resolve links if needed - if (!pObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (!pObj->isDerivedFrom()) { pObj = Part::Feature::getShapeOwner(pObj, sSubName); } - if (pObj && pObj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + if (pObj && pObj->isDerivedFrom()) { return allowPartFeature(pObj, sSubName); } @@ -138,10 +138,10 @@ App::OriginGroupExtension* ReferenceSelection::getOriginGroupExtension(PartDesig bool ReferenceSelection::allowOrigin(PartDesign::Body *body, App::OriginGroupExtension* originGroup, App::DocumentObject* pObj) const { bool fits = false; - if (type.testFlag(AllowSelection::FACE) && pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + if (type.testFlag(AllowSelection::FACE) && pObj->isDerivedFrom()) { fits = true; } - else if (type.testFlag(AllowSelection::EDGE) && pObj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) { + else if (type.testFlag(AllowSelection::EDGE) && pObj->isDerivedFrom()) { fits = true; } @@ -173,11 +173,11 @@ bool ReferenceSelection::allowDatum(PartDesign::Body *body, App::DocumentObject* return false; } - if (type.testFlag(AllowSelection::FACE) && (pObj->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId()))) + if (type.testFlag(AllowSelection::FACE) && (pObj->isDerivedFrom())) return true; - if (type.testFlag(AllowSelection::EDGE) && (pObj->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId()))) + if (type.testFlag(AllowSelection::EDGE) && (pObj->isDerivedFrom())) return true; - if (type.testFlag(AllowSelection::POINT) && (pObj->getTypeId().isDerivedFrom(PartDesign::Point::getClassTypeId()))) + if (type.testFlag(AllowSelection::POINT) && (pObj->isDerivedFrom())) return true; return false; diff --git a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp index 07c7774828..7bfc3a2150 100644 --- a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp @@ -111,7 +111,7 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg) return; // if the selected object is not a body then get the body it is part of - if (!pcBody->getTypeId().isDerivedFrom(PartDesign::Body::getClassTypeId())) { + if (!pcBody->isDerivedFrom()) { pcBody = PartDesign::Body::findBodyOf(pcBody); if (!pcBody) return; diff --git a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp index 986d52c84c..3179cf20b7 100644 --- a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp @@ -100,7 +100,7 @@ bool TaskDlgFeatureParameters::accept() { } // Make sure the feature is what we are expecting // Should be fine but you never know... - if ( !feature->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId()) ) { + if ( !feature->isDerivedFrom() ) { throw Base::TypeError("Bad object processed in the feature dialog."); } diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index d5c0649120..d6d2a8da7c 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -263,7 +263,7 @@ std::vector TaskFeaturePick::buildFeatures() else if (status == notInBody) { activeBody->addObject(copy); // doesn't supposed to get here anything but sketch but to be on the safe side better to check - if (copy->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) { + if (copy->isDerivedFrom()) { Sketcher::SketchObject *sketch = static_cast(copy); PartDesignGui::fixSketchSupport(sketch); } @@ -325,10 +325,10 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st //independent copies don't have links and are not attached if(independent && ( - prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId()) || - prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId()) || - prop->getTypeId().isDerivedFrom(App::PropertyLinkSub::getClassTypeId()) || - prop->getTypeId().isDerivedFrom(App::PropertyLinkSubList::getClassTypeId())|| + prop->isDerivedFrom() || + prop->isDerivedFrom() || + prop->isDerivedFrom() || + prop->isDerivedFrom()|| ( prop->getGroup() && strcmp(prop->getGroup(),"Attachment")==0) )) { ++it; @@ -378,13 +378,13 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st long int mode = mmDeactivated; Part::Datum *datumCopy = static_cast(copy); - if(obj->getTypeId() == PartDesign::Point::getClassTypeId()) { + if(obj->is()) { mode = mm0Vertex; } - else if(obj->getTypeId() == PartDesign::Line::getClassTypeId()) { + else if(obj->is()) { mode = mm1TwoPoints; } - else if(obj->getTypeId() == PartDesign::Plane::getClassTypeId()) { + else if(obj->is()) { mode = mmFlatFace; } else @@ -401,7 +401,7 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st datumCopy->Shape.setValue(static_cast(obj)->Shape.getValue()); } } - else if(obj->getTypeId() == PartDesign::ShapeBinder::getClassTypeId() || + else if(obj->is() || obj->isDerivedFrom(Part::Feature::getClassTypeId())) { copy = App::GetApplication().getActiveDocument()->addObject("PartDesign::ShapeBinder", name.c_str()); diff --git a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp index 62ee1b697b..bc7b385c87 100644 --- a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.cpp @@ -260,13 +260,13 @@ void TaskMultiTransformParameters::onTransformEdit() std::vector transformFeatures = pcMultiTransform->Transformations.getValues(); subFeature = static_cast(transformFeatures[row]); - if (transformFeatures[row]->getTypeId() == PartDesign::Mirrored::getClassTypeId()) + if (transformFeatures[row]->is()) subTask = new TaskMirroredParameters(this, ui->verticalLayout); - else if (transformFeatures[row]->getTypeId() == PartDesign::LinearPattern::getClassTypeId()) + else if (transformFeatures[row]->is()) subTask = new TaskLinearPatternParameters(this, ui->verticalLayout); - else if (transformFeatures[row]->getTypeId() == PartDesign::PolarPattern::getClassTypeId()) + else if (transformFeatures[row]->is()) subTask = new TaskPolarPatternParameters(this, ui->verticalLayout); - else if (transformFeatures[row]->getTypeId() == PartDesign::Scaled::getClassTypeId()) + else if (transformFeatures[row]->is()) subTask = new TaskScaledParameters(this, ui->verticalLayout); else return; // TODO: Show an error? diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index 5cf5eb65e4..4bf845c716 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -146,11 +146,11 @@ QVariant TaskSketchBasedParameters::setUpToFace(const QString& text) if (!obj) return {}; - if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { + if (obj->isDerivedFrom()) { // everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree) return {}; } - else if (obj->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId())) { + else if (obj->isDerivedFrom()) { // it's up to the document to check that the datum plane is in the same body return {}; } @@ -256,7 +256,7 @@ bool TaskDlgSketchBasedParameters::accept() { // Make sure the feature is what we are expecting // Should be fine but you never know... - if (!feature->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (!feature->isDerivedFrom()) { throw Base::TypeError("Bad object processed in the sketch based dialog."); } diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 158caaf9ae..f52009f8fa 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -457,14 +457,14 @@ bool isFeatureMovable(App::DocumentObject* const feat) if (!feat) return false; - if (feat->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) { + if (feat->isDerivedFrom()) { auto prim = static_cast(feat); App::DocumentObject* bf = prim->BaseFeature.getValue(); if (bf) return false; } - if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (feat->isDerivedFrom()) { auto prim = static_cast(feat); auto sk = prim->getVerifiedSketch(true); @@ -501,7 +501,7 @@ bool isFeatureMovable(App::DocumentObject* const feat) if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { auto attachable = feat->getExtensionByType(); App::DocumentObject* support = attachable->Support.getValue(); - if (support && !support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) + if (support && !support->isDerivedFrom()) return false; } @@ -516,7 +516,7 @@ std::vector collectMovableDependencies(std::vectorgetTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + if (feat->isDerivedFrom()) { auto prim = static_cast(feat); Part::Part2DObject* sk = prim->getVerifiedSketch(true); if (sk) { @@ -529,19 +529,19 @@ std::vector collectMovableDependencies(std::vector(prim->getPropertyByName("ReferenceAxis"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } if (auto prop = static_cast(prim->getPropertyByName("Spine"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } if (auto prop = static_cast(prim->getPropertyByName("AuxillerySpine"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && !axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && !axis->isDerivedFrom()){ unique_objs.insert(axis); } } @@ -560,7 +560,7 @@ void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody) if (feat->hasExtension(Part::AttachExtension::getExtensionClassTypeId())) { auto attachable = feat->getExtensionByType(); App::DocumentObject* support = attachable->Support.getValue(); - if (support && support->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())) { + if (support && support->isDerivedFrom()) { auto originfeat = static_cast(support); App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue()); if (targetOriginFeature) { @@ -568,11 +568,11 @@ void relinkToOrigin(App::DocumentObject* feat, PartDesign::Body* targetbody) } } } - else if (feat->getTypeId().isDerivedFrom(PartDesign::ProfileBased::getClassTypeId())) { + else if (feat->isDerivedFrom()) { auto prim = static_cast(feat); if (auto prop = static_cast(prim->getPropertyByName("ReferenceAxis"))) { App::DocumentObject* axis = prop->getValue(); - if (axis && axis->getTypeId().isDerivedFrom(App::OriginFeature::getClassTypeId())){ + if (axis && axis->isDerivedFrom()){ auto originfeat = static_cast(axis); App::OriginFeature* targetOriginFeature = targetbody->getOrigin()->getOriginFeature(originfeat->Role.getValue()); if (targetOriginFeature) { diff --git a/src/Mod/PartDesign/Gui/ViewProvider.cpp b/src/Mod/PartDesign/Gui/ViewProvider.cpp index 94b314d5f6..14874a71fc 100644 --- a/src/Mod/PartDesign/Gui/ViewProvider.cpp +++ b/src/Mod/PartDesign/Gui/ViewProvider.cpp @@ -161,7 +161,7 @@ void ViewProvider::unsetEdit(int ModNum) void ViewProvider::updateData(const App::Property* prop) { // TODO What's that? (2015-07-24, Fat-Zer) - if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && + if (prop->is() && strcmp(prop->getName(),"AddSubShape") == 0) { return; } diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 19313c0003..fac6d815b0 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -490,7 +490,7 @@ bool ViewProviderBody::canDropObject(App::DocumentObject* obj) const void ViewProviderBody::dropObject(App::DocumentObject* obj) { PartDesign::Body* body = static_cast(getObject()); - if (obj->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) { + if (obj->isDerivedFrom()) { body->addObject(obj); } else if (PartDesign::Body::isAllowed(obj) && PartDesignGui::isFeatureMovable(obj)) { @@ -519,7 +519,7 @@ void ViewProviderBody::dropObject(App::DocumentObject* obj) // check if a proxy object has been created for the base feature std::vector links = body->Group.getValues(); for (auto it : links) { - if (it->getTypeId().isDerivedFrom(PartDesign::FeatureBase::getClassTypeId())) { + if (it->isDerivedFrom()) { PartDesign::FeatureBase* base = static_cast(it); if (base && base->BaseFeature.getValue() == obj) { Gui::Application::Instance->hideViewProvider(obj); diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp index 7c84e38206..13676e04e0 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatum.cpp @@ -105,22 +105,22 @@ void ViewProviderDatum::attach(App::DocumentObject *obj) // TODO remove this field (2015-09-08, Fat-Zer) App::DocumentObject* o = getObject(); - if (o->getTypeId() == PartDesign::Plane::getClassTypeId()) { + if (o->is()) { datumType = QString::fromLatin1("Plane"); datumText = QObject::tr("Plane"); datumMenuText = tr("Datum Plane parameters"); } - else if (o->getTypeId() == PartDesign::Line::getClassTypeId()) { + else if (o->is()) { datumType = QString::fromLatin1("Line"); datumText = QObject::tr("Line"); datumMenuText = tr("Datum Line parameters"); } - else if (o->getTypeId() == PartDesign::Point::getClassTypeId()) { + else if (o->is()) { datumType = QString::fromLatin1("Point"); datumText = QObject::tr("Point"); datumMenuText = tr("Datum Point parameters"); } - else if (o->getTypeId() == PartDesign::CoordinateSystem::getClassTypeId()) { + else if (o->is()) { datumType = QString::fromLatin1("CoordinateSystem"); datumText = QObject::tr("Coordinate System"); datumMenuText = tr("Local Coordinate System parameters"); diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index c931cd31dc..e34c811f4f 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -136,7 +136,7 @@ void ViewProviderShapeBinder::highlightReferences(bool on) return; // stop if not a Part feature was found - if (!obj || !obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) + if (!obj || !obj->isDerivedFrom()) return; PartGui::ViewProviderPart* svp = dynamic_cast(