添加高程界面
This commit is contained in:
@@ -207,6 +207,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
menuBarUI->showMessage(tr("存在bug,连接界面udp数字输入的.可以超过3个,不合理"));
|
||||
|
||||
//==== showmessage=====
|
||||
connect(copk,SIGNAL(showMessage(QString,int)),this,SLOT(showMessage(QString,int)));
|
||||
connect(dlink,SIGNAL(showMessage(QString,int)),this,SLOT(showMessage(QString,int)));
|
||||
connect(map,SIGNAL(showMessage(QString,int)),this,SLOT(showMessage(QString,int)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -129,6 +129,8 @@ typedef struct{
|
||||
Q_SIGNALS:
|
||||
void errorSignal(int);
|
||||
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
bool NormalSize()
|
||||
|
||||
@@ -119,10 +119,10 @@ signals:
|
||||
|
||||
void SendMessageTo(quint8 ch, quint8 *data,quint16 len);
|
||||
|
||||
|
||||
|
||||
void commandAccepted(bool flag,uint16_t command,uint8_t result);
|
||||
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
private:
|
||||
bool running_flag = false;
|
||||
quint32 running_frq = 200;//200Hz
|
||||
|
||||
@@ -25,11 +25,18 @@ MavLinkNode::MavLinkNode(QObject *parent) : QObject(parent)
|
||||
connect(this,SIGNAL(setCurrentID(int,int)),
|
||||
Mission,SLOT(setID(int,int)),Qt::DirectConnection);
|
||||
|
||||
connect(Mission,SIGNAL(showMessage(QString,int)),
|
||||
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
||||
|
||||
|
||||
|
||||
Parameter = new ParameterProcess();
|
||||
connect(Parameter,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),
|
||||
this,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),Qt::DirectConnection);
|
||||
|
||||
connect(Parameter,SIGNAL(showMessage(QString,int)),
|
||||
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
||||
|
||||
|
||||
Commander = new commandprocess();
|
||||
connect(Commander,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),
|
||||
@@ -38,6 +45,9 @@ MavLinkNode::MavLinkNode(QObject *parent) : QObject(parent)
|
||||
connect(this,SIGNAL(setCurrentID(int,int)),
|
||||
Commander,SLOT(setID(int,int)),Qt::DirectConnection);
|
||||
|
||||
connect(Commander,SIGNAL(showMessage(QString,int)),
|
||||
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
||||
|
||||
}
|
||||
|
||||
MavLinkNode::~MavLinkNode()
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
void addVehicles(int sysid,int compid);
|
||||
|
||||
|
||||
@@ -131,6 +131,8 @@ private slots:
|
||||
void write_partial_list(void);
|
||||
|
||||
signals:
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
void readError();
|
||||
|
||||
void SendMessageTo(quint8 ch, quint8 *data,quint16 len);
|
||||
|
||||
@@ -107,6 +107,8 @@ private slots:
|
||||
void request_read(const char *id, int16_t index);
|
||||
|
||||
signals:
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
void readError();
|
||||
|
||||
void SendMessageTo(quint8 ch, quint8 *data,quint16 len);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="zh_CN">
|
||||
</TS>
|
||||
+8
-2
@@ -18,6 +18,10 @@ DLink::DLink(QObject *parent) : QObject(parent)
|
||||
connect(mavlinknode,SIGNAL(SendMessageTo(quint8,quint8*,quint16)),
|
||||
this,SLOT(SendMessageTo(quint8,quint8*,quint16)),Qt::DirectConnection);//采用直连的方式,因为是多线程
|
||||
|
||||
connect(mavlinknode,SIGNAL(showMessage(QString,int)),
|
||||
this,SIGNAL(showMessage(QString,int)),Qt::DirectConnection);
|
||||
|
||||
|
||||
//其他协议节点。。。
|
||||
|
||||
}
|
||||
@@ -96,12 +100,13 @@ bool DLink::setupPort(const QString port, qint32 baudrate, QSerialPort::Parity p
|
||||
|
||||
isSuccess = true;
|
||||
|
||||
emit showMessage(tr("Serial Port Open Success"));
|
||||
qDebug() << "Serial Port Open Success";
|
||||
}
|
||||
else
|
||||
{
|
||||
isSuccess = false;
|
||||
|
||||
emit showMessage(tr("Serial Port Open Fail"));
|
||||
qDebug() << "Serial Port Open Fail";
|
||||
delete serialPort;
|
||||
serialPort = nullptr;
|
||||
@@ -117,6 +122,7 @@ bool DLink::statesPort()
|
||||
|
||||
void DLink::stopPort()
|
||||
{
|
||||
emit showMessage(tr("Serial Port close"));
|
||||
serialPort->close();
|
||||
delete serialPort;
|
||||
serialPort = nullptr;
|
||||
@@ -215,7 +221,7 @@ bool DLink::setupClient(const QHostAddress &remote_addr, int remote_port, int lo
|
||||
mavlinknode->start();
|
||||
|
||||
isSuccess = true;
|
||||
|
||||
emit showMessage(tr("UdpSocket open"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
MavLinkNode *mavlinknode = nullptr;
|
||||
|
||||
signals:
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
|
||||
void PortConnected(QVariant m_state,
|
||||
QVariant m_usrName,QVariant m_Type,
|
||||
|
||||
@@ -72,9 +72,6 @@ CONFIG(release, debug|release) {
|
||||
}
|
||||
|
||||
|
||||
TRANSLATIONS = GCS_zh_CN.ts
|
||||
|
||||
|
||||
DESTDIR = $$PWD/../thirdpart/lib
|
||||
MOC_DIR = $$PWD/../build
|
||||
OBJECTS_DIR = $$PWD/../build
|
||||
|
||||
@@ -14,6 +14,14 @@ AltitudeItem::AltitudeItem(MapGraphicItem *map, QColor background) : myMap(map),
|
||||
connect(map, SIGNAL(childSetOpacity(qreal)), this, SLOT(setOpacitySlot(qreal)));
|
||||
|
||||
this->setZValue(4);
|
||||
|
||||
|
||||
Elevation = 300;
|
||||
|
||||
Altitude = 100;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
QRectF AltitudeItem::boundingRect() const //鼠标可以操作的大小
|
||||
@@ -27,9 +35,61 @@ void AltitudeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
Q_UNUSED(widget);
|
||||
|
||||
|
||||
|
||||
|
||||
QPen ePen;
|
||||
ePen.setWidth(1);
|
||||
|
||||
//画边框
|
||||
ePen.setColor(QColor("#a39d9c"));
|
||||
painter->setPen(ePen);
|
||||
painter->setBrush(QColor("#a39d9c"));
|
||||
painter->drawRect(0,
|
||||
10,
|
||||
this->boundingRect().width(),this->boundingRect().height());
|
||||
|
||||
if(Altitude >= Elevation)
|
||||
{
|
||||
//画海拔
|
||||
ePen.setColor(QColor("#5CACEE"));
|
||||
painter->setPen(ePen);
|
||||
painter->setBrush(QColor("#5CACEE"));
|
||||
painter->drawRect(1,
|
||||
this->boundingRect().height() *(1 - (Altitude - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min)),
|
||||
this->boundingRect().width() - 2,
|
||||
this->boundingRect().height() * (Altitude - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min));
|
||||
|
||||
//画地形高度
|
||||
ePen.setColor(QColor("#8B5A2B"));
|
||||
painter->setPen(ePen);
|
||||
painter->setBrush(QColor("#8B5A2B"));
|
||||
painter->drawRect(1,
|
||||
this->boundingRect().height() *(1 - (Elevation - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min)),
|
||||
this->boundingRect().width() - 2,
|
||||
this->boundingRect().height() * (Elevation - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min));
|
||||
}
|
||||
else
|
||||
{
|
||||
//画地形高度
|
||||
ePen.setColor(QColor("#8B5A2B"));
|
||||
painter->setPen(ePen);
|
||||
painter->setBrush(QColor("#8B5A2B"));
|
||||
painter->drawRect(1,
|
||||
this->boundingRect().height() *(1 - (Elevation - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min)),
|
||||
this->boundingRect().width() - 2,
|
||||
this->boundingRect().height() * (Elevation - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min));
|
||||
|
||||
//画海拔
|
||||
ePen.setColor(QColor("#5CACEE"));
|
||||
painter->setPen(ePen);
|
||||
painter->setBrush(QColor("#5CACEE"));
|
||||
painter->drawRect(1,
|
||||
this->boundingRect().height() *(1 - (Altitude - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min)),
|
||||
this->boundingRect().width() - 2,
|
||||
this->boundingRect().height() * (Altitude - AltitudeItem::min) / (AltitudeItem::max - AltitudeItem::min));
|
||||
}
|
||||
|
||||
|
||||
if (this->isSelected()) {
|
||||
ePen.setColor(QColor("#008B00"));
|
||||
painter->setBrush(QColor("#008B00"));
|
||||
@@ -40,7 +100,9 @@ void AltitudeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
}
|
||||
|
||||
painter->setPen(ePen);
|
||||
painter->drawEllipse(0,0,20,20);
|
||||
painter->drawEllipse(0,
|
||||
0,
|
||||
20,20);
|
||||
|
||||
ePen.setColor(QColor("#FFFFFF"));
|
||||
painter->setPen(ePen);
|
||||
@@ -51,16 +113,18 @@ void AltitudeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
font.setFamily("Arial");//非衬线
|
||||
font.setPixelSize(12);
|
||||
painter->setFont(font);
|
||||
painter->drawText(0,0,20,20,Qt::AlignCenter,QString::number(0));
|
||||
|
||||
|
||||
painter->drawText(0,
|
||||
0,
|
||||
20,20,
|
||||
Qt::AlignCenter,QString::number(number));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AltitudeItem::RefreshPos()
|
||||
{
|
||||
this->setPos(0,myMap->boundingRect().height() - this->boundingRect().height());
|
||||
this->setPos(this->x(),
|
||||
myMap->boundingRect().height() - this->boundingRect().height());
|
||||
}
|
||||
|
||||
void AltitudeItem::setOpacitySlot(qreal opacity)
|
||||
@@ -75,7 +139,7 @@ void AltitudeItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
}
|
||||
|
||||
qDebug() << event;
|
||||
//qDebug() << event;
|
||||
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
@@ -104,6 +168,51 @@ void AltitudeItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
QGraphicsItem::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void AltitudeItem::setNumber(int value)
|
||||
{
|
||||
number = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AltitudeItem::setElevation(float value)
|
||||
{
|
||||
Elevation = value;
|
||||
|
||||
|
||||
if(value > AltitudeItem::max)
|
||||
{
|
||||
AltitudeItem::max = value;
|
||||
}
|
||||
|
||||
if(value < AltitudeItem::min)
|
||||
{
|
||||
AltitudeItem::min = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AltitudeItem::setAltitude(float value)
|
||||
{
|
||||
Altitude = value;
|
||||
|
||||
|
||||
if(value > max)
|
||||
{
|
||||
max = value;
|
||||
}
|
||||
|
||||
if(value < min)
|
||||
{
|
||||
min = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
float AltitudeItem::max = 500;
|
||||
float AltitudeItem::min = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ class AltitudeItem : public QObject, public QGraphicsItem {
|
||||
Q_OBJECT Q_INTERFACES(QGraphicsItem)
|
||||
|
||||
public:
|
||||
|
||||
|
||||
AltitudeItem(MapGraphicItem *map, QColor background = Qt::green);
|
||||
|
||||
QRectF boundingRect() const;
|
||||
@@ -34,12 +36,17 @@ public:
|
||||
{
|
||||
myColor = color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static float max;
|
||||
static float min;
|
||||
|
||||
private:
|
||||
MapGraphicItem *myMap;
|
||||
QColor myColor;
|
||||
|
||||
float max;
|
||||
float min;
|
||||
|
||||
|
||||
float Altitude;//离开地面高度
|
||||
float Elevation;//离开海平面高度
|
||||
@@ -47,6 +54,10 @@ private:
|
||||
|
||||
bool isDragging;
|
||||
|
||||
|
||||
int number;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
@@ -58,11 +69,17 @@ protected:
|
||||
public slots:
|
||||
|
||||
|
||||
void setNumber(int value);
|
||||
void setElevation(float value);
|
||||
void setAltitude(float value);
|
||||
|
||||
void RefreshPos();
|
||||
void setOpacitySlot(qreal opacity);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
} //NAME SPACE
|
||||
#endif // ALTITUDEITEM_H
|
||||
|
||||
@@ -79,8 +79,7 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
|
||||
|
||||
|
||||
|
||||
altitudeitem = new AltitudeItem(map,Qt::red);
|
||||
altitudeitem->setParentItem(map);
|
||||
|
||||
setOverlayOpacity(overlayOpacity);
|
||||
|
||||
|
||||
@@ -407,6 +406,14 @@ void OPMapWidget::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
|
||||
WPLineCreate(WPFind(Item->Number() - 1),Item,Qt::green,false,2);
|
||||
|
||||
|
||||
AltitudeItem *AltItem = new AltitudeItem(map,Qt::red);
|
||||
AltItem->setParentItem(map);
|
||||
|
||||
AltItem->setNumber(Item->Number());
|
||||
|
||||
AltItem->setPos(Item->Number() * 20,this->height() - AltItem->boundingRect().height());
|
||||
|
||||
qDebug() << "WPCreate Point"
|
||||
<< QThread::currentThreadId();
|
||||
}
|
||||
|
||||
@@ -457,6 +457,8 @@ protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
// private slots:
|
||||
signals:
|
||||
void showMessage(const QString &message,int TimeOut = 0);
|
||||
|
||||
//map property
|
||||
void MapTypes(QStringList list);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user