Fix double scaling in DPG AutoScale

This commit is contained in:
wandererfan
2018-09-23 15:03:11 -04:00
committed by wmayer
parent 3163c3d6f5
commit 859fed207d
3 changed files with 11 additions and 20 deletions

View File

@@ -103,7 +103,6 @@ void DrawProjGroup::onChanged(const App::Property* prop)
}
}
if (prop == &Scale) {
// Base::Console().Message("TRACE - DPG::onChanged(Scale) - %s\n",getNameInDocument());
updateChildren();
}
if (prop == &Source) {
@@ -111,7 +110,6 @@ void DrawProjGroup::onChanged(const App::Property* prop)
}
if (prop == &ScaleType) {
// Base::Console().Message("TRACE - DPG::onChanged(ScaleType) - %s\n",getNameInDocument());
double newScale = getScale();
if (ScaleType.isValue("Automatic")) {
//Recalculate scale if Group is too big or too small!
@@ -134,7 +132,6 @@ void DrawProjGroup::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
{
// Base::Console().Message("TRACE - DPG::execute() - %s\n",getNameInDocument());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
@@ -241,6 +238,7 @@ double DrawProjGroup::calculateAutomaticScale() const
width *= bbFudge;
height *= bbFudge;
// C++ Standard says casting bool to int gives 0 or 1
int numVertSpaces = (viewPtrs[0] || viewPtrs[3] || viewPtrs[7]) +
(viewPtrs[2] || viewPtrs[5] || viewPtrs[9]) +
@@ -264,6 +262,7 @@ double DrawProjGroup::calculateAutomaticScale() const
Base::Console().Log("DPG - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),result);
result = 1.0;
}
return result;
}
@@ -286,7 +285,7 @@ void DrawProjGroup::minimumBbViews(DrawProjGroupItem *viewPtrs[10],
{
// Get bounding boxes in object scale
Base::BoundBox3d bboxes[10];
makeViewBbs(viewPtrs, bboxes, false);
makeViewBbs(viewPtrs, bboxes, true);
//TODO: note that TLF/TRF/BLF,BRF extend a bit farther than a strict row/col arrangement would suggest.
//get widest view in each row/column

View File

@@ -112,10 +112,7 @@ void DrawView::checkScale(void)
void DrawView::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
if ((this->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) ||
(this->isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId()))) {
//do nothing. DPGI/DPG handles itself
} else if (prop == &ScaleType) {
if (prop == &ScaleType) {
auto page = findParentPage();
if (ScaleType.isValue("Page")) {
Scale.setStatus(App::Property::ReadOnly,true);
@@ -133,18 +130,15 @@ void DrawView::onChanged(const App::Property* prop)
} else if ( ScaleType.isValue("Automatic") ) {
Scale.setStatus(App::Property::ReadOnly,true);
App::GetApplication().signalChangePropertyEditor(Scale);
if (this->isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId())) {
//do nothing. DPG handles itself
} else {
if (!checkFit(page)) {
double newScale = autoScale(page->getPageWidth(),page->getPageHeight());
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
Scale.setValue(newScale);
Scale.purgeTouched();
}
if (!checkFit(page)) {
double newScale = autoScale(page->getPageWidth(),page->getPageHeight());
if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop
Scale.setValue(newScale);
Scale.purgeTouched();
}
}
}
}
// }
}
if (prop == &X || //nothing needs to be calculated, just the graphic needs to be shifted.
prop == &Y) {

View File

@@ -231,13 +231,11 @@ void TaskProjGroup::scaleTypeChanged(int index)
// Automatic Scale Type
// Gui::Command::doCommand(Gui::Command::Doc, "App.activeDocument().%s.ScaleType = '%s'", multiView->getNameInDocument()
// , "Automatic");
// Base::Console().Message("TRACE - TPG::scaleTypeChanged - Auto\n");
//block recompute
multiView->ScaleType.setValue("Automatic");
double autoScale = multiView->calculateAutomaticScale();
multiView->Scale.setValue(autoScale);
//unblock recompute
// Base::Console().Message("TRACE - TPG::scaleTypeChanged - autoScale: %.3f\n",autoScale);
} else if(index == 2) {
// Custom Scale Type