Ensure DrawView picks up DrawPage Scale at creation

This commit is contained in:
WandererFan
2017-09-07 19:47:40 -04:00
committed by wmayer
parent dfe174aec5
commit d15cd94f19
3 changed files with 16 additions and 8 deletions

View File

@@ -267,6 +267,8 @@ int DrawPage::addView(App::DocumentObject *docObj)
view->ScaleType.setValue("Automatic");
}
view->checkScale();
return Views.getSize();
}

View File

@@ -94,14 +94,22 @@ DrawView::~DrawView()
App::DocumentObjectExecReturn *DrawView::execute(void)
{
// TechDraw::DrawPage *page = findParentPage();
// if(page &&
// keepUpdated()) {
// //nothing for DrawView to do
// }
return App::DocumentObject::StdReturn; //DO::execute returns 0
}
void DrawView::checkScale(void)
{
TechDraw::DrawPage *page = findParentPage();
if(page &&
keepUpdated()) {
if (ScaleType.isValue("Page")) {
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
Scale.setValue(page->Scale.getValue());
}
}
}
}
void DrawView::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
@@ -136,9 +144,6 @@ void DrawView::onChanged(const App::Property* prop)
} else if (prop == &X || //nothing needs to be calculated, just the graphic needs to be shifted.
prop == &Y) {
requestPaint();
// if (isMouseMove()) { //actually "has mouse moved this item?"
// setAutoPos(false);
// }
}
}
App::DocumentObject::onChanged(prop);

View File

@@ -87,6 +87,7 @@ public:
bool keepUpdated(void);
boost::signal<void (const DrawView*)> signalGuiPaint;
virtual double getScale(void) const;
void checkScale(void);
protected:
void onChanged(const App::Property* prop);