return aMinX;
}
+/*!
+ Gets curve's maximal abscissa
+*/
+double Plot2d_Curve::getMaxX() const
+{
+ pointList::const_iterator aIt;
+ double aMaxX = -1e150;
+ for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
+ if ( (*aIt).x > aMaxX )
+ aMaxX = (*aIt).x;
+ }
+ return aMaxX;
+}
+
/*!
Gets curve's minimal ordinate
*/
return aMinY;
}
+/*!
+ Gets curve's maximal ordinate
+*/
+double Plot2d_Curve::getMaxY() const
+{
+ pointList::const_iterator aIt;
+ double aMaxY = -1e150;
+ for(aIt = myPoints.begin(); aIt != myPoints.end(); ++aIt) {
+ if ( (*aIt).y > aMaxY )
+ aMaxY = (*aIt).y;
+ }
+ return aMaxY;
+}
+
/*!
Changes text assigned to point of curve
\param ind -- index of point
myPlot->setAxisAutoScale( QwtPlot::xBottom );
myPlot->replot();
- // for existing grid
- QwtScaleMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
- QwtScaleMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
+ double xmin, xmax, y1min, y1max, y2min, y2max;
+ getFitRangeByCurves(xmin, xmax, y1min, y1max, y2min, y2max);
- myPlot->setAxisScale( QwtPlot::xBottom, xMap.s1(), xMap.s2() );
- myPlot->setAxisScale( QwtPlot::yLeft, yMap.s1(), yMap.s2() );
+ myPlot->setAxisScale( QwtPlot::xBottom, xmin, xmax );
+ myPlot->setAxisScale( QwtPlot::yLeft, y1min, y1max );
if (mySecondY) {
myPlot->setAxisAutoScale( QwtPlot::yRight );
myPlot->replot();
QwtScaleMap yMap2 = myPlot->canvasMap( QwtPlot::yRight );
- myPlot->setAxisScale( QwtPlot::yRight, yMap2.s1(), yMap2.s2() );
+ myPlot->setAxisScale( QwtPlot::yRight, y2min, y2max );
}
myPlot->replot();
}
}
}
+/*!
+ Gets current fit ranges by Curves
+*/
+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();
+ }
+ y2Min = yMin;
+ y2Max = yMax;
+}
+
/*!
Tests if it is necessary to start operation on mouse action
*/
double& yMin, double& yMax,
double& y2Min, double& y2Max);
+ void getFitRangeByCurves(double& xMin, double& xMax,
+ double& yMin, double& yMax,
+ double& y2Min, double& y2Max);
+
/* view parameters */
void copyPreferences( Plot2d_ViewFrame* );
void setCurveType( int curveType, bool update = true );