|
|
|
@ -1116,18 +1116,67 @@ void HSIDisplay::drawSetpointXYZYaw(float x, float y, float z, float yaw, const
@@ -1116,18 +1116,67 @@ void HSIDisplay::drawSetpointXYZYaw(float x, float y, float z, float yaw, const
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HSIDisplay::drawWaypoint(QPainter& painter, const QColor& color, float width, const QVector<Waypoint*>& list, int i, const QPointF& p) |
|
|
|
|
{ |
|
|
|
|
painter.setBrush(Qt::NoBrush); |
|
|
|
|
|
|
|
|
|
// Setup pen for background
|
|
|
|
|
QPen penBg(color); |
|
|
|
|
penBg.setWidthF(width*2.0f); |
|
|
|
|
|
|
|
|
|
// Setup pen for foreground
|
|
|
|
|
QPen pen(color); |
|
|
|
|
pen.setWidthF(width); |
|
|
|
|
|
|
|
|
|
// DRAW WAYPOINT
|
|
|
|
|
float waypointSize = vwidth / 20.0f * 2.0f; |
|
|
|
|
QPolygonF poly(4); |
|
|
|
|
// Top point
|
|
|
|
|
poly.replace(0, QPointF(p.x(), p.y()-waypointSize/2.0f)); |
|
|
|
|
// Right point
|
|
|
|
|
poly.replace(1, QPointF(p.x()+waypointSize/2.0f, p.y())); |
|
|
|
|
// Bottom point
|
|
|
|
|
poly.replace(2, QPointF(p.x(), p.y() + waypointSize/2.0f)); |
|
|
|
|
poly.replace(3, QPointF(p.x() - waypointSize/2.0f, p.y())); |
|
|
|
|
|
|
|
|
|
float radius = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f)); |
|
|
|
|
float acceptRadius = list.at(i)->getAcceptanceRadius(); |
|
|
|
|
|
|
|
|
|
// Draw background
|
|
|
|
|
pen.setColor(Qt::black); |
|
|
|
|
painter.setPen(penBg); |
|
|
|
|
drawLine(p.x(), p.y(), p.x()+sin(list.at(i)->getYaw()/180.0*M_PI-yaw) * radius, p.y()-cos(list.at(i)->getYaw()/180.0*M_PI-yaw) * radius, refLineWidthToPen(0.4f), color, &painter); |
|
|
|
|
drawPolygon(poly, &painter); |
|
|
|
|
drawCircle(p.x(), p.y(), metricToRef(acceptRadius), 1.0, Qt::black, &painter); |
|
|
|
|
|
|
|
|
|
// Draw foreground
|
|
|
|
|
pen.setColor(color); |
|
|
|
|
painter.setPen(pen); |
|
|
|
|
drawLine(p.x(), p.y(), p.x()+sin(list.at(i)->getYaw()/180.0*M_PI-yaw) * radius, p.y()-cos(list.at(i)->getYaw()/180.0*M_PI-yaw) * radius, refLineWidthToPen(0.4f), color, &painter); |
|
|
|
|
drawPolygon(poly, &painter); |
|
|
|
|
drawCircle(p.x(), p.y(), metricToRef(acceptRadius), 1.0, Qt::green, &painter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void HSIDisplay::drawWaypoints(QPainter& painter) |
|
|
|
|
{ |
|
|
|
|
if (uas) |
|
|
|
|
{ |
|
|
|
|
const QVector<Waypoint*>& list = uas->getWaypointManager()->getWaypointEditableList(); |
|
|
|
|
|
|
|
|
|
// Do not work on empty lists
|
|
|
|
|
if (list.size() == 0) return; |
|
|
|
|
|
|
|
|
|
QColor color; |
|
|
|
|
painter.setBrush(Qt::NoBrush); |
|
|
|
|
|
|
|
|
|
// XXX Ugly hacks, needs rewrite
|
|
|
|
|
|
|
|
|
|
QPointF lastWaypoint; |
|
|
|
|
QPointF currentWaypoint; |
|
|
|
|
int currentIndex = 0; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
|
for (int i = 0; i < list.size(); i++) |
|
|
|
|
{ |
|
|
|
|
QPointF in; |
|
|
|
|
if (list.at(i)->getFrame() == MAV_FRAME_LOCAL_NED) |
|
|
|
|
{ |
|
|
|
@ -1144,42 +1193,22 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
@@ -1144,42 +1193,22 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
|
|
|
|
|
// Scale from metric to screen reference coordinates
|
|
|
|
|
QPointF p = metricBodyToRef(in); |
|
|
|
|
|
|
|
|
|
// Setup pen
|
|
|
|
|
QPen pen(color); |
|
|
|
|
painter.setBrush(Qt::NoBrush); |
|
|
|
|
|
|
|
|
|
// DRAW WAYPOINT
|
|
|
|
|
float waypointSize = vwidth / 20.0f * 2.0f; |
|
|
|
|
QPolygonF poly(4); |
|
|
|
|
// Top point
|
|
|
|
|
poly.replace(0, QPointF(p.x(), p.y()-waypointSize/2.0f)); |
|
|
|
|
// Right point
|
|
|
|
|
poly.replace(1, QPointF(p.x()+waypointSize/2.0f, p.y())); |
|
|
|
|
// Bottom point
|
|
|
|
|
poly.replace(2, QPointF(p.x(), p.y() + waypointSize/2.0f)); |
|
|
|
|
poly.replace(3, QPointF(p.x() - waypointSize/2.0f, p.y())); |
|
|
|
|
|
|
|
|
|
// Select color based on if this is the current waypoint
|
|
|
|
|
if (list.at(i)->getCurrent()) { |
|
|
|
|
color = QGC::colorYellow;//uas->getColor();
|
|
|
|
|
pen.setWidthF(refLineWidthToPen(0.8f)); |
|
|
|
|
} else { |
|
|
|
|
color = QGC::colorCyan; |
|
|
|
|
pen.setWidthF(refLineWidthToPen(0.4f)); |
|
|
|
|
if (list.at(i)->getCurrent()) |
|
|
|
|
{ |
|
|
|
|
currentIndex = i; |
|
|
|
|
currentWaypoint = p; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
drawWaypoint(painter, QGC::colorCyan, refLineWidthToPen(0.4f), list, i, p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pen.setColor(color); |
|
|
|
|
painter.setPen(pen); |
|
|
|
|
float radius = (waypointSize/2.0f) * 0.8 * (1/sqrt(2.0f)); |
|
|
|
|
drawLine(p.x(), p.y(), p.x()+sin(list.at(i)->getYaw()/180.0*M_PI-yaw) * radius, p.y()-cos(list.at(i)->getYaw()/180.0*M_PI-yaw) * radius, refLineWidthToPen(0.4f), color, &painter); |
|
|
|
|
drawPolygon(poly, &painter); |
|
|
|
|
float acceptRadius = list.at(i)->getAcceptanceRadius(); |
|
|
|
|
drawCircle(p.x(), p.y(), metricToRef(acceptRadius), 1.0, Qt::green, &painter); |
|
|
|
|
|
|
|
|
|
// DRAW CONNECTING LINE
|
|
|
|
|
// Draw line from last waypoint to this one
|
|
|
|
|
if (!lastWaypoint.isNull()) |
|
|
|
|
{ |
|
|
|
|
QPen pen(QGC::colorCyan); |
|
|
|
|
pen.setWidthF(refLineWidthToPen(0.4f)); |
|
|
|
|
painter.setPen(pen); |
|
|
|
|
color = QGC::colorCyan; |
|
|
|
@ -1187,6 +1216,8 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
@@ -1187,6 +1216,8 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
|
|
|
|
|
} |
|
|
|
|
lastWaypoint = p; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
drawWaypoint(painter, QGC::colorYellow, refLineWidthToPen(0.8f), list, currentIndex, currentWaypoint); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|