isis/src/qisis/objs/PlotWindow/PlotWindow.cpp
QPair<double, double> PlotWindow::findDataRange(int axisId) const {
    QList<const CubePlotCurve *> curves = plotCurves();

    bool foundDataValue = false;
    QPair<double, double> rangeMinMax;

    foreach(const CubePlotCurve *curve, curves) {
      for (int dataIndex = 0; dataIndex < (int)curve->dataSize(); dataIndex++) {
        if (axisId == QwtPlot::xBottom) {
          if (!foundDataValue) {
            rangeMinMax.first = curve->sample(dataIndex).x();
            rangeMinMax.second = curve->sample(dataIndex).x();
            foundDataValue = true;
          }
          else {
            rangeMinMax.first = qMin(rangeMinMax.first, curve->sample(dataIndex).x());
            rangeMinMax.second = qMax(rangeMinMax.second, curve->sample(dataIndex).x());
          }
        }
        else if (axisId == QwtPlot::yLeft) {
          if (!foundDataValue) {
            rangeMinMax.first = curve->sample(dataIndex).y();
            rangeMinMax.second = curve->sample(dataIndex).y();
            foundDataValue = true;
          }
          else {
            rangeMinMax.first = qMin(rangeMinMax.first, curve->sample(dataIndex).y());
            rangeMinMax.second = qMax(rangeMinMax.second, curve->sample(dataIndex).y());
          }
        }
      }
    }

    if (!foundDataValue) {
      rangeMinMax.first = 1;
      rangeMinMax.second = 10;
    }
    else if(rangeMinMax.first == rangeMinMax.second) {
      rangeMinMax.first -= 0.5;
      rangeMinMax.second += 0.5;
    }

    return rangeMinMax;
  }
/**
   * This calculates the data range of the specified axis (works with xBottom
   *   and yLeft only). This is used to provide unit context (band #'s shouldn't
   *   ever pad) and to fix the lack of an axis when only one value exists (if
   *   there is only one x-value, this will always pad with +/- 0.5).
   *
   * @param axisId This must be yLeft or xBottom
   * @return The double range of the data contained by the given axis.
   */
This calculates the data range of the specified axis (works with xBottom
and yLeft only). This is used to provide unit context (band #'s shouldn't
ever pad) and to fix the lack of an axis when only one value exists (if
there is only one x-value, this will always pad with +/- 0.5).

@param axisId This must be yLeft or xBottom
@return The double range of the data contained by the given axis.
This calculates the data range of the specified axis ( works with xBottom and yLeft only ) . This is used to provide unit context ( band # ' s shouldn ' t ever pad ) and to fix the lack of an axis when only one value exists ( if there is only one x - value this will always pad with + / - 0 . 5 ) . @param axisId This must be yLeft or xBottom @return The double range of the data contained by the given axis .
QPair<double, double> PlotWindow::findDataRange(int axisId) const {
    QList<const CubePlotCurve *> curves = plotCurves();
    bool foundDataValue = false;
    QPair<double, double> rangeMinMax;
    foreach(const CubePlotCurve *curve, curves) {
      for (int dataIndex = 0; dataIndex < (int)curve->dataSize(); dataIndex++) {
        if (axisId == QwtPlot::xBottom) {
          if (!foundDataValue) {
            rangeMinMax.first = curve->sample(dataIndex).x();
            rangeMinMax.second = curve->sample(dataIndex).x();
            foundDataValue = true;
          }
          else {
            rangeMinMax.first = qMin(rangeMinMax.first, curve->sample(dataIndex).x());
            rangeMinMax.second = qMax(rangeMinMax.second, curve->sample(dataIndex).x());
          }
        }
        else if (axisId == QwtPlot::yLeft) {
          if (!foundDataValue) {
            rangeMinMax.first = curve->sample(dataIndex).y();
            rangeMinMax.second = curve->sample(dataIndex).y();
            foundDataValue = true;
          }
          else {
            rangeMinMax.first = qMin(rangeMinMax.first, curve->sample(dataIndex).y());
            rangeMinMax.second = qMax(rangeMinMax.second, curve->sample(dataIndex).y());
          }
        }
      }
    }
    if (!foundDataValue) {
      rangeMinMax.first = 1;
      rangeMinMax.second = 10;
    }
    else if(rangeMinMax.first == rangeMinMax.second) {
      rangeMinMax.first -= 0.5;
      rangeMinMax.second += 0.5;
    }
    return rangeMinMax;
  }
QPair < double , double > PlotWindow :: findDataRange ( int axisId ) const { QList < const CubePlotCurve * > curves = plotCurves ( ) ; bool foundDataValue = false ; QPair < double , double > rangeMinMax ; foreach ( const CubePlotCurve * curve , curves ) { for ( int dataIndex = 0 ; dataIndex < ( int ) curve -> dataSize ( ) ; dataIndex ++ ) { if ( axisId == QwtPlot :: xBottom ) { if ( ! foundDataValue ) { rangeMinMax . first = curve -> sample ( dataIndex ) . x ( ) ; rangeMinMax . second = curve -> sample ( dataIndex ) . x ( ) ; foundDataValue = true ; } else { rangeMinMax . first = qMin ( rangeMinMax . first , curve -> sample ( dataIndex ) . x ( ) ) ; rangeMinMax . second = qMax ( rangeMinMax . second , curve -> sample ( dataIndex ) . x ( ) ) ; } } else if ( axisId == QwtPlot :: yLeft ) { if ( ! foundDataValue ) { rangeMinMax . first = curve -> sample ( dataIndex ) . y ( ) ; rangeMinMax . second = curve -> sample ( dataIndex ) . y ( ) ; foundDataValue = true ; } else { rangeMinMax . first = qMin ( rangeMinMax . first , curve -> sample ( dataIndex ) . y ( ) ) ; rangeMinMax . second = qMax ( rangeMinMax . second , curve -> sample ( dataIndex ) . y ( ) ) ; } } } } if ( ! foundDataValue ) { rangeMinMax . first = 1 ; rangeMinMax . second = 10 ; } else if ( rangeMinMax . first == rangeMinMax . second ) { rangeMinMax . first -= 0.5 ; rangeMinMax . second += 0.5 ; } return rangeMinMax ; }
This calculates the data range of the specified axis (works with xBottom
   and yLeft only).
This calculates the data range of the specified axis ( works with xBottom and yLeft only ) .