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