1692 lines
51 KiB
C++
1692 lines
51 KiB
C++
#include "propertyui.h"
|
|
#include "ui_propertyui.h"
|
|
#include <iterator>
|
|
#include <QMetaObject>
|
|
|
|
|
|
|
|
const char* propertyui::_categoryJsonKey = "category";
|
|
const char* propertyui::_decimalPlacesJsonKey = "decimalPlaces";
|
|
const char* propertyui::_defaultJsonKey = "default";
|
|
const char* propertyui::_descriptionJsonKey = "description";
|
|
const char* propertyui::_enumStringsJsonKey = "enumStrings";
|
|
const char* propertyui::_enumValuesJsonKey = "enumValues";
|
|
const char* propertyui::_nanUnchangedJsonKey = "nanUnchanged";
|
|
const char* propertyui::_friendlyEditJsonKey = "friendlyEdit";
|
|
const char* propertyui::_friendlyNameJsonKey = "friendlyName";
|
|
const char* propertyui::_idJsonKey = "id";
|
|
const char* propertyui::_labelJsonKey = "label";
|
|
const char* propertyui::_mavCmdInfoJsonKey = "mavCmdInfo";
|
|
const char* propertyui::_param1JsonKey = "param1";
|
|
const char* propertyui::_param2JsonKey = "param2";
|
|
const char* propertyui::_param3JsonKey = "param3";
|
|
const char* propertyui::_param4JsonKey = "param4";
|
|
const char* propertyui::_param5JsonKey = "param5";
|
|
const char* propertyui::_param6JsonKey = "param6";
|
|
const char* propertyui::_param7JsonKey = "param7";
|
|
const char* propertyui::_paramJsonKeyFormat = "param%1";
|
|
const char* propertyui::_paramRemoveJsonKey = "paramRemove";
|
|
const char* propertyui::_rawNameJsonKey = "rawName";
|
|
const char* propertyui::_standaloneCoordinateJsonKey = "standaloneCoordinate";
|
|
const char* propertyui::_specifiesCoordinateJsonKey = "specifiesCoordinate";
|
|
const char* propertyui::_specifiesAltitudeOnlyJsonKey = "specifiesAltitudeOnly";
|
|
const char* propertyui::_unitsJsonKey = "units";
|
|
const char* propertyui::_commentJsonKey = "comment";
|
|
const char* propertyui::_advancedCategory = "Advanced";
|
|
const char* propertyui::_versionJsonKey = "version";
|
|
|
|
|
|
MissionCmdParamInfo::MissionCmdParamInfo(QObject* parent)
|
|
: QObject(parent)
|
|
{
|
|
|
|
}
|
|
|
|
MissionCmdParamInfo::MissionCmdParamInfo(const MissionCmdParamInfo& other, QObject* parent)
|
|
: QObject(parent)
|
|
{
|
|
*this = other;
|
|
}
|
|
|
|
const MissionCmdParamInfo& MissionCmdParamInfo::operator=(const MissionCmdParamInfo& other)
|
|
{
|
|
_decimalPlaces = other._decimalPlaces;
|
|
_defaultValue = other._defaultValue;
|
|
_enumStrings = other._enumStrings;
|
|
_enumValues = other._enumValues;
|
|
_label = other._label;
|
|
_param = other._param;
|
|
_units = other._units;
|
|
_nanUnchanged = other._nanUnchanged;
|
|
|
|
return *this;
|
|
}
|
|
|
|
|
|
//向地图发送信息请求读取一个航点
|
|
|
|
//收到地图的一个航点
|
|
|
|
propertyui::propertyui(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::propertyui)
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
//load qss
|
|
QFile file(":/qss/propertyui.qss");
|
|
file.open(QFile::ReadOnly);
|
|
QTextStream filetext(&file);
|
|
QString stylesheet = filetext.readAll();
|
|
this->setStyleSheet(stylesheet);
|
|
file.close();
|
|
|
|
|
|
this->adjustSize();
|
|
|
|
//初始化参数
|
|
setWayPointProperty(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
|
|
|
|
//初始化ui
|
|
//一个一个设置
|
|
ui->label_Param1->setHidden(true);
|
|
ui->label_Param2->setHidden(true);
|
|
ui->label_Param3->setHidden(true);
|
|
ui->label_Param4->setHidden(true);
|
|
ui->label_Param5->setHidden(true);
|
|
ui->label_Param6->setHidden(true);
|
|
ui->label_Param7->setHidden(true);
|
|
|
|
ui->pushButton_Param1->setHidden(true);
|
|
ui->pushButton_Param2->setHidden(true);
|
|
ui->pushButton_Param3->setHidden(true);
|
|
ui->pushButton_Param4->setHidden(true);
|
|
ui->pushButton_Param5->setHidden(true);
|
|
ui->pushButton_Param6->setHidden(true);
|
|
ui->pushButton_Param7->setHidden(true);
|
|
|
|
//载入json
|
|
_loadMavCmdInfoJson(":/json/MavCmdInfoCommon_cn_2.json", true);
|
|
|
|
ui->label_Descript->adjustSize();
|
|
ui->label_Descript->setWordWrap(true);
|
|
ui->label_Descript->setAlignment(Qt::AlignTop);
|
|
|
|
//rebuildUI(" ");
|
|
|
|
}
|
|
|
|
|
|
void propertyui::clearLayout(QLayout *layout)
|
|
{
|
|
QLayoutItem *item;
|
|
while((item = layout->takeAt(0)) != 0)
|
|
{
|
|
//删除widget
|
|
if(item->widget()){
|
|
item->widget()->deleteLater();
|
|
delete item->widget();
|
|
}
|
|
//删除子布局
|
|
QLayout *childLayout = item->layout();
|
|
if(childLayout){
|
|
clearLayout(childLayout);
|
|
}
|
|
delete item;
|
|
}
|
|
}
|
|
|
|
//还需要修正
|
|
void propertyui::rebuildUI(QString CMD)
|
|
{
|
|
//QJsonValue info
|
|
for(QJsonValue info: MAV_CMD_infoArray) {
|
|
if (!info.isObject()) {
|
|
return;
|
|
}
|
|
|
|
if(info.toObject().find(_friendlyNameJsonKey).value() == CMD)
|
|
{
|
|
QString str;
|
|
loadJsonInfo(info.toObject(),true,str);
|
|
}
|
|
}
|
|
|
|
ui->pushButton_friendlyName->setText(CMD);
|
|
|
|
//重新载入UI
|
|
ui->pushButton_Seq->setText(QString::number(m_seq));
|
|
ui->label_Descript->setText(description());
|
|
|
|
//载入高度
|
|
ui->pushButton_Alt->setText(QString::number(m_z,'f',0));
|
|
|
|
if(m_frame == FrameType::MAV_FRAME_GLOBAL_RELATIVE_ALT)
|
|
{
|
|
ui->pushButton_AltType->setText(tr("Relative"));
|
|
}
|
|
else if(m_frame == FrameType::MAV_FRAME_GLOBAL)
|
|
{
|
|
ui->pushButton_AltType->setText(tr("Absolutely"));
|
|
}
|
|
|
|
//载入经纬度
|
|
ui->pushButton_Lat->setText(QString::number(m_x * 10e-8,'f',6));
|
|
ui->pushButton_Lng->setText(QString::number(m_y * 10e-8,'f',6));
|
|
|
|
|
|
|
|
//一个一个设置
|
|
ui->label_Param1->setHidden(true);
|
|
ui->label_Param2->setHidden(true);
|
|
ui->label_Param3->setHidden(true);
|
|
ui->label_Param4->setHidden(true);
|
|
ui->label_Param5->setHidden(true);
|
|
ui->label_Param6->setHidden(true);
|
|
ui->label_Param7->setHidden(true);
|
|
|
|
ui->pushButton_Param1->setHidden(true);
|
|
ui->pushButton_Param2->setHidden(true);
|
|
ui->pushButton_Param3->setHidden(true);
|
|
ui->pushButton_Param4->setHidden(true);
|
|
ui->pushButton_Param5->setHidden(true);
|
|
ui->pushButton_Param6->setHidden(true);
|
|
ui->pushButton_Param7->setHidden(true);
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
|
|
switch(i->param())
|
|
{
|
|
case 1:
|
|
{
|
|
ui->label_Param1->show();
|
|
ui->pushButton_Param1->show();
|
|
ui->label_Param1->setText(i->label());
|
|
|
|
if(i->enumStrings().size() != 0)
|
|
{
|
|
param1_type = "QComboBox";
|
|
int index;
|
|
if(m_param1 > (i->enumValues().size() - 1))
|
|
{
|
|
//m_param1 = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param1->text())).toDouble();
|
|
index = i->enumValues().indexOf(i->defaultValue());
|
|
}
|
|
else
|
|
{
|
|
index = i->enumValues().indexOf(m_param1);
|
|
if(index == -1)
|
|
{
|
|
index = 0;
|
|
}
|
|
}
|
|
|
|
ui->pushButton_Param1->setText(i->enumStrings().at(index));//当前值大于index
|
|
}
|
|
else
|
|
{
|
|
param1_type = "QLineEdit";
|
|
ui->pushButton_Param1->setText(QString::number(m_param1,'f',i->decimalPlaces()));
|
|
}
|
|
}break;
|
|
case 2:
|
|
{
|
|
ui->label_Param2->show();
|
|
ui->pushButton_Param2->show();
|
|
ui->label_Param2->setText(i->label());
|
|
|
|
if(i->enumStrings().size() != 0)
|
|
{
|
|
param2_type = "QComboBox";
|
|
|
|
int index;
|
|
if(m_param2 > (i->enumValues().size() - 1))
|
|
{
|
|
index = i->defaultValue();
|
|
}
|
|
else
|
|
{
|
|
index = m_param2;
|
|
}
|
|
|
|
ui->pushButton_Param2->setText(i->enumStrings().at(index));
|
|
}
|
|
else
|
|
{
|
|
param2_type = "QLineEdit";
|
|
ui->pushButton_Param2->setText(QString::number(m_param2,'f',i->decimalPlaces()));
|
|
}
|
|
}break;
|
|
case 3:
|
|
{
|
|
ui->label_Param3->show();
|
|
ui->pushButton_Param3->show();
|
|
ui->label_Param3->setText(i->label());
|
|
|
|
if(i->enumStrings().size() != 0)
|
|
{
|
|
param3_type = "QComboBox";
|
|
|
|
int index;
|
|
if(m_param3 > (i->enumValues().size() - 1))
|
|
{
|
|
index = i->defaultValue();
|
|
}
|
|
else
|
|
{
|
|
index = m_param3;
|
|
}
|
|
|
|
ui->pushButton_Param3->setText(i->enumStrings().at(index));
|
|
}
|
|
else
|
|
{
|
|
param3_type = "QLineEdit";
|
|
ui->pushButton_Param3->setText(QString::number(m_param3,'f',i->decimalPlaces()));
|
|
}
|
|
}break;
|
|
case 4:
|
|
{
|
|
ui->label_Param4->show();
|
|
ui->pushButton_Param4->show();
|
|
ui->label_Param4->setText(i->label());
|
|
|
|
if(i->enumStrings().size() != 0)
|
|
{
|
|
param4_type = "QComboBox";
|
|
|
|
int index;
|
|
if(m_param4 > (i->enumValues().size() - 1))
|
|
{
|
|
index = i->defaultValue();
|
|
}
|
|
else
|
|
{
|
|
index = m_param4;
|
|
}
|
|
|
|
ui->pushButton_Param4->setText(i->enumStrings().at(index));
|
|
}
|
|
else
|
|
{
|
|
param4_type = "QLineEdit";
|
|
ui->pushButton_Param4->setText(QString::number(m_param4,'f',i->decimalPlaces()));
|
|
}
|
|
}break;
|
|
case 5:
|
|
{
|
|
ui->label_Param5->show();
|
|
ui->pushButton_Param5->show();
|
|
ui->label_Param5->setText(i->label());
|
|
|
|
if(i->enumStrings().size() != 0)
|
|
{
|
|
param5_type = "QComboBox";
|
|
|
|
int index;
|
|
if(m_x > (i->enumValues().size() - 1))
|
|
{
|
|
index = i->defaultValue();
|
|
}
|
|
else
|
|
{
|
|
index = m_x;
|
|
}
|
|
|
|
ui->pushButton_Param5->setText(i->enumStrings().at(index));
|
|
}
|
|
else
|
|
{
|
|
param5_type = "QLineEdit";
|
|
ui->pushButton_Param5->setText(QString::number(m_x,'f',i->decimalPlaces()));
|
|
}
|
|
}break;
|
|
case 6:
|
|
{
|
|
ui->label_Param6->show();
|
|
ui->pushButton_Param6->show();
|
|
ui->label_Param6->setText(i->label());
|
|
|
|
if(i->enumStrings().size() != 0)
|
|
{
|
|
param6_type = "QComboBox";
|
|
|
|
int index;
|
|
if(m_y > (i->enumValues().size() - 1))
|
|
{
|
|
index = i->defaultValue();
|
|
}
|
|
else
|
|
{
|
|
index = m_y;
|
|
}
|
|
|
|
ui->pushButton_Param6->setText(i->enumStrings().at(index));
|
|
}
|
|
else
|
|
{
|
|
param6_type = "QLineEdit";
|
|
ui->pushButton_Param6->setText(QString::number(m_y,'f',i->decimalPlaces()));
|
|
}
|
|
}break;
|
|
case 7:
|
|
{
|
|
ui->label_Param7->show();
|
|
ui->pushButton_Param7->show();
|
|
ui->label_Param7->setText(i->label());
|
|
|
|
if(i->enumStrings().size() != 0)
|
|
{
|
|
param7_type = "QComboBox";
|
|
|
|
int index;
|
|
if(m_z > (i->enumValues().size() - 1))
|
|
{
|
|
index = i->defaultValue();
|
|
}
|
|
else
|
|
{
|
|
index = m_z;
|
|
}
|
|
|
|
ui->pushButton_Param7->setText(i->enumStrings().at(index));
|
|
}
|
|
else
|
|
{
|
|
param7_type = "QLineEdit";
|
|
ui->pushButton_Param7->setText(QString::number(m_z,'f',i->decimalPlaces()));
|
|
}
|
|
}break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void propertyui::WayPointPropertyUpdate(void)
|
|
{
|
|
//设置高度
|
|
m_z = ui->pushButton_Alt->text().toDouble();
|
|
|
|
|
|
//设置经纬度
|
|
|
|
m_x = ui->pushButton_Lat->text().toDouble() * 10e6;
|
|
m_y = ui->pushButton_Lng->text().toDouble() * 10e6;
|
|
|
|
qDebug() << m_x << m_y;
|
|
|
|
//设置高度类型
|
|
if(ui->pushButton_AltType->text() == tr("Relative"))
|
|
{
|
|
m_frame = FrameType::MAV_FRAME_GLOBAL_RELATIVE_ALT;
|
|
}
|
|
else if(ui->pushButton_AltType->text() == tr("Absolutely"))
|
|
{
|
|
m_frame = FrameType::MAV_FRAME_GLOBAL;
|
|
}
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
|
|
switch(i->param())
|
|
{
|
|
case 1:
|
|
{
|
|
if(param1_type == "QComboBox")
|
|
{
|
|
//根据值寻找index,当前做法错误
|
|
m_param1 = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param1->text())).toDouble();
|
|
}
|
|
else if(param1_type == "QLineEdit")
|
|
{
|
|
m_param1 = ui->pushButton_Param1->text().toDouble();
|
|
}
|
|
}break;
|
|
case 2:
|
|
{
|
|
if(param2_type == "QComboBox")
|
|
{
|
|
m_param2 = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param2->text())).toDouble();
|
|
}
|
|
else if(param2_type == "QLineEdit")
|
|
{
|
|
m_param2 = ui->pushButton_Param2->text().toDouble();
|
|
}
|
|
}break;
|
|
case 3:
|
|
{
|
|
if(param3_type == "QComboBox")
|
|
{
|
|
m_param3 = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param3->text())).toDouble();
|
|
}
|
|
else if(param3_type == "QLineEdit")
|
|
{
|
|
m_param3 = ui->pushButton_Param3->text().toDouble();
|
|
}
|
|
}break;
|
|
case 4:
|
|
{
|
|
if(param4_type == "QComboBox")
|
|
{
|
|
m_param4 = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param4->text())).toDouble();
|
|
}
|
|
else if(param4_type == "QLineEdit")
|
|
{
|
|
m_param4 = ui->pushButton_Param4->text().toDouble();
|
|
}
|
|
}break;
|
|
case 5:
|
|
{
|
|
if(param5_type == "QComboBox")
|
|
{
|
|
m_x = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param5->text())).toDouble();
|
|
}
|
|
else if(param5_type == "QLineEdit")
|
|
{
|
|
m_x = ui->pushButton_Param5->text().toDouble();
|
|
}
|
|
}break;
|
|
case 6:
|
|
{
|
|
if(param6_type == "QComboBox")
|
|
{
|
|
m_y = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param6->text())).toDouble();
|
|
}
|
|
else if(param6_type == "QLineEdit")
|
|
{
|
|
m_y = ui->pushButton_Param6->text().toDouble();
|
|
}
|
|
}break;
|
|
case 7:
|
|
{
|
|
if(param7_type == "QComboBox")
|
|
{
|
|
m_z = i->enumValues().at(i->enumStrings().indexOf(ui->pushButton_Param7->text())).toDouble();
|
|
}
|
|
else if(param7_type == "QLineEdit")
|
|
{
|
|
m_z = ui->pushButton_Param7->text().toDouble();
|
|
}
|
|
}break;
|
|
}
|
|
}
|
|
|
|
qDebug() << "PropertyUpdate"
|
|
<< m_param1
|
|
<< m_param2
|
|
<< m_param3
|
|
<< m_param4
|
|
<< m_x
|
|
<< m_y
|
|
<< m_z
|
|
<< m_seq
|
|
<< m_group
|
|
<< m_command
|
|
<< m_target_system
|
|
<< m_target_component
|
|
<< m_frame
|
|
<< m_current
|
|
<< m_autocontinue
|
|
<< m_mission_type ;
|
|
|
|
emit WayPointPropertyChanged(m_param1,m_param2,m_param3,m_param4,
|
|
m_x,m_y,m_z,
|
|
m_seq,m_group,m_command,
|
|
m_target_system,m_target_component,
|
|
m_frame,m_current,m_autocontinue,m_mission_type);
|
|
}
|
|
|
|
void propertyui::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)
|
|
{
|
|
m_param1 = param1;
|
|
m_param2 = param2;
|
|
m_param3 = param3;
|
|
m_param4 = param4;
|
|
m_x = x;
|
|
m_y = y;
|
|
m_z = z;
|
|
m_seq = seq;
|
|
m_group = group;
|
|
m_command = command;
|
|
m_target_system = target_system;
|
|
m_target_component = target_component;
|
|
m_frame = frame;
|
|
m_current = current;
|
|
m_autocontinue = autocontinue;
|
|
m_mission_type = mission_type;
|
|
|
|
for(QJsonValue info: MAV_CMD_infoArray) {
|
|
if (!info.isObject()) {
|
|
return;
|
|
}
|
|
|
|
if(info.toObject().value(_idJsonKey).toInt() == m_command)
|
|
{
|
|
rebuildUI(info.toObject().value(_friendlyNameJsonKey).toString());
|
|
}
|
|
}
|
|
|
|
qDebug() << " set PROPERTY"
|
|
<< m_param1
|
|
<< m_param2
|
|
<< m_param3
|
|
<< m_param4
|
|
<< m_x
|
|
<< m_y
|
|
<< m_z
|
|
<< m_seq
|
|
<< m_group
|
|
<< m_command
|
|
<< m_target_system
|
|
<< m_target_component
|
|
<< m_frame
|
|
<< m_current
|
|
<< m_autocontinue
|
|
<< m_mission_type ;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
propertyui::~propertyui()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
//读取航点所有信息之后 从json 载入 相关设置 然后在这个界面设置之后发送信号到航点
|
|
|
|
|
|
void propertyui::_loadMavCmdInfoJson(const QString& jsonFilename, bool baseCommandList)
|
|
{
|
|
if (jsonFilename.isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
qDebug() << "Loading" << jsonFilename;
|
|
|
|
QFile jsonFile(jsonFilename);
|
|
if (!jsonFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
qWarning() << "Unable to open file" << jsonFilename << jsonFile.errorString();
|
|
return;
|
|
}
|
|
|
|
QByteArray bytes = jsonFile.readAll();
|
|
|
|
jsonFile.close();
|
|
QJsonParseError jsonParseError;
|
|
QJsonDocument doc = QJsonDocument::fromJson(bytes, &jsonParseError);
|
|
if (jsonParseError.error != QJsonParseError::NoError) {
|
|
qWarning() << jsonFilename << "Unable to open json document" << jsonParseError.errorString();
|
|
return;
|
|
}
|
|
|
|
QJsonObject json = doc.object();
|
|
int version = json.value(_versionJsonKey).toInt();
|
|
qDebug() << "MAV CMD version :" << version;
|
|
if (version != 1) {
|
|
qWarning() << jsonFilename << "Invalid version" << version;
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
QJsonValue jsonValue = json.value(_mavCmdInfoJsonKey);
|
|
|
|
if (!jsonValue.isArray()) {
|
|
qWarning() << jsonFilename << "mavCmdInfo not array";
|
|
return;
|
|
}
|
|
|
|
// Iterate over MissionCommandUIInfo objects
|
|
MAV_CMD_infoArray = jsonValue.toArray();
|
|
|
|
//qDebug() << MAV_CMD_infoArray;
|
|
|
|
for(QJsonValue info: MAV_CMD_infoArray) {
|
|
if (!info.isObject()) {
|
|
qWarning() << jsonFilename << "mavCmdArray should contain objects";
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
QString propertyui::category(void) const
|
|
{
|
|
if (_infoMap.contains(_categoryJsonKey)) {
|
|
return _infoMap[_categoryJsonKey].toString();
|
|
} else {
|
|
return _advancedCategory;
|
|
}
|
|
}
|
|
|
|
QString propertyui::description(void) const
|
|
{
|
|
if (_infoMap.contains(_descriptionJsonKey)) {
|
|
return _infoMap[_descriptionJsonKey].toString();
|
|
} else {
|
|
return QString();
|
|
}
|
|
}
|
|
|
|
bool propertyui::friendlyEdit(void) const
|
|
{
|
|
if (_infoMap.contains(_friendlyEditJsonKey)) {
|
|
return _infoMap[_friendlyEditJsonKey].toBool();
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
QString propertyui::friendlyName(void) const
|
|
{
|
|
if (_infoMap.contains(_friendlyNameJsonKey)) {
|
|
return _infoMap[_friendlyNameJsonKey].toString();
|
|
} else {
|
|
return QString();
|
|
}
|
|
}
|
|
|
|
QString propertyui::rawName(void) const
|
|
{
|
|
if (_infoMap.contains(_rawNameJsonKey)) {
|
|
return _infoMap[_rawNameJsonKey].toString();
|
|
} else {
|
|
return QString();
|
|
}
|
|
}
|
|
|
|
bool propertyui::isStandaloneCoordinate(void) const
|
|
{
|
|
if (_infoMap.contains(_standaloneCoordinateJsonKey)) {
|
|
return _infoMap[_standaloneCoordinateJsonKey].toBool();
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool propertyui::specifiesCoordinate(void) const
|
|
{
|
|
if (_infoMap.contains(_specifiesCoordinateJsonKey)) {
|
|
return _infoMap[_specifiesCoordinateJsonKey].toBool();
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool propertyui::specifiesAltitudeOnly(void) const
|
|
{
|
|
if (_infoMap.contains(_specifiesAltitudeOnlyJsonKey)) {
|
|
return _infoMap[_specifiesAltitudeOnlyJsonKey].toBool();
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void propertyui::_overrideInfo(propertyui *uiInfo)
|
|
{
|
|
// Override info values
|
|
for (const QString& valueKey: uiInfo->_infoMap.keys()) {
|
|
_setInfoValue(valueKey, uiInfo->_infoMap[valueKey]);
|
|
}
|
|
|
|
// Add to the remove params list
|
|
for (int removeIndex: uiInfo->_paramRemoveList) {
|
|
if (!_paramRemoveList.contains(removeIndex)) {
|
|
_paramRemoveList.append(removeIndex);
|
|
}
|
|
}
|
|
|
|
// Override param info
|
|
for (const int paramIndex: uiInfo->_paramInfoMap.keys()) {
|
|
_paramRemoveList.removeOne(paramIndex);
|
|
// MissionCmdParamInfo objects are owned by MissionCommandTree are are in existence for the entire run so
|
|
// we can just use the same pointer reference.
|
|
_paramInfoMap[paramIndex] = uiInfo->_paramInfoMap[paramIndex];
|
|
}
|
|
}
|
|
|
|
QString propertyui::_loadErrorString(const QString& errorString) const
|
|
{
|
|
return QString("%1 %2").arg(_infoValue(_rawNameJsonKey).toString()).arg(errorString);
|
|
}
|
|
|
|
bool propertyui::loadJsonInfo(const QJsonObject& jsonObject, bool requireFullObject, QString& errorString)
|
|
{
|
|
QString internalError;
|
|
|
|
QStringList allKeys;
|
|
allKeys << _idJsonKey << _rawNameJsonKey << _friendlyNameJsonKey << _descriptionJsonKey << _standaloneCoordinateJsonKey << _specifiesCoordinateJsonKey
|
|
<< _friendlyEditJsonKey << _param1JsonKey << _param2JsonKey << _param3JsonKey << _param4JsonKey << _param5JsonKey << _param6JsonKey << _param7JsonKey
|
|
<< _paramRemoveJsonKey << _categoryJsonKey << _specifiesAltitudeOnlyJsonKey;
|
|
|
|
// Look for unknown keys in top level object
|
|
for (const QString& key: jsonObject.keys()) {
|
|
if (!allKeys.contains(key) && key != _commentJsonKey) {
|
|
errorString = _loadErrorString(QString("Unknown key: %1").arg(key));
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Make sure we have the required keys
|
|
QStringList requiredKeys;
|
|
requiredKeys << _idJsonKey;
|
|
if (requireFullObject) {
|
|
requiredKeys << _rawNameJsonKey;
|
|
}
|
|
|
|
if (!JsonHelper::validateRequiredKeys(jsonObject, requiredKeys, internalError)) {
|
|
errorString = _loadErrorString(internalError);
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
// Only the full object should specify rawName, friendlyName
|
|
if (!requireFullObject && (jsonObject.contains(_rawNameJsonKey) || jsonObject.contains(_friendlyNameJsonKey))) {
|
|
errorString = _loadErrorString(QStringLiteral("Only the full object should specify rawName or friendlyName"));
|
|
return false;
|
|
}
|
|
|
|
// Validate key types
|
|
|
|
QList<QJsonValue::Type> types;
|
|
types << QJsonValue::Double << QJsonValue::String << QJsonValue::String<< QJsonValue::String << QJsonValue::Bool << QJsonValue::Bool << QJsonValue::Bool
|
|
<< QJsonValue::Object << QJsonValue::Object << QJsonValue::Object << QJsonValue::Object << QJsonValue::Object << QJsonValue::Object << QJsonValue::Object
|
|
<< QJsonValue::String << QJsonValue::String << QJsonValue::Bool;
|
|
|
|
if (!JsonHelper::validateKeyTypes(jsonObject, allKeys, types, internalError)) {
|
|
errorString = _loadErrorString(internalError);
|
|
return false;
|
|
}
|
|
|
|
|
|
// Read in top level values
|
|
|
|
_command = (MAV_CMD)jsonObject.value(_idJsonKey).toInt();
|
|
|
|
if (jsonObject.contains(_categoryJsonKey)) {
|
|
_infoMap[_categoryJsonKey] = jsonObject.value(_categoryJsonKey).toVariant();
|
|
}
|
|
if (jsonObject.contains(_rawNameJsonKey)) {
|
|
_infoMap[_rawNameJsonKey] = jsonObject.value(_rawNameJsonKey).toVariant();
|
|
}
|
|
if (jsonObject.contains(_friendlyNameJsonKey)) {
|
|
_infoMap[_friendlyNameJsonKey] = jsonObject.value(_friendlyNameJsonKey).toVariant();
|
|
}
|
|
if (jsonObject.contains(_descriptionJsonKey)) {
|
|
_infoMap[_descriptionJsonKey] = jsonObject.value(_descriptionJsonKey).toVariant();
|
|
}
|
|
if (jsonObject.contains(_standaloneCoordinateJsonKey)) {
|
|
_infoMap[_standaloneCoordinateJsonKey] = jsonObject.value(_standaloneCoordinateJsonKey).toVariant();
|
|
}
|
|
if (jsonObject.contains(_specifiesCoordinateJsonKey)) {
|
|
_infoMap[_specifiesCoordinateJsonKey] = jsonObject.value(_specifiesCoordinateJsonKey).toVariant();
|
|
}
|
|
if (jsonObject.contains(_specifiesAltitudeOnlyJsonKey)) {
|
|
_infoMap[_specifiesAltitudeOnlyJsonKey] = jsonObject.value(_specifiesAltitudeOnlyJsonKey).toBool();
|
|
}
|
|
if (jsonObject.contains(_friendlyEditJsonKey)) {
|
|
_infoMap[_friendlyEditJsonKey] = jsonObject.value(_friendlyEditJsonKey).toVariant();
|
|
}
|
|
if (jsonObject.contains(_paramRemoveJsonKey)) {
|
|
QStringList indexList = jsonObject.value(_paramRemoveJsonKey).toString().split(QStringLiteral(","));
|
|
for (const QString& indexString: indexList) {
|
|
_paramRemoveList.append(indexString.toInt());
|
|
}
|
|
}
|
|
|
|
if (requireFullObject) {
|
|
// Since this is the base of the hierarchy it must contain valid defaults for all values.
|
|
if (!_infoAvailable(_categoryJsonKey)) {
|
|
_setInfoValue(_categoryJsonKey, _advancedCategory);
|
|
}
|
|
if (!_infoAvailable(_friendlyNameJsonKey)) {
|
|
_setInfoValue(_friendlyNameJsonKey, _infoValue(_rawNameJsonKey));
|
|
}
|
|
if (!_infoAvailable(_descriptionJsonKey)) {
|
|
_setInfoValue(_descriptionJsonKey, QStringLiteral(""));
|
|
}
|
|
if (!_infoAvailable(_standaloneCoordinateJsonKey)) {
|
|
_setInfoValue(_standaloneCoordinateJsonKey, false);
|
|
}
|
|
if (!_infoAvailable(_specifiesCoordinateJsonKey)) {
|
|
_setInfoValue(_specifiesCoordinateJsonKey, false);
|
|
}
|
|
if (!_infoAvailable(_friendlyEditJsonKey)) {
|
|
_setInfoValue(_friendlyEditJsonKey, false);
|
|
}
|
|
}
|
|
|
|
if (requireFullObject) {
|
|
if (_infoAvailable(_friendlyEditJsonKey) && _infoValue(_friendlyEditJsonKey).toBool()) {
|
|
if (!_infoAvailable(_descriptionJsonKey)) {
|
|
errorString = _loadErrorString(QStringLiteral("Missing description for friendly edit"));
|
|
return false;
|
|
}
|
|
if (_infoValue(_rawNameJsonKey).toString() == _infoValue(_friendlyNameJsonKey).toString()) {
|
|
errorString = _loadErrorString(QStringLiteral("Missing friendlyName for friendly edit"));
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
QString debugOutput;
|
|
for (const QString& infoKey: _infoMap.keys()) {
|
|
debugOutput.append(QString("MavCmdInfo %1: %2 ").arg(infoKey).arg(_infoMap[infoKey].toString()));
|
|
}
|
|
|
|
// Read params
|
|
|
|
//先清除这个参数存储buff
|
|
_paramInfoMap.clear();
|
|
|
|
for (int i=1; i<=7; i++) {
|
|
QString paramKey = QString(_paramJsonKeyFormat).arg(i);
|
|
|
|
if (jsonObject.contains(paramKey)) {
|
|
QJsonObject paramObject = jsonObject.value(paramKey).toObject();
|
|
|
|
QStringList allParamKeys;
|
|
allParamKeys << _defaultJsonKey << _decimalPlacesJsonKey << _enumStringsJsonKey << _enumValuesJsonKey << _labelJsonKey << _unitsJsonKey << _nanUnchangedJsonKey;
|
|
|
|
// Look for unknown keys in param object
|
|
for (const QString& key: paramObject.keys()) {
|
|
if (!allParamKeys.contains(key) && key != _commentJsonKey) {
|
|
errorString = _loadErrorString(QString("Unknown param key: %1").arg(key));
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Validate key types
|
|
|
|
QList<QJsonValue::Type> types;
|
|
types << QJsonValue::Null << QJsonValue::Double << QJsonValue::String << QJsonValue::String << QJsonValue::String << QJsonValue::String << QJsonValue::Bool;
|
|
if (!JsonHelper::validateKeyTypes(jsonObject, allParamKeys, types, internalError)) {
|
|
errorString = _loadErrorString(internalError);
|
|
return false;
|
|
}
|
|
|
|
|
|
_setInfoValue(_friendlyEditJsonKey, true); // Assume friendly edit if we have params
|
|
|
|
if (!paramObject.contains(_labelJsonKey)) {
|
|
internalError = QString("param object missing label key: %1").arg(paramKey);
|
|
errorString = _loadErrorString(internalError);
|
|
return false;
|
|
}
|
|
|
|
MissionCmdParamInfo* paramInfo = new MissionCmdParamInfo(this);
|
|
|
|
paramInfo->_label = paramObject.value(_labelJsonKey).toString();
|
|
paramInfo->_decimalPlaces = paramObject.value(_decimalPlacesJsonKey).toInt();
|
|
paramInfo->_enumStrings = paramObject.value(_enumStringsJsonKey).toString().split(",", QString::SkipEmptyParts);
|
|
paramInfo->_param = i;
|
|
paramInfo->_units = paramObject.value(_unitsJsonKey).toString();
|
|
paramInfo->_nanUnchanged = paramObject.value(_nanUnchangedJsonKey).toBool(false);
|
|
|
|
if (paramObject.contains(_defaultJsonKey)) {
|
|
if (paramInfo->_nanUnchanged) {
|
|
paramInfo->_defaultValue = JsonHelper::possibleNaNJsonValue(paramObject[_defaultJsonKey]);
|
|
} else {
|
|
if (paramObject[_defaultJsonKey].type() == QJsonValue::Null) {
|
|
errorString = QString("Param %1 default value was null/NaN but NaN is not allowed");
|
|
return false;
|
|
}
|
|
paramInfo->_defaultValue = paramObject.value(_defaultJsonKey).toDouble(0.0);
|
|
}
|
|
} else {
|
|
paramInfo->_defaultValue = paramInfo->_nanUnchanged ? std::numeric_limits<double>::quiet_NaN() : 0;
|
|
}
|
|
|
|
QStringList enumValues = paramObject.value(_enumValuesJsonKey).toString().split(",", QString::SkipEmptyParts);
|
|
for (const QString &enumValue: enumValues) {
|
|
bool convertOk;
|
|
double value = enumValue.toDouble(&convertOk);
|
|
|
|
if (!convertOk) {
|
|
internalError = QString("Bad enumValue: %1").arg(enumValue);
|
|
errorString = _loadErrorString(internalError);
|
|
return false;
|
|
}
|
|
|
|
paramInfo->_enumValues << QVariant(value);
|
|
}
|
|
if (paramInfo->_enumValues.count() != paramInfo->_enumStrings.count()) {
|
|
internalError = QString("enum strings/values count mismatch: %1, %2").arg(paramInfo->_enumStrings.count()).arg(paramInfo->_enumValues.count());
|
|
errorString = _loadErrorString(internalError);
|
|
return false;
|
|
}
|
|
_paramInfoMap[i] = paramInfo;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
void propertyui::setallPoint(QMap<int,int> list)
|
|
{
|
|
allPoint.clear();
|
|
|
|
for (QMap<int,int>::iterator i = list.begin();i != list.end(); ++i)
|
|
{
|
|
int index = i.key();
|
|
QString Seq = QString::number(i.key());
|
|
QString Type;
|
|
|
|
for(QJsonValue info: MAV_CMD_infoArray) {
|
|
if (!info.isObject()) {
|
|
return;
|
|
}
|
|
|
|
if(info.toObject().find(_idJsonKey).value() == i.value())
|
|
{
|
|
Type = (QString)info.toObject().find(_friendlyNameJsonKey).value().toString();
|
|
}
|
|
}
|
|
|
|
//string存在排序问题
|
|
|
|
QVector< QString> value;
|
|
|
|
value << Seq
|
|
<< Type;
|
|
|
|
|
|
allPoint.insert(index,value);
|
|
}
|
|
|
|
for (QMap<int, QVector< QString> >::iterator i = allPoint.begin();i != allPoint.end(); ++i)
|
|
{
|
|
qDebug() << i.key() << i.value();
|
|
}
|
|
|
|
|
|
MultiSelector *selector = new MultiSelector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
//读取所有的航点的cmd,然后设置list
|
|
selector->setList(allPoint,ui->pushButton_Seq->text());
|
|
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setSeqNav(QVariant)));
|
|
|
|
selector->show();
|
|
|
|
}
|
|
|
|
void propertyui::setSeqNav(QVariant value)
|
|
{
|
|
//读取这个值得航点
|
|
emit WPotherPoint(value.toInt()+1);
|
|
}
|
|
|
|
void propertyui::on_pushButton_Seq_clicked()
|
|
{
|
|
emit searchall();
|
|
}
|
|
|
|
|
|
void propertyui::setFriendlyName(QVariant value)
|
|
{
|
|
ui->pushButton_friendlyName->setText(value.toString());
|
|
|
|
for(QJsonValue info: MAV_CMD_infoArray) {
|
|
if (!info.isObject()) {
|
|
return;
|
|
}
|
|
|
|
if(info.toObject().find(_friendlyNameJsonKey).value() == value.toString())
|
|
{
|
|
m_command = (MAV_CMD)info.toObject().find(_idJsonKey).value().toInt();
|
|
}
|
|
}
|
|
|
|
//然后重置一下参数
|
|
WayPointPropertyUpdate();
|
|
//更新界面
|
|
rebuildUI(value.toString());
|
|
|
|
}
|
|
|
|
void propertyui::on_pushButton_friendlyName_clicked()
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QJsonValue info: MAV_CMD_infoArray) {
|
|
if (!info.isObject()) {
|
|
return;
|
|
}
|
|
|
|
QString str = info.toObject().value(_friendlyNameJsonKey).toString();
|
|
if(str.size() != 0)
|
|
{
|
|
list.append(str);
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_friendlyName->text());
|
|
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setFriendlyName(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
|
|
void propertyui::setAltType(QVariant value)
|
|
{
|
|
ui->pushButton_AltType->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_AltType_clicked()
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
list << tr("Relative")
|
|
<< tr("Absolutely");
|
|
|
|
|
|
selector->setList(list,ui->pushButton_AltType->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setAltType(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
|
|
|
|
void propertyui::setAltitude(QVariant value)
|
|
{
|
|
ui->pushButton_Alt->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
|
|
}
|
|
|
|
void propertyui::on_pushButton_Alt_clicked()
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(tr("set") + ui->pushButton_AltType->text() + tr("Altitude"));
|
|
inputter->setInitValue(ui->pushButton_Alt->text());
|
|
|
|
inputter->setDecimalPlaces(0);
|
|
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setAltitude(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
|
|
void propertyui::setLatitude(QVariant value)
|
|
{
|
|
ui->pushButton_Lat->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Lat_clicked()
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(tr("setLatitude"));
|
|
inputter->setDecimalPlaces(6);
|
|
inputter->setInitValue(ui->pushButton_Lat->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setLatitude(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
|
|
void propertyui::setLongitude(QVariant value)
|
|
{
|
|
ui->pushButton_Lng->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Lng_clicked()
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(tr("setLongitude"));
|
|
inputter->setDecimalPlaces(6);
|
|
|
|
inputter->setInitValue(ui->pushButton_Lng->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setLongitude(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
|
|
|
|
|
|
void propertyui::setParam1(QVariant value)
|
|
{
|
|
ui->pushButton_Param1->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Param1_clicked()
|
|
{
|
|
if(param1_type == "QComboBox")
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 1)
|
|
{
|
|
list = i->enumStrings();
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_Param1->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam1(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
else if(param1_type == "QLineEdit")
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(ui->label_Param1->text());
|
|
|
|
int DecimalPlaces = 0;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 1)
|
|
{
|
|
DecimalPlaces = i->decimalPlaces();
|
|
}
|
|
}
|
|
|
|
inputter->setDecimalPlaces(DecimalPlaces);
|
|
|
|
inputter->setInitValue(ui->pushButton_Param1->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam1(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
}
|
|
|
|
void propertyui::setParam2(QVariant value)
|
|
{
|
|
ui->pushButton_Param2->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Param2_clicked()
|
|
{
|
|
if(param2_type == "QComboBox")
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 2)
|
|
{
|
|
list = i->enumStrings();
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_Param2->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam2(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
else if(param2_type == "QLineEdit")
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(ui->label_Param2->text());
|
|
|
|
int DecimalPlaces = 0;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 2)
|
|
{
|
|
DecimalPlaces = i->decimalPlaces();
|
|
}
|
|
}
|
|
|
|
inputter->setDecimalPlaces(DecimalPlaces);
|
|
|
|
|
|
inputter->setInitValue(ui->pushButton_Param2->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam2(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
}
|
|
|
|
void propertyui::setParam3(QVariant value)
|
|
{
|
|
ui->pushButton_Param3->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Param3_clicked()
|
|
{
|
|
if(param3_type == "QComboBox")
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 3)
|
|
{
|
|
list = i->enumStrings();
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_Param3->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam3(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
else if(param3_type == "QLineEdit")
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(ui->label_Param3->text());
|
|
|
|
int DecimalPlaces = 0;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 3)
|
|
{
|
|
DecimalPlaces = i->decimalPlaces();
|
|
}
|
|
}
|
|
|
|
inputter->setDecimalPlaces(DecimalPlaces);
|
|
|
|
inputter->setInitValue(ui->pushButton_Param3->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam3(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
}
|
|
|
|
void propertyui::setParam4(QVariant value)
|
|
{
|
|
ui->pushButton_Param4->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Param4_clicked()
|
|
{
|
|
if(param4_type == "QComboBox")
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 4)
|
|
{
|
|
list = i->enumStrings();
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_Param4->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam4(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
else if(param4_type == "QLineEdit")
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(ui->label_Param4->text());
|
|
|
|
int DecimalPlaces = 0;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 4)
|
|
{
|
|
DecimalPlaces = i->decimalPlaces();
|
|
}
|
|
}
|
|
|
|
inputter->setDecimalPlaces(DecimalPlaces);
|
|
|
|
inputter->setInitValue(ui->pushButton_Param4->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam4(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
}
|
|
|
|
void propertyui::setParam5(QVariant value)
|
|
{
|
|
ui->pushButton_Param5->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Param5_clicked()
|
|
{
|
|
if(param5_type == "QComboBox")
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 5)
|
|
{
|
|
list = i->enumStrings();
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_Param5->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam5(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
else if(param5_type == "QLineEdit")
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(ui->label_Param5->text());
|
|
|
|
int DecimalPlaces = 0;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 5)
|
|
{
|
|
DecimalPlaces = i->decimalPlaces();
|
|
}
|
|
}
|
|
|
|
inputter->setDecimalPlaces(DecimalPlaces);
|
|
|
|
inputter->setInitValue(ui->pushButton_Param5->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam5(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
}
|
|
|
|
void propertyui::setParam6(QVariant value)
|
|
{
|
|
ui->pushButton_Param6->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Param6_clicked()
|
|
{
|
|
if(param6_type == "QComboBox")
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 6)
|
|
{
|
|
list = i->enumStrings();
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_Param6->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam6(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
else if(param6_type == "QLineEdit")
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(ui->label_Param6->text());
|
|
|
|
int DecimalPlaces = 0;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 6)
|
|
{
|
|
DecimalPlaces = i->decimalPlaces();
|
|
}
|
|
}
|
|
|
|
inputter->setDecimalPlaces(DecimalPlaces);
|
|
|
|
inputter->setInitValue(ui->pushButton_Param6->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam6(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
}
|
|
|
|
void propertyui::setParam7(QVariant value)
|
|
{
|
|
ui->pushButton_Param7->setText(value.toString());
|
|
//重置一下参数
|
|
WayPointPropertyUpdate();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Param7_clicked()
|
|
{
|
|
if(param7_type == "QComboBox")
|
|
{
|
|
Selector *selector = new Selector(this);
|
|
selector->setGeometry(0,0,this->width(),this->height());
|
|
|
|
QStringList list;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 7)
|
|
{
|
|
list = i->enumStrings();
|
|
}
|
|
}
|
|
|
|
selector->setList(list,ui->pushButton_Param7->text());
|
|
connect(selector,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam7(QVariant)));
|
|
|
|
selector->show();
|
|
}
|
|
else if(param7_type == "QLineEdit")
|
|
{
|
|
Inputter *inputter = new Inputter(this);
|
|
inputter->setGeometry(0,0,this->width(),this->height());
|
|
|
|
inputter->setLabel(ui->label_Param7->text());
|
|
|
|
int DecimalPlaces = 0;
|
|
|
|
for(QMap<int, MissionCmdParamInfo*>::const_iterator item = _paramInfoMap.begin();item != _paramInfoMap.end();item++)
|
|
{
|
|
MissionCmdParamInfo* i = item.value();
|
|
if(i->param() == 7)
|
|
{
|
|
DecimalPlaces = i->decimalPlaces();
|
|
}
|
|
}
|
|
|
|
inputter->setDecimalPlaces(DecimalPlaces);
|
|
|
|
inputter->setInitValue(ui->pushButton_Param7->text());
|
|
connect(inputter,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setParam7(QVariant)));
|
|
|
|
inputter->show();
|
|
}
|
|
}
|
|
|
|
//模仿qgc
|
|
void propertyui::setLoad(QVariant value)
|
|
{
|
|
qDebug() << "Loadvalue" << value;
|
|
if(value.toBool() == true)
|
|
{
|
|
QFileDialog *dlg = new QFileDialog();
|
|
QString fileName = dlg->getOpenFileName(this, tr("Selete Way Point File..."),
|
|
"./plan/",
|
|
tr("plan file (*.plan)"));
|
|
if(!fileName.isEmpty())
|
|
{
|
|
emit WPLoad(fileName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
void propertyui::on_pushButton_Load_clicked()
|
|
{
|
|
|
|
Confirm *conf = new Confirm(this);
|
|
conf->setGeometry(0,0,this->width(),this->height());
|
|
|
|
conf->setNotice(tr("click to clear all points"));
|
|
|
|
connect(conf,SIGNAL(confirmValue(QVariant)),
|
|
this,SLOT(setLoad(QVariant)));
|
|
|
|
conf->show();
|
|
|
|
}
|
|
|
|
void propertyui::on_pushButton_Save_clicked()
|
|
{
|
|
QFileDialog *dlg = new QFileDialog();
|
|
|
|
QString fileName = dlg->getSaveFileName(this, tr("Selete Way Point File..."),
|
|
"./plan/",
|
|
tr("plan file (*.plan)"));
|
|
if(!fileName.isEmpty())
|
|
{
|
|
emit WPSave(fileName);
|
|
}
|
|
|
|
}
|
|
|
|
void propertyui::on_pushButton_Upload_clicked()
|
|
{
|
|
emit WPUpload();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Download_clicked()
|
|
{
|
|
emit WPDownload();
|
|
}
|
|
|
|
void propertyui::on_pushButton_Previous_clicked()
|
|
{
|
|
if(m_seq > 0)
|
|
emit WPotherPoint(m_seq - 1);
|
|
}
|
|
|
|
void propertyui::on_pushButton_Next_clicked()
|
|
{
|
|
emit WPotherPoint(m_seq +1);
|
|
}
|
|
|
|
|
|
void propertyui::on_pushButton_Insert_clicked()
|
|
{
|
|
emit WPInsert(m_seq);
|
|
}
|
|
|
|
void propertyui::on_pushButton_Delete_clicked()
|
|
{
|
|
emit WPDelete(m_seq);
|
|
}
|
|
|
|
|
|
|
|
|
|
|