当前位置: 首页>>代码示例>>C++>>正文


C++ QwtDoubleRect::toRect方法代码示例

本文整理汇总了C++中QwtDoubleRect::toRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtDoubleRect::toRect方法的具体用法?C++ QwtDoubleRect::toRect怎么用?C++ QwtDoubleRect::toRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QwtDoubleRect的用法示例。


在下文中一共展示了QwtDoubleRect::toRect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawRays

/*!
  Draw lines from the pole

  \param painter Painter
  \param canvasRect Contents rect of the canvas in painter coordinates
  \param pole Position of the pole in painter coordinates
  \param radius Length of the lines in painter coordinates
  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  \param values Azimuth values, indicating the direction of the lines
*/
void QwtPolarGrid::drawRays(
  QPainter *painter, const QwtDoubleRect &canvasRect,
  const QwtDoublePoint &pole, double radius,
  const QwtScaleMap &azimuthMap, const QwtValueList &values ) const
{
  for ( int i = 0; i < int( values.size() ); i++ )
  {
    double azimuth = azimuthMap.xTransform( values[i] );
    azimuth = ::fmod( azimuth, 2 * M_PI );

    bool skipLine = false;
    if ( testDisplayFlag( SmartScaleDraw ) )
    {
      const QwtAbstractScaleDraw::ScaleComponent bone =
        QwtAbstractScaleDraw::Backbone;
      if ( isClose( azimuth, 0.0 ) )
      {
        const AxisData &axis = d_data->axisData[QwtPolar::AxisRight];
        if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
          skipLine = true;
      }
      else if ( isClose( azimuth, M_PI / 2 ) )
      {
        const AxisData &axis = d_data->axisData[QwtPolar::AxisTop];
        if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
          skipLine = true;
      }
      else if ( isClose( azimuth, M_PI ) )
      {
        const AxisData &axis = d_data->axisData[QwtPolar::AxisLeft];
        if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
          skipLine = true;
      }
      else if ( isClose( azimuth, 3 * M_PI / 2.0 ) )
      {
        const AxisData &axis = d_data->axisData[QwtPolar::AxisBottom];
        if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
          skipLine = true;
      }
    }
    if ( !skipLine )
    {
      const QwtDoublePoint pos = qwtPolar2Pos( pole, radius, azimuth );

      /*
          Qt4 is horrible slow, when painting primitives,
          with coordinates far outside the visible area.
       */

      QwtPolygon pa( 2 );
      pa.setPoint( 0, pole.toPoint() );
      pa.setPoint( 1, pos.toPoint() );

      if ( testDisplayFlag( ClipGridLines ) )
        pa = QwtClipper::clipPolygon( canvasRect.toRect(), pa );

      QwtPainter::drawPolyline( painter, pa );
    }
  }
}
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:70,代码来源:qwt_polar_grid.cpp

示例2: render

/*!
  Render the SVG data

  \param painter Painter
  \param viewBox View Box, see QSvgRenderer::viewBox
  \param rect Traget rectangle on the paint device
*/
void QwtPlotSvgItem::render(QPainter *painter,
        const QwtDoubleRect &viewBox, const QRect &rect) const
{
    if ( !viewBox.isValid() )
        return;

#if QT_VERSION >= 0x040200
    d_data->renderer.setViewBox(viewBox);
    d_data->renderer.render(painter, rect);
    return;
#else

#if QT_VERSION >= 0x040100
    const QSize paintSize(painter->window().width(),
        painter->window().height());
    if ( !paintSize.isValid() )
        return;

    const double xRatio = paintSize.width() / viewBox.width();
    const double yRatio = paintSize.height() / viewBox.height();

    const double dx = rect.left() / xRatio + 1.0;
    const double dy = rect.top() / yRatio + 1.0;

    const double mx = double(rect.width()) / paintSize.width();
    const double my = double(rect.height()) / paintSize.height();

    painter->save();

    painter->translate(dx, dy);
    painter->scale(mx, my);

    d_data->renderer.setViewBox(viewBox.toRect());
    d_data->renderer.render(painter);

    painter->restore();
#else
    const double mx = rect.width() / viewBox.width();
    const double my = rect.height() / viewBox.height();
    const double dx = rect.x() - mx * viewBox.x();
    const double dy = rect.y() - my * viewBox.y();

    painter->save();

    painter->translate(dx, dy);
    painter->scale(mx, my);

    d_data->picture.play(painter);

    painter->restore();
#endif // < 0x040100
#endif // < 0x040200
}
开发者ID:DMachuca,项目名称:ar2tech-SGeMS-public,代码行数:60,代码来源:qwt_plot_svgitem.cpp

