Skip to content

Commit

Permalink
[TD]fix LeaderLine noshow on doc load
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jan 12, 2020
1 parent acd3cd9 commit 00c69a9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
29 changes: 17 additions & 12 deletions src/Mod/TechDraw/Gui/MDIViewPage.cpp
Expand Up @@ -161,8 +161,16 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
App::Document* appDoc = m_vpPage->getDocument()->getDocument();
auto bnd = boost::bind(&MDIViewPage::onDeleteObject, this, _1);
connectDeletedObject = appDoc->signalDeletedObject.connect(bnd);
}


MDIViewPage::~MDIViewPage()
{
connectDeletedObject.disconnect();
}

void MDIViewPage::addChildrenToPage(void)
{
// 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
Expand Down Expand Up @@ -190,12 +198,8 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
attachTemplate(pageTemplate);
matchSceneRectToTemplate();
}
}


MDIViewPage::~MDIViewPage()
{
connectDeletedObject.disconnect();
viewAll();
}

void MDIViewPage::matchSceneRectToTemplate(void)
Expand Down Expand Up @@ -246,10 +250,13 @@ void MDIViewPage::setBalloonGroups(void)

void MDIViewPage::setLeaderGroups(void)
{
// Base::Console().Message("MDIVP::setLeaderGroups()\n");
const std::vector<QGIView *> &allItems = m_view->getViews();
std::vector<QGIView *>::const_iterator itInspect;
int leadItemType = QGraphicsItem::UserType + 232;

//make sure that qgileader belongs to correct parent.
//quite possibly redundant
for (itInspect = allItems.begin(); itInspect != allItems.end(); itInspect++) {
if (((*itInspect)->type() == leadItemType) && (!(*itInspect)->group())) {
QGIView* parent = m_view->findParent((*itInspect));
Expand Down Expand Up @@ -400,7 +407,7 @@ void MDIViewPage::onDeleteObject(const App::DocumentObject& obj)
}

void MDIViewPage::onTimer() {
updateDrawing(true);
fixOrphans(true);
}

void MDIViewPage::updateTemplate(bool forceUpdate)
Expand Down Expand Up @@ -430,9 +437,7 @@ void MDIViewPage::updateTemplate(bool forceUpdate)
}

//this is time consuming. should only be used when there is a problem.
//should have been called MDIViewPage::fixWidowAndOrphans()
//void MDIViewPage::updateDrawing(bool forceUpdate)
void MDIViewPage::updateDrawing(bool force)
void MDIViewPage::fixOrphans(bool force)
{
if(!force) {
m_timer->start(100);
Expand Down Expand Up @@ -479,15 +484,15 @@ void MDIViewPage::updateDrawing(bool force)
// WF: why do we do this? views should be keeping themselves up to date.
// const std::vector<QGIView *> &upviews = m_view->getViews();
// for(std::vector<QGIView *>::const_iterator it = upviews.begin(); it != upviews.end(); ++it) {
// Base::Console().Message("TRACE - MDIVP::updateDrawing - updating a QGIVxxxx\n");
// Base::Console().Message("TRACE - MDIVP::fixOrphans - updating a QGIVxxxx\n");
// if((*it)->getViewObject()->isTouched() ||
// forceUpdate) {
// (*it)->updateView(forceUpdate);
// }
// }
}

//NOTE: this doesn't add missing views. see updateDrawing()
//NOTE: this doesn't add missing views. see fixOrphans()
void MDIViewPage::redrawAllViews()
{
const std::vector<QGIView *> &upviews = m_view->getViews();
Expand All @@ -496,7 +501,7 @@ void MDIViewPage::redrawAllViews()
}
}

//NOTE: this doesn't add missing views. see updateDrawing()
//NOTE: this doesn't add missing views. see fixOrphans()
void MDIViewPage::redraw1View(TechDraw::DrawView* dv)
{
std::string dvName = dv->getNameInDocument();
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/TechDraw/Gui/MDIViewPage.h
Expand Up @@ -57,6 +57,9 @@ class TechDrawGuiExport MDIViewPage : public Gui::MDIView, public Gui::Selection
MDIViewPage(ViewProviderPage *page, Gui::Document* doc, QWidget* parent = 0);
virtual ~MDIViewPage();

void addChildrenToPage(void);


/// Observer message from the Tree Selection mechanism
void onSelectionChanged(const Gui::SelectionChanges& msg);
void preSelectionChanged(const QPoint &pos);
Expand All @@ -68,7 +71,7 @@ class TechDrawGuiExport MDIViewPage : public Gui::MDIView, public Gui::Selection

void attachTemplate(TechDraw::DrawTemplate *obj);
void updateTemplate(bool force = false);
void updateDrawing(bool force = false);
void fixOrphans(bool force = false);
void matchSceneRectToTemplate(void);

bool onMsg(const char* pMsg,const char** ppReturn);
Expand Down
9 changes: 3 additions & 6 deletions src/Mod/TechDraw/Gui/QGILeaderLine.cpp
Expand Up @@ -132,6 +132,7 @@ QGILeaderLine::QGILeaderLine(QGraphicsItem* myParent,
m_editPath, SIGNAL(pointsUpdated(QPointF, std::vector<QPointF>)),
this , SLOT (onLineEditFinished(QPointF, std::vector<QPointF>))
);

}

QVariant QGILeaderLine::itemChange(GraphicsItemChange change, const QVariant &value)
Expand Down Expand Up @@ -358,18 +359,13 @@ void QGILeaderLine::draw()
return;
}
TechDraw::DrawView* parent = featLeader->getBaseView();
QGVPage* view = QGIView::getGraphicsView(parent);
if (view == nullptr) {
// Base::Console().Message("QGIL::draw - no graphcisView for parent!! - setup?\n");
return;
}

