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


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

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


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

示例1: painterSaver

/**
 * Draws a 3D cuboid by extending a 2D rectangle in the z-axis
 *
 * @param rect The rectangle to draw
 * @param brush The brush fill the surfaces of the cuboid with
 * @param pen The pen to draw the edges with
 * @param props The 3D properties to use for drawing the cuboid
 * @return The drawn cuboid as a polygon
 */
QPolygonF StockDiagram::Private::ThreeDPainter::drawThreeDRect( const QRectF &rect, const QBrush &brush,
                                                                const QPen &pen, const ThreeDProperties &props )
{
    // Restores the painting properties when destroyed
    PainterSaver painterSaver( painter );

    // Make sure that the top really is the top
    const QRectF normalizedRect = rect.normalized();

    // Calculate all the four sides of the rectangle
    const QLineF topSide = QLineF( normalizedRect.topLeft(), normalizedRect.topRight() );
    const QLineF bottomSide = QLineF( normalizedRect.bottomLeft(), normalizedRect.bottomRight() );
    const QLineF leftSide = QLineF( normalizedRect.topLeft(), normalizedRect.bottomLeft() );
    const QLineF rightSide = QLineF( normalizedRect.topRight(), normalizedRect.bottomRight() );

    QPolygonF drawnPolygon;

    // Shorter names are easier on the eyes
    const qreal angle = props.angle;

    // Only top and right side is visible
    if ( angle >= 0.0 && angle < 90.0 ) {
        drawnPolygon = drawnPolygon.united( drawThreeDLine( topSide, brush, pen, props ) );
        drawnPolygon = drawnPolygon.united( drawThreeDLine( rightSide, brush, pen, props ) );
    // Only top and left side is visible
    } else if ( angle >= 90.0 && angle < 180.0 ) {
        drawnPolygon = drawnPolygon.united( drawThreeDLine( topSide, brush, pen, props ) );
        drawnPolygon = drawnPolygon.united( drawThreeDLine( leftSide, brush, pen, props ) );
    // Only bottom and left side is visible
    } else if ( angle >= 180.0 && angle < 270.0 ) {
        drawnPolygon = drawnPolygon.united( drawThreeDLine( bottomSide, brush, pen, props ) );
        drawnPolygon = drawnPolygon.united( drawThreeDLine( leftSide, brush, pen, props ) );
    // Only bottom and right side is visible
    } else if ( angle >= 270.0 && angle <= 360.0 ) {
        drawnPolygon = drawnPolygon.united( drawThreeDLine( bottomSide, brush, pen, props ) );
        drawnPolygon = drawnPolygon.united( drawThreeDLine( rightSide, brush, pen, props ) );
    }

    // Draw the front side
    painter->setPen( pen );
    painter->setBrush( brush );
    painter->drawRect( normalizedRect );

    return drawnPolygon;
}
开发者ID:Wushaowei001,项目名称:mksPlanner,代码行数:54,代码来源:KDChartStockDiagram_p.cpp

示例2: calcShape

void Edge::calcShape() {
    QPainterPath p;

    auto route = mConnectionReference->displayRoute();
    std::vector<QRectF> v;
    for(size_t i = 0; i < route.size() - 1; ++i) {
        QPointF p1(route.at(i).x, route.at(i).y);
        QPointF p2(route.at(i+1).x, route.at(i+1).y);
        QRectF r(p1, p2);
        grow(r, 10);
        v.push_back(r);
    }

    QPolygonF poly;
    for(auto r : v) {
        poly = poly.united(r);
    }

    p.addPolygon(poly);
    p.closeSubpath();
    mShape = p;
}
开发者ID:SynthiNet,项目名称:Qumulus,代码行数:22,代码来源:Edge.cpp


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