[TechDraw] Unify Projection Group parent linking

This commit is contained in:
pavltom
2024-03-14 10:16:02 +01:00
committed by WandererFan
parent fc8f93d437
commit 8a4f13fb16
8 changed files with 25 additions and 55 deletions

View File

@@ -257,16 +257,6 @@ int QGSPage::addQView(QGIView* view)
// Find if it belongs to a parent
QGIView *parent = findParent(view);
if (parent) {
auto parentDocObj = parent->getViewObject();
auto parentDPG = dynamic_cast<TechDraw::DrawProjGroup*>(parentDocObj);
if (parentDPG) {
// move the DPGI to the center of the DPG. the DPGI must be placed in the
// correct position on the page before adding it to the DPG or it will be
// placed at scene(0,0).
QPointF posRef(0., 0.);
QPointF mapPos = view->mapToItem(parent, posRef);
view->moveBy(-mapPos.x(), -mapPos.y());
}
parent->addToGroup(view);
}
view->setPos(viewPos);
@@ -744,24 +734,6 @@ QGIView* QGSPage::findParent(QGIView* view) const
}
}
// Check if part of view collection
for (std::vector<QGIView*>::const_iterator it = qviews.begin(); it != qviews.end(); ++it) {
QGIViewCollection* grp = nullptr;
grp = dynamic_cast<QGIViewCollection*>(*it);
if (grp) {
TechDraw::DrawViewCollection* collection = nullptr;
collection = dynamic_cast<TechDraw::DrawViewCollection*>(grp->getViewObject());
if (collection) {
std::vector<App::DocumentObject*> objs = collection->Views.getValues();
for (std::vector<App::DocumentObject*>::iterator it = objs.begin();
it != objs.end(); ++it) {
if (strcmp(myFeat->getNameInDocument(), (*it)->getNameInDocument()) == 0)
return grp;
}
}
}
}
// Not found a parent
return nullptr;
}