TechDraw: modernize type checking
This commit is contained in:
@@ -132,7 +132,7 @@ private:
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
if (obj->getTypeId().isDerivedFrom(TechDraw::DrawPage::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<TechDraw::DrawPage>()) {
|
||||
page = static_cast<TechDraw::DrawPage*>(obj);
|
||||
Gui::Document* activeGui = Gui::Application::Instance->getDocument(page->getDocument());
|
||||
Gui::ViewProvider* vp = activeGui->getViewProvider(obj);
|
||||
|
||||
@@ -98,7 +98,7 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val
|
||||
QGIView* gView = dynamic_cast<QGIView *>(childItem);
|
||||
if(gView) {
|
||||
TechDraw::DrawView *fView = gView->getViewObject();
|
||||
if(fView->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
|
||||
if(fView->isDerivedFrom<TechDraw::DrawProjGroupItem>()) {
|
||||
TechDraw::DrawProjGroupItem *projItemPtr = static_cast<TechDraw::DrawProjGroupItem *>(fView);
|
||||
QString type = QString::fromLatin1(projItemPtr->Type.getValueAsString());
|
||||
|
||||
|
||||
@@ -910,7 +910,7 @@ void QGSPage::findMissingViews(const std::vector<App::DocumentObject*>& list,
|
||||
if (!hasQView(*it))
|
||||
missing.push_back(*it);
|
||||
|
||||
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewCollection::getClassTypeId())) {
|
||||
if ((*it)->isDerivedFrom<TechDraw::DrawViewCollection>()) {
|
||||
std::vector<App::DocumentObject*> missingChildViews;
|
||||
TechDraw::DrawViewCollection* collection =
|
||||
dynamic_cast<TechDraw::DrawViewCollection*>(*it);
|
||||
|
||||
@@ -69,10 +69,10 @@ std::vector<App::DocumentObject*> ViewProviderAnnotation::claimChildren() const
|
||||
try {
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = views.begin();
|
||||
it != views.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())) {
|
||||
if ((*it)->isDerivedFrom<TechDraw::DrawViewBalloon>()) {
|
||||
temp.push_back((*it));
|
||||
}
|
||||
else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
else if ((*it)->isDerivedFrom<TechDraw::DrawLeaderLine>()) {
|
||||
temp.push_back((*it));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void ViewProviderDrawingView::show()
|
||||
if (!obj || obj->isRestoring())
|
||||
return;
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<TechDraw::DrawView>()) {
|
||||
QGIView* qView = getQView();
|
||||
if (qView) {
|
||||
qView->draw();
|
||||
@@ -151,7 +151,7 @@ void ViewProviderDrawingView::hide()
|
||||
if (!obj || obj->isRestoring())
|
||||
return;
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<TechDraw::DrawView>()) {
|
||||
QGIView* qView = getQView();
|
||||
if (qView) {
|
||||
//note: hiding an item in the scene clears its selection status
|
||||
|
||||
@@ -142,9 +142,9 @@ std::vector<App::DocumentObject*> ViewProviderLeader::claimChildren() const
|
||||
const std::vector<App::DocumentObject *> &views = getFeature()->getInList();
|
||||
try {
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
|
||||
if ((*it)->isDerivedFrom<TechDraw::DrawRichAnno>()) {
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId())) {
|
||||
} else if ((*it)->isDerivedFrom<TechDraw::DrawWeldSymbol>()) {
|
||||
temp.push_back((*it));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ void ViewProviderViewClip::show()
|
||||
App::DocumentObject* obj = getObject();
|
||||
if (!obj || obj->isRestoring())
|
||||
return;
|
||||
if (obj->getTypeId().isDerivedFrom(TechDraw::DrawViewClip::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<TechDraw::DrawViewClip>()) {
|
||||
std::vector<App::DocumentObject*> inp = obj->getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
|
||||
(*it)->touch();
|
||||
@@ -79,7 +79,7 @@ void ViewProviderViewClip::hide()
|
||||
App::DocumentObject* obj = getObject();
|
||||
if (!obj || obj->isRestoring())
|
||||
return;
|
||||
if (obj->getTypeId().isDerivedFrom(TechDraw::DrawViewClip::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<TechDraw::DrawViewClip>()) {
|
||||
std::vector<App::DocumentObject*> inp = obj->getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
|
||||
(*it)->touch();
|
||||
|
||||
@@ -199,7 +199,7 @@ std::vector<App::DocumentObject*> ViewProviderViewPart::claimChildren() const
|
||||
const std::vector<App::DocumentObject *> &views = getViewPart()->getInList();
|
||||
try {
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
if((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
||||
if((*it)->isDerivedFrom<TechDraw::DrawViewDimension>()) {
|
||||
//TODO: make a list, then prune it. should be faster?
|
||||
bool skip = false;
|
||||
std::string dimName = (*it)->getNameInDocument();
|
||||
@@ -213,15 +213,15 @@ std::vector<App::DocumentObject*> ViewProviderViewPart::claimChildren() const
|
||||
if (!skip) {
|
||||
temp.push_back(*it);
|
||||
}
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawHatch::getClassTypeId())) {
|
||||
} else if ((*it)->isDerivedFrom<TechDraw::DrawHatch>()) {
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawGeomHatch::getClassTypeId())) {
|
||||
} else if ((*it)->isDerivedFrom<TechDraw::DrawGeomHatch>()) {
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())) {
|
||||
} else if ((*it)->isDerivedFrom<TechDraw::DrawViewBalloon>()) {
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
|
||||
} else if ((*it)->isDerivedFrom<TechDraw::DrawRichAnno>()) {
|
||||
temp.push_back((*it));
|
||||
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) {
|
||||
} else if ((*it)->isDerivedFrom<TechDraw::DrawLeaderLine>()) {
|
||||
temp.push_back((*it));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ std::vector<App::DocumentObject*> ViewProviderWeld::claimChildren() const
|
||||
const std::vector<App::DocumentObject *> &tiles = getFeature()->getInList();
|
||||
try {
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = tiles.begin(); it != tiles.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawTile::getClassTypeId())) {
|
||||
if ((*it)->isDerivedFrom<TechDraw::DrawTile>()) {
|
||||
temp.push_back((*it));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user