Files
gcs-nf/opmap/mapwidget/waypointsetting.h
T
2022-09-06 09:10:14 +08:00

337 lines
7.5 KiB
C++

#ifndef WAYPOINTSETTING_H
#define WAYPOINTSETTING_H
#include <QGraphicsItem>
#include <QPainter>
#include <QLabel>
#include "pointlatlng.h"
#include "mapgraphicitem.h"
#include "waypointitem.h"
#include <QObject>
#include <QPoint>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneHoverEvent>
#include "waypointbutton.h"
#include "QDebug"
#include "mavlink.h"
//#include "JsonHelper.h"
#include "QComboBox"
#include "QLineEdit"
#include "QLabel"
#include "QHBoxLayout"
#include "QVBoxLayout"
#include "QGridLayout"
//#include "multiselector.h"
//#include "Selector.h"
//#include "Inputter.h"
//#include "Confirm.h"
#include "QFileDialog"
namespace mapcontrol {
//class OPMapWidget;
#ifdef QtopmapWidget
#include <mapwidgetglobal.h>
class OPMAPWIDGETSHARED_EXPORT WayPointSetting : public QObject, public QGraphicsItem {
#else
class WayPointSetting : public QObject, public QGraphicsItem {
#endif
Q_OBJECT Q_INTERFACES(QGraphicsItem)
public:
enum { Type = UserType + 27 };
WayPointSetting(MapGraphicItem *map, QColor background = Qt::green);
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
MapGraphicItem *myMap;
QColor myColor;
bool isDragging;
qreal opacity = 0.2;
MAV_CMD _command;
QMap<QString, QVariant> _infoMap;//一个
//QMap<int, MissionCmdParamInfo*> _paramInfoMap;//一个
QList<int> _paramRemoveList;
static const char* _categoryJsonKey;
static const char* _decimalPlacesJsonKey;
static const char* _defaultJsonKey;
static const char* _descriptionJsonKey;
static const char* _enumStringsJsonKey;
static const char* _enumValuesJsonKey;
static const char* _nanUnchangedJsonKey;
static const char* _friendlyNameJsonKey;
static const char* _friendlyEditJsonKey;
static const char* _idJsonKey;
static const char* _labelJsonKey;
static const char* _mavCmdInfoJsonKey;
static const char* _param1JsonKey;
static const char* _param2JsonKey;
static const char* _param3JsonKey;
static const char* _param4JsonKey;
static const char* _param5JsonKey;
static const char* _param6JsonKey;
static const char* _param7JsonKey;
static const char* _paramJsonKeyFormat;
static const char* _paramRemoveJsonKey;
static const char* _rawNameJsonKey;
static const char* _standaloneCoordinateJsonKey;
static const char* _specifiesCoordinateJsonKey;
static const char* _specifiesAltitudeOnlyJsonKey;
static const char* _unitsJsonKey;
static const char* _commentJsonKey;
static const char* _advancedCategory;
static const char* _versionJsonKey;
QByteArray allBytes;
QJsonArray MAV_CMD_infoArray;
bool isShowDetails = false;
//因为无法使用其他类定义的东西,因此这里自己定义
float m_param1;
float m_param2;
float m_param3;
float m_param4;
int32_t m_x;
int32_t m_y;
float m_z;
uint16_t m_seq;
uint16_t m_group;
uint16_t m_command;
uint8_t m_target_system;
uint8_t m_target_component;
uint8_t m_frame;
uint8_t m_current;
uint8_t m_autocontinue;
uint8_t m_mission_type;
QString param1_type = "QComboBox";
QString param2_type = "QComboBox";
QString param3_type = "QComboBox";
QString param4_type = "QComboBox";
QString param5_type = "QLineEdit";
QString param6_type = "QLineEdit";
QString param7_type = "QLineEdit";
QMap<int,QVector<QString>> allPoint;//所有航点
QRectF rect = QRectF(0,0,100,370);
int showMode = 0;
WayPointButton *btn_load;
WayPointButton *btn_save;
WayPointButton *btn_upload;
WayPointButton *btn_download;
WayPointButton *btn_insert;
WayPointButton *btn_delete;
WayPointButton *btn_last;
WayPointButton *btn_next;
WayPointButton *btn_group;
WayPointButton *btn_aircraft;
WayPointButton *btn_tip;
WayPointButton *btn_ruler;
WayPointButton *btn_table;
signals:
void showMessage(const QString &message,int TimeOut = 0);
void WayPointPropertyChanged(float param1,float param2,float param3,float param4,
int32_t x,int32_t y,float z,
uint16_t seq,
uint16_t group,
uint16_t command,
uint8_t target_system,
uint8_t target_component,
uint8_t frame,
uint8_t current,
uint8_t autocontinue,
uint8_t mission_type);
void WPnearPoint(int dir);
void WPotherPoint(int seq);
void WPInsert();
void WPDelete();
void WPSave(QString path);
void WPLoad(QString path);
void WPUpload(void);
void WPDownload(void);
void searchall(void);
void WPRuler(void);
void WPTable(void);
void WPShowTip(bool flag);
void UAVShowTip(bool flag);
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
public slots:
/*
void load_clicked(void);
void save_clicked(void);
void upload_clicked(void);
void download_clicked(void);
void insert_clicked(void);
void delete_clicked(void);
void last_clicked(void);
void next_clicked(void);
*/
void RefreshPos();
void setOpacitySlot(qreal opacity);
void measureState(bool flag);
void setMode(int mode)
{
showMode = mode;
switch (showMode) {
case 0:
rect.setX(0);
rect.setY(0);
rect.setWidth(100);
rect.setHeight(370);
if(btn_aircraft)
{
btn_aircraft->show();
}
if(btn_tip)
{
btn_tip->show();
}
if(btn_ruler)
{
btn_ruler->show();
}
if(btn_table)
{
btn_table->show();
}
break;
case 1:
rect.setX(0);
rect.setY(0);
rect.setWidth(100);
rect.setHeight(190);
if(btn_aircraft)
{
btn_aircraft->show();
}
if(btn_tip)
{
btn_tip->show();
}
if(btn_ruler)
{
btn_ruler->hide();
}
if(btn_table)
{
btn_table->hide();
}
break;
case 2:
rect.setX(0);
rect.setY(0);
rect.setWidth(100);
rect.setHeight(100);
if(btn_aircraft)
{
btn_aircraft->show();
}
if(btn_tip)
{
btn_tip->hide();
}
if(btn_ruler)
{
btn_ruler->hide();
}
if(btn_table)
{
btn_table->hide();
}
break;
default:
break;
}
update();
}
};
} //NAME SPACE
#endif // WAYPOINTSETTING_H