示例3: drawCanvas

/*!
  Redraw the canvas.
  \param painter Painter used for drawing
  \param canvasRect Contents rect of the canvas
*/
void QwtPolarPlot::drawCanvas( QPainter *painter,
                               const QwtDoubleRect &canvasRect ) const
{
  const QwtDoubleRect cr = canvasRect;
  const QwtDoubleRect pr = plotRect( cr.toRect() );

  const double radius = pr.width() / 2.0;

  if ( d_data->canvasBrush.style() != Qt::NoBrush )
  {
    painter->save();
    painter->setPen( Qt::NoPen );
    painter->setBrush( d_data->canvasBrush );

    if ( qwtDistance( pr.center(), cr.topLeft() ) < radius &&
         qwtDistance( pr.center(), cr.topRight() ) < radius &&
         qwtDistance( pr.center(), cr.bottomRight() ) < radius &&
         qwtDistance( pr.center(), cr.bottomLeft() ) < radius )
    {
      QwtPainter::drawRect( painter, cr.toRect() );
    }
    else
    {
#if QT_VERSION < 0x040000
      QwtPainter::drawEllipse( painter, pr.toRect() );
#else
      painter->setRenderHint( QPainter::Antialiasing, true );
      QwtPainter::drawEllipse( painter, pr.toRect() );
#endif
    }
    painter->restore();
  }

  drawItems( painter,
             scaleMap( QwtPolar::Azimuth, radius ),
             scaleMap( QwtPolar::Radius, radius ),
             pr.center(), radius, canvasRect );
}
开发者ID:ACorradini,项目名称:QGIS,代码行数:43,代码来源:qwt_polar_plot.cpp

示例4: drawItems

/*!
  Redraw the canvas items.

  \param painter Painter used for drawing
  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  \param radialMap Maps radius values into painter coordinates.
  \param pole Position of the pole in painter coordinates
  \param radius Radius of the complete plot area in painter coordinates
  \param canvasRect Contents rect of the canvas in painter coordinates
*/
void QwtPolarPlot::drawItems( QPainter *painter,
                              const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
                              const QwtDoublePoint &pole, double radius,
                              const QwtDoubleRect &canvasRect ) const
{
  const QwtDoubleRect pr = plotRect( canvasRect.toRect() );

  const QwtPolarItemList& itmList = itemList();
  for ( QwtPolarItemIterator it = itmList.begin();
        it != itmList.end(); ++it )
  {
    QwtPolarItem *item = *it;
    if ( item && item->isVisible() )
    {
      painter->save();

      // Unfortunately circular clipping slows down
      // painting a lot. So we better try to avoid it.

      bool doClipping = false;
      if ( item->rtti() != QwtPolarItem::Rtti_PolarGrid )
      {
        const QwtDoubleInterval intv =
          item->boundingInterval( QwtPolar::Radius );

        if ( !intv.isValid() )
          doClipping = true;
        else
        {
          if ( radialMap.s1() < radialMap.s2() )
            doClipping = intv.maxValue() > radialMap.s2();
          else
            doClipping = intv.minValue() < radialMap.s2();
        }
      }

      if ( doClipping )
      {
        const int margin = item->marginHint();
        const QwtDoubleRect clipRect( pr.x() - margin, pr.y() - margin,
                                      pr.width() + 2 * margin, pr.height() + 2 * margin );

        if ( !clipRect.contains( canvasRect ) )
        {
          QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse );
#if QT_VERSION >= 0x040000
          painter->setClipRegion( clipRegion, Qt::IntersectClip );
#else
          if ( painter->hasClipping() )
            clipRegion &= painter->clipRegion();

          painter->setClipRegion( clipRegion );
#endif
        }
      }

#if QT_VERSION >= 0x040000
      painter->setRenderHint( QPainter::Antialiasing,
                              item->testRenderHint( QwtPolarItem::RenderAntialiased ) );
#endif

      item->draw( painter, azimuthMap, radialMap,
                  pole, radius, canvasRect );
      painter->restore();
    }
  }

}
开发者ID:ACorradini,项目名称:QGIS,代码行数:78,代码来源:qwt_polar_plot.cpp

