From: vsr Date: Mon, 9 Mar 2009 15:17:20 +0000 (+0000) Subject: Fix fitAll() function problem on empty view caused by previous integration X-Git-Tag: V5_1_1rc2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=47f3d64a88dbae2ad503dc9c654ab026bafb7d1c;p=modules%2Fgui.git Fix fitAll() function problem on empty view caused by previous integration --- 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; } /*!