Example #1
0
/*!
  Build a scale map

  The azimuth map translates between the scale values and angles from
  [0.0, 2 * PI[. The radial map translates scale values into the distance
  from the pole.

  \param scaleId Scale index
  \param radius Radius of the plot are in pixels
  \return Map for the scale on the canvas. With this map pixel coordinates can
          translated to plot coordinates and vice versa.

  \sa QwtScaleMap, transform(), invTransform()
*/
QwtScaleMap QwtPolarPlot::scaleMap( int scaleId, const double radius ) const
{
  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
    return QwtScaleMap();

  QwtScaleMap map;
  map.setTransformation( scaleEngine( scaleId )->transformation() );

  const QwtScaleDiv *sd = scaleDiv( scaleId );
#if QWT_VERSION < 0x050200
  map.setScaleInterval( sd->lBound(), sd->hBound() );
#else
  map.setScaleInterval( sd->lowerBound(), sd->upperBound() );
#endif

  if ( scaleId == QwtPolar::Azimuth )
  {
    map.setPaintXInterval( d_data->azimuthOrigin,
                           d_data->azimuthOrigin + M_2PI );
  }
  else
  {
    map.setPaintXInterval( 0.0, radius );
  }

  return map;
}
Example #2
0
/*!
   \brief Calculate the bounding rect of the plot area

   The plot area depends on the zoom parameters.

   \param canvasRect Rectangle of the canvas
   \return Rectangle for displaying 100% of the plot
*/
QRectF QwtPolarPlot::plotRect( const QRectF &canvasRect ) const
{
    const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius );
    const QwtScaleEngine *se = scaleEngine( QwtPolar::Radius );

    const int margin = plotMarginHint();
    const QRectF cr = canvasRect;
    const int radius = qMin( cr.width(), cr.height() ) / 2 - margin;

    QwtScaleMap map;
    map.setTransformation( se->transformation() );
    map.setPaintInterval( 0.0, radius / d_data->zoomFactor );
    map.setScaleInterval( sd->lowerBound(), sd->upperBound() );

    double v = map.s1();
    if ( map.s1() <= map.s2() )
        v += d_data->zoomPos.radius();
    else
        v -= d_data->zoomPos.radius();
    v = map.transform( v );

    const QPointF off =
        QwtPointPolar( d_data->zoomPos.azimuth(), v ).toPoint();

    QPointF center( cr.center().x(), cr.top() + margin + radius );
    center -= QPointF( off.x(), -off.y() );

    QRectF rect( 0, 0, 2 * map.p2(), 2 * map.p2() );
    rect.moveCenter( center );

    return rect;
}
Example #3
0
/*!
  \brief Set the range

  \param minValue value corresponding lower or left end 
                  of the thermometer
  \param maxValue value corresponding to the upper or 
                  right end of the thermometer
  \param logarithmic logarithmic mapping, true or false
*/
void QwtThermo::setRange( 
    double minValue, double maxValue, bool logarithmic )
{
    if ( minValue == d_data->minValue && maxValue == d_data->maxValue
        && logarithmic == qwtIsLogarithmic( this ) )
    {
        return;
    }

    if ( logarithmic != qwtIsLogarithmic( this ) )
    {
        if ( logarithmic )
            setScaleEngine( new QwtLog10ScaleEngine );
        else
            setScaleEngine( new QwtLinearScaleEngine );
    }

    d_data->minValue = minValue;
    d_data->maxValue = maxValue;

    /*
      There are two different maps, one for the scale, the other
      for the values. This is confusing and will be changed
      in the future. TODO ...
     */

    d_data->map.setTransformation( scaleEngine()->transformation() );
    d_data->map.setScaleInterval( minValue, maxValue );

    if ( autoScale() )
        rescale( minValue, maxValue );

    layoutThermo( true );
}
Example #4
0
void TimelineWidget::setRange(double vmin, double vmax, bool lg)
{
   mpD->minValue = vmin;
   mpD->maxValue = vmax;
   setScaleEngine(new QwtLinearScaleEngine);
   mpD->map.setTransformation(scaleEngine()->transformation());
   mpD->map.setScaleInterval(mpD->minValue, mpD->maxValue);
   if(autoScale())
   {
      rescale(mpD->minValue, mpD->maxValue);
   }
}
/*!
  \brief Set the range
  \param vmin value corresponding lower or left end of the thermometer
  \param vmax value corresponding to the upper or right end of the thermometer
  \param logarithmic logarithmic mapping, true or false
*/
void QwtThermo::setRange(double vmin, double vmax, bool logarithmic)
{
    d_data->minValue = vmin;
    d_data->maxValue = vmax;

    if ( logarithmic )
        setScaleEngine(new QwtLog10ScaleEngine);
    else
        setScaleEngine(new QwtLinearScaleEngine);

    /*
      There are two different maps, one for the scale, the other
      for the values. This is confusing and will be changed
      in the future. TODO ...
     */

    d_data->map.setTransformation(scaleEngine()->transformation());
    d_data->map.setScaleInterval(d_data->minValue, d_data->maxValue);

    if (autoScale())
        rescale(d_data->minValue, d_data->maxValue);

    layoutThermo();
}
Example #6
0
/*!
   \brief Calculate the bounding rect of the plot area

   The plot area depends on the zoom parameters.

   \param canvasRect Rectangle of the canvas
   \return Rectangle for displaying 100% of the plot
*/
QwtDoubleRect QwtPolarPlot::plotRect( const QRect &canvasRect ) const
{
  const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius );
  const QwtScaleEngine *se = scaleEngine( QwtPolar::Radius );

  const int margin = plotMarginHint();
  const QRect cr = canvasRect;
  const int radius = qwtMin( cr.width(), cr.height() ) / 2 - margin;

  QwtScaleMap map;
  map.setTransformation( se->transformation() );
  map.setPaintXInterval( 0.0, radius / d_data->zoomFactor );
#if QWT_VERSION < 0x050200
  map.setScaleInterval( sd->lBound(), sd->hBound() );
#else
  map.setScaleInterval( sd->lowerBound(), sd->upperBound() );
#endif

  double v = map.s1();
  if ( map.s1() <= map.s2() )
    v += d_data->zoomPos.radius();
  else
    v -= d_data->zoomPos.radius();
  v = map.xTransform( v );

  const QwtDoublePoint off =
    QwtPolarPoint( d_data->zoomPos.azimuth(), v ).toPoint();

  QwtDoublePoint center( cr.center().x(), cr.top() + margin + radius );
  center -= QwtDoublePoint( off.x(), -off.y() );

  QwtDoubleRect rect( 0, 0, 2 * map.p2(), 2 * map.p2() );
  rect.moveCenter( center );

  return rect;
}