Path: modernize type checking

This commit is contained in:
Florian Foinant-Willig
2023-10-15 21:39:14 +02:00
parent 773c701eec
commit 939f30420c
5 changed files with 14 additions and 14 deletions

View File

@@ -49,7 +49,7 @@ App::DocumentObjectExecReturn *FeatureCompound::execute()
Path::Toolpath result;
for (std::vector<DocumentObject*>::const_iterator it= Paths.begin();it!=Paths.end();++it) {
if ((*it)->getTypeId().isDerivedFrom(Path::Feature::getClassTypeId())){
if ((*it)->isDerivedFrom<Path::Feature>()){
const std::vector<Command*> &cmds = static_cast<Path::Feature*>(*it)->Path.getValue().getCommands();
const Base::Placement pl = static_cast<Path::Feature*>(*it)->Placement.getValue();
for (std::vector<Command*>::const_iterator it2= cmds.begin();it2!=cmds.end();++it2) {

View File

@@ -58,10 +58,10 @@ PyObject* FeaturePathCompoundPy::addObject(PyObject *args)
FeatureCompound* comp = getFeaturePathCompoundPtr();
if (comp->getTypeId().isDerivedFrom(Path::FeatureCompoundPython::getClassTypeId())) {
if (comp->isDerivedFrom<Path::FeatureCompoundPython>()) {
FeatureCompoundPython* comppy = static_cast<FeatureCompoundPython*>(comp);
App::Property* proxy = comppy->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
if (proxy && proxy->is<App::PropertyPythonObject>()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("addObject"))) {
Py::Callable method(vp.getAttr(std::string("addObject")));
@@ -99,10 +99,10 @@ PyObject* FeaturePathCompoundPy::removeObject(PyObject *args)
FeatureCompound* comp = getFeaturePathCompoundPtr();
if (comp->getTypeId().isDerivedFrom(Path::FeatureCompoundPython::getClassTypeId())) {
if (comp->isDerivedFrom<Path::FeatureCompoundPython>()) {
FeatureCompoundPython* comppy = static_cast<FeatureCompoundPython*>(comp);
App::Property* proxy = comppy->getPropertyByName("Proxy");
if (proxy && proxy->getTypeId() == App::PropertyPythonObject::getClassTypeId()) {
if (proxy && proxy->is<App::PropertyPythonObject>()) {
Py::Object vp = static_cast<App::PropertyPythonObject*>(proxy)->getValue();
if (vp.hasAttr(std::string("removeObject"))) {
Py::Callable method(vp.getAttr(std::string("removeObject")));

View File

@@ -66,7 +66,7 @@ void CmdPathArea::activated(int iMsg)
if(addView && !areaName.empty()) addView = false;
if(subnames.empty()) {
if(addView && pcObj->getTypeId().isDerivedFrom(Path::FeatureArea::getClassTypeId()))
if(addView && pcObj->isDerivedFrom<Path::FeatureArea>())
areaName = pcObj->getNameInDocument();
sources << "FreeCAD.activeDocument()." << pcObj->getNameInDocument() << ",";
continue;
@@ -151,7 +151,7 @@ void CmdPathAreaWorkplane::activated(int iMsg)
}
const Part::Feature *pcObj = static_cast<Part::Feature*>(selObj.getObject());
if(subnames.empty()) {
if(pcObj->getTypeId().isDerivedFrom(Path::FeatureArea::getClassTypeId())) {
if(pcObj->isDerivedFrom<Path::FeatureArea>()) {
if(!areaName.empty()){
Base::Console().Error("Please select one FeatureArea only\n");
return;
@@ -232,7 +232,7 @@ void CmdPathCompound::activated(int iMsg)
cmd << "[";
Path::Feature *pcPathObject;
for (std::vector<Gui::SelectionSingleton::SelObj>::const_iterator it=Sel.begin();it!=Sel.end();++it) {
if ((*it).pObject->getTypeId().isDerivedFrom(Path::Feature::getClassTypeId())) {
if ((*it).pObject->isDerivedFrom<Path::Feature>()) {
pcPathObject = static_cast<Path::Feature*>((*it).pObject);
cmd << "FreeCAD.activeDocument()." << pcPathObject->getNameInDocument() << ",";
} else {

View File

@@ -54,7 +54,7 @@ bool ViewProviderArea::canDragObjects() const
bool ViewProviderArea::canDragObject(App::DocumentObject* obj) const
{
return obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId());
return obj && obj->isDerivedFrom<Part::Feature>();
}
void ViewProviderArea::dragObject(App::DocumentObject* obj)
@@ -91,7 +91,7 @@ void ViewProviderArea::dropObject(App::DocumentObject* obj)
void ViewProviderArea::updateData(const App::Property* prop)
{
PartGui::ViewProviderPart::updateData(prop);
if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) {
if (prop->isDerivedFrom<App::PropertyLinkList>()) {
std::vector<App::DocumentObject*> pShapes = static_cast<const App::PropertyLinkList*>(prop)->getValues();
for (std::vector<App::DocumentObject*>::iterator it = pShapes.begin(); it != pShapes.end(); ++it) {
if (*it)
@@ -141,7 +141,7 @@ bool ViewProviderAreaView::canDragObjects() const
bool ViewProviderAreaView::canDragObject(App::DocumentObject* obj) const
{
return obj && obj->getTypeId().isDerivedFrom(Path::FeatureArea::getClassTypeId());
return obj && obj->isDerivedFrom<Path::FeatureArea>();
}
void ViewProviderAreaView::dragObject(App::DocumentObject* )
@@ -169,7 +169,7 @@ void ViewProviderAreaView::dropObject(App::DocumentObject* obj)
void ViewProviderAreaView::updateData(const App::Property* prop)
{
PartGui::ViewProviderPlaneParametric::updateData(prop);
if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId()))
if (prop->isDerivedFrom<App::PropertyLink>())
Gui::Application::Instance->hideViewProvider(
static_cast<const App::PropertyLink*>(prop)->getValue());
}

View File

@@ -52,7 +52,7 @@ bool ViewProviderPathShape::canDragObjects() const
bool ViewProviderPathShape::canDragObject(App::DocumentObject* obj) const
{
return obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId());
return obj && obj->isDerivedFrom<Part::Feature>();
}
void ViewProviderPathShape::dragObject(App::DocumentObject* obj)
@@ -89,7 +89,7 @@ void ViewProviderPathShape::dropObject(App::DocumentObject* obj)
void ViewProviderPathShape::updateData(const App::Property* prop)
{
PathGui::ViewProviderPath::updateData(prop);
if (prop->getTypeId().isDerivedFrom(App::PropertyLinkList::getClassTypeId())) {
if (prop->isDerivedFrom<App::PropertyLinkList>()) {
std::vector<App::DocumentObject*> pShapes = static_cast<const App::PropertyLinkList*>(prop)->getValues();
for (std::vector<App::DocumentObject*>::iterator it = pShapes.begin(); it != pShapes.end(); ++it) {
if (*it)