From 47f3d64a88dbae2ad503dc9c654ab026bafb7d1c Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 9 Mar 2009 15:17:20 +0000 Subject: [PATCH] Fix fitAll() function problem on empty view caused by previous integration --- src/Plot2d/Plot2d_ViewFrame.cxx | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 2e95cc8cb..119e548e0 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -833,17 +833,27 @@ void Plot2d_ViewFrame::getFitRangeByCurves(double& xMin,double& xMax, double& yMin, double& yMax, double& y2Min, double& y2Max) { - CurveDict::const_iterator it = myPlot->getCurves().begin(); - xMin = yMin = y2Min = 1e150; - xMax = yMax = y2Max = -1e150; - for ( ; it != myPlot->getCurves().end(); it++ ) { - if ( xMin > it.value()->getMinX() ) xMin = it.value()->getMinX(); - if ( xMax < it.value()->getMaxX() ) xMax = it.value()->getMaxX(); - if ( yMin > it.value()->getMinY() ) yMin = it.value()->getMinY(); - if ( yMax < it.value()->getMaxY() ) yMax = it.value()->getMaxY(); + CurveDict cdict = getCurves(); + if ( !cdict.isEmpty() ) { + CurveDict::const_iterator it = myPlot->getCurves().begin(); + xMin = yMin = y2Min = 1e150; + xMax = yMax = y2Max = -1e150; + for ( ; it != myPlot->getCurves().end(); it++ ) { + if ( xMin > it.value()->getMinX() ) xMin = it.value()->getMinX(); + if ( xMax < it.value()->getMaxX() ) xMax = it.value()->getMaxX(); + if ( yMin > it.value()->getMinY() ) yMin = it.value()->getMinY(); + if ( yMax < it.value()->getMaxY() ) yMax = it.value()->getMaxY(); + } + y2Min = yMin; + y2Max = yMax; + } + else { + // default values + xMin = isModeHorLinear() ? 0. : 1.; + xMax = isModeHorLinear() ? 1000. : 1e5; + yMin = y2Min = isModeVerLinear() ? 0. : 1.; + yMax = y2Max = isModeVerLinear() ? 1000 : 1e5; } - y2Min = yMin; - y2Max = yMax; } /*! -- 2.39.2