修改航点属性

This commit is contained in:
2020-04-17 09:14:05 +08:00
parent 0fc5e65983
commit 5b7b11d8b6
5 changed files with 222 additions and 243 deletions
+18
View File
@@ -66,6 +66,24 @@ FORMS += \
INCLUDEPATH += $$PWD/../../thirdpart/include INCLUDEPATH += $$PWD/../../thirdpart/include
#添加mavlink目录
INCLUDEPATH += $$PWD/../../mavlink \
$$PWD/../../mavlink/ardupilotmega \
$$PWD/../../mavlink/common \
$$PWD/../../mavlink/icarous \
$$PWD/../../mavlink/uAvionix \
$$PWD/../../mavlink/XYK \
$$PWD/../../mavlink/message_definitions
LIBS += -L$$PWD/../../thirdpart/lib -lcore LIBS += -L$$PWD/../../thirdpart/lib -lcore
LIBS += -L$$PWD/../../thirdpart/lib -linternals LIBS += -L$$PWD/../../thirdpart/lib -linternals
-17
View File
@@ -105,7 +105,6 @@ void WayPointCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
dashes << 4 << 8; dashes << 4 << 8;
myPen.setDashPattern(dashes); myPen.setDashPattern(dashes);
} }
qreal arrowSize = 10;
painter->setPen(myPen); painter->setPen(myPen);
QBrush brush = painter->brush(); QBrush brush = painter->brush();
painter->setBrush(myColor); painter->setBrush(myColor);
@@ -114,23 +113,7 @@ void WayPointCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
angle += M_PI; angle += M_PI;
} }
/* QPointF arrowP1 = p1 + QPointF(sin(angle + M_PI / 3) * arrowSize,
cos(angle + M_PI / 3) * arrowSize);
QPointF arrowP2 = p1 + QPointF(sin(angle + M_PI - M_PI / 3) * arrowSize,
cos(angle + M_PI - M_PI / 3) * arrowSize);
QPointF arrowP21 = p2 + QPointF(sin(angle + M_PI + M_PI / 3) * arrowSize,
cos(angle + M_PI + M_PI / 3) * arrowSize);
QPointF arrowP22 = p2 + QPointF(sin(angle + M_PI + M_PI - M_PI / 3) * arrowSize,
cos(angle + M_PI + M_PI - M_PI / 3) * arrowSize);
arrowHead.clear();
arrowHead << p1 << arrowP1 << arrowP2;
painter->drawPolygon(arrowHead);
arrowHead.clear();
arrowHead << p2 << arrowP21 << arrowP22;
painter->drawPolygon(arrowHead);
*/
painter->translate(-line.length(), -line.length()); painter->translate(-line.length(), -line.length());
painter->setBrush(brush); painter->setBrush(brush);
painter->drawEllipse(this->rect()); painter->drawEllipse(this->rect());
+104 -97
View File
@@ -31,18 +31,18 @@
namespace mapcontrol { namespace mapcontrol {
WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & altitude, MapGraphicItem *map, wptype type) : coord(coord), reached(false), description(""), shownumber(true), isDragging(false), altitude(altitude), map(map), myType(type) WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & altitude, MapGraphicItem *map, wptype type) : coord(coord), reached(false), description(""), shownumber(true), isDragging(false), altitude(altitude), map(map), myType(type)
{ {
text = 0;
numberI = 0; numberI = 0;
isMagic = false; isMagic = false;
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
number = WayPointItem::snumber; number = WayPointItem::snumber;
++WayPointItem::snumber; ++WayPointItem::snumber;
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
SetShowNumber(shownumber); SetShowNumber(shownumber);
RefreshToolTip();
RefreshPos(); RefreshPos();
SetDefault(coord.Lat(),coord.Lng(),altitude,number);
myHome = NULL; myHome = NULL;
QList<QGraphicsItem *> list = map->childItems(); QList<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) { foreach(QGraphicsItem * obj, list) {
@@ -72,21 +72,21 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint) : reached(fa
myType = relative; myType = relative;
if (magicwaypoint) { if (magicwaypoint) {
isMagic = true; isMagic = true;
picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png"));
number = -1; number = -1;
} else { } else {
isMagic = false; isMagic = false;
number = WayPointItem::snumber; number = WayPointItem::snumber;
++WayPointItem::snumber; ++WayPointItem::snumber;
} }
text = 0;
numberI = 0; numberI = 0;
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
SetShowNumber(shownumber); SetShowNumber(shownumber);
RefreshToolTip();
RefreshPos(); RefreshPos();
SetDefault(coord.Lat(),coord.Lng(),altitude,number);
myHome = NULL; myHome = NULL;
QList<QGraphicsItem *> list = map->childItems(); QList<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) { foreach(QGraphicsItem * obj, list) {
@@ -109,18 +109,19 @@ WayPointItem::WayPointItem(MapGraphicItem *map, bool magicwaypoint) : reached(fa
} }
WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & altitude, const QString &description, MapGraphicItem *map, wptype type) : coord(coord), reached(false), description(description), shownumber(true), isDragging(false), altitude(altitude), map(map), myType(type) WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & altitude, const QString &description, MapGraphicItem *map, wptype type) : coord(coord), reached(false), description(description), shownumber(true), isDragging(false), altitude(altitude), map(map), myType(type)
{ {
text = 0;
numberI = 0; numberI = 0;
isMagic = false; isMagic = false;
picture.load(QString::fromUtf8(":/markers/images/marker.png")); //picture.load(QString::fromUtf8(":/markers/images/marker.png"));
number = WayPointItem::snumber; number = WayPointItem::snumber;
++WayPointItem::snumber; ++WayPointItem::snumber;
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
SetShowNumber(shownumber); SetShowNumber(shownumber);
RefreshToolTip();
RefreshPos(); RefreshPos();
SetDefault(coord.Lat(),coord.Lng(),altitude,number);
myHome = NULL; myHome = NULL;
QList<QGraphicsItem *> list = map->childItems(); QList<QGraphicsItem *> list = map->childItems();
foreach(QGraphicsItem * obj, list) { foreach(QGraphicsItem * obj, list) {
@@ -158,18 +159,18 @@ WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate, const
SetAltitude(myHome->Altitude() + relativeCoord.altitudeRelative); SetAltitude(myHome->Altitude() + relativeCoord.altitudeRelative);
} }
myType = relative; myType = relative;
text = 0;
numberI = 0; numberI = 0;
isMagic = false; isMagic = false;
picture.load(QString::fromUtf8(":/markers/images/marker.png"));
number = WayPointItem::snumber; number = WayPointItem::snumber;
++WayPointItem::snumber; ++WayPointItem::snumber;
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true); this->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
SetShowNumber(shownumber); SetShowNumber(shownumber);
RefreshToolTip();
RefreshPos(); RefreshPos();
SetDefault(coord.Lat(),coord.Lng(),altitude,number);
connect(this, SIGNAL(waypointdoubleclick(WayPointItem *)), map, SIGNAL(wpdoubleclicked(WayPointItem *))); connect(this, SIGNAL(waypointdoubleclick(WayPointItem *)), map, SIGNAL(wpdoubleclicked(WayPointItem *)));
emit manualCoordChange(this); emit manualCoordChange(this);
connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos())); connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos()));
@@ -181,11 +182,11 @@ void WayPointItem::setWPType(wptype type)
myType = type; myType = type;
emit WPValuesChanged(this); emit WPValuesChanged(this);
RefreshPos(); RefreshPos();
RefreshToolTip();
this->update(); this->update();
} }
QRectF WayPointItem::boundingRect() const QRectF WayPointItem::boundingRect() const //鼠标可以操作的大小
{ {
return QRectF(-10,-10,20,20); return QRectF(-10,-10,20,20);
} }
@@ -193,13 +194,15 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
{ {
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
//painter->drawPixmap(-picture.width() / 2, -picture.height(), picture);
painter->setPen(Qt::green); painter->setPen(Qt::green);
painter->drawRect(-6,-6,12,12); painter->drawRect(-6,-6,12,12);
painter->drawLine(-6,-6,6,6); painter->drawLine(-6,-6,6,6);
painter->drawLine(-6,6,6,-6); painter->drawLine(-6,6,6,-6);
if (this->isSelected()) { if (this->isSelected()) {
painter->setPen(Qt::red); painter->setPen(Qt::red);
painter->drawRect(QRectF(-10,-10,20,20)); painter->drawRect(QRectF(-10,-10,20,20));
@@ -208,6 +211,7 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
void WayPointItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void WayPointItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
qInfo() << "DoubleClickEvent";
emit waypointdoubleclick(this); emit waypointdoubleclick(this);
} }
} }
@@ -215,16 +219,7 @@ void WayPointItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
void WayPointItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void WayPointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
text = new QGraphicsSimpleTextItem(this); qInfo() << "PressEvent";
textBG = new QGraphicsRectItem(this);
textBG->setBrush(Qt::white);
text->setPen(QPen(Qt::black));
text->setPos(10, -picture.height());
textBG->setPos(10, -picture.height());
text->setZValue(3);
RefreshToolTip();
isDragging = true; isDragging = true;
} }
QGraphicsItem::mousePressEvent(event); QGraphicsItem::mousePressEvent(event);
@@ -232,44 +227,34 @@ void WayPointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void WayPointItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void WayPointItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
if (text) { qInfo() << "ReleaseEvent";
delete text;
text = NULL;
}
if (textBG) {
delete textBG;
textBG = NULL;
}
isDragging = false; isDragging = false;
RefreshToolTip();
emit manualCoordChange(this); emit manualCoordChange(this);
emit localPositionChanged(this->pos(), this); emit localPositionChanged(this->pos(), this);
emit WPValuesChanged(this); emit WPValuesChanged(this);
coord = map->FromLocalToLatLng(this->pos().x(), this->pos().y()); coord = map->FromLocalToLatLng(this->pos().x(), this->pos().y());
SetLat(coord.Lat());
SetLng(coord.Lng());
emit WPChanged(this->Number(),Coord().Lat(),Coord().Lng()); emit WPChanged(this->Number(),Coord().Lat(),Coord().Lng());
} }
QGraphicsItem::mouseReleaseEvent(event); QGraphicsItem::mouseReleaseEvent(event);
} }
void WayPointItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void WayPointItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (isDragging) { if (isDragging) {
coord = map->FromLocalToLatLng(this->pos().x(), this->pos().y());
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
if (myHome) {
map->Projection()->offSetFromLatLngs(myHome->Coord(), coord, relativeCoord.distance, relativeCoord.bearing);
}
QString relativeCoord_str =QString::number(relativeCoord.distance) + "m " + QString::number(relativeCoord.bearing * 180 / M_PI) + "deg";
text->setText(coord_str + "\n" + relativeCoord_str);
textBG->setRect(text->boundingRect());
emit localPositionChanged(this->pos(), this); emit localPositionChanged(this->pos(), this);
emit WPValuesChanged(this); emit WPValuesChanged(this);
} }
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
} }
void WayPointItem::SetAltitude(const float &value) void WayPointItem::SetAltitude(const float &value)
{ {
if (altitude == value) { if (altitude == value) {
@@ -279,7 +264,6 @@ void WayPointItem::SetAltitude(const float &value)
if (myHome) { if (myHome) {
relativeCoord.altitudeRelative = altitude - myHome->Altitude(); relativeCoord.altitudeRelative = altitude - myHome->Altitude();
} }
RefreshToolTip();
emit WPValuesChanged(this); emit WPValuesChanged(this);
this->update(); this->update();
} }
@@ -296,7 +280,6 @@ void WayPointItem::setRelativeCoord(distBearingAltitude value)
SetAltitude(myHome->Altitude() + relativeCoord.altitudeRelative); SetAltitude(myHome->Altitude() + relativeCoord.altitudeRelative);
} }
RefreshPos(); RefreshPos();
RefreshToolTip();
emit WPValuesChanged(this); emit WPValuesChanged(this);
this->update(); this->update();
} }
@@ -316,7 +299,6 @@ void WayPointItem::SetCoord(const internals::PointLatLng &value)
} }
emit WPValuesChanged(this); emit WPValuesChanged(this);
RefreshPos(); RefreshPos();
RefreshToolTip();
this->update(); this->update();
} }
void WayPointItem::SetDescription(const QString &value) void WayPointItem::SetDescription(const QString &value)
@@ -325,7 +307,6 @@ void WayPointItem::SetDescription(const QString &value)
return; return;
} }
description = value; description = value;
RefreshToolTip();
emit WPValuesChanged(this); emit WPValuesChanged(this);
this->update(); this->update();
} }
@@ -334,7 +315,6 @@ void WayPointItem::SetNumber(const int &value)
int oldnumber = number; int oldnumber = number;
number = value; number = value;
RefreshToolTip();
numberI->setText(QString::number(numberAdjusted())); numberI->setText(QString::number(numberAdjusted()));
this->update(); this->update();
emit WPNumberChanged(oldnumber, value, this); emit WPNumberChanged(oldnumber, value, this);
@@ -344,16 +324,16 @@ void WayPointItem::SetReached(const bool &value)
reached = value; reached = value;
emit WPValuesChanged(this); emit WPValuesChanged(this);
if (value) { if (value) {
picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png")); //picture.load(QString::fromUtf8(":/markers/images/bigMarkerGreen.png"));
} else { } else {
if (!isMagic) { if (!isMagic) {
if ((this->flags() & QGraphicsItem::ItemIsMovable) == QGraphicsItem::ItemIsMovable) { if ((this->flags() & QGraphicsItem::ItemIsMovable) == QGraphicsItem::ItemIsMovable) {
picture.load(QString::fromUtf8(":/markers/images/marker.png")); //picture.load(QString::fromUtf8(":/markers/images/marker.png"));
} else { } else {
picture.load(QString::fromUtf8(":/markers/images/waypoint_marker2.png")); //picture.load(QString::fromUtf8(":/markers/images/waypoint_marker2.png"));
} }
} else { } else {
picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png")); //picture.load(QString::fromUtf8(":/opmap/images/waypoint_marker3.png"));
} }
} }
this->update(); this->update();
@@ -408,7 +388,6 @@ void WayPointItem::onHomePositionChanged(internals::PointLatLng homepos, float h
SetAltitude(relativeCoord.altitudeRelative + homeAltitude); SetAltitude(relativeCoord.altitudeRelative + homeAltitude);
emit WPValuesChanged(this); emit WPValuesChanged(this);
RefreshPos(); RefreshPos();
RefreshToolTip();
this->update(); this->update();
} else { } else {
if (myHome) { if (myHome) {
@@ -455,24 +434,7 @@ void WayPointItem::setOpacitySlot(qreal opacity)
{ {
setOpacity(opacity); setOpacity(opacity);
} }
void WayPointItem::RefreshToolTip()
{
QString type_str;
if (myType == relative) {
type_str = "Relative";
} else {
type_str = "Absolute";
}
QString coord_str = " " + QString::number(coord.Lat(), 'f', 6) + " " + QString::number(coord.Lng(), 'f', 6);
QString relativeCoord_str = " Distance:" + QString::number(relativeCoord.distance) + " Bearing:" + QString::number(relativeCoord.bearing * 180 / M_PI);
QString relativeAltitude_str = QString::number(relativeCoord.altitudeRelative);
if (Number() != -1) {
setToolTip(QString("WayPoint Number:%1\nDescription:%2\nCoordinate:%4\nFrom Home:%5\nRelative altitude:%6\nAltitude:%7\nType:%8\n%9").arg(QString::number(numberAdjusted())).arg(description).arg(coord_str).arg(relativeCoord_str).arg(relativeAltitude_str).arg(QString::number(altitude)).arg(type_str).arg(myCustomString));
} else {
setToolTip(QString("Magic WayPoint\nCoordinate:%1\nFrom Home:%2\nAltitude:%3\nType:%4\n%5").arg(coord_str).arg(relativeCoord_str).arg(QString::number(altitude)).arg(type_str).arg(myCustomString));
}
}
void WayPointItem::setFlag(QGraphicsItem::GraphicsItemFlag flag, bool enabled) void WayPointItem::setFlag(QGraphicsItem::GraphicsItemFlag flag, bool enabled)
{ {
@@ -481,14 +443,82 @@ void WayPointItem::setFlag(QGraphicsItem::GraphicsItemFlag flag, bool enabled)
return; return;
} else if (flag == QGraphicsItem::ItemIsMovable) { } else if (flag == QGraphicsItem::ItemIsMovable) {
if (enabled) { if (enabled) {
picture.load(QString::fromUtf8(":/markers/images/marker.png")); //picture.load(QString::fromUtf8(":/markers/images/marker.png"));
} else { } else {
picture.load(QString::fromUtf8(":/markers/images/waypoint_marker2.png")); //picture.load(QString::fromUtf8(":/markers/images/waypoint_marker2.png"));
} }
} }
QGraphicsItem::setFlag(flag, enabled); QGraphicsItem::setFlag(flag, enabled);
} }
//=============属性设置=================
void WayPointItem::SetDefault(double lat,double lng,float alt,uint16_t seq)
{
property.param1 = 100;
property.param2 = 50;
property.param3 = 50;
property.param4 = 0;
property.x = lat * 10e5;
property.y = lng * 10e5;
property.z = alt;
property.seq = seq;
property.command = MAV_CMD::MAV_CMD_NAV_WAYPOINT;
//...
}
void WayPointItem::SetParam1(float value)
{
property.param1 = value;
}
void WayPointItem::SetParam2(float value)
{
property.param2 = value;
}
void WayPointItem::SetParam3(float value)
{
property.param3 = value;
}
void WayPointItem::SetParam4(float value)
{
property.param4 = value;
}
void WayPointItem::SetLat(double value)
{
property.x = value * 10e5;
}
void WayPointItem::SetLng(double value)
{
property.y = value * 10e5;
}
void WayPointItem::SetAlt(float value)
{
property.z = value;
}
void WayPointItem::SetSeq(uint16_t value)
{
property.seq = value;
}
void WayPointItem::SetCommand(uint16_t value)
{
property.command = value;
}
void WayPointItem::SetGroup(uint16_t value)
{
property.group = value;
}
//==============全局计数===================
int WayPointItem::snumber = 0; int WayPointItem::snumber = 0;
} }
@@ -497,29 +527,6 @@ int WayPointItem::snumber = 0;
/*
float param1;
float param2;
float param3;
float param4;
int32_t x; PARAM5 / local: x position in meters * 1e4, global: latitude in degrees * 10^7*
int32_t y; PARAM6 / y position: local: x position in meters * 1e4, global: longitude in degrees *10^7
float z; PARAM7 / z position: global: altitude in meters (relative or absolute, depending on frame.
uint16_t seq; Waypoint ID (sequence number). Starts at zero. Increases monotonically for each waypoint, no gaps in the sequence (0,1,2,3,4)
uint16_t command; /*< The scheduled action for the waypoint.
uint8_t target_system; /*< System ID*
uint8_t target_component; /*< Component ID*
uint8_t frame; /*< The coordinate system of the waypoint.
uint8_t current; /*< false:0, true:1
uint8_t autocontinue; /*< Autocontinue to next waypoint
uint8_t mission_type; /*< Mission type.
*/
+94 -129
View File
@@ -35,6 +35,9 @@
#include <QObject> #include <QObject>
#include <QPoint> #include <QPoint>
#include "mavlink.h"
namespace mapcontrol { namespace mapcontrol {
struct distBearingAltitude { struct distBearingAltitude {
double distance; double distance;
@@ -99,62 +102,23 @@ public:
_property property; _property property;
/**
* @brief Constructer
*
* @param coord coordinates in LatLng of the Waypoint
* @param altitude altitude of the WayPoint
* @param map pointer to map to use
* @return
*/
WayPointItem(internals::PointLatLng const & coord, int const & altitude, MapGraphicItem *map, wptype type = absolute); WayPointItem(internals::PointLatLng const & coord, int const & altitude, MapGraphicItem *map, wptype type = absolute);
WayPointItem(MapGraphicItem *map, bool magicwaypoint); WayPointItem(MapGraphicItem *map, bool magicwaypoint);
/**
* @brief Constructer
*
* @param coord coordinates in LatLng of the WayPoint
* @param altitude altitude of the WayPoint
* @param description description fo the WayPoint
* @param map pointer to map to use
* @return
*/
WayPointItem(internals::PointLatLng const & coord, int const & altitude, QString const & description, MapGraphicItem *map, wptype type = absolute); WayPointItem(internals::PointLatLng const & coord, int const & altitude, QString const & description, MapGraphicItem *map, wptype type = absolute);
WayPointItem(distBearingAltitude const & relativeCoord, QString const & description, MapGraphicItem *map); WayPointItem(distBearingAltitude const & relativeCoord, QString const & description, MapGraphicItem *map);
/**
* @brief Returns the WayPoint description
*
* @return QString
*/
QString Description() QString Description()
{ {
return description; return description;
} }
/**
* @brief Sets the WayPoint description
*
* @param value
*/
void SetDescription(QString const & value); void SetDescription(QString const & value);
/**
* @brief Returns true if WayPoint is Reached
*
* @return bool
*/
bool Reached() bool Reached()
{ {
return reached; return reached;
} }
/**
* @brief Sets if WayPoint is Reached
*
* @param value
*/
void SetReached(bool const & value); void SetReached(bool const & value);
/**
* @brief Returns the WayPoint number
*
*/
int Number() int Number()
{ {
return number; return number;
@@ -163,54 +127,27 @@ public:
{ {
return number + 1; return number + 1;
} }
/**
* @brief Sets WayPoint number
*
* @param value
*/
void SetNumber(int const & value); void SetNumber(int const & value);
/**
* @brief Returns WayPoint LatLng coordinate
*
*/
internals::PointLatLng Coord() internals::PointLatLng Coord()
{ {
return coord; return coord;
} }
/**
* @brief Sets WayPoint LatLng coordinate
*
* @param value
*/
void SetCoord(internals::PointLatLng const & value); void SetCoord(internals::PointLatLng const & value);
/**
* @brief Used if WayPoint number is to be drawn on screen
*
*/
bool ShowNumber() bool ShowNumber()
{ {
return shownumber; return shownumber;
} }
/**
* @brief Used to set if WayPoint number is to be drawn on screen
*
* @param value
*/
void SetShowNumber(bool const & value); void SetShowNumber(bool const & value);
/**
* @brief Returns the WayPoint altitude
*
* @return int
*/
float Altitude() float Altitude()
{ {
return altitude; return altitude;
} }
/**
* @brief Sets the WayPoint Altitude
*
* @param value
*/
void SetAltitude(const float &value); void SetAltitude(const float &value);
void setRelativeCoord(distBearingAltitude value); void setRelativeCoord(distBearingAltitude value);
distBearingAltitude getRelativeCoord() distBearingAltitude getRelativeCoord()
@@ -221,7 +158,6 @@ public:
QRectF boundingRect() const; QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
void RefreshToolTip();
QPixmap picture; QPixmap picture;
QString customString() QString customString()
{ {
@@ -240,24 +176,94 @@ public:
{ {
return myType; return myType;
} }
//=============属性=================
void SetDefault(double lat, double lng, float alt, uint16_t seq);//默认属性
void SetParam1(float value);
void SetParam2(float value);
void SetParam3(float value);
void SetParam4(float value);
void SetLat(double value);
void SetLng(double value);
void SetAlt(float value);
void SetSeq(uint16_t value);
void SetCommand(uint16_t value);
void SetGroup(uint16_t value);
float Param1(void)
{
return property.param1;
}
float Param2(void)
{
return property.param2;
}
float Param3(void)
{
return property.param3;
}
float Param4(void)
{
return property.param4;
}
int32_t Lat(void)
{
return property.x;
}
int32_t Lng(void)
{
return property.y;
}
float Alt(void)
{
return property.z;
}
uint16_t Seq(void)
{
return property.seq;
}
uint16_t Command(void)
{
return property.command;
}
uint16_t Group(void)
{
return property.group;
}
protected: protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
private: private:
bool isEdit = false;
internals::PointLatLng coord; // coordinates of this WayPoint internals::PointLatLng coord; // coordinates of this WayPoint
typedef struct {
float altitude;//相对海拔
float velocity;//当前点速度
float radiu;//半径
qint8 action;//动作
}_waypoint;
distBearingAltitude relativeCoord; distBearingAltitude relativeCoord;
bool reached; bool reached;
QString description; QString description;
@@ -268,8 +274,6 @@ private:
int number; int number;
bool isMagic; bool isMagic;
QGraphicsSimpleTextItem *text;
QGraphicsRectItem *textBG;
QGraphicsSimpleTextItem *numberI; QGraphicsSimpleTextItem *numberI;
QTransform transf; QTransform transf;
HomeItem *myHome; HomeItem *myHome;
@@ -277,56 +281,17 @@ private:
QString myCustomString; QString myCustomString;
public slots: public slots:
/**
* @brief Called when a WayPoint is deleted
*
* @param number number of the WayPoint that was deleted
*/
void WPDeleted(int const & number, WayPointItem *waypoint);
/**
* @brief Called when a WayPoint is renumbered
*
* @param oldnumber the old WayPoint number
* @param newnumber the new WayPoint number
* @param waypoint a pointer to the WayPoint renumbered
*/
void WPRenumbered(int const & oldnumber, int const & newnumber, WayPointItem *waypoint);
/**
* @brief Called when a WayPoint is inserted
*
* @param number the number of the WayPoint
* @param waypoint a pointer to the WayPoint inserted
*/
void WPInserted(int const & number, WayPointItem *waypoint);
void WPDeleted(int const & number, WayPointItem *waypoint);
void WPRenumbered(int const & oldnumber, int const & newnumber, WayPointItem *waypoint);
void WPInserted(int const & number, WayPointItem *waypoint);
void onHomePositionChanged(internals::PointLatLng, float altitude); void onHomePositionChanged(internals::PointLatLng, float altitude);
void RefreshPos(); void RefreshPos();
void setOpacitySlot(qreal opacity); void setOpacitySlot(qreal opacity);
signals: signals:
/**
*
* @brief fires when this WayPoint Value changes
*
*/
void WPChanged(int Number,double Lat,double Lng); void WPChanged(int Number,double Lat,double Lng);
/**
* @brief fires when this WayPoint number changes (not fired if due to a auto-renumbering)
*
* @param oldnumber this WayPoint old number
* @param newnumber this WayPoint new number
* @param waypoint a pointer to this WayPoint
*/
void WPNumberChanged(int const & oldnumber, int const & newnumber, WayPointItem *waypoint); void WPNumberChanged(int const & oldnumber, int const & newnumber, WayPointItem *waypoint);
/**
* @brief Fired when the description, altitude or coordinates change
*
* @param waypoint a pointer to this WayPoint
*/
void WPValuesChanged(WayPointItem *waypoint); void WPValuesChanged(WayPointItem *waypoint);
void waypointdoubleclick(WayPointItem *waypoint); void waypointdoubleclick(WayPointItem *waypoint);
void localPositionChanged(QPointF point, WayPointItem *waypoint); void localPositionChanged(QPointF point, WayPointItem *waypoint);
+6
View File
@@ -9,6 +9,12 @@ TEMPLATE = subdirs
CONFIG += ordered CONFIG += ordered
SUBDIRS += internals SUBDIRS += internals
SUBDIRS += core SUBDIRS += core
SUBDIRS += mapwidget SUBDIRS += mapwidget