添加围栏
This commit is contained in:
@@ -56,3 +56,35 @@ CommandButton:pressed[state="2"] {
|
||||
font: 15px "黑体";
|
||||
}
|
||||
|
||||
.QToolBar QToolButton::right-arrow {
|
||||
background-color:rgb(132, 171, 255);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.QToolBar QToolButton::right-arrow:hover {
|
||||
background-color:rgb(255, 171, 208);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.QToolBar QToolButton::right-arrow:disabled {
|
||||
background-color:rgb(132, 255, 208);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.QToolBar QToolButton::left-arrow {
|
||||
background-color:rgb(132, 171, 255);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.QToolBar QToolButton::left-arrow:hover {
|
||||
background-color:rgb(255, 171, 208);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.QToolBar QToolButton::left-arrow:disabled {
|
||||
background-color:rgb(132, 255, 208);
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "CustomButton.h"
|
||||
|
||||
CustomButton::CustomButton(QWidget *parent) : QPushButton(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CustomButton::~CustomButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CustomButton::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
void CustomButton::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
QWidget::keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef CUSTOMBUTTON_H
|
||||
#define CUSTOMBUTTON_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include "QPushButton"
|
||||
#include "QDebug"
|
||||
#include "QEvent"
|
||||
|
||||
class CustomButton : public QPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomButton(QWidget *parent = nullptr);
|
||||
|
||||
~CustomButton();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // CUSTOMBUTTON_H
|
||||
+251
-247
@@ -7,7 +7,7 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle(tr("Mission Table"));
|
||||
//setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
|
||||
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
//load qss
|
||||
|
||||
QFile file(":/qss/propertyui.qss");
|
||||
@@ -17,14 +17,217 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
this->setStyleSheet(stylesheet);
|
||||
file.close();
|
||||
|
||||
ui->pushButton_load->setFixedSize(80,40);
|
||||
ui->pushButton_save->setFixedSize(80,40);
|
||||
ui->pushButton_upload->setFixedSize(80,40);
|
||||
ui->pushButton_download->setFixedSize(80,40);
|
||||
ui->pushButton_insert->setFixedSize(80,40);
|
||||
ui->pushButton_delete->setFixedSize(80,40);
|
||||
ui->pushButton_clean->setFixedSize(80,40);
|
||||
ui->pushButton_add->setFixedSize(80,40);
|
||||
CustomButton *btn_load = new CustomButton(this);
|
||||
CustomButton *btn_save = new CustomButton(this);
|
||||
CustomButton *btn_upload = new CustomButton(this);
|
||||
CustomButton *btn_download = new CustomButton(this);
|
||||
CustomButton *btn_insert = new CustomButton(this);
|
||||
CustomButton *btn_delete = new CustomButton(this);
|
||||
CustomButton *btn_clean = new CustomButton(this);
|
||||
CustomButton *btn_add = new CustomButton(this);
|
||||
|
||||
btn_load->setText(tr("load"));
|
||||
btn_save->setText(tr("save"));
|
||||
btn_upload->setText(tr("upload"));
|
||||
btn_download->setText(tr("download"));
|
||||
btn_insert->setText(tr("insert"));
|
||||
btn_delete->setText(tr("delete"));
|
||||
btn_clean->setText(tr("clean"));
|
||||
btn_add->setText(tr("add"));
|
||||
|
||||
btn_load->setFixedSize(80,40);
|
||||
btn_save->setFixedSize(80,40);
|
||||
btn_upload->setFixedSize(80,40);
|
||||
btn_download->setFixedSize(80,40);
|
||||
btn_insert->setFixedSize(80,40);
|
||||
btn_delete->setFixedSize(80,40);
|
||||
btn_clean->setFixedSize(80,40);
|
||||
btn_add->setFixedSize(80,40);
|
||||
|
||||
|
||||
|
||||
ui->gridLayout_btn->addWidget(btn_load, 0,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_save, 1,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_upload, 2,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_download,3,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_insert, 4,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_delete, 5,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_clean, 6,0,1,1);
|
||||
ui->gridLayout_btn->addWidget(btn_add, 7,0,1,1);
|
||||
ui->gridLayout_btn->setRowStretch(8,1);
|
||||
|
||||
|
||||
connect(btn_load,&CustomButton::clicked,[=](){
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
connect(btn_save,&CustomButton::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);
|
||||
}
|
||||
});
|
||||
|
||||
connect(btn_upload,&CustomButton::clicked,[=](){
|
||||
emit WPUpload();
|
||||
});
|
||||
|
||||
connect(btn_download,&CustomButton::clicked,[=](){
|
||||
QTableWidget *widget;
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
while (widget->rowCount() > 0) {
|
||||
widget->removeRow(widget->currentRow());
|
||||
}
|
||||
emit WPDownload();
|
||||
});
|
||||
|
||||
connect(btn_insert,&CustomButton::clicked,[=](){
|
||||
emit WPInsert();
|
||||
int group = 3;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
group = 1;
|
||||
break;
|
||||
case 1:
|
||||
group = 3;
|
||||
break;
|
||||
case 2:
|
||||
group = 4;
|
||||
break;
|
||||
case 3:
|
||||
group = 5;
|
||||
break;
|
||||
case 4:
|
||||
group = 6;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints(group);
|
||||
});
|
||||
|
||||
connect(btn_delete,&CustomButton::clicked,[=](){
|
||||
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
int idx = widget->currentRow();
|
||||
widget->removeRow(idx);
|
||||
emit WPDelete();
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints(tablelist.key(widget));
|
||||
});
|
||||
|
||||
connect(btn_clean,&CustomButton::clicked,[=](){
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
while (widget->rowCount() > 0) {
|
||||
widget->removeRow(widget->currentRow());
|
||||
}
|
||||
emit WPDeleteAll();
|
||||
});
|
||||
|
||||
connect(btn_add,&CustomButton::clicked,[=](){
|
||||
emit WPAdd();
|
||||
int group = 3;
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
group = 1;
|
||||
break;
|
||||
case 1:
|
||||
group = 3;
|
||||
break;
|
||||
case 2:
|
||||
group = 4;
|
||||
break;
|
||||
case 3:
|
||||
group = 5;
|
||||
break;
|
||||
case 4:
|
||||
group = 6;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
emit getAllPoints(group);
|
||||
});
|
||||
|
||||
|
||||
tablelist.insert(1,ui->tableWidget_1);
|
||||
@@ -38,52 +241,53 @@ MissionUI::MissionUI(QWidget *parent) :
|
||||
foreach (QTableWidget *table, tablelist) {
|
||||
if(table)
|
||||
{
|
||||
table->setColumnCount(9); //设置列数为7
|
||||
table->setGeometry(QRect(10,455,740,95)); //设置tableWidget的大小
|
||||
table->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选中模式为选中行
|
||||
table->setSelectionMode ( QAbstractItemView::SingleSelection); //设置选择模式,选择单行
|
||||
table->setAlternatingRowColors(true);
|
||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);//不能编辑
|
||||
table->setMouseTracking(true);
|
||||
table->setFocus();
|
||||
table->setFocusPolicy(Qt::StrongFocus);
|
||||
table->setStyleSheet("QTableWidget::item:selected { background-color: rgb(85, 255, 127); color: rgb(255, 255, 255); } ");
|
||||
if(tablelist.key(table) == 1)//围栏
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
table->setColumnCount(9); //设置列数为7
|
||||
table->setGeometry(QRect(10,455,740,95)); //设置tableWidget的大小
|
||||
table->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选中模式为选中行
|
||||
table->setSelectionMode ( QAbstractItemView::SingleSelection); //设置选择模式,选择单行
|
||||
table->setAlternatingRowColors(true);
|
||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);//不能编辑
|
||||
table->setMouseTracking(true);
|
||||
table->setFocus();
|
||||
table->setFocusPolicy(Qt::StrongFocus);
|
||||
table->setStyleSheet("QTableWidget::item:selected { background-color: rgb(85, 255, 127); color: rgb(255, 255, 255); } ");
|
||||
|
||||
table->setColumnWidth(0,45); //设置第一列的列宽(num)
|
||||
table->setColumnWidth(1,80); //设置第二列的列宽(cmd)
|
||||
table->setColumnWidth(2,80); //设置第三列的列宽(par1)
|
||||
table->setColumnWidth(3,80); //设置第四列的列宽(par2)
|
||||
table->setColumnWidth(4,80); //设置第五列的列宽(par3)
|
||||
table->setColumnWidth(5,80); //设置第六列的列宽(par4)
|
||||
table->setColumnWidth(6,150); //设置第七列的列宽(lat)
|
||||
table->setColumnWidth(7,150); //设置第八列的列宽(lng)
|
||||
table->setColumnWidth(8,80); //设置第九列的列宽(alt)
|
||||
table->setColumnWidth(0,45); //设置第一列的列宽(num)
|
||||
table->setColumnWidth(1,80); //设置第二列的列宽(cmd)
|
||||
table->setColumnWidth(2,80); //设置第三列的列宽(par1)
|
||||
table->setColumnWidth(3,80); //设置第四列的列宽(par2)
|
||||
table->setColumnWidth(4,80); //设置第五列的列宽(par3)
|
||||
table->setColumnWidth(5,80); //设置第六列的列宽(par4)
|
||||
table->setColumnWidth(6,150); //设置第七列的列宽(lat)
|
||||
table->setColumnWidth(7,150); //设置第八列的列宽(lng)
|
||||
table->setColumnWidth(8,80); //设置第九列的列宽(alt)
|
||||
|
||||
|
||||
table->setHorizontalHeaderLabels(QStringList() <<tr("number")<<tr("command")<<tr("par1")<<tr("par2")<<tr("par3")<<tr("par4")<<tr("lat")<<tr("lng")<<tr("alt"));
|
||||
QHeaderView* V_headerView = table->verticalHeader();
|
||||
V_headerView->setHidden(true); //行名隐藏
|
||||
table->setHorizontalHeaderLabels(QStringList() <<tr("number")<<tr("command")<<tr("par1")<<tr("par2")<<tr("par3")<<tr("par4")<<tr("lat")<<tr("lng")<<tr("alt"));
|
||||
QHeaderView* V_headerView = table->verticalHeader();
|
||||
V_headerView->setHidden(true); //行名隐藏
|
||||
|
||||
QHeaderView* H_headerView = table->horizontalHeader();
|
||||
H_headerView->setDefaultAlignment(Qt::AlignLeft); //表头信息显示居中靠左
|
||||
H_headerView->setHighlightSections(false); //不高亮选中内容的所在列标题
|
||||
H_headerView->setStretchLastSection(true);
|
||||
QHeaderView* H_headerView = table->horizontalHeader();
|
||||
H_headerView->setDefaultAlignment(Qt::AlignLeft); //表头信息显示居中靠左
|
||||
H_headerView->setHighlightSections(false); //不高亮选中内容的所在列标题
|
||||
H_headerView->setStretchLastSection(true);
|
||||
|
||||
|
||||
connect(table,&QTableWidget::itemSelectionChanged,
|
||||
this,&MissionUI::itemSelectionChanged);
|
||||
|
||||
connect(table,&QTableWidget::itemDoubleClicked,
|
||||
this,&MissionUI::itemDoubleClicked);
|
||||
|
||||
connect(table,&QTableWidget::itemClicked,
|
||||
this,&MissionUI::itemClicked);
|
||||
/*
|
||||
connect(table,&QTableWidget::itemEntered,
|
||||
this,&MissionUI::itemClicked);
|
||||
*/
|
||||
connect(table,&QTableWidget::itemSelectionChanged,
|
||||
this,&MissionUI::itemSelectionChanged);
|
||||
|
||||
connect(table,&QTableWidget::itemDoubleClicked,
|
||||
this,&MissionUI::itemDoubleClicked);
|
||||
|
||||
connect(table,&QTableWidget::itemClicked,
|
||||
this,&MissionUI::itemClicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,206 +542,6 @@ void MissionUI::on_tabWidget_currentChanged(int index)
|
||||
//emit waypointSelect(group,idx);
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_load_clicked()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void MissionUI::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 MissionUI::on_pushButton_upload_clicked()
|
||||
{
|
||||
emit WPUpload();
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_download_clicked()
|
||||
{
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
while (widget->rowCount() > 0) {
|
||||
widget->removeRow(widget->currentRow());
|
||||
}
|
||||
|
||||
|
||||
emit WPDownload();
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_insert_clicked()
|
||||
{
|
||||
emit WPInsert();
|
||||
|
||||
int group = 3;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
group = 1;
|
||||
break;
|
||||
case 1:
|
||||
group = 3;
|
||||
break;
|
||||
case 2:
|
||||
group = 4;
|
||||
break;
|
||||
case 3:
|
||||
group = 5;
|
||||
break;
|
||||
case 4:
|
||||
group = 6;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints(group);
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_delete_clicked()
|
||||
{
|
||||
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int idx = widget->currentRow();
|
||||
widget->removeRow(idx);
|
||||
|
||||
emit WPDelete();
|
||||
|
||||
//删除完成后,刷新一次所有航点
|
||||
emit getAllPoints(tablelist.key(widget));
|
||||
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_add_clicked()
|
||||
{
|
||||
emit WPAdd();
|
||||
|
||||
int group = 3;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
group = 1;
|
||||
break;
|
||||
case 1:
|
||||
group = 3;
|
||||
break;
|
||||
case 2:
|
||||
group = 4;
|
||||
break;
|
||||
case 3:
|
||||
group = 5;
|
||||
break;
|
||||
case 4:
|
||||
group = 6;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//刷新一次所有航点
|
||||
emit getAllPoints(group);
|
||||
}
|
||||
|
||||
void MissionUI::on_pushButton_clean_clicked()
|
||||
{
|
||||
QTableWidget *widget;
|
||||
//根据tabwidget
|
||||
int tab_idx =ui->tabWidget->currentIndex();
|
||||
|
||||
switch (tab_idx) {
|
||||
case 0:
|
||||
widget = tablelist.value(1);
|
||||
break;
|
||||
case 1:
|
||||
widget = tablelist.value(3);
|
||||
break;
|
||||
case 2:
|
||||
widget = tablelist.value(4);
|
||||
break;
|
||||
case 3:
|
||||
widget = tablelist.value(5);
|
||||
break;
|
||||
case 4:
|
||||
widget = tablelist.value(6);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
while (widget->rowCount() > 0) {
|
||||
widget->removeRow(widget->currentRow());
|
||||
}
|
||||
|
||||
emit WPDeleteAll();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void MissionUI::itemSelectionChanged()
|
||||
{
|
||||
QTableWidget *widget = qobject_cast<QTableWidget *>(sender());
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
#include "QLineEdit"
|
||||
#include "QTableWidget"
|
||||
#include "QFileDialog"
|
||||
|
||||
#include "CustomButton.h"
|
||||
#include "QSpacerItem"
|
||||
|
||||
namespace Ui {
|
||||
class MissionUI;
|
||||
}
|
||||
@@ -51,16 +55,6 @@ private slots:
|
||||
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
void on_pushButton_load_clicked();
|
||||
void on_pushButton_save_clicked();
|
||||
void on_pushButton_upload_clicked();
|
||||
void on_pushButton_download_clicked();
|
||||
void on_pushButton_insert_clicked();
|
||||
void on_pushButton_delete_clicked();
|
||||
void on_pushButton_add_clicked();
|
||||
|
||||
void on_pushButton_clean_clicked();
|
||||
|
||||
void itemClicked(QTableWidgetItem *item);
|
||||
void itemDoubleClicked(QTableWidgetItem *item);
|
||||
|
||||
|
||||
@@ -21,11 +21,13 @@ FORMS += \
|
||||
$$PWD/propertyui.ui
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/CustomButton.h \
|
||||
$$PWD/JsonHelper.h \
|
||||
$$PWD/MissionUI.h \
|
||||
$$PWD/propertyui.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/CustomButton.cpp \
|
||||
$$PWD/JsonHelper.cc \
|
||||
$$PWD/MissionUI.cpp \
|
||||
$$PWD/propertyui.cpp
|
||||
|
||||
@@ -14,81 +14,10 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton_save">
|
||||
<property name="text">
|
||||
<string>save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="pushButton_insert">
|
||||
<property name="text">
|
||||
<string>insert</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButton_upload">
|
||||
<property name="text">
|
||||
<string>upload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QPushButton" name="pushButton_add">
|
||||
<property name="text">
|
||||
<string>add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="pushButton_download">
|
||||
<property name="text">
|
||||
<string>download</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton_load">
|
||||
<property name="text">
|
||||
<string>load</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="gridLayout_btn"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QPushButton" name="pushButton_delete">
|
||||
<property name="text">
|
||||
<string>delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="20">
|
||||
<item row="0" column="1">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
@@ -228,13 +157,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QPushButton" name="pushButton_clean">
|
||||
<property name="text">
|
||||
<string>clean</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -68,3 +68,31 @@
|
||||
}
|
||||
|
||||
|
||||
.CustomButton {
|
||||
background-color: #FFFFFF;
|
||||
border-width: 2px;
|
||||
border-color: darkkhaki;
|
||||
border-style: solid;
|
||||
border-radius: 5;
|
||||
padding: 3px;
|
||||
font :15px "黑体";
|
||||
}
|
||||
|
||||
.CustomButton:pressed {
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #dadbde, stop: 1 #f6f7fa);
|
||||
}
|
||||
|
||||
|
||||
.QTabBar::tab:!selected {
|
||||
color:#000000;
|
||||
background-color: #81F79F;
|
||||
}
|
||||
|
||||
.QTabBar::tab:selected {
|
||||
color:#000000;
|
||||
background-color: #FE9A2E;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "geoFenceitem.h"
|
||||
#include <QDateTime>
|
||||
namespace mapcontrol {
|
||||
geoFenceitem::geoFenceitem(int index, internals::PointLatLng const & coord, int const & altitude, QBrush color, MapGraphicItem *map) : QGraphicsItem(map), number(index) , coord(coord), m_brush(color), m_map(map)
|
||||
{
|
||||
//qDebug() << "geoFenceitem:" << index << coord.Lat() << coord.Lng();
|
||||
|
||||
this->setZValue(3);
|
||||
|
||||
connect(map, SIGNAL(childRefreshPosition()), this, SLOT(RefreshPos()));
|
||||
|
||||
//qDebug() << this->pos();
|
||||
RefreshPos();
|
||||
}
|
||||
|
||||
void geoFenceitem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setBrush(m_brush);
|
||||
painter->drawPoint(0,0);
|
||||
}
|
||||
QRectF geoFenceitem::boundingRect() const
|
||||
{
|
||||
return QRectF(-2, -2, 4, 4);
|
||||
}
|
||||
|
||||
int geoFenceitem::type() const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
void geoFenceitem::setPosSLOT()
|
||||
{
|
||||
//qDebug() << "virtual set pos";
|
||||
|
||||
setPos(m_map->FromLatLngToLocal(this->coord).X(), m_map->FromLatLngToLocal(this->coord).Y());
|
||||
emit localPositionChanged(this->pos(),this);
|
||||
}
|
||||
|
||||
void geoFenceitem::RefreshPos()
|
||||
{
|
||||
setPosSLOT();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#ifndef GEOFENCEITEM_H
|
||||
#define GEOFENCEITEM_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "pointlatlng.h"
|
||||
#include <QObject>
|
||||
#include "mapgraphicitem.h"
|
||||
|
||||
namespace mapcontrol {
|
||||
|
||||
#ifdef QtopmapWidget
|
||||
#include <mapwidgetglobal.h>
|
||||
class OPMAPWIDGETSHARED_EXPORT geoFenceitem : public QObject, public QGraphicsItem {
|
||||
#else
|
||||
class geoFenceitem : public QObject, public QGraphicsItem {
|
||||
#endif
|
||||
|
||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 11 };
|
||||
geoFenceitem(int index,internals::PointLatLng const & coord, int const & altitude, QBrush color, MapGraphicItem *map);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget);
|
||||
QRectF boundingRect() const;
|
||||
int type() const;
|
||||
internals::PointLatLng coord;
|
||||
int number;
|
||||
private:
|
||||
QBrush m_brush;
|
||||
MapGraphicItem *m_map;
|
||||
|
||||
public slots:
|
||||
void setPosSLOT();
|
||||
|
||||
void RefreshPos();
|
||||
|
||||
signals:
|
||||
|
||||
void localPositionChanged(QPointF point, geoFenceitem *p);
|
||||
void aboutToBeDeleted(geoFenceitem *);
|
||||
|
||||
};
|
||||
}
|
||||
#endif // GEOFENCEITEM_H
|
||||
@@ -0,0 +1,137 @@
|
||||
#include "geoFenceitemline.h"
|
||||
#include <math.h>
|
||||
|
||||
namespace mapcontrol {
|
||||
geoFenceitemline::geoFenceitemline(geoFenceitem *from, geoFenceitem *to, MapGraphicItem *map, QColor color, bool dashed, int width ) : QGraphicsLineItem(map),
|
||||
source(from), destination(to), my_map(map), myColor(color), dashed(dashed), lineWidth(width)
|
||||
{
|
||||
this->setLine(from->pos().x(), from->pos().y(), to->pos().x(), to->pos().y());
|
||||
connect(from, SIGNAL(localPositionChanged(QPointF, geoFenceitem *)), this, SLOT(refreshLocations()));
|
||||
connect(to, SIGNAL(localPositionChanged(QPointF, geoFenceitem *)), this, SLOT(refreshLocations()));
|
||||
connect(from, SIGNAL(aboutToBeDeleted(geoFenceitem *)), this, SLOT(waypointdeleted()));
|
||||
connect(to, SIGNAL(aboutToBeDeleted(geoFenceitem *)), this, SLOT(waypointdeleted()));
|
||||
|
||||
this->setZValue(3);
|
||||
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
|
||||
|
||||
isEdit = true;
|
||||
|
||||
//qDebug() << "virtual line create";
|
||||
|
||||
//qDebug() << this->pos();
|
||||
|
||||
lineWidth = 5;
|
||||
}
|
||||
|
||||
|
||||
int geoFenceitemline::type() const
|
||||
{
|
||||
// Enable the use of qgraphicsitem_cast with this item.
|
||||
return Type;
|
||||
}
|
||||
QPainterPath geoFenceitemline::shape() const
|
||||
{
|
||||
QPainterPath path = QGraphicsLineItem::shape();
|
||||
|
||||
path.addPolygon(arrowHead);
|
||||
return path;
|
||||
}
|
||||
void geoFenceitemline::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
|
||||
//qDebug() << "virtual line update";
|
||||
|
||||
QPen myPen = pen();
|
||||
|
||||
|
||||
myPen.setColor(myColor);
|
||||
|
||||
|
||||
|
||||
//qreal arrowSize = 10;
|
||||
painter->setPen(myPen);
|
||||
|
||||
/*
|
||||
if(isEdit == false)
|
||||
{
|
||||
painter->setBrush(myColor);
|
||||
}
|
||||
*/
|
||||
|
||||
double angle = ::acos(line().dx() / line().length());
|
||||
if (line().dy() >= 0) {
|
||||
angle = (M_PI * 2) - angle;
|
||||
}
|
||||
|
||||
/*
|
||||
QPointF arrowP1 = line().pointAt(0.5) + QPointF(sin(angle + M_PI / 3) * arrowSize,
|
||||
cos(angle + M_PI / 3) * arrowSize);
|
||||
QPointF arrowP2 = line().pointAt(0.5) + QPointF(sin(angle + M_PI - M_PI / 3) * arrowSize,
|
||||
cos(angle + M_PI - M_PI / 3) * arrowSize);
|
||||
arrowHead.clear();
|
||||
arrowHead << line().pointAt(0.5) << arrowP1 << arrowP2;
|
||||
painter->drawPolygon(arrowHead);
|
||||
*/
|
||||
|
||||
if (dashed) {
|
||||
QVector<qreal> dashes;
|
||||
dashes << 4 << 8;
|
||||
myPen.setDashPattern(dashes);
|
||||
}
|
||||
|
||||
|
||||
myPen.setWidth(lineWidth);
|
||||
|
||||
painter->setPen(myPen);
|
||||
painter->drawLine(line());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void geoFenceitemline::setEdit(bool value)
|
||||
{
|
||||
isEdit = value;
|
||||
}
|
||||
|
||||
|
||||
void geoFenceitemline::refreshLocations()
|
||||
{
|
||||
//qDebug() << "reflush location";
|
||||
this->setLine(source->pos().x(), source->pos().y(),
|
||||
destination->pos().x(), destination->pos().y());
|
||||
}
|
||||
|
||||
void geoFenceitemline::waypointdeleted()
|
||||
{
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
void geoFenceitemline::WPLinedelete(geoFenceitem *from, geoFenceitem *to)
|
||||
{
|
||||
Q_UNUSED(from)
|
||||
Q_UNUSED(to)
|
||||
|
||||
|
||||
this->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void geoFenceitemline::setOpacitySlot(qreal opacity)
|
||||
{
|
||||
setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef GEOFENCEITEMLINE_H
|
||||
#define GEOFENCEITEMLINE_H
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include <QLabel>
|
||||
#include "pointlatlng.h"
|
||||
#include "mapgraphicitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
|
||||
#include "geoFenceitem.h"
|
||||
|
||||
namespace mapcontrol {
|
||||
|
||||
#ifdef QtopmapWidget
|
||||
#include <mapwidgetglobal.h>
|
||||
class OPMAPWIDGETSHARED_EXPORT geoFenceitemline : public QObject, public QGraphicsLineItem {
|
||||
#else
|
||||
class geoFenceitemline : public QObject, public QGraphicsLineItem {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||
public:
|
||||
enum { Type = UserType + 12 };
|
||||
geoFenceitemline(geoFenceitem *from, geoFenceitem *to, MapGraphicItem *map, QColor color = Qt::green, bool dashed = false, int width = 2);
|
||||
int type() const;
|
||||
QPainterPath shape() const;
|
||||
void setColor(const QColor &color)
|
||||
{
|
||||
myColor = color;
|
||||
}
|
||||
|
||||
|
||||
void setEdit(bool value);
|
||||
|
||||
|
||||
bool Edit(void)
|
||||
{
|
||||
return isEdit;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
QGraphicsItem *source;
|
||||
QGraphicsItem *destination;
|
||||
MapGraphicItem *my_map;
|
||||
QPolygonF arrowHead;
|
||||
QColor myColor;
|
||||
bool dashed;
|
||||
int lineWidth;
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
public slots:
|
||||
|
||||
QGraphicsItem *WPLineFrom(void)
|
||||
{
|
||||
return this->source;
|
||||
}
|
||||
|
||||
QGraphicsItem *WPLineTo(void)
|
||||
{
|
||||
return this->destination;
|
||||
}
|
||||
|
||||
|
||||
void WPLinedelete(geoFenceitem *from, geoFenceitem *to);
|
||||
void refreshLocations();
|
||||
void waypointdeleted();
|
||||
void setOpacitySlot(qreal opacity);
|
||||
|
||||
private:
|
||||
|
||||
bool isEdit = false;
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -51,6 +51,8 @@ SOURCES += $$PWD/mapgraphicitem.cpp \
|
||||
$$PWD/AltitudeItem.cpp \
|
||||
$$PWD/waypointbutton.cpp \
|
||||
$$PWD/waypointsetting.cpp \
|
||||
geoFenceitem.cpp \
|
||||
geoFenceitemline.cpp \
|
||||
measureline.cpp
|
||||
|
||||
HEADERS += $$PWD/mapgraphicitem.h \
|
||||
@@ -72,6 +74,8 @@ HEADERS += $$PWD/mapgraphicitem.h \
|
||||
$$PWD/AltitudeItem.h \
|
||||
$$PWD/waypointbutton.h \
|
||||
$$PWD/waypointsetting.h \
|
||||
geoFenceitem.h \
|
||||
geoFenceitemline.h \
|
||||
measureline.h
|
||||
|
||||
RESOURCES += mapresources.qrc
|
||||
|
||||
@@ -1877,17 +1877,73 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
|
||||
|
||||
/*
|
||||
"circles": [
|
||||
{
|
||||
"circle": {
|
||||
"center": [
|
||||
32.04290131170435,
|
||||
118.81779757301473
|
||||
],
|
||||
"radius": 104.72920614551222
|
||||
},
|
||||
"inclusion": true,
|
||||
"version": 1
|
||||
},
|
||||
{
|
||||
"circle": {
|
||||
"center": [
|
||||
32.04275580264579,
|
||||
118.8194498137916
|
||||
],
|
||||
"radius": 91.2720266761384
|
||||
},
|
||||
"inclusion": true,
|
||||
"version": 1
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//安全区解码
|
||||
QJsonArray circlesArray = json.value("geoFence").toObject().value("circles").toArray().at(0).toObject().value("circles").toArray();
|
||||
QJsonArray circlesArray = json.value("geoFence").toObject().value("circles").toArray();
|
||||
for(QJsonValue item: circlesArray) {
|
||||
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
QJsonObject circle = item.toObject().value("circle").toObject();
|
||||
|
||||
QJsonArray center = circle.value("center").toArray();
|
||||
|
||||
qreal lat = center.at(0).toDouble();
|
||||
qreal lng = center.at(1).toDouble();
|
||||
qreal radius = circle.value("radius").toDouble();
|
||||
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
qDebug() << "circle" << inclusion << lat << lng << radius << version;
|
||||
}
|
||||
|
||||
QJsonArray polygonsArray = json.value("geoFence").toObject().value("polygons").toArray().at(0).toObject().value("polygon").toArray();
|
||||
QJsonArray polygonsArray = json.value("geoFence").toObject().value("polygons").toArray();
|
||||
for(QJsonValue item: polygonsArray) {
|
||||
//获得边界
|
||||
bool inclusion = item.toObject().value("inclusion").toBool();
|
||||
QJsonArray polygon = item.toObject().value("polygon").toArray();
|
||||
|
||||
qDebug() << "polygons" << item.toArray().at(0).toDouble() << item.toArray().at(1).toDouble();
|
||||
for (QJsonValue point: polygon) {
|
||||
qreal lat = point.toArray().at(0).toDouble();
|
||||
qreal lng = point.toArray().at(1).toDouble();
|
||||
}
|
||||
|
||||
int version = item.toObject().value("version").toInt();
|
||||
|
||||
|
||||
qDebug() << "polygon" << inclusion << version << item.toObject();
|
||||
|
||||
}
|
||||
|
||||
@@ -1909,7 +1965,8 @@ void OPMapWidget::WPLoad(QString path)//带文件目录参数
|
||||
uint16_t seq = item.toObject().find("doJumpId").value().toInt();
|
||||
uint8_t frame = item.toObject().find("frame").value().toInt();
|
||||
QJsonArray params = item.toObject().find("params").value().toArray();//array
|
||||
uint8_t mission_type = item.toObject().find("type").value().toInt();
|
||||
//uint8_t mission_type = item.toObject().find("type").value().toInt();
|
||||
uint8_t mission_type = currentGroup;
|
||||
|
||||
float param1 = params.at(0).toDouble();
|
||||
float param2 = params.at(1).toDouble();
|
||||
@@ -2381,9 +2438,22 @@ void OPMapWidget::receivedPoint(float param1,float param2,float param3,float par
|
||||
|
||||
qDebug() << "receivers Point";
|
||||
|
||||
QString typestr;
|
||||
|
||||
//emit showMessage(tr("recieve way point %1").arg(seq + 1));
|
||||
emit showMessage(tr("recieve way point group:%1 seq:%2").arg(mission_type - 2).arg(seq + 1));
|
||||
switch (mission_type - 2) {
|
||||
case -1:
|
||||
typestr = tr("polygons");
|
||||
break;
|
||||
case 0:
|
||||
typestr = tr("circles");
|
||||
break;
|
||||
default:
|
||||
typestr = QString::number(mission_type - 2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
emit showMessage(tr("recieve way point group:%1 seq:%2").arg(typestr).arg(seq + 1));
|
||||
|
||||
|
||||
//qDebug() << "receivers Point" << x * 10e-8 << y * 10e-8 << 10e-8;
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
namespace mapcontrol {
|
||||
WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & altitude,int seq, int missiontype, MapGraphicItem *map, wptype type) : coord(coord), reached(false), description(""), shownumber(true), isDragging(false), altitude(altitude), map(map), myType(type)
|
||||
{
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
numberI = 0;
|
||||
isEdit = true;
|
||||
isMagic = false;
|
||||
@@ -76,6 +78,8 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti
|
||||
|
||||
WayPointItem::WayPointItem(int seq,int missiontype, MapGraphicItem *map, bool magicwaypoint) : reached(false), description(""), shownumber(true), isDragging(false), altitude(0), map(map)
|
||||
{
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
isEdit = true;
|
||||
relativeCoord.bearing = 0;
|
||||
relativeCoord.distance = 0;
|
||||
@@ -122,6 +126,9 @@ WayPointItem::WayPointItem(int seq,int missiontype, MapGraphicItem *map, bool ma
|
||||
}
|
||||
WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & altitude,int seq, int missiontype, const QString &description, MapGraphicItem *map, wptype type) : coord(coord), reached(false), description(description), shownumber(true), isDragging(false), altitude(altitude), map(map), myType(type)
|
||||
{
|
||||
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
isEdit = true;
|
||||
numberI = 0;
|
||||
isMagic = false;
|
||||
@@ -160,6 +167,8 @@ WayPointItem::WayPointItem(const internals::PointLatLng &coord, int const & alti
|
||||
|
||||
WayPointItem::WayPointItem(const distBearingAltitude &relativeCoordenate,int seq,int missiontype, const QString &description, MapGraphicItem *map) : relativeCoord(relativeCoordenate), reached(false), description(description), shownumber(true), isDragging(false), map(map)
|
||||
{
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
isEdit = true;
|
||||
myHome = NULL;
|
||||
QList<QGraphicsItem *> list = map->childItems();
|
||||
@@ -344,11 +353,15 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
|
||||
if(isShowTip)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QRectF rect = QRectF(-50,-70,100,50);
|
||||
|
||||
//画一块底色#58ACFA
|
||||
painter->setBrush(QColor("#A9F5F2"));
|
||||
//painter->setBrush(Qt::NoBrush);
|
||||
painter->setOpacity(TipOpacity);
|
||||
|
||||
|
||||
ePen.setColor(QColor("#58ACFA"));
|
||||
ePen.setWidth(2);
|
||||
@@ -422,6 +435,8 @@ void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
|
||||
_h.append(tr("Height: %1m\n%2").arg(QString::number(property.z,'f',0)).arg(_v));
|
||||
painter->drawText(QRectF(rect.x() + 2,rect.y()+2,rect.width() - 4,rect.height() - 4),Qt::AlignLeft | Qt::AlignVCenter,_h);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,6 +534,28 @@ void WayPointItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
QGraphicsItem::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
|
||||
void WayPointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
TipOpacity = 1;
|
||||
|
||||
this->setZValue(15);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void WayPointItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
TipOpacity = 0.5;
|
||||
|
||||
this->setZValue(5);
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void WayPointItem::setPosition(QPointF p)
|
||||
{
|
||||
|
||||
@@ -623,7 +660,7 @@ void WayPointItem::SetShowNumber(const bool &value)
|
||||
|
||||
QFont font;
|
||||
font.setWeight(QFont::ExtraLight);
|
||||
font.setFamily("Arial");//非衬线
|
||||
font.setFamily("Arial");
|
||||
font.setPixelSize(12);
|
||||
numberI->setFont(font);
|
||||
numberI->setZValue(3);
|
||||
|
||||
@@ -321,10 +321,13 @@ protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
private:
|
||||
|
||||
_property property;
|
||||
|
||||
qreal TipOpacity = 0.5;
|
||||
bool isShowTip = false;
|
||||
bool isFancy = false;
|
||||
bool FancyType = 0;
|
||||
|
||||
Reference in New Issue
Block a user