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


C++ QPolygonF::reserve方法代码示例

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


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

示例1: clippedLineWKB

QgsConstWkbPtr QgsClipper::clippedLineWKB( QgsConstWkbPtr wkbPtr, const QgsRectangle& clipExtent, QPolygonF& line )
{
  QgsWKBTypes::Type wkbType = wkbPtr.readHeader();

  int nPoints;
  wkbPtr >> nPoints;

  int skipZM = ( QgsWKBTypes::coordDimensions( wkbType ) - 2 ) * sizeof( double );

  if ( static_cast<int>( nPoints * ( 2 * sizeof( double ) + skipZM ) ) > wkbPtr.remaining() )
  {
    QgsDebugMsg( QString( "%1 points exceed wkb length (%2>%3)" ).arg( nPoints ).arg( nPoints * ( 2 * sizeof( double ) + skipZM ) ).arg( wkbPtr.remaining() ) );
    return QgsConstWkbPtr( nullptr, 0 );
  }

  double p0x, p0y, p1x = 0.0, p1y = 0.0; //original coordinates
  double p1x_c, p1y_c; //clipped end coordinates
  double lastClipX = 0.0, lastClipY = 0.0; //last successfully clipped coords

  line.clear();
  line.reserve( nPoints + 1 );

  for ( int i = 0; i < nPoints; ++i )
  {
    if ( i == 0 )
    {
      wkbPtr >> p1x >> p1y;
      wkbPtr += skipZM;
      continue;
    }
    else
    {
开发者ID:Antoviscomi,项目名称:QGIS,代码行数:32,代码来源:qgsclipper.cpp

示例2: read_line

QPolygonF read_line(uint8_t byte_order, InputIterator& itr, const frame& fr)
{
  const uint32_t count(brig::detail::ogc::read<uint32_t>(byte_order, itr));
  QPolygonF line; line.reserve(count);
  for (uint32_t i(0); i < count; ++i)
    line.push_back( read_point(byte_order, itr, fr) );
  return line;
}
开发者ID:respu,项目名称:brig,代码行数:8,代码来源:draw_line.hpp

示例3: toQPolygonF

static QPolygonF toQPolygonF(const b2Vec2 *vertices, int32 vertexCount)
{
    QPolygonF polygon;
    polygon.reserve(vertexCount);

    for (int i = 0; i < vertexCount; ++i)
        polygon.append(toQPointF(vertices[i]));

    return polygon;
}
开发者ID:ragner,项目名称:quickbox2d,代码行数:10,代码来源:box2ddebugdraw.cpp

示例4:

QPolygonF b2Util::qPolygonF(const b2Vec2 *vertices, int32 vertexCount, const qreal &scaleRatio)
{
    QPolygonF polygon;
    polygon.reserve(vertexCount);

    for (int i = 0; i < vertexCount; ++i)
        polygon.append(qPointF(vertices[i], scaleRatio));

    return polygon;
}
开发者ID:alvloureiro,项目名称:Quasi-Engine,代码行数:10,代码来源:util.cpp

示例5: asQPolygonF

QPolygonF QgsCurve::asQPolygonF() const
{
  const int nb = numPoints();
  QPolygonF points;
  points.reserve( nb );
  for ( int i = 0; i < nb; ++i )
  {
    points << QPointF( xAt( i ), yAt( i ) );
  }
  return points;
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:11,代码来源:qgscurve.cpp

示例6: drawArrow

void CaptureWgt::drawArrow()
{
    pd->arrow->setVisible( pd->drawArrow );
    if ( pd->drawArrow )
    {
        QPointF back  = pd->arrowFrom;
        QPointF front = pd->arrowTo;
        if ( front == back )
            return;
        qreal iw = static_cast<qreal>( pd->img.size().width() );
        qreal ih = static_cast<qreal>( pd->img.size().height() );
        if ( pd->flipX )
        {
            front.setY( ih - front.y() );
            back.setY( ih - back.y() );
        }
        if ( pd->flipY )
        {
            front.setX( iw - front.x() );
            back.setX( iw - back.x() );
        }

        // ≈диничный сонаправленный вектор.
        QPointF a = front - back;
        qreal l = sqrt( a.x() * a.x() + a.y() * a.y () );
        a.setX( a.x() / l );
        a.setY( a.y() / l );
        // ≈диничный перпендикул¤рный сектор.
        QPointF b = QPointF( a.y(), -a.x() );
        // ѕараметры стрелки.
        const qreal w = 2.0; // Ўирина линии.
        const qreal h = 7.0; // Ўирина собственно треугольничка.

        QPolygonF path;
        path.reserve( 8 );
        QPen pen = QPen( Qt::darkBlue );
        pd->arrow->setPen( pen );
        QBrush brush = QBrush( QColor( 150, 150, 200, 100 ) );
        pd->arrow->setBrush( brush );
        path << ( back + w * b );
        path << ( front - h * a + w * b );
        path << ( front + h * ( b - a ) );
        path << ( front );
        path << ( front - h * ( b + a ) );
        path << ( front - h * a - w * b );
        path << ( back - w * b );
        path << ( back + w * b );
        pd->arrow->setPolygon( path );
    }
}
开发者ID:z80,项目名称:chassis,代码行数:50,代码来源:capture_wgt.cpp

示例7: clippedLineWKB

QgsConstWkbPtr QgsClipper::clippedLineWKB( QgsConstWkbPtr& wkbPtr, const QgsRectangle& clipExtent, QPolygonF& line )
{
  QgsWKBTypes::Type wkbType = wkbPtr.readHeader();

  int nPoints;
  wkbPtr >> nPoints;

  int skipZM = ( QgsWKBTypes::coordDimensions( wkbType ) - 2 ) * sizeof( double );

  if ( static_cast<int>( nPoints * ( 2 * sizeof( double ) + skipZM ) ) > wkbPtr.remaining() )
  {
    QgsDebugMsg( QString( "%1 points exceed wkb length (%2>%3)" ).arg( nPoints ).arg( nPoints * ( 2 * sizeof( double ) + skipZM ) ).arg( wkbPtr.remaining() ) );
    return QgsConstWkbPtr( nullptr, 0 );
  }

  double p0x, p0y, p1x = 0.0, p1y = 0.0; //original coordinates
  double p1x_c, p1y_c; //clipped end coordinates
  double lastClipX = 0.0, lastClipY = 0.0; //last successfully clipped coords

  QPolygonF pts;
  wkbPtr -= sizeof( unsigned int );
  wkbPtr >> pts;
  nPoints = pts.size();

  line.clear();
  line.reserve( nPoints + 1 );

  QPointF *ptr = pts.data();

  for ( int i = 0; i < nPoints; ++i, ++ptr )
  {
    if ( i == 0 )
    {
      p1x = ptr->rx();
      p1y = ptr->ry();
      continue;
    }
    else
    {
      p0x = p1x;
      p0y = p1y;

      p1x = ptr->rx();
      p1y = ptr->ry();

      p1x_c = p1x;
      p1y_c = p1y;
      if ( clipLineSegment( clipExtent.xMinimum(), clipExtent.xMaximum(), clipExtent.yMinimum(), clipExtent.yMaximum(),
                            p0x, p0y, p1x_c,  p1y_c ) )
      {
        bool newLine = !line.isEmpty() && ( !qgsDoubleNear( p0x, lastClipX ) || !qgsDoubleNear( p0y, lastClipY ) );
        if ( newLine )
        {
          //add edge points to connect old and new line
          connectSeparatedLines( lastClipX, lastClipY, p0x, p0y, clipExtent, line );
        }
        if ( line.size() < 1 || newLine )
        {
          //add first point
          line << QPointF( p0x, p0y );
        }

        //add second point
        lastClipX = p1x_c;
        lastClipY = p1y_c;
        line << QPointF( p1x_c,  p1y_c );
      }
    }
  }
  return wkbPtr;
}
开发者ID:AM7000000,项目名称:QGIS,代码行数:71,代码来源:qgsclipper.cpp

示例8: loadData

void DataCurve::loadData()
{
    Graph *g = (Graph *)plot();
    if (!g)
        return;

    int xcol = d_x_table->colIndex(d_x_column);
    int ycol = d_table->colIndex(title().text());
    if (xcol < 0 || ycol < 0) {
        remove();
        return;
    }

    int rows = d_table->numRows();
    if (d_end_row < 0 || d_end_row >= rows)
        d_end_row = rows - 1;

    int xColType = d_x_table->columnType(xcol);
    int yColType = d_table->columnType(ycol);
    int r = abs(d_end_row - d_start_row) + 1;

    QPolygonF data;
    data.reserve(r);

    QStringList xLabels, yLabels;// store text labels

    int xAxis = QwtPlot::xBottom;
    if (d_type == Graph::HorizontalBars)
        xAxis = QwtPlot::yLeft;

    QString date_time_fmt = d_table->columnFormat(xcol);
    int size = 0, from = 0;
    d_data_ranges.clear();
    for (int i = d_start_row; i <= d_end_row; i++ ) {
        QString xval = d_x_table->text(i, xcol);
        QString yval = d_table->text(i, ycol);
        if (!xval.isEmpty() && !yval.isEmpty()) {
            bool valid_data = true;
            QPointF p;
            if (xColType == Table::Text) {
                xLabels << xval;
                p.setX((double)(size + 1));
            } else if (xColType == Table::Time)
                p.setX(Table::fromTime(QTime::fromString(xval.trimmed(), date_time_fmt)));
            else if (xColType == Table::Date)
                p.setX(Table::fromDateTime(QDateTime::fromString(xval.trimmed(), date_time_fmt)));
            else
                p.setX(g->locale().toDouble(xval, &valid_data));

            if (yColType == Table::Text) {
                yLabels << yval;
                p.setY((double)(size + 1));
            } else
                p.setY(g->locale().toDouble(yval, &valid_data));

            if (valid_data) {
                data << p;
                size++;
            }
        } else if (from < size) {
            DataRange range;
            range.from = from;
            range.to = size - 1;
            d_data_ranges.push_back(range);
            from = size;
        }
    }

    if (d_data_ranges.size() && from < size) {
        DataRange range;
        range.from = from;
        range.to = size - 1;
        d_data_ranges.push_back(range);
    }

    if (!size) {
        remove();
        return;
    }
    data.resize(size);

    if (g->isWaterfallPlot()) {
        int index = g->curveIndex(this);
        int curves = g->curveCount();
        DataCurve *c = g->dataCurve(0);
        if (index > 0 && c) {
            double xmin = c->minXValue();
            double dx = index*g->waterfallXOffset()*0.01*g->canvas()->width()/(double)(curves - 1);
            d_x_offset = g->invTransform(xAxis, g->transform(xAxis, xmin) + dx) - xmin;

            double ymin = c->minYValue();
            double dy = index*g->waterfallYOffset()*0.01*g->canvas()->height()/(double)(curves - 1);
            d_y_offset = ymin - g->invTransform(yAxis(), g->transform(yAxis(), ymin) + dy);

            setZ(-index);
            setBaseline(d_y_offset);
            data.translate(d_x_offset, d_y_offset);
        } else {
            setZ(0);
            setBaseline(0.0);
//.........这里部分代码省略.........
开发者ID:kuzavas,项目名称:qtiplot,代码行数:101,代码来源:PlotCurve.cpp


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