if (m_editPath->inEdit()) {
// Base::Console().Message("QGIL::draw - m_editPath in edit\n");
return;
}

//********

if (featLeader->isLocked()) {
setFlag(QGraphicsItem::ItemIsMovable, false);
} else {
Expand Down Expand Up @@ -453,6 +449,7 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)

QPointF QGILeaderLine::getAttachFromFeature(void)
{
// Base::Console().Message("QGILL::getAttachFromFeature()\n");
QPointF result;
TechDraw::DrawLeaderLine* featLeader = getFeature();
if((!featLeader) ) {
Expand Down
14 changes: 6 additions & 8 deletions src/Mod/TechDraw/Gui/QGVPage.cpp
Expand Up @@ -516,15 +516,13 @@ QGIView * QGVPage::addViewLeader(TechDraw::DrawLeaderLine *leader)
return nullptr;
}

//assign leader to correct parent if not already so
void QGVPage::addLeaderToParent(QGILeaderLine* lead, QGIView* parent)
{
assert(lead);
assert(parent); //blow up if we don't have Leader or Parent
QPointF posRef(0.,0.);
QPointF mapPos = lead->mapToItem(parent, posRef);
lead->moveBy(-mapPos.x(), -mapPos.y());
parent->addToGroup(lead); //vs lead->setParentItem(parent)??
lead->setZValue(ZVALUE::DIMENSION);
QGraphicsItem* qgiParent = lead->parentItem();
if (qgiParent != parent) {
parent->addToGroup(lead);
}
}

QGIView * QGVPage::addRichAnno(TechDraw::DrawRichAnno* anno)
Expand Down Expand Up @@ -610,7 +608,7 @@ QGIView* QGVPage::getQGIVByName(std::string name)
return nullptr;
}


//find the parent of a QGIV based on the corresponding feature's parentage
QGIView * QGVPage::findParent(QGIView *view) const
{
const std::vector<QGIView *> qviews = getViews();
Expand Down
16 changes: 7 additions & 9 deletions src/Mod/TechDraw/Gui/ViewProviderPage.cpp
Expand Up @@ -185,7 +185,7 @@ void ViewProviderPage::updateData(const App::Property* prop)
}
} else if (prop == &page->Views) {
if(m_mdiView && !page->isUnsetting())
m_mdiView->updateDrawing();
m_mdiView->fixOrphans();
}

Gui::ViewProviderDocumentObject::updateData(prop);
Expand Down Expand Up @@ -247,24 +247,22 @@ bool ViewProviderPage::showMDIViewPage()
Gui::Document* doc = Gui::Application::Instance->getDocument
(pcObject->getDocument());
m_mdiView = new MDIViewPage(this, doc, Gui::getMainWindow());
// QString tabTitle = QString::fromUtf8(getDrawPage()->getNameInDocument());
QString tabTitle = QString::fromUtf8(getDrawPage()->Label.getValue());

m_mdiView->setDocumentObject(getDrawPage()->getNameInDocument());
m_mdiView->setDocumentName(pcObject->getDocument()->getName());

m_mdiView->setWindowTitle(tabTitle + QString::fromLatin1("[*]"));
m_mdiView->setWindowIcon(Gui::BitmapFactory().pixmap("TechDraw_Tree_Page"));
m_mdiView->updateDrawing(true);
Gui::getMainWindow()->addWindow(m_mdiView);
m_mdiView->viewAll(); //this is empty function
m_mdiView->viewAll();
m_mdiView->showMaximized();
// if(!getDrawPage()->KeepUpdated.getValue())
// getDrawPage()->KeepUpdated.setValue(true);
m_mdiView->addChildrenToPage();
m_mdiView->fixOrphans(true);
} else {
m_mdiView->updateDrawing(true);
m_mdiView->redrawAllViews();
m_mdiView->updateTemplate(true);
m_mdiView->redrawAllViews();
m_mdiView->fixOrphans(true);
}
return true;
}
Expand Down Expand Up @@ -429,7 +427,7 @@ void ViewProviderPage::onGuiRepaint(const TechDraw::DrawPage* dp)
if (dp == getDrawPage()) {
if(!m_mdiView.isNull() &&
!getDrawPage()->isUnsetting()) {
m_mdiView->updateDrawing();
m_mdiView->fixOrphans();
}
}
}
Expand Down

0 comments on commit 00c69a9

Please sign in to comment.