本文整理汇总了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 );
}
示例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;
}
示例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
//.........这里部分代码省略.........