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


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

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


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

示例1: paintPolygon

void QgsHighlight::paintPolygon( QPainter *p, QgsPolygon polygon )
{
  // OddEven fill rule by default
  QPainterPath path;

  p->setPen( mPen );
  p->setBrush( mBrush );

  for ( int i = 0; i < polygon.size(); i++ )
  {
    if ( polygon[i].empty() ) continue;

    QPolygonF ring;
    ring.reserve( polygon[i].size() + 1 );

    for ( int j = 0; j < polygon[i].size(); j++ )
    {
      //adding point only if it is more than a pixel appart from the previous one
      const QPointF cur = toCanvasCoordinates( polygon[i][j] ) - pos();
      if ( 0 == j || std::abs( ring.back().x() - cur.x() ) > 1 || std::abs( ring.back().y() - cur.y() ) > 1 )
      {
        ring.push_back( cur );
      }
    }

    ring.push_back( ring[ 0 ] );

    path.addPolygon( ring );
  }

  p->drawPath( path );
}
开发者ID:ColeCummins,项目名称:QGIS,代码行数:32,代码来源:qgshighlight.cpp

示例2: square

qreal Geometry::square(QPolygonF const &polygon)
{
	qreal result = 0;
	for (int i = 0; i < polygon.size(); ++i) {
		QPointF const p1 = i ? polygon[i-1] : polygon.back();
		QPointF const p2 = polygon[i];
		result += (p1.x() - p2.x()) * (p1.y() + p2.y());
	}

	return fabs(result) / 2;
}
开发者ID:ASabina,项目名称:qreal,代码行数:11,代码来源:geometry.cpp

示例3: renderPolyline

void QgsArrowSymbolLayer::renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context )
{
  Q_UNUSED( points );

  if ( !context.renderContext().painter() )
  {
    return;
  }

  context.renderContext().expressionContext().appendScope( mExpressionScope.data() );
  mExpressionScope->setVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_COUNT, points.size() + 1 );
  mExpressionScope->setVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_NUM, 1 );
  if ( isCurved() )
  {
    _resolveDataDefined( context );

    if ( ! isRepeated() )
    {
      if ( points.size() >= 3 )
      {
        // origin point
        QPointF po( points.at( 0 ) );
        // middle point
        QPointF pm( points.at( points.size() / 2 ) );
        // destination point
        QPointF pd( points.back() );

        QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
        mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
      }
      // straight arrow
      else if ( points.size() == 2 )
      {
        // origin point
        QPointF po( points.at( 0 ) );
        // destination point
        QPointF pd( points.at( 1 ) );

        QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
        mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
      }
    }
    else
    {
      for ( int pIdx = 0; pIdx < points.size() - 1; pIdx += 2 )
      {
        mExpressionScope->setVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_NUM, pIdx + 1 );
        _resolveDataDefined( context );

        if ( points.size() - pIdx >= 3 )
        {
          // origin point
          QPointF po( points.at( pIdx ) );
          // middle point
          QPointF pm( points.at( pIdx + 1 ) );
          // destination point
          QPointF pd( points.at( pIdx + 2 ) );

          QPolygonF poly = curvedArrow( po, pm, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
          mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
        }
        // straight arrow
        else if ( points.size() - pIdx == 2 )
        {
          // origin point
          QPointF po( points.at( pIdx ) );
          // destination point
          QPointF pd( points.at( pIdx + 1 ) );

          QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
          mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
        }
      }
    }
  }
  else
  {
    if ( !isRepeated() )
    {
      _resolveDataDefined( context );

      // origin point
      QPointF po( points.at( 0 ) );
      // destination point
      QPointF pd( points.back() );

      QPolygonF poly = straightArrow( po, pd, mScaledArrowStartWidth, mScaledArrowWidth, mScaledHeadWidth, mScaledHeadHeight, mComputedHeadType, mComputedArrowType, mScaledOffset );
      mSymbol->renderPolygon( poly, /* rings */ nullptr, context.feature(), context.renderContext() );
    }
    else
    {
      // only straight arrows
      for ( int pIdx = 0; pIdx < points.size() - 1; pIdx++ )
      {
        mExpressionScope->setVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_NUM, pIdx + 1 );
        _resolveDataDefined( context );

        // origin point
        QPointF po( points.at( pIdx ) );
        // destination point
//.........这里部分代码省略.........
开发者ID:AM7000000,项目名称:QGIS,代码行数:101,代码来源:qgsarrowsymbollayer.cpp


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