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


C++ Point::toQPointF方法代码示例

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


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

示例1: drawTeamSpace

void SimFieldView::drawTeamSpace(QPainter& p) {
    FieldView::drawTeamSpace(p);

    // Simulator drag-to-shoot
    std::shared_ptr<LogFrame> frame = currentFrame();
    if (_dragMode == DRAG_SHOOT && frame) {
        p.setPen(QPen(Qt::white, 0.1f));
        Geometry2d::Point ball = frame->ball().pos();
        p.drawLine(ball.toQPointF(), _dragTo.toQPointF());

        if (ball != _dragTo) {
            p.setPen(QPen(Qt::gray, 0.1f));

            _shot = (ball - _dragTo) * ShootScale;
            float speed = _shot.mag();
            Geometry2d::Point shotExtension = ball + _shot / speed * 8;

            p.drawLine(ball.toQPointF(), shotExtension.toQPointF());

            p.setPen(Qt::black);
            drawText(p, _dragTo.toQPointF(),
                     QString("%1 m/s").arg(speed, 0, 'f', 1));
        }
    }
}
开发者ID:Riley-Brooksher,项目名称:robocup-software,代码行数:25,代码来源:SimFieldView.cpp

示例2: drawTeamSpace

void FieldView::drawTeamSpace(QPainter& p) {
    // Get the latest LogFrame
    const LogFrame* frame = _history->at(0).get();

    if (showTeamNames) {
        // Draw Team Names
        QFont savedFont = p.font();
        QFont fontstyle = p.font();
        fontstyle.setPointSize(20);
        p.setFont(fontstyle);
        p.setPen(bluePen);
        drawText(p, QPointF(0, 4.75), QString(frame->team_name_blue().c_str()),
                 true);  // Blue
        p.setPen(yellowPen);
        drawText(p, QPointF(0, 1.75),
                 QString(frame->team_name_yellow().c_str()),
                 true);  // Yellow
        p.setFont(savedFont);
    }

    // Block off half the field
    if (!frame->use_our_half()) {
        const float FX = Field_Dimensions::Current_Dimensions.FloorWidth() / 2;
        const float FY1 = -Field_Dimensions::Current_Dimensions.Border();
        const float FY2 = Field_Dimensions::Current_Dimensions.Length() / 2;
        p.fillRect(QRectF(QPointF(-FX, FY1), QPointF(FX, FY2)),
                   QColor(0, 0, 0, 128));
    }
    if (!frame->use_opponent_half()) {
        const float FX = Field_Dimensions::Current_Dimensions.FloorWidth() / 2;
        const float FY1 = Field_Dimensions::Current_Dimensions.Length() / 2;
        const float FY2 = Field_Dimensions::Current_Dimensions.Length() +
                          Field_Dimensions::Current_Dimensions.Border();
        p.fillRect(QRectF(QPointF(-FX, FY1), QPointF(FX, FY2)),
                   QColor(0, 0, 0, 128));
    }

    if (showCoords) {
        drawCoords(p);
    }

    // History
    p.setBrush(Qt::NoBrush);
    QPainterPath ballTrail;
    for (unsigned int i = 0; i < 200 && i < _history->size(); ++i) {
        const LogFrame* oldFrame = _history->at(i).get();
        if (oldFrame && oldFrame->has_ball()) {
            QPointF pos = qpointf(oldFrame->ball().pos());

            if (i == 0)
                ballTrail.moveTo(pos);
            else
                ballTrail.lineTo(pos);
        }
    }
    QPen ballTrailPen(ballColor, 0.03);
    ballTrailPen.setCapStyle(Qt::RoundCap);
    p.setPen(ballTrailPen);
    p.drawPath(ballTrail);

    // Debug lines
    for (const DebugPath& path : frame->debug_paths()) {
        if (path.layer() < 0 || layerVisible(path.layer())) {
            tempPen.setColor(qcolor(path.color()));
            p.setPen(tempPen);
            std::vector<QPointF> pts;
            for (int i = 0; i < path.points_size(); ++i) {
                pts.push_back(qpointf(path.points(i)));
            }
            p.drawPolyline(pts.data(), pts.size());
        }
    }

    for (const DebugRobotPath& path : frame->debug_robot_paths()) {
        if (path.layer() < 0 || layerVisible(path.layer())) {
            for (int i = 0; i < path.points_size() - 1; ++i) {
                const DebugRobotPath::DebugRobotPathPoint& from =
                    path.points(i);
                const DebugRobotPath::DebugRobotPathPoint& to =
                    path.points(i + 1);

                Geometry2d::Point avgVel =
                    (Geometry2d::Point(path.points(i).vel()) +
                     Geometry2d::Point(path.points(i + 1).vel())) /
                    2;
                float pcntMaxSpd =
                    avgVel.mag() / MotionConstraints::defaultMaxSpeed();
                QColor mixedColor(std::min((int)(255 * pcntMaxSpd), 255), 0,
                                  std::min((int)(255 * (1 - pcntMaxSpd)), 255));
                QPen pen(mixedColor);
                pen.setCapStyle(Qt::RoundCap);
                pen.setWidthF(0.03);
                p.setPen(pen);

                const Geometry2d::Point fromPos = Geometry2d::Point(from.pos());
                const Geometry2d::Point toPos = Geometry2d::Point(to.pos());
                p.drawLine(fromPos.toQPointF(), toPos.toQPointF());
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:idaohang,项目名称:PVA-robocup-software,代码行数:101,代码来源:FieldView.cpp


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