400 lines
15 KiB
C++
400 lines
15 KiB
C++
#ifndef PROPERTYUI_H
|
|
#define PROPERTYUI_H
|
|
|
|
#include <QWidget>
|
|
#include "QFile"
|
|
#include "QJsonArray"
|
|
#include "QJsonDocument"
|
|
#include "QJsonObject"
|
|
#include "QJsonParseError"
|
|
|
|
#include "QQuickWidget"
|
|
#include "QQuickView"
|
|
#include "QtQml"
|
|
|
|
#include "qqml.h"
|
|
#include "QQmlEngine"
|
|
|
|
#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"
|
|
|
|
|
|
#include "QtQmlDepends"
|
|
|
|
|
|
|
|
|
|
#ifdef QtopmapWidget
|
|
#include <mapwidgetglobal.h>
|
|
class OPMAPWIDGETSHARED_EXPORT MissionCmdParamInfo : public QObject {
|
|
#else
|
|
class MissionCmdParamInfo : public QObject {
|
|
#endif
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MissionCmdParamInfo(QObject* parent = nullptr);
|
|
|
|
MissionCmdParamInfo(const MissionCmdParamInfo& other, QObject* parent = nullptr);
|
|
const MissionCmdParamInfo& operator=(const MissionCmdParamInfo& other);
|
|
|
|
Q_PROPERTY(int decimalPlaces READ decimalPlaces CONSTANT)
|
|
Q_PROPERTY(double defaultValue READ defaultValue CONSTANT)
|
|
Q_PROPERTY(QStringList enumStrings READ enumStrings CONSTANT)
|
|
Q_PROPERTY(QVariantList enumValues READ enumValues CONSTANT)
|
|
Q_PROPERTY(QString label READ label CONSTANT)
|
|
Q_PROPERTY(int param READ param CONSTANT)
|
|
Q_PROPERTY(QString units READ units CONSTANT)
|
|
Q_PROPERTY(bool nanUnchanged READ nanUnchanged CONSTANT)
|
|
|
|
int decimalPlaces (void) const { return _decimalPlaces; }
|
|
double defaultValue (void) const { return _defaultValue; }
|
|
QStringList enumStrings (void) const { return _enumStrings; }
|
|
QVariantList enumValues (void) const { return _enumValues; }
|
|
QString label (void) const { return _label; }
|
|
int param (void) const { return _param; }
|
|
QString units (void) const { return _units; }
|
|
bool nanUnchanged (void) const { return _nanUnchanged; }
|
|
|
|
private:
|
|
int _decimalPlaces;
|
|
double _defaultValue;
|
|
QStringList _enumStrings;
|
|
QVariantList _enumValues;
|
|
QString _label;
|
|
int _param;
|
|
QString _units;
|
|
bool _nanUnchanged;
|
|
|
|
friend class propertyui;
|
|
};
|
|
|
|
|
|
#ifdef QtopmapWidget
|
|
#include <mapwidgetglobal.h>
|
|
class OPMAPWIDGETSHARED_EXPORT FrameType : public QObject {
|
|
#else
|
|
class FrameType : public QObject {
|
|
#endif
|
|
Q_OBJECT Q_ENUMS(Types)
|
|
public:
|
|
enum Types {
|
|
MAV_FRAME_GLOBAL=0, /* Global coordinate frame, WGS84 coordinate system. First value / x: latitude, second value / y: longitude, third value / z: positive altitude over mean sea level (MSL). | */
|
|
MAV_FRAME_LOCAL_NED=1, /* Local coordinate frame, Z-down (x: north, y: east, z: down). | */
|
|
MAV_FRAME_MISSION=2, /* NOT a coordinate frame, indicates a mission command. | */
|
|
MAV_FRAME_GLOBAL_RELATIVE_ALT=3, /* Global coordinate frame, WGS84 coordinate system, relative altitude over ground with respect to the home position. First value / x: latitude, second value / y: longitude, third value / z: positive altitude with 0 being at the altitude of the home location. | */
|
|
MAV_FRAME_LOCAL_ENU=4, /* Local coordinate frame, Z-up (x: east, y: north, z: up). | */
|
|
MAV_FRAME_GLOBAL_INT=5, /* Global coordinate frame, WGS84 coordinate system. First value / x: latitude in degrees*1.0e-7, second value / y: longitude in degrees*1.0e-7, third value / z: positive altitude over mean sea level (MSL). | */
|
|
MAV_FRAME_GLOBAL_RELATIVE_ALT_INT=6, /* Global coordinate frame, WGS84 coordinate system, relative altitude over ground with respect to the home position. First value / x: latitude in degrees*10e-7, second value / y: longitude in degrees*10e-7, third value / z: positive altitude with 0 being at the altitude of the home location. | */
|
|
MAV_FRAME_LOCAL_OFFSET_NED=7, /* Offset to the current local frame. Anything expressed in this frame should be added to the current local frame position. | */
|
|
MAV_FRAME_BODY_NED=8, /* Setpoint in body NED frame. This makes sense if all position control is externalized - e.g. useful to command 2 m/s^2 acceleration to the right. | */
|
|
MAV_FRAME_BODY_OFFSET_NED=9, /* Offset in body NED frame. This makes sense if adding setpoints to the current flight path, to avoid an obstacle - e.g. useful to command 2 m/s^2 acceleration to the east. | */
|
|
MAV_FRAME_GLOBAL_TERRAIN_ALT=10, /* Global (WGS84) coordinate frame with AGL altitude (at the waypoint coordinate). First value / x: latitude in degrees, second value / y: longitude in degrees, third value / z: positive altitude in meters with 0 being at ground level in terrain model. | */
|
|
MAV_FRAME_GLOBAL_TERRAIN_ALT_INT=11, /* Global (WGS84) coordinate frame with AGL altitude (at the waypoint coordinate). First value / x: latitude in degrees*10e-7, second value / y: longitude in degrees*10e-7, third value / z: positive altitude in meters with 0 being at ground level in terrain model. | */
|
|
MAV_FRAME_BODY_FRD=12, /* Body fixed frame of reference, Z-down (x: forward, y: right, z: down). | */
|
|
MAV_FRAME_BODY_FLU=13, /* Body fixed frame of reference, Z-up (x: forward, y: left, z: up). | */
|
|
MAV_FRAME_MOCAP_NED=14, /* Odometry local coordinate frame of data given by a motion capture system, Z-down (x: north, y: east, z: down). | */
|
|
MAV_FRAME_MOCAP_ENU=15, /* Odometry local coordinate frame of data given by a motion capture system, Z-up (x: east, y: north, z: up). | */
|
|
MAV_FRAME_VISION_NED=16, /* Odometry local coordinate frame of data given by a vision estimation system, Z-down (x: north, y: east, z: down). | */
|
|
MAV_FRAME_VISION_ENU=17, /* Odometry local coordinate frame of data given by a vision estimation system, Z-up (x: east, y: north, z: up). | */
|
|
MAV_FRAME_ESTIM_NED=18, /* Odometry local coordinate frame of data given by an estimator running onboard the vehicle, Z-down (x: north, y: east, z: down). | */
|
|
MAV_FRAME_ESTIM_ENU=19, /* Odometry local coordinate frame of data given by an estimator running onboard the vehicle, Z-up (x: east, y: noth, z: up). | */
|
|
MAV_FRAME_ENUM_END=20, /* | */
|
|
};
|
|
static QString StrByType(Types const & value)
|
|
{
|
|
QMetaObject metaObject = FrameType().staticMetaObject;
|
|
QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("Types"));
|
|
QString s = metaEnum.valueToKey(value);
|
|
|
|
return s;
|
|
}
|
|
static Types TypeByStr(QString const & value)
|
|
{
|
|
QMetaObject metaObject = FrameType().staticMetaObject;
|
|
QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("Types"));
|
|
Types s = (Types)metaEnum.keyToValue(value.toLatin1());
|
|
|
|
return s;
|
|
}
|
|
static QStringList TypesList()
|
|
{
|
|
QStringList ret;
|
|
QMetaObject metaObject = FrameType().staticMetaObject;
|
|
QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("Types"));
|
|
|
|
for (int x = 0; x < metaEnum.keyCount(); ++x) {
|
|
ret.append(metaEnum.key(x));
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
friend class propertyui;
|
|
|
|
};
|
|
|
|
|
|
|
|
//#include "waypointitem.h"
|
|
|
|
|
|
#ifdef QtopmapWidget
|
|
#include <mapwidgetglobal.h>
|
|
namespace Ui {
|
|
class OPMAPWIDGETSHARED_EXPORT propertyui;
|
|
}
|
|
|
|
class OPMAPWIDGETSHARED_EXPORT propertyui : public QWidget{
|
|
#else
|
|
|
|
namespace Ui {
|
|
class propertyui;
|
|
}
|
|
|
|
class propertyui : public QWidget{
|
|
#endif
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit propertyui(QWidget *parent = nullptr);
|
|
~propertyui();
|
|
|
|
|
|
Q_PROPERTY(QString category READ category CONSTANT)
|
|
Q_PROPERTY(QString description READ description CONSTANT)
|
|
Q_PROPERTY(bool friendlyEdit READ friendlyEdit CONSTANT)
|
|
Q_PROPERTY(QString friendlyName READ friendlyName CONSTANT)
|
|
Q_PROPERTY(QString rawName READ rawName CONSTANT)
|
|
Q_PROPERTY(bool isStandaloneCoordinate READ isStandaloneCoordinate CONSTANT)
|
|
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate CONSTANT)
|
|
Q_PROPERTY(bool specifiesAltitudeOnly READ specifiesAltitudeOnly CONSTANT)
|
|
Q_PROPERTY(int command READ intCommand CONSTANT)
|
|
|
|
MAV_CMD command(void) const { return _command; }
|
|
int intCommand(void) const { return (int)_command; }
|
|
|
|
QString category (void) const;
|
|
QString description (void) const;
|
|
bool friendlyEdit (void) const;
|
|
QString friendlyName (void) const;
|
|
QString rawName (void) const;
|
|
bool isStandaloneCoordinate (void) const;
|
|
bool specifiesCoordinate (void) const;
|
|
bool specifiesAltitudeOnly (void) const;
|
|
|
|
void _loadMavCmdInfoJson(const QString& jsonFilename, bool baseCommandList);
|
|
bool loadJsonInfo(const QJsonObject& jsonObject, bool requireFullObject, QString& errorString);
|
|
|
|
public slots:
|
|
|
|
void setallPoint(QMap<int,int> list);
|
|
|
|
void setWayPointProperty(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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
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 WPotherPoint(int seq);
|
|
void WPInsert(int seq);
|
|
void WPDelete(int seq);
|
|
|
|
|
|
void WPSave(QString path);
|
|
void WPLoad(QString path);
|
|
void WPUpload(void);
|
|
void WPDownload(void);
|
|
|
|
void searchall(void);
|
|
|
|
private slots:
|
|
|
|
void setSeqNav(QVariant value);
|
|
void setFriendlyName(QVariant value);
|
|
void setAltType(QVariant value);
|
|
void setAltitude(QVariant value);
|
|
|
|
|
|
void setParam1(QVariant value);
|
|
void setParam2(QVariant value);
|
|
void setParam3(QVariant value);
|
|
void setParam4(QVariant value);
|
|
void setParam5(QVariant value);
|
|
void setParam6(QVariant value);
|
|
void setParam7(QVariant value);
|
|
|
|
void setLoad(QVariant value);
|
|
|
|
void WayPointPropertyUpdate(void);
|
|
|
|
void on_pushButton_friendlyName_clicked();
|
|
|
|
void on_pushButton_Alt_clicked();
|
|
|
|
void on_pushButton_Param1_clicked();
|
|
|
|
void on_pushButton_Param2_clicked();
|
|
|
|
void on_pushButton_Param3_clicked();
|
|
|
|
void on_pushButton_Param4_clicked();
|
|
|
|
void on_pushButton_Param5_clicked();
|
|
|
|
void on_pushButton_Param6_clicked();
|
|
|
|
void on_pushButton_Param7_clicked();
|
|
|
|
void on_pushButton_Previous_clicked();
|
|
|
|
void on_pushButton_Next_clicked();
|
|
|
|
void on_pushButton_Insert_clicked();
|
|
|
|
void on_pushButton_Delete_clicked();
|
|
|
|
void on_pushButton_Upload_clicked();
|
|
|
|
void on_pushButton_Download_clicked();
|
|
|
|
void on_pushButton_Load_clicked();
|
|
|
|
void on_pushButton_Save_clicked();
|
|
|
|
void on_pushButton_Seq_clicked();
|
|
|
|
void on_pushButton_AltType_clicked();
|
|
|
|
private:
|
|
QString _loadErrorString(const QString& errorString) const;
|
|
bool _infoAvailable(const QString& key) const { return _infoMap.contains(key); }
|
|
const QVariant _infoValue(const QString& key) const { return _infoMap[key]; }
|
|
void _setInfoValue(const QString& key, const QVariant& value) { _infoMap[key] = value; }
|
|
void _overrideInfo(propertyui* uiInfo);
|
|
|
|
void rebuildUI(QString CMD);
|
|
void clearLayout(QLayout *layout);
|
|
|
|
private:
|
|
|
|
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;
|
|
|
|
Ui::propertyui *ui;
|
|
|
|
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;//所有航点
|
|
|
|
};
|
|
|
|
#endif // PROPERTYUI_H
|