Exemplo n.º 1
0
/*!
  \brief Translate a series of points into a QPolygon

  - WeedOutPoints & boundingRect().isValid()
    All points that are mapped to the same position 
    will be one point. Points outside of the bounding
    rectangle are ignored.
 
  - WeedOutPoints & !boundingRect().isValid()
    All consecutive points that are mapped to the same position 
    will one point

  - !WeedOutPoints & boundingRect().isValid()
    Points outside of the bounding rectangle are ignored.

  \param xMap x map
  \param yMap y map
  \param series Series of points to be mapped
  \param from Index of the first point to be painted
  \param to Index of the last point to be painted

  \return Translated polygon
*/
QPolygon QwtPointMapper::toPoints(
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QwtSeriesData<QPointF> *series, int from, int to ) const
{
    QPolygon points;

    if ( d_data->flags & WeedOutPoints )
    {
        if ( d_data->boundingRect.isValid() )
        {
            points = qwtToPointsFilteredI( d_data->boundingRect,
                xMap, yMap, series, from, to );
        }
        else
        {
            // when we don't have the bounding rectangle all
            // we can do is to filter out consecutive duplicates

            points = qwtToPolylineFilteredI( 
                xMap, yMap, series, from, to );
        }
    }
    else
    {
        points = qwtToPointsI( 
            d_data->boundingRect, xMap, yMap, series, from, to );
    }

    return points;
}
/*!
  \brief Translate a series of points into a QPolygon

  When the WeedOutPoints flag is enabled consecutive points,
  that are mapped to the same position will be one point. 

  \param xMap x map
  \param yMap y map
  \param series Series of points to be mapped
  \param from Index of the first point to be painted
  \param to Index of the last point to be painted

  \return Translated polygon
*/
QPolygon QwtPointMapper::toPolygon(
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QwtSeriesData<QPointF> *series, int from, int to ) const
{
    QPolygon polyline;

    if ( d_data->flags & WeedOutIntermediatePoints )
    {
        // TODO WeedOutIntermediatePointsY ...
        polyline = qwtMapPointsQuad<QPolygon, QPoint>( 
            xMap, yMap, series, from, to );
    }
    else if ( d_data->flags & WeedOutPoints )
    {
        polyline = qwtToPolylineFilteredI( 
            xMap, yMap, series, from, to );
    }
    else
    {
        polyline = qwtToPointsI( 
            qwtInvalidRect, xMap, yMap, series, from, to );
    }

    return polyline;
}