TechDraw: Enable App::Links to work with TechDraw views.
This commit is contained in:
committed by
WandererFan
parent
ed6c12773e
commit
4d84efb061
@@ -112,17 +112,13 @@ 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
|
||||
const std::vector<App::DocumentObject*>& grp = m_vpPage->getDrawPage()->Views.getValues();
|
||||
std::vector<App::DocumentObject*> childViews;
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = grp.begin(); it != grp.end();
|
||||
++it) {
|
||||
attachView(*it);
|
||||
TechDraw::DrawViewCollection* collect = dynamic_cast<TechDraw::DrawViewCollection*>(*it);
|
||||
for (auto* view : m_vpPage->getDrawPage()->getViews()) {
|
||||
attachView(view);
|
||||
auto* collect = dynamic_cast<TechDraw::DrawViewCollection*>(view);
|
||||
if (collect) {
|
||||
childViews = collect->Views.getValues();
|
||||
for (std::vector<App::DocumentObject*>::iterator itChild = childViews.begin();
|
||||
itChild != childViews.end(); ++itChild) {
|
||||
attachView(*itChild);
|
||||
for (auto* childView : collect->getViews()) {
|
||||
attachView(childView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,9 +242,8 @@ std::vector<QGIView*> QGSPage::getViews() const
|
||||
|
||||
int QGSPage::addQView(QGIView* view)
|
||||
{
|
||||
//don't add twice!
|
||||
QGIView* existing = getQGIVByName(view->getViewName());
|
||||
if (!existing) {
|
||||
if (!existing) { //don't add twice!
|
||||
addItem(view);
|
||||
|
||||
TechDraw::DrawView *viewObj = view->getViewObject();
|
||||
@@ -261,7 +256,7 @@ int QGSPage::addQView(QGIView* view)
|
||||
}
|
||||
view->setPos(viewPos);
|
||||
|
||||
auto viewProvider = dynamic_cast<ViewProviderDrawingView *>(QGIView::getViewProvider(view->getViewObject()));
|
||||
auto viewProvider = dynamic_cast<ViewProviderDrawingView *>(QGIView::getViewProvider(viewObj));
|
||||
if (viewProvider) {
|
||||
view->setZValue(viewProvider->StackOrder.getValue());
|
||||
}
|
||||
@@ -704,36 +699,30 @@ QGIView* QGSPage::findParent(QGIView* view) const
|
||||
}
|
||||
|
||||
//If type is dimension we check references first
|
||||
TechDraw::DrawViewDimension* dim = nullptr;
|
||||
dim = dynamic_cast<TechDraw::DrawViewDimension*>(myFeat);
|
||||
auto* dim = dynamic_cast<TechDraw::DrawViewDimension*>(myFeat);
|
||||
if (dim) {
|
||||
std::vector<App::DocumentObject*> objs = dim->References2D.getValues();
|
||||
|
||||
if (!objs.empty()) {
|
||||
std::vector<App::DocumentObject*> objs = dim->References2D.getValues();
|
||||
// Attach the dimension to the first object's group
|
||||
for (std::vector<QGIView*>::const_iterator it = qviews.begin(); it != qviews.end();
|
||||
++it) {
|
||||
if (strcmp((*it)->getViewName(), objs.at(0)->getNameInDocument()) == 0) {
|
||||
return *it;
|
||||
for (auto* qview : qviews) {
|
||||
if (strcmp(qview->getViewName(), objs.at(0)->getNameInDocument()) == 0) {
|
||||
return qview;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If type is balloon we check references first
|
||||
TechDraw::DrawViewBalloon* balloon = nullptr;
|
||||
balloon = dynamic_cast<TechDraw::DrawViewBalloon*>(myFeat);
|
||||
|
||||
auto* balloon = dynamic_cast<TechDraw::DrawViewBalloon*>(myFeat);
|
||||
if (balloon) {
|
||||
App::DocumentObject* obj = balloon->SourceView.getValue();
|
||||
|
||||
if (obj) {
|
||||
// Attach the Balloon to the first object's group
|
||||
for (std::vector<QGIView*>::const_iterator it = qviews.begin(); it != qviews.end();
|
||||
++it) {
|
||||
if (strcmp((*it)->getViewName(), obj->getNameInDocument()) == 0) {
|
||||
return *it;
|
||||
for (auto* qview : qviews) {
|
||||
if (strcmp(qview->getViewName(), obj->getNameInDocument()) == 0) {
|
||||
return qview;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -782,23 +771,20 @@ void QGSPage::refreshViews()
|
||||
void QGSPage::findMissingViews(const std::vector<App::DocumentObject*>& list,
|
||||
std::vector<App::DocumentObject*>& missing)
|
||||
{
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = list.begin(); it != list.end();
|
||||
++it) {
|
||||
for (auto* obj : list) {
|
||||
|
||||
if (!hasQView(*it))
|
||||
missing.push_back(*it);
|
||||
if (!hasQView(obj))
|
||||
missing.push_back(obj);
|
||||
|
||||
if ((*it)->isDerivedFrom<TechDraw::DrawViewCollection>()) {
|
||||
if (obj->isDerivedFrom<TechDraw::DrawViewCollection>()) {
|
||||
std::vector<App::DocumentObject*> missingChildViews;
|
||||
TechDraw::DrawViewCollection* collection =
|
||||
dynamic_cast<TechDraw::DrawViewCollection*>(*it);
|
||||
auto* collection = dynamic_cast<TechDraw::DrawViewCollection*>(obj);
|
||||
// Find Child Views recursively
|
||||
findMissingViews(collection->Views.getValues(), missingChildViews);
|
||||
findMissingViews(collection->getViews(), missingChildViews);
|
||||
|
||||
// Append the views to current missing list
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = missingChildViews.begin();
|
||||
it != missingChildViews.end(); ++it) {
|
||||
missing.push_back(*it);
|
||||
for (auto* missingChild : missingChildViews) {
|
||||
missing.push_back(missingChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -886,19 +872,17 @@ void QGSPage::fixOrphans(bool force)
|
||||
|
||||
bool QGSPage::orphanExists(const char* viewName, const std::vector<App::DocumentObject*>& list)
|
||||
{
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = list.begin(); it != list.end();
|
||||
++it) {
|
||||
for (auto* obj : list) {
|
||||
|
||||
//Check child objects too recursively
|
||||
if ((*it)->isDerivedFrom(TechDraw::DrawViewCollection::getClassTypeId())) {
|
||||
TechDraw::DrawViewCollection* collection =
|
||||
dynamic_cast<TechDraw::DrawViewCollection*>(*it);
|
||||
if (orphanExists(viewName, collection->Views.getValues()))
|
||||
if (obj->isDerivedFrom<TechDraw::DrawViewCollection>()) {
|
||||
auto* collection = dynamic_cast<TechDraw::DrawViewCollection*>(obj);
|
||||
if (orphanExists(viewName, collection->getViews()))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Unsure if we can compare pointers so rely on name
|
||||
if (strcmp(viewName, (*it)->getNameInDocument()) == 0) {
|
||||
if (strcmp(viewName, obj->getNameInDocument()) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user