[TD]fix ScaleType change behaviour
This commit is contained in:
committed by
WandererFan
parent
2cff977548
commit
437a89e42a
@@ -143,15 +143,15 @@ void DrawProjGroup::onChanged(const App::Property* prop)
|
||||
}
|
||||
|
||||
if (prop == &ScaleType) {
|
||||
double newScale = getScale();
|
||||
if (ScaleType.isValue("Automatic")) {
|
||||
//Nothing in particular
|
||||
} else if (ScaleType.isValue("Page")) {
|
||||
newScale = page->Scale.getValue();
|
||||
double newScale = page->Scale.getValue();
|
||||
if(std::abs(getScale() - newScale) > FLT_EPSILON) {
|
||||
Scale.setValue(newScale);
|
||||
}
|
||||
}
|
||||
updateChildrenScale();
|
||||
}
|
||||
if (prop == &Rotation) {
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
@@ -1008,8 +1008,8 @@ void DrawProjGroup::updateChildrenScale(void)
|
||||
Base::Console().Log("PROBLEM - DPG::updateChildrenScale - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
|
||||
} else if(view->Scale.getValue() != Scale.getValue()) {
|
||||
view->Scale.setValue(Scale.getValue());
|
||||
} else {
|
||||
view->Scale.setValue(getScale());
|
||||
view->recomputeFeature();
|
||||
}
|
||||
}
|
||||
@@ -1063,7 +1063,7 @@ void DrawProjGroup::updateViews(void) {
|
||||
auto view(dynamic_cast<DrawProjGroupItem *>(it));
|
||||
if (view == nullptr) {
|
||||
//if an element in Views is not a DPGI, something really bad has happened somewhere
|
||||
Base::Console().Log("PROBLEM - DPG::updateChildrenScale - non DPGI entry in Views! %s\n",
|
||||
Base::Console().Log("PROBLEM - DPG::updateViews - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ double DrawProjGroupItem::getScale(void) const
|
||||
double result = 1.0;
|
||||
auto pgroup = getPGroup();
|
||||
if (pgroup != nullptr) {
|
||||
result = pgroup->Scale.getValue();
|
||||
result = pgroup->getScale();
|
||||
if (!(result > 0.0)) {
|
||||
Base::Console().Log("DPGI - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue());
|
||||
result = 1.0; //kludgy protective fix. autoscale sometimes serves up 0.0!
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Exception.h>
|
||||
@@ -87,6 +88,8 @@ DrawView::DrawView(void):
|
||||
Scale.setConstraints(&scaleRange);
|
||||
|
||||
ADD_PROPERTY_TYPE(Caption, (""), group, App::Prop_Output, "Short text about the view");
|
||||
|
||||
setScaleAttribute();
|
||||
}
|
||||
|
||||
DrawView::~DrawView()
|
||||
@@ -148,7 +151,6 @@ void DrawView::onChanged(const App::Property* prop)
|
||||
if (page != nullptr) {
|
||||
if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) {
|
||||
Scale.setValue(page->Scale.getValue());
|
||||
Scale.purgeTouched();
|
||||
}
|
||||
}
|
||||
} else if ( ScaleType.isValue("Custom") ) {
|
||||
@@ -160,7 +162,6 @@ void DrawView::onChanged(const App::Property* prop)
|
||||
double newScale = autoScale(page->getPageWidth(),page->getPageHeight());
|
||||
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
|
||||
Scale.setValue(newScale);
|
||||
Scale.purgeTouched();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,6 +238,7 @@ QRectF DrawView::getRect() const
|
||||
void DrawView::onDocumentRestored()
|
||||
{
|
||||
handleXYLock();
|
||||
setScaleAttribute();
|
||||
DrawView::execute();
|
||||
}
|
||||
/**
|
||||
@@ -409,10 +411,15 @@ void DrawView::setPosition(double x, double y, bool force)
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: getScale is no longer needed and could revert to Scale.getValue
|
||||
double DrawView::getScale(void) const
|
||||
{
|
||||
auto result = Scale.getValue();
|
||||
if (ScaleType.isValue("Page")) {
|
||||
auto page = findParentPage();
|
||||
if (page) {
|
||||
result = page->Scale.getValue();
|
||||
}
|
||||
}
|
||||
if (!(result > 0.0)) {
|
||||
result = 1.0;
|
||||
Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue());
|
||||
@@ -538,6 +545,16 @@ bool DrawView::keepUpdated(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawView::setScaleAttribute()
|
||||
{
|
||||
if (ScaleType.isValue("Page") ||
|
||||
ScaleType.isValue("Automatic")) {
|
||||
Scale.setStatus(App::Property::ReadOnly,true);
|
||||
} else {
|
||||
Scale.setStatus(App::Property::ReadOnly, false);
|
||||
}
|
||||
}
|
||||
|
||||
int DrawView::prefScaleType(void)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
|
||||
@@ -105,6 +105,7 @@ public:
|
||||
virtual bool showLock(void) const;
|
||||
|
||||
std::vector<TechDraw::DrawLeaderLine*> getLeaders(void) const;
|
||||
void setScaleAttribute();
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop) override;
|
||||
|
||||
Reference in New Issue
Block a user