示例5: visibleInterval

/*!
   Calculate the bounding interval of the radial scale that is
   visible on the canvas.
*/
QwtDoubleInterval QwtPolarPlot::visibleInterval() const
{
  const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius );

  const QwtDoubleRect cRect = canvas()->contentsRect();
  const QwtDoubleRect pRect = plotRect( cRect.toRect() );
  if ( cRect.contains( pRect.toRect() ) || !cRect.intersects( pRect ) )
  {
#if QWT_VERSION < 0x050200
    return QwtDoubleInterval( sd->lBound(), sd->hBound() );
#else
    return QwtDoubleInterval( sd->lowerBound(), sd->upperBound() );
#endif
  }

  const QwtDoublePoint pole = pRect.center();
  const QwtDoubleRect scaleRect = pRect & cRect;

  const QwtScaleMap map = scaleMap( QwtPolar::Radius );

  double dmin = 0.0;
  double dmax = 0.0;
  if ( scaleRect.contains( pole ) )
  {
    dmin = 0.0;

    QwtDoublePoint corners[4];
    corners[0] = scaleRect.bottomRight();
    corners[1] = scaleRect.topRight();
    corners[2] = scaleRect.topLeft();
    corners[3] = scaleRect.bottomLeft();

    dmax = 0.0;
    for ( int i = 0; i < 4; i++ )
    {
      const double dist = qwtDistance( pole, corners[i] );
      if ( dist > dmax )
        dmax = dist;
    }
  }
  else
  {
    if ( pole.x() < scaleRect.left() )
    {
      if ( pole.y() < scaleRect.top() )
      {
        dmin = qwtDistance( pole, scaleRect.topLeft() );
        dmax = qwtDistance( pole, scaleRect.bottomRight() );
      }
      else if ( pole.y() > scaleRect.bottom() )
      {
        dmin = qwtDistance( pole, scaleRect.bottomLeft() );
        dmax = qwtDistance( pole, scaleRect.topRight() );
      }
      else
      {
        dmin = scaleRect.left() - pole.x();
        dmax = qwtMax( qwtDistance( pole, scaleRect.bottomRight() ),
                       qwtDistance( pole, scaleRect.topRight() ) );
      }
    }
    else if ( pole.x() > scaleRect.right() )
    {
      if ( pole.y() < scaleRect.top() )
      {
        dmin = qwtDistance( pole, scaleRect.topRight() );
        dmax = qwtDistance( pole, scaleRect.bottomLeft() );
      }
      else if ( pole.y() > scaleRect.bottom() )
      {
        dmin = qwtDistance( pole, scaleRect.bottomRight() );
        dmax = qwtDistance( pole, scaleRect.topLeft() );
      }
      else
      {
        dmin = pole.x() - scaleRect.right();
        dmax = qwtMax( qwtDistance( pole, scaleRect.bottomLeft() ),
                       qwtDistance( pole, scaleRect.topLeft() ) );
      }
    }
    else if ( pole.y() < scaleRect.top() )
    {
      dmin = scaleRect.top() - pole.y();
      dmax = qwtMax( qwtDistance( pole, scaleRect.bottomLeft() ),
                     qwtDistance( pole, scaleRect.bottomRight() ) );
    }
    else if ( pole.y() > scaleRect.bottom() )
    {
      dmin = pole.y() - scaleRect.bottom();
      dmax = qwtMax( qwtDistance( pole, scaleRect.topLeft() ),
                     qwtDistance( pole, scaleRect.topRight() ) );
    }
  }

  const double radius = pRect.width() / 2.0;
  if ( dmax > radius )
//.........这里部分代码省略.........
开发者ID:ACorradini,项目名称:QGIS,代码行数:101,代码来源:qwt_polar_plot.cpp

示例6: draw

/*!
  Draw the grid and axes

  \param painter Painter
  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  \param radialMap Maps radius values into painter coordinates.
  \param pole Position of the pole in painter coordinates
  \param radius Radius of the complete plot area in painter coordinates
  \param canvasRect Contents rect of the canvas in painter coordinates
*/
void QwtPolarGrid::draw( QPainter *painter,
                         const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
                         const QwtDoublePoint &pole, double radius,
                         const QwtDoubleRect &canvasRect ) const
{
  updateScaleDraws( azimuthMap, radialMap, pole, radius );

  painter->save();

  if ( testDisplayFlag( ClipAxisBackground ) )
  {
    QRegion clipRegion( canvasRect.toRect() );
    for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
    {
      const AxisData &axis = d_data->axisData[axisId];
      if ( axisId != QwtPolar::AxisAzimuth && axis.isVisible )
      {
        QwtScaleDraw *scaleDraw = ( QwtScaleDraw * )axis.scaleDraw;
        if ( scaleDraw->hasComponent( QwtScaleDraw::Labels ) )
        {
          const QwtValueList &ticks =
            scaleDraw->scaleDiv().ticks( QwtScaleDiv::MajorTick );
          for ( int i = 0; i < int( ticks.size() ); i++ )
          {
            QRect labelRect =
              scaleDraw->boundingLabelRect( axis.font, ticks[i] );

            const int margin = 2;
            labelRect.setRect(
              labelRect.x() - margin,
              labelRect.y() - margin,
              labelRect.width() + 2 * margin,
              labelRect.height() + 2 * margin
            );

            if ( labelRect.isValid() )
              clipRegion -= QRegion( labelRect );
          }
        }
      }
    }
    painter->setClipRegion( clipRegion );
  }

  //  draw radial grid

  const GridData &radialGrid = d_data->gridData[QwtPolar::Radius];
  if ( radialGrid.isVisible && radialGrid.isMinorVisible )
  {
    painter->setPen( radialGrid.minorPen );

    drawCircles( painter, canvasRect, pole, radialMap,
                 radialGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) );
    drawCircles( painter, canvasRect, pole, radialMap,
                 radialGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) );
  }
  if ( radialGrid.isVisible )
  {
    painter->setPen( radialGrid.majorPen );

    drawCircles( painter, canvasRect, pole, radialMap,
                 radialGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) );
  }

  // draw azimuth grid

  const GridData &azimuthGrid =
    d_data->gridData[QwtPolar::Azimuth];

  if ( azimuthGrid.isVisible && azimuthGrid.isMinorVisible )
  {
    painter->setPen( azimuthGrid.minorPen );

    drawRays( painter, canvasRect, pole, radius, azimuthMap,
              azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) );
    drawRays( painter, canvasRect, pole, radius, azimuthMap,
              azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) );
  }
  if ( azimuthGrid.isVisible )
  {
    painter->setPen( azimuthGrid.majorPen );

    drawRays( painter, canvasRect, pole, radius, azimuthMap,
              azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) );
  }
  painter->restore();

  for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
  {
    const AxisData &axis = d_data->axisData[axisId];
//.........这里部分代码省略.........
开发者ID:Adam-Brown,项目名称:Quantum-GIS,代码行数:101,代码来源:qwt_polar_grid.cpp


注:本文中的QwtDoubleRect::toRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。