TechDraw: Fix child of linked view.
This commit is contained in:
committed by
WandererFan
parent
156ae209f5
commit
4f3bb4e543
@@ -112,7 +112,6 @@ void QGSPage::addChildrenToPage()
|
||||
// A fresh page is added and we iterate through its collected children and add these to Canvas View -MLP
|
||||
// if docobj is a featureviewcollection (ex orthogroup), add its child views. if there are ever children that have children,
|
||||
// we'll have to make this recursive. -WF
|
||||
std::vector<App::DocumentObject*> childViews;
|
||||
for (auto* view : m_vpPage->getDrawPage()->getViews()) {
|
||||
attachView(view);
|
||||
auto* collect = dynamic_cast<TechDraw::DrawViewCollection*>(view);
|
||||
@@ -833,7 +832,8 @@ void QGSPage::fixOrphans(bool force)
|
||||
}
|
||||
else {
|
||||
//DrawView exists in Document. Does it belong to this DrawPage?
|
||||
int numParentPages = qv->getViewObject()->countParentPages();
|
||||
TechDraw::DrawView* viewObj = qv->getViewObject();
|
||||
int numParentPages = viewObj->countParentPages();
|
||||
if (numParentPages == 0) {
|
||||
//DrawView does not belong to any DrawPage
|
||||
//remove QGItem from QGScene
|
||||
@@ -841,8 +841,16 @@ void QGSPage::fixOrphans(bool force)
|
||||
}
|
||||
else if (numParentPages == 1) {
|
||||
//Does DrawView belong to this DrawPage?
|
||||
TechDraw::DrawPage* parentPage = qv->getViewObject()->findParentPage();
|
||||
TechDraw::DrawPage* parentPage = viewObj->findParentPage();
|
||||
if (thisPage != parentPage) {
|
||||
// The view could be a child of a link (ea Dimension).
|
||||
TechDraw::DrawView* parentView = viewObj->claimParent();
|
||||
for (auto* v : thisPage->getViews()) {
|
||||
if (v == parentView) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//DrawView does not belong to this DrawPage
|
||||
//remove QGItem from QGScene
|
||||
removeQView(qv);
|
||||
|
||||
@@ -129,25 +129,35 @@ void ViewProviderPageExtension::dropObject(App::DocumentObject* obj)
|
||||
}
|
||||
if (obj->isDerivedFrom<App::Link>()) {
|
||||
auto* link = static_cast<App::Link*>(obj);
|
||||
if (!link->getLinkedObject()->isDerivedFrom<TechDraw::DrawView>()) {
|
||||
obj = link->getLinkedObject();
|
||||
if (!obj->isDerivedFrom<TechDraw::DrawView>()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawPage* page = nullptr;
|
||||
for (auto& parent : obj->getInListRecursive()) {
|
||||
if (parent->isDerivedFrom<TechDraw::DrawPage>()) {
|
||||
page = static_cast<TechDraw::DrawPage*>(parent);
|
||||
std::vector<App::DocumentObject*> deps;
|
||||
for (auto& inObj : obj->getInList()) {
|
||||
if (inObj && inObj->isDerivedFrom<TechDraw::DrawView>()) {
|
||||
deps.push_back(inObj);
|
||||
}
|
||||
}
|
||||
|
||||
if (page) {
|
||||
break;
|
||||
TechDraw::DrawPage* page = nullptr;
|
||||
for (auto& inObj : link->getInList()) {
|
||||
if (inObj->isDerivedFrom<TechDraw::DrawPage>()) {
|
||||
page = static_cast<TechDraw::DrawPage*>(inObj);
|
||||
}
|
||||
}
|
||||
if (page) {
|
||||
page->removeView(obj);
|
||||
for (auto* dep : deps) {
|
||||
page->removeView(dep);
|
||||
}
|
||||
page->removeView(link);
|
||||
}
|
||||
|
||||
getViewProviderPage()->getDrawPage()->addView(obj);
|
||||
getViewProviderPage()->getDrawPage()->addView(link, false);
|
||||
for (auto* dep : deps) {
|
||||
getViewProviderPage()->getDrawPage()->addView(dep, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user