2022-10-11 10:20:37 +08:00
# ifndef PROPERTYUI_H
2020-05-06 08:17:24 +08:00
# 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"
2020-05-12 16:16:06 +08:00
# include "multiselector.h"
2020-05-07 19:14:44 +08:00
# include "Selector.h"
# include "Inputter.h"
2020-08-05 22:39:33 +08:00
# include "Confirm.h"
2020-05-06 08:17:24 +08:00
2020-06-04 18:20:13 +08:00
# include "QFileDialog"
2020-05-18 21:00:05 +08:00
2020-05-06 08:17:24 +08:00
# include "QtQmlDepends"
2022-07-29 01:43:16 +08:00
# include "MissionUI.h"
# include "ruledialog.h"
2020-05-06 08:17:24 +08:00
# 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 , /* | */
} ;
2020-11-20 18:57:45 +08:00
static QString StrByType ( int const & value )
2020-05-06 08:17:24 +08:00
{
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 :
2022-10-11 10:20:37 +08:00
/**
* @brief 清除表格中指定航线的信息
* @param air_route 指定航线
*/
void clearAirRouteInfo ( int air_route ) ;
2020-05-15 14:16:33 +08:00
void setallPoint ( QMap < int , int > list ) ;
2020-05-06 08:17:24 +08:00
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 ) ;
2020-05-07 19:14:44 +08:00
2022-07-29 01:43:16 +08:00
void measureState ( bool flag ) ;
2020-05-07 19:14:44 +08:00
2022-07-29 01:43:16 +08:00
void closeMissionDialog ( bool flag ) ;
2020-05-07 19:14:44 +08:00
2020-05-06 08:17:24 +08:00
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 ) ;
2022-07-29 01:43:16 +08:00
void WPnearPoint ( int dir ) ;
2020-05-09 18:01:58 +08:00
void WPotherPoint ( int seq ) ;
2022-07-29 01:43:16 +08:00
void WPInsert ( ) ;
void WPDelete ( ) ;
void WPDeleteAll ( void ) ;
void WPAdd ( void ) ;
2020-05-09 18:01:58 +08:00
2020-06-04 18:20:13 +08:00
void WPSave ( QString path ) ;
void WPLoad ( QString path ) ;
2020-05-10 17:22:16 +08:00
void WPUpload ( void ) ;
void WPDownload ( void ) ;
2020-05-09 18:01:58 +08:00
2020-05-15 14:16:33 +08:00
void searchall ( void ) ;
2020-05-09 18:01:58 +08:00
2022-07-29 01:43:16 +08:00
void WPGroup ( int group ) ;
void settableGroup ( int ) ;
void getAllPoints ( int group ) ;
// void ruler_clicked();
void createFenceCircle ( int , qreal radius , bool inclusion , qreal lat , qreal lng ) ;
void createFencePolygon ( int , qreal vertex , bool inclusion , QList < QPointF > latlng ) ;
void setFenceCircle ( int group , qreal radius , bool inclusion , qreal lat , qreal lng ) ;
void setFencePolygon ( int group , qreal vertex , bool inclusion , QList < QPointF > latlng ) ;
void updateFenceCircle ( int group , qreal radius , bool inclusion , qreal lat , qreal lng ) ;
void updateFencePolygon ( int group , qreal vertex , bool inclusion , QList < QPointF > latlng ) ;
void addCircle ( ) ;
void addPolygon ( ) ;
void delFence ( int group ) ;
void currentPointSeleted ( int group , int point ) ;
void getCurrentPoint ( int group ) ;
void FenceGroupChanged ( int old , int cur ) ;
void clearTable ( ) ;
void GetPoint ( quint8 ) ;
void exitRuler ( ) ;
void mousePosition ( qreal lat , qreal lng ) ;
void MeasurePosition ( int num , qreal lat , qreal lng ) ;
void Lineinfo ( qreal dis , qreal bearing ) ;
void valuechanged ( int num , qreal value ) ;
2020-05-06 08:17:24 +08:00
private slots :
2022-07-29 01:43:16 +08:00
void GroupChanged ( int value ) ;
void waypointSelect ( int group , int idx ) ;
2020-05-12 16:16:06 +08:00
void setSeqNav ( QVariant value ) ;
2020-05-07 19:14:44 +08:00
void setFriendlyName ( QVariant value ) ;
2020-07-20 18:06:14 +08:00
void setAltType ( QVariant value ) ;
2020-05-07 19:14:44 +08:00
void setAltitude ( QVariant value ) ;
2022-07-29 01:43:16 +08:00
void setGroup ( QVariant value ) ;
2020-10-12 10:22:10 +08:00
void setLatitude ( QVariant value ) ;
2020-05-06 08:17:24 +08:00
2020-10-12 10:22:10 +08:00
void setLongitude ( QVariant value ) ;
2020-05-07 19:14:44 +08:00
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 ) ;
2020-05-06 08:17:24 +08:00
2020-08-05 22:39:33 +08:00
void setLoad ( QVariant value ) ;
2020-12-10 18:47:49 +08:00
void WayPointPropertyUpdate ( bool flag ) ;
2020-05-06 08:17:24 +08:00
2020-05-07 19:14:44 +08:00
void on_pushButton_friendlyName_clicked ( ) ;
void on_pushButton_Alt_clicked ( ) ;
void on_pushButton_Param1_clicked ( ) ;
void on_pushButton_Param2_clicked ( ) ;
2020-05-06 08:17:24 +08:00
2020-05-07 19:14:44 +08:00
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 ( ) ;
2020-05-06 08:17:24 +08:00
2020-05-08 17:03:58 +08:00
void on_pushButton_Previous_clicked ( ) ;
2020-05-09 18:01:58 +08:00
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 ( ) ;
2020-05-12 16:16:06 +08:00
void on_pushButton_Seq_clicked ( ) ;
2020-07-20 18:06:14 +08:00
void on_pushButton_AltType_clicked ( ) ;
2020-10-12 10:22:10 +08:00
void on_pushButton_Lat_clicked ( ) ;
void on_pushButton_Lng_clicked ( ) ;
2022-07-29 01:43:16 +08:00
void on_pushButton_Group_clicked ( ) ;
void on_pushButton_Ruler_clicked ( ) ;
void on_pushButton_Table_clicked ( ) ;
2020-12-10 18:47:49 +08:00
2020-05-06 08:17:24 +08:00
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 ;
2022-07-29 01:43:16 +08:00
MissionUI * table = nullptr ;
RuleDialog * ruler = nullptr ;
2020-05-06 08:17:24 +08:00
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 ;
2020-05-07 19:14:44 +08:00
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 " ;
2020-05-15 14:16:33 +08:00
2022-07-29 01:43:16 +08:00
int missionGroups = 3 ;
2020-05-15 14:16:33 +08:00
2020-05-21 14:02:04 +08:00
QMap < int , QVector < QString > > allPoint ; //所有航点
2020-05-15 14:16:33 +08:00
2020-05-06 08:17:24 +08:00
} ;
# endif // PROPERTYUI_H