mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-11 19:24:10 +01:00
OP-1071 Adds support for dashed lines and circles. Emergency lines were changed to be dashed and less wide.
This commit is contained in:
parent
151d44b8e7
commit
e8dca2d089
@ -100,40 +100,40 @@ void OPMapWidget::SetUavPic(QString UAVPic)
|
||||
}
|
||||
}
|
||||
|
||||
WayPointLine *OPMapWidget::WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color)
|
||||
WayPointLine *OPMapWidget::WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed, int width)
|
||||
{
|
||||
if (!from | !to) {
|
||||
return NULL;
|
||||
}
|
||||
WayPointLine *ret = new WayPointLine(from, to, map, color);
|
||||
WayPointLine *ret = new WayPointLine(from, to, map, color, dashed, width);
|
||||
ret->setOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
WayPointLine *OPMapWidget::WPLineCreate(HomeItem *from, WayPointItem *to, QColor color)
|
||||
WayPointLine *OPMapWidget::WPLineCreate(HomeItem *from, WayPointItem *to, QColor color, bool dashed, int width)
|
||||
{
|
||||
if (!from | !to) {
|
||||
return NULL;
|
||||
}
|
||||
WayPointLine *ret = new WayPointLine(from, to, map, color);
|
||||
WayPointLine *ret = new WayPointLine(from, to, map, color, dashed, width);
|
||||
ret->setOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
WayPointCircle *OPMapWidget::WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise, QColor color)
|
||||
WayPointCircle *OPMapWidget::WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise, QColor color, bool dashed, int width)
|
||||
{
|
||||
if (!center | !radius) {
|
||||
return NULL;
|
||||
}
|
||||
WayPointCircle *ret = new WayPointCircle(center, radius, clockwise, map, color);
|
||||
WayPointCircle *ret = new WayPointCircle(center, radius, clockwise, map, color, dashed, width);
|
||||
ret->setOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
|
||||
WayPointCircle *OPMapWidget::WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise, QColor color)
|
||||
WayPointCircle *OPMapWidget::WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise, QColor color, bool dashed, int width)
|
||||
{
|
||||
if (!center | !radius) {
|
||||
return NULL;
|
||||
}
|
||||
WayPointCircle *ret = new WayPointCircle(center, radius, clockwise, map, color);
|
||||
WayPointCircle *ret = new WayPointCircle(center, radius, clockwise, map, color, dashed, width);
|
||||
ret->setOpacity(overlayOpacity);
|
||||
return ret;
|
||||
}
|
||||
|
@ -510,10 +510,10 @@ public:
|
||||
}
|
||||
void SetShowDiagnostics(bool const & value);
|
||||
void SetUavPic(QString UAVPic);
|
||||
WayPointLine *WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color);
|
||||
WayPointLine *WPLineCreate(HomeItem *from, WayPointItem *to, QColor color);
|
||||
WayPointCircle *WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise, QColor color);
|
||||
WayPointCircle *WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise, QColor color);
|
||||
WayPointLine *WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed = false, int width = -1);
|
||||
WayPointLine *WPLineCreate(HomeItem *from, WayPointItem *to, QColor color, bool dashed = false, int width = -1);
|
||||
WayPointCircle *WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise, QColor color, bool dashed = false, int width = -1);
|
||||
WayPointCircle *WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise, QColor color, bool dashed = false, int width = -1);
|
||||
void deleteAllOverlays();
|
||||
void WPSetVisibleAll(bool value);
|
||||
WayPointItem *magicWPCreate();
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include "homeitem.h"
|
||||
|
||||
namespace mapcontrol {
|
||||
WayPointCircle::WayPointCircle(WayPointItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color) : my_center(center),
|
||||
my_radius(radius), my_map(map), QGraphicsEllipseItem(map), myColor(color), myClockWise(clockwise)
|
||||
WayPointCircle::WayPointCircle(WayPointItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color, bool dashed, int width) : my_center(center),
|
||||
my_radius(radius), my_map(map), QGraphicsEllipseItem(map), myColor(color), myClockWise(clockwise), dashed(dashed), width(width)
|
||||
{
|
||||
connect(center, SIGNAL(localPositionChanged(QPointF, WayPointItem *)), this, SLOT(refreshLocations()));
|
||||
connect(radius, SIGNAL(localPositionChanged(QPointF, WayPointItem *)), this, SLOT(refreshLocations()));
|
||||
@ -40,7 +40,7 @@ WayPointCircle::WayPointCircle(WayPointItem *center, WayPointItem *radius, bool
|
||||
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
|
||||
}
|
||||
|
||||
WayPointCircle::WayPointCircle(HomeItem *radius, WayPointItem *center, bool clockwise, MapGraphicItem *map, QColor color) : my_center(center),
|
||||
WayPointCircle::WayPointCircle(HomeItem *radius, WayPointItem *center, bool clockwise, MapGraphicItem *map, QColor color, bool dashed, int width) : my_center(center),
|
||||
my_radius(radius), my_map(map), QGraphicsEllipseItem(map), myColor(color), myClockWise(clockwise)
|
||||
{
|
||||
connect(radius, SIGNAL(homePositionChanged(internals::PointLatLng, float)), this, SLOT(refreshLocations()));
|
||||
|
@ -40,8 +40,8 @@ class WayPointCircle : public QObject, public QGraphicsEllipseItem {
|
||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 9 };
|
||||
WayPointCircle(WayPointItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color = Qt::green);
|
||||
WayPointCircle(HomeItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color = Qt::green);
|
||||
WayPointCircle(WayPointItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = -1);
|
||||
WayPointCircle(HomeItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = -1);
|
||||
int type() const;
|
||||
void setColor(const QColor &color)
|
||||
{
|
||||
@ -55,6 +55,8 @@ private:
|
||||
QColor myColor;
|
||||
bool myClockWise;
|
||||
QLineF line;
|
||||
bool dashed;
|
||||
int width;
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
public slots:
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include "homeitem.h"
|
||||
|
||||
namespace mapcontrol {
|
||||
WayPointLine::WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem *map, QColor color) : source(from),
|
||||
destination(to), my_map(map), QGraphicsLineItem(map), myColor(color)
|
||||
WayPointLine::WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem *map, QColor color, bool dashed, int width) : source(from),
|
||||
destination(to), my_map(map), QGraphicsLineItem(map), myColor(color), dashed(dashed), lineWidth(width)
|
||||
{
|
||||
this->setLine(to->pos().x(), to->pos().y(), from->pos().x(), from->pos().y());
|
||||
connect(from, SIGNAL(localPositionChanged(QPointF, WayPointItem *)), this, SLOT(refreshLocations()));
|
||||
@ -47,8 +47,8 @@ WayPointLine::WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem
|
||||
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
|
||||
}
|
||||
|
||||
WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color) : source(from),
|
||||
destination(to), my_map(map), QGraphicsLineItem(map), myColor(color)
|
||||
WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color, bool dashed, int width) : source(from),
|
||||
destination(to), my_map(map), QGraphicsLineItem(map), myColor(color), dashed(dashed), lineWidth(width)
|
||||
{
|
||||
this->setLine(to->pos().x(), to->pos().y(), from->pos().x(), from->pos().y());
|
||||
connect(from, SIGNAL(homePositionChanged(internals::PointLatLng, float)), this, SLOT(refreshLocations()));
|
||||
@ -98,12 +98,25 @@ void WayPointLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
arrowHead.clear();
|
||||
arrowHead << line().pointAt(0.5) << arrowP1 << arrowP2;
|
||||
painter->drawPolygon(arrowHead);
|
||||
if (myColor == Qt::red) {
|
||||
myPen.setWidth(3);
|
||||
} else if (myColor == Qt::yellow) {
|
||||
myPen.setWidth(2);
|
||||
} else if (myColor == Qt::green) {
|
||||
myPen.setWidth(1);
|
||||
|
||||
if(dashed)
|
||||
{
|
||||
QVector<qreal> dashes;
|
||||
dashes << 4 << 8;
|
||||
myPen.setDashPattern(dashes);
|
||||
}
|
||||
|
||||
if(lineWidth == -1) {
|
||||
if (myColor == Qt::red) {
|
||||
myPen.setWidth(3);
|
||||
} else if (myColor == Qt::yellow) {
|
||||
myPen.setWidth(2);
|
||||
} else if (myColor == Qt::green) {
|
||||
myPen.setWidth(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
myPen.setWidth(lineWidth);
|
||||
}
|
||||
painter->setPen(myPen);
|
||||
painter->drawLine(line());
|
||||
|
@ -40,8 +40,8 @@ class WayPointLine : public QObject, public QGraphicsLineItem {
|
||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 8 };
|
||||
WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem *map, QColor color = Qt::green);
|
||||
WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color = Qt::green);
|
||||
WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = -1);
|
||||
WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = -1);
|
||||
int type() const;
|
||||
QPainterPath shape() const;
|
||||
void setColor(const QColor &color)
|
||||
@ -54,6 +54,8 @@ private:
|
||||
MapGraphicItem *my_map;
|
||||
QPolygonF arrowHead;
|
||||
QColor myColor;
|
||||
bool dashed;
|
||||
int lineWidth;
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
public slots:
|
||||
|
@ -108,39 +108,39 @@ modelMapProxy::overlayType modelMapProxy::overlayTranslate(int type)
|
||||
}
|
||||
}
|
||||
|
||||
void modelMapProxy::createOverlay(WayPointItem *from, WayPointItem *to, modelMapProxy::overlayType type, QColor color)
|
||||
void modelMapProxy::createOverlay(WayPointItem *from, WayPointItem *to, modelMapProxy::overlayType type, QColor color, bool dashed, int width)
|
||||
{
|
||||
if (from == NULL || to == NULL || from == to) {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case OVERLAY_LINE:
|
||||
myMap->WPLineCreate(from, to, color);
|
||||
myMap->WPLineCreate(from, to, color, dashed, width);
|
||||
break;
|
||||
case OVERLAY_CIRCLE_RIGHT:
|
||||
myMap->WPCircleCreate(to, from, true, color);
|
||||
myMap->WPCircleCreate(to, from, true, color, dashed, width);
|
||||
break;
|
||||
case OVERLAY_CIRCLE_LEFT:
|
||||
myMap->WPCircleCreate(to, from, false, color);
|
||||
myMap->WPCircleCreate(to, from, false, color, dashed, width);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
void modelMapProxy::createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color)
|
||||
void modelMapProxy::createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color, bool dashed, int width)
|
||||
{
|
||||
if (from == NULL || to == NULL) {
|
||||
return;
|
||||
}
|
||||
switch (type) {
|
||||
case OVERLAY_LINE:
|
||||
myMap->WPLineCreate(to, from, color);
|
||||
myMap->WPLineCreate(to, from, color, dashed, width);
|
||||
break;
|
||||
case OVERLAY_CIRCLE_RIGHT:
|
||||
myMap->WPCircleCreate(to, from, true, color);
|
||||
myMap->WPCircleCreate(to, from, true, color, dashed, width);
|
||||
break;
|
||||
case OVERLAY_CIRCLE_LEFT:
|
||||
myMap->WPCircleCreate(to, from, false, color);
|
||||
myMap->WPCircleCreate(to, from, false, color, dashed, width);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -169,7 +169,7 @@ void modelMapProxy::refreshOverlays()
|
||||
wp_next_overlay = overlayTranslate(model->data(model->index(x + 1, flightDataModel::MODE)).toInt());
|
||||
wp_jump_overlay = overlayTranslate(model->data(model->index(wp_jump, flightDataModel::MODE)).toInt());
|
||||
wp_error_overlay = overlayTranslate(model->data(model->index(wp_error, flightDataModel::MODE)).toInt());
|
||||
createOverlay(wp_current, findWayPointNumber(wp_error), wp_error_overlay, Qt::red);
|
||||
createOverlay(wp_current, findWayPointNumber(wp_error), wp_error_overlay, Qt::red, true, 1);
|
||||
switch (model->data(model->index(x, flightDataModel::COMMAND)).toInt()) {
|
||||
case MapDataDelegate::COMMAND_ONCONDITIONNEXTWAYPOINT:
|
||||
wp_next = findWayPointNumber(x + 1);
|
||||
|
@ -56,8 +56,8 @@ private slots:
|
||||
void selectedWPChanged(QList<WayPointItem *>);
|
||||
private:
|
||||
overlayType overlayTranslate(int type);
|
||||
void createOverlay(WayPointItem *from, WayPointItem *to, overlayType type, QColor color);
|
||||
void createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color);
|
||||
void createOverlay(WayPointItem *from, WayPointItem *to, overlayType type, QColor color, bool dashed = false, int width = -1);
|
||||
void createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color, bool dashed = false, int width = -1);
|
||||
OPMapWidget *myMap;
|
||||
flightDataModel *model;
|
||||
void refreshOverlays();
|
||||
|
Loading…
Reference in New Issue
Block a user