diff --git a/src/Mod/TechDraw/App/DrawPage.cpp b/src/Mod/TechDraw/App/DrawPage.cpp index 084c12325206..a4e7f564f7ee 100644 --- a/src/Mod/TechDraw/App/DrawPage.cpp +++ b/src/Mod/TechDraw/App/DrawPage.cpp @@ -78,7 +78,7 @@ DrawPage::DrawPage(void) Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", 1l); + bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", true); //this is the default value for new pages! ADD_PROPERTY_TYPE(KeepUpdated, (autoUpdate), group, (App::PropertyType)(App::Prop_Output), "Keep page in sync with model"); ADD_PROPERTY_TYPE(Template, (0), group, (App::PropertyType)(App::Prop_None), "Attached Template"); @@ -324,14 +324,23 @@ void DrawPage::requestPaint(void) signalGuiPaint(this); } +//this doesn't work right because there is no guaranteed of the restoration order void DrawPage::onDocumentRestored() { - //control drawing updates on restore based on Preference - Base::Reference hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", 1l); - KeepUpdated.setValue(autoUpdate); + if (GlobalUpdateDrawings() && + KeepUpdated.getValue()) { + updateAllViews(); + } else if (!GlobalUpdateDrawings() && + AllowPageOverride() && + KeepUpdated.getValue()) { + updateAllViews(); + } + + App::DocumentObject::onDocumentRestored(); +} +void DrawPage::updateAllViews() +{ std::vector featViews = getAllViews(); std::vector::const_iterator it = featViews.begin(); //first, make sure all the Parts have been executed so GeometryObjects exist @@ -349,7 +358,6 @@ void DrawPage::onDocumentRestored() dim->recomputeFeature(); } } - App::DocumentObject::onDocumentRestored(); } std::vector DrawPage::getAllViews(void) @@ -439,6 +447,23 @@ void DrawPage::handleChangedPropertyType( } } +bool DrawPage::GlobalUpdateDrawings(void) +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); + bool result = hGrp->GetBool("GlobalUpdateDrawings", true); + return result; +} + +bool DrawPage::AllowPageOverride(void) +{ + Base::Reference hGrp = App::GetApplication().GetUserParameter() + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); + bool result = hGrp->GetBool("AllowPageOverride", true); + return result; +} + + // Python Drawing feature --------------------------------------------------------- namespace App { diff --git a/src/Mod/TechDraw/App/DrawPage.h b/src/Mod/TechDraw/App/DrawPage.h index a0cd5be3af86..4beabb78dc5a 100644 --- a/src/Mod/TechDraw/App/DrawPage.h +++ b/src/Mod/TechDraw/App/DrawPage.h @@ -97,6 +97,10 @@ class TechDrawExport DrawPage: public App::DocumentObject DrawViewPart *balloonParent; //could be many balloons on page? int getNextBalloonIndex(void); + + void updateAllViews(void); + static bool GlobalUpdateDrawings(void); + static bool AllowPageOverride(void); protected: void onBeforeChange(const App::Property* prop) override; diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index c09f68f1af28..ff46985473e7 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -365,10 +365,22 @@ void DrawView::handleChangedPropertyType( bool DrawView::keepUpdated(void) { bool result = false; + + bool pageUpdate = false; TechDraw::DrawPage *page = findParentPage(); if(page) { - result = page->KeepUpdated.getValue(); + pageUpdate = page->KeepUpdated.getValue(); + } + + if (DrawPage::GlobalUpdateDrawings() && + pageUpdate) { + result = true; + } else if (!DrawPage::GlobalUpdateDrawings() && + DrawPage::AllowPageOverride() && + pageUpdate) { + result = true; } + return result; } diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui index 7b75b8ed4416..7cdec64c1247 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui @@ -7,12 +7,15 @@ 0 0 558 - 935 + 1095 TechDraw General + + Default value for new Page + @@ -141,40 +144,91 @@ - + - Update Pages as scheduled or skip + Automatically distribute secondary views. - Keep Pages Up to Date + AutoDistribute Secondary Views true - KeepPagesUpToDate + AutoDist - Mod/TechDraw/General + /Mod/TechDraw/General - + + + + 75 + true + + + + Drawing Updates + + + + + - Automatically distribute secondary views. + Update drawings with changes in 3D model - AutoDistribute Secondary Views + Update with 3D (Global Policy) true - AutoDist + GlobalUpdateDrawings - /Mod/TechDraw/General + Mod/TechDraw/General + + + + + + + Allow Page to override Global update setting + + + Allow Page Override + + + true + + + AllowPageOverride + + + Mod/TechDraw/General + + + + + + + <html><head/><body><p>Update Pages as scheduled or skip updates. This is the default setting for new Pages.</p></body></html> + + + Keep Page Up to Date (default) + + + true + + + KeepPagesUpToDate + + + Mod/TechDraw/General diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp index ff532ecc9261..53be57bdc393 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawImp.cpp @@ -50,6 +50,8 @@ void DlgPrefsTechDrawImp::saveSettings() cb_Faces->onSave(); cb_SectionEdges->onSave(); cb_PageUpdate->onSave(); + cb_Global->onSave(); + cb_Override->onSave(); cb_AutoDist->onSave(); pcb_Normal->onSave(); @@ -81,6 +83,8 @@ void DlgPrefsTechDrawImp::loadSettings() cb_Faces->onRestore(); cb_SectionEdges->onRestore(); cb_PageUpdate->onRestore(); + cb_Global->onRestore(); + cb_Override->onRestore(); cb_AutoDist->onRestore(); pcb_Normal->onRestore(); diff --git a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp index f1bb5746494a..5fbda4d4c2fb 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp @@ -259,8 +259,8 @@ bool ViewProviderPage::showMDIViewPage() Gui::getMainWindow()->addWindow(m_mdiView); m_mdiView->viewAll(); //this is empty function m_mdiView->showMaximized(); - if(!getDrawPage()->KeepUpdated.getValue()) - getDrawPage()->KeepUpdated.setValue(true); +// if(!getDrawPage()->KeepUpdated.getValue()) +// getDrawPage()->KeepUpdated.setValue(true); } else { m_mdiView->updateDrawing(true); m_mdiView->redrawAllViews();