Fix page alignment when change to different Template

This commit is contained in:
WandererFan
2017-09-03 19:42:25 -04:00
committed by wmayer
parent ab28ef7f62
commit 833bd66a18
2 changed files with 15 additions and 3 deletions

View File

@@ -133,7 +133,7 @@ void DrawPage::onChanged(const App::Property* prop)
} else if (prop == &Template) {
if (!isRestoring() &&
!isDeleting()) {
Template.getValue()->touch();
//nothing to page to do??
}
} else if(prop == &Scale) {
// touch all views in the Page as they may be dependent on this scale
@@ -248,8 +248,6 @@ int DrawPage::addView(App::DocumentObject *docObj)
if(!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()))
return -1;
DrawView* view = static_cast<DrawView*>(docObj);
//TODO: replace list of views with PropertyLink to Page in subordinate DrawView
// view->Page.setValue(this);
//position all new views in center of Page (exceptDVDimension)
if (!docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {

View File

@@ -43,6 +43,7 @@
#include <Gui/Selection.h>
#include <Mod/TechDraw/App/DrawTemplate.h>
#include <Mod/TechDraw/App/DrawSVGTemplate.h>
#include "QGITemplate.h"
#include "QGVPage.h"
#include "MDIViewPage.h"
@@ -86,6 +87,19 @@ std::vector<std::string> ViewProviderTemplate::getDisplayModes(void) const
void ViewProviderTemplate::updateData(const App::Property* prop)
{
if (getTemplate()->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) {
auto t = static_cast<TechDraw::DrawSVGTemplate*>(getTemplate());
if (prop == &(t->Template)) {
Gui::MDIView* gmdi = getActiveView();
if (gmdi != nullptr) {
MDIViewPage* mdi = dynamic_cast<MDIViewPage*>(gmdi);
if (mdi != nullptr) {
mdi->attachTemplate(t);
mdi->viewAll();
}
}
}
}
Gui::ViewProviderDocumentObject::updateData(prop);
}