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


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

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


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

示例1: 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

示例2: boundingRect

QwtDoubleRect HistogramItem::boundingRect() const
{
    QwtDoubleRect rect = d_data->data.boundingRect();
    if ( !rect.isValid() ) 
        return rect;

    if ( d_data->attributes & Xfy )
    {
        rect = QwtDoubleRect( rect.y(), rect.x(), 
            rect.height(), rect.width() );

        if ( rect.left() > d_data->reference ) 
            rect.setLeft( d_data->reference );
        else if ( rect.right() < d_data->reference ) 
            rect.setRight( d_data->reference );
    } 
    else 
    {
        if ( rect.bottom() < d_data->reference ) 
            rect.setBottom( d_data->reference );
        else if ( rect.top() > d_data->reference ) 
            rect.setTop( d_data->reference );
    }

    return rect;
}
开发者ID:gibbogle,项目名称:trophocell2D-abm,代码行数:26,代码来源:histogram_item.cpp

示例3: rasterHint

/** Return how many pixels this area should be rendered as
 *
 * @param area :: area under view
 * @return # of pixels in each direction
 */
QSize QwtRasterDataMD::rasterHint(const QwtDoubleRect &area) const {
  if (!m_ws || !m_X || !m_Y)
    return QSize();
  // Slow mode? Don't give a raster hint. This will be 1 pixel per point
  if (!m_fast)
    return QSize();

  // Fast mode: use the bin size to guess at the pixel density
  coord_t binX = m_X->getBinWidth();
  coord_t binY = m_Y->getBinWidth();

  // Use the overlay workspace, if any, and if its bins are smaller
  if (m_overlayWS && m_overlayInSlice) {
    coord_t temp;
    temp = m_overlayWS->getDimension(m_dimX)->getBinWidth();
    if (temp < binX)
      binX = temp;
    temp = m_overlayWS->getDimension(m_dimY)->getBinWidth();
    if (temp < binY)
      binY = temp;
  }

  int w = 3 * int(area.width() / binX);
  int h = 3 * int(area.height() / binY);
  if (w < 10)
    w = 10;
  if (h < 10)
    h = 10;
  return QSize(w, h);
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:35,代码来源:QwtRasterDataMD.cpp

示例4: 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

示例5: 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

示例6: scaleMap

/*!
  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. The radial map is calculated from the current geometry
  of the canvas.

  \param scaleId Scale index
  \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
{
  const QwtDoubleRect pr = plotRect();
  return scaleMap( scaleId, pr.width() / 2.0 );
}
开发者ID:ACorradini,项目名称:QGIS,代码行数:19,代码来源:qwt_polar_plot.cpp

示例7: 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

示例8: contourLines

    const QList<double> &levels, int flags) const
#else
QwtRasterData::ContourLines QwtRasterData::contourLines(
    const QwtDoubleRect &rect, const QSize &raster, 
    const QValueList<double> &levels, int flags) const
#endif
{   
    ContourLines contourLines;
    
    if ( levels.size() == 0 || !rect.isValid() || !raster.isValid() )
        return contourLines;

    const double dx = rect.width() / raster.width();
    const double dy = rect.height() / raster.height();

    const bool ignoreOnPlane =
        flags & QwtRasterData::IgnoreAllVerticesOnLevel;

    const QwtDoubleInterval range = this->range();
    bool ignoreOutOfRange = false;
    if ( range.isValid() )
        ignoreOutOfRange = flags & IgnoreOutOfRange;

    ((QwtRasterData*)this)->initRaster(rect, raster);

    for ( int y = 0; y < raster.height() - 1; y++ )
    {
        enum Position
        {
            Center,

            TopLeft,
            TopRight,
            BottomRight,
            BottomLeft,

            NumPositions
        };

        Contour3DPoint xy[NumPositions];

        for ( int x = 0; x < raster.width() - 1; x++ )
        {
            const QwtDoublePoint pos(rect.x() + x * dx, rect.y() + y * dy);

            if ( x == 0 )
            {
                xy[TopRight].setPos(pos.x(), pos.y());
                xy[TopRight].setZ(
                    value( xy[TopRight].x(), xy[TopRight].y())
                );

                xy[BottomRight].setPos(pos.x(), pos.y() + dy);
                xy[BottomRight].setZ(
                    value(xy[BottomRight].x(), xy[BottomRight].y())
                );
            }

            xy[TopLeft] = xy[TopRight];
            xy[BottomLeft] = xy[BottomRight];

            xy[TopRight].setPos(pos.x() + dx, pos.y());
            xy[BottomRight].setPos(pos.x() + dx, pos.y() + dy);

            xy[TopRight].setZ(
                value(xy[TopRight].x(), xy[TopRight].y())
            );
            xy[BottomRight].setZ(
                value(xy[BottomRight].x(), xy[BottomRight].y())
            );

            double zMin = xy[TopLeft].z();
            double zMax = zMin;
            double zSum = zMin;

            for ( int i = TopRight; i <= BottomLeft; i++ )
            {
                const double z = xy[i].z();

                zSum += z;
                if ( z < zMin )
                    zMin = z;
                if ( z > zMax )
                    zMax = z;
            }

            if ( ignoreOutOfRange )
            {
                if ( !range.contains(zMin) || !range.contains(zMax) )
                    continue;
            }

            if ( zMax < levels[0] ||
                zMin > levels[levels.size() - 1] )
            {
                continue;
            }

            xy[Center].setPos(pos.x() + 0.5 * dx, pos.y() + 0.5 * dy);
            xy[Center].setZ(0.25 * zSum);
//.........这里部分代码省略.........
开发者ID:DTUautopilot,项目名称:qgroundcontrol,代码行数:101,代码来源:qwt_raster_data.cpp


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