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) {
|
if (!from | !to) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
WayPointLine *ret = new WayPointLine(from, to, map, color);
|
WayPointLine *ret = new WayPointLine(from, to, map, color, dashed, width);
|
||||||
ret->setOpacity(overlayOpacity);
|
ret->setOpacity(overlayOpacity);
|
||||||
return ret;
|
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) {
|
if (!from | !to) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
WayPointLine *ret = new WayPointLine(from, to, map, color);
|
WayPointLine *ret = new WayPointLine(from, to, map, color, dashed, width);
|
||||||
ret->setOpacity(overlayOpacity);
|
ret->setOpacity(overlayOpacity);
|
||||||
return ret;
|
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) {
|
if (!center | !radius) {
|
||||||
return NULL;
|
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);
|
ret->setOpacity(overlayOpacity);
|
||||||
return ret;
|
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) {
|
if (!center | !radius) {
|
||||||
return NULL;
|
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);
|
ret->setOpacity(overlayOpacity);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -510,10 +510,10 @@ public:
|
|||||||
}
|
}
|
||||||
void SetShowDiagnostics(bool const & value);
|
void SetShowDiagnostics(bool const & value);
|
||||||
void SetUavPic(QString UAVPic);
|
void SetUavPic(QString UAVPic);
|
||||||
WayPointLine *WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color);
|
WayPointLine *WPLineCreate(WayPointItem *from, WayPointItem *to, QColor color, bool dashed = false, int width = -1);
|
||||||
WayPointLine *WPLineCreate(HomeItem *from, WayPointItem *to, QColor color);
|
WayPointLine *WPLineCreate(HomeItem *from, WayPointItem *to, QColor color, bool dashed = false, int width = -1);
|
||||||
WayPointCircle *WPCircleCreate(WayPointItem *center, WayPointItem *radius, bool clockwise, QColor color);
|
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);
|
WayPointCircle *WPCircleCreate(HomeItem *center, WayPointItem *radius, bool clockwise, QColor color, bool dashed = false, int width = -1);
|
||||||
void deleteAllOverlays();
|
void deleteAllOverlays();
|
||||||
void WPSetVisibleAll(bool value);
|
void WPSetVisibleAll(bool value);
|
||||||
WayPointItem *magicWPCreate();
|
WayPointItem *magicWPCreate();
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
#include "homeitem.h"
|
#include "homeitem.h"
|
||||||
|
|
||||||
namespace mapcontrol {
|
namespace mapcontrol {
|
||||||
WayPointCircle::WayPointCircle(WayPointItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color) : my_center(center),
|
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)
|
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(center, SIGNAL(localPositionChanged(QPointF, WayPointItem *)), this, SLOT(refreshLocations()));
|
||||||
connect(radius, 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)));
|
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)
|
my_radius(radius), my_map(map), QGraphicsEllipseItem(map), myColor(color), myClockWise(clockwise)
|
||||||
{
|
{
|
||||||
connect(radius, SIGNAL(homePositionChanged(internals::PointLatLng, float)), this, SLOT(refreshLocations()));
|
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)
|
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 9 };
|
enum { Type = UserType + 9 };
|
||||||
WayPointCircle(WayPointItem *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);
|
WayPointCircle(HomeItem *center, WayPointItem *radius, bool clockwise, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = -1);
|
||||||
int type() const;
|
int type() const;
|
||||||
void setColor(const QColor &color)
|
void setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
@ -55,6 +55,8 @@ private:
|
|||||||
QColor myColor;
|
QColor myColor;
|
||||||
bool myClockWise;
|
bool myClockWise;
|
||||||
QLineF line;
|
QLineF line;
|
||||||
|
bool dashed;
|
||||||
|
int width;
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
#include "homeitem.h"
|
#include "homeitem.h"
|
||||||
|
|
||||||
namespace mapcontrol {
|
namespace mapcontrol {
|
||||||
WayPointLine::WayPointLine(WayPointItem *from, WayPointItem *to, MapGraphicItem *map, QColor color) : source(from),
|
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)
|
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());
|
this->setLine(to->pos().x(), to->pos().y(), from->pos().x(), from->pos().y());
|
||||||
connect(from, SIGNAL(localPositionChanged(QPointF, WayPointItem *)), this, SLOT(refreshLocations()));
|
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)));
|
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
|
||||||
}
|
}
|
||||||
|
|
||||||
WayPointLine::WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color) : source(from),
|
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)
|
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());
|
this->setLine(to->pos().x(), to->pos().y(), from->pos().x(), from->pos().y());
|
||||||
connect(from, SIGNAL(homePositionChanged(internals::PointLatLng, float)), this, SLOT(refreshLocations()));
|
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.clear();
|
||||||
arrowHead << line().pointAt(0.5) << arrowP1 << arrowP2;
|
arrowHead << line().pointAt(0.5) << arrowP1 << arrowP2;
|
||||||
painter->drawPolygon(arrowHead);
|
painter->drawPolygon(arrowHead);
|
||||||
if (myColor == Qt::red) {
|
|
||||||
myPen.setWidth(3);
|
if(dashed)
|
||||||
} else if (myColor == Qt::yellow) {
|
{
|
||||||
myPen.setWidth(2);
|
QVector<qreal> dashes;
|
||||||
} else if (myColor == Qt::green) {
|
dashes << 4 << 8;
|
||||||
myPen.setWidth(1);
|
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->setPen(myPen);
|
||||||
painter->drawLine(line());
|
painter->drawLine(line());
|
||||||
|
@ -40,8 +40,8 @@ class WayPointLine : public QObject, public QGraphicsLineItem {
|
|||||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||||
public:
|
public:
|
||||||
enum { Type = UserType + 8 };
|
enum { Type = UserType + 8 };
|
||||||
WayPointLine(WayPointItem *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);
|
WayPointLine(HomeItem *from, WayPointItem *to, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = -1);
|
||||||
int type() const;
|
int type() const;
|
||||||
QPainterPath shape() const;
|
QPainterPath shape() const;
|
||||||
void setColor(const QColor &color)
|
void setColor(const QColor &color)
|
||||||
@ -54,6 +54,8 @@ private:
|
|||||||
MapGraphicItem *my_map;
|
MapGraphicItem *my_map;
|
||||||
QPolygonF arrowHead;
|
QPolygonF arrowHead;
|
||||||
QColor myColor;
|
QColor myColor;
|
||||||
|
bool dashed;
|
||||||
|
int lineWidth;
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
public slots:
|
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) {
|
if (from == NULL || to == NULL || from == to) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OVERLAY_LINE:
|
case OVERLAY_LINE:
|
||||||
myMap->WPLineCreate(from, to, color);
|
myMap->WPLineCreate(from, to, color, dashed, width);
|
||||||
break;
|
break;
|
||||||
case OVERLAY_CIRCLE_RIGHT:
|
case OVERLAY_CIRCLE_RIGHT:
|
||||||
myMap->WPCircleCreate(to, from, true, color);
|
myMap->WPCircleCreate(to, from, true, color, dashed, width);
|
||||||
break;
|
break;
|
||||||
case OVERLAY_CIRCLE_LEFT:
|
case OVERLAY_CIRCLE_LEFT:
|
||||||
myMap->WPCircleCreate(to, from, false, color);
|
myMap->WPCircleCreate(to, from, false, color, dashed, width);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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) {
|
if (from == NULL || to == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OVERLAY_LINE:
|
case OVERLAY_LINE:
|
||||||
myMap->WPLineCreate(to, from, color);
|
myMap->WPLineCreate(to, from, color, dashed, width);
|
||||||
break;
|
break;
|
||||||
case OVERLAY_CIRCLE_RIGHT:
|
case OVERLAY_CIRCLE_RIGHT:
|
||||||
myMap->WPCircleCreate(to, from, true, color);
|
myMap->WPCircleCreate(to, from, true, color, dashed, width);
|
||||||
break;
|
break;
|
||||||
case OVERLAY_CIRCLE_LEFT:
|
case OVERLAY_CIRCLE_LEFT:
|
||||||
myMap->WPCircleCreate(to, from, false, color);
|
myMap->WPCircleCreate(to, from, false, color, dashed, width);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -169,7 +169,7 @@ void modelMapProxy::refreshOverlays()
|
|||||||
wp_next_overlay = overlayTranslate(model->data(model->index(x + 1, flightDataModel::MODE)).toInt());
|
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_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());
|
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()) {
|
switch (model->data(model->index(x, flightDataModel::COMMAND)).toInt()) {
|
||||||
case MapDataDelegate::COMMAND_ONCONDITIONNEXTWAYPOINT:
|
case MapDataDelegate::COMMAND_ONCONDITIONNEXTWAYPOINT:
|
||||||
wp_next = findWayPointNumber(x + 1);
|
wp_next = findWayPointNumber(x + 1);
|
||||||
|
@ -56,8 +56,8 @@ private slots:
|
|||||||
void selectedWPChanged(QList<WayPointItem *>);
|
void selectedWPChanged(QList<WayPointItem *>);
|
||||||
private:
|
private:
|
||||||
overlayType overlayTranslate(int type);
|
overlayType overlayTranslate(int type);
|
||||||
void createOverlay(WayPointItem *from, WayPointItem *to, 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);
|
void createOverlay(WayPointItem *from, HomeItem *to, modelMapProxy::overlayType type, QColor color, bool dashed = false, int width = -1);
|
||||||
OPMapWidget *myMap;
|
OPMapWidget *myMap;
|
||||||
flightDataModel *model;
|
flightDataModel *model;
|
||||||
void refreshOverlays();
|
void refreshOverlays();
|
||||||
|
Loading…
Reference in New Issue
Block a user