Ensure ProjGroup is created before child

This commit is contained in:
wandererfan
2019-03-06 15:23:34 -05:00
committed by wmayer
parent e29c610993
commit 86cc2641bc
5 changed files with 31 additions and 26 deletions

View File

@@ -144,7 +144,7 @@ void DrawProjGroup::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
{
// Base::Console().Message("DPG::execute()\n");
// Base::Console().Message("DPG::execute() - %s\n", getNameInDocument());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
@@ -421,7 +421,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
view->LockPosition.setStatus(App::Property::ReadOnly,true); //Front should stay locked.
App::GetApplication().signalChangePropertyEditor(view->LockPosition);
view->LockPosition.purgeTouched();
// requestPaint();
requestPaint(); //make sure the group object is on the Gui page
}
// addView(view); //from DrawViewCollection
// if (view != getAnchor()) { //anchor is done elsewhere
@@ -871,8 +871,6 @@ void DrawProjGroup::updateChildrenLock(void)
Base::Console().Log("PROBLEM - DPG::updateChildrenLock - non DPGI entry in Views! %s\n",
getNameInDocument());
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
} else {
view->requestPaint();
}
}
}

View File

@@ -268,6 +268,11 @@ void MDIViewPage::centerOnPage(void)
}
}
bool MDIViewPage::addView(const App::DocumentObject *obj)
{
return attachView(const_cast<App::DocumentObject*>(obj));
}
bool MDIViewPage::attachView(App::DocumentObject *obj)
{
auto typeId(obj->getTypeId());

View File

@@ -102,6 +102,7 @@ public:
void setTabText(std::string t);
bool addView(const App::DocumentObject *obj);
public Q_SLOTS:
void viewAll();

View File

@@ -203,30 +203,33 @@ std::vector<QGIView *> QGVPage::getViews() const
int QGVPage::addQView(QGIView *view)
{
auto ourScene( scene() );
assert(ourScene);
//don't add twice!
QGIView* existing = getQGIVByName(view->getViewName());
if (existing == nullptr) {
auto ourScene( scene() );
assert(ourScene);
ourScene->addItem(view);
ourScene->addItem(view);
// Find if it belongs to a parent
QGIView *parent = 0;
parent = findParent(view);
// Find if it belongs to a parent
QGIView *parent = 0;
parent = findParent(view);
QPointF viewPos(Rez::guiX(view->getViewObject()->X.getValue()),
Rez::guiX(view->getViewObject()->Y.getValue() * -1));
QPointF viewPos(Rez::guiX(view->getViewObject()->X.getValue()),
Rez::guiX(view->getViewObject()->Y.getValue() * -1));
if(parent) {
// move child view to center of parent
QPointF posRef(0.,0.);
QPointF mapPos = view->mapToItem(parent, posRef);
view->moveBy(-mapPos.x(), -mapPos.y());
if(parent) {
// move child view to center of parent
QPointF posRef(0.,0.);
QPointF mapPos = view->mapToItem(parent, posRef);
view->moveBy(-mapPos.x(), -mapPos.y());
parent->addToGroup(view);
parent->addToGroup(view);
}
view->setPos(viewPos);
view->updateView(true);
}
view->setPos(viewPos);
view->updateView(true);
return 0;
}
@@ -281,8 +284,6 @@ QGIView * QGVPage::addViewPart(TechDraw::DrawViewPart *part)
{
QGIView* existing = findQViewForDocObj(part);
if (existing != nullptr) {
Base::Console().Log("INFO - QGVP::addViewPart - %s - QView exists\n",
part->getNameInDocument());
return existing;
}

View File

@@ -244,9 +244,9 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
if (qgiv) {
qgiv->updateView(true);
} else { //we are not part of the Gui page yet. ask page to add us.
auto page = dv->findParentPage();
MDIViewPage* page = getMDIViewPage();
if (page != nullptr) {
page->requestPaint();
page->addView(dv);
}
}
}