This commit is contained in:
2020-08-01 10:53:17 +08:00
parent ffc8207491
commit cfa905548a
14 changed files with 294 additions and 134 deletions
+47 -15
View File
@@ -9,6 +9,16 @@ Scope::Scope(QWidget *parent) :
{
ui->setupUi(this);
//load qss
QFile file(":/qss/Scope.qss");
file.open(QFile::ReadOnly);
QTextStream filetext(&file);
QString stylesheet = filetext.readAll();
this->setStyleSheet(stylesheet);
file.close();
timeseries = 0;
chartView = new QChartView(this);
@@ -16,6 +26,7 @@ Scope::Scope(QWidget *parent) :
chartView->chart()->legend()->setAlignment(Qt::AlignRight);
chartView->chart()->legend()->setMarkerShape(QLegend::MarkerShapeCircle);
chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean);
//chartView->setMouseTracking(true);
//chartView->setRubberBand(QChartView::RectangleRubberBand);
//chartView->chart()->setAcceptDrops(true);
@@ -30,13 +41,16 @@ Scope::Scope(QWidget *parent) :
chartView->chart()->addAxis(axisX, Qt::AlignBottom);
QValueAxis *axisY = new QValueAxis();
axisY->setRange(-10, 10);
axisY->setTickCount(11);
axisY->setRange(-3, 3);
axisY->setTickCount(7);
axisY->setLabelFormat("%.2f");
chartView->chart()->addAxis(axisY, Qt::AlignLeft);
chartView->setGeometry(ui->frame->geometry());
//默认不使用,因为使用显卡加速图形会闪
setUseOpenGL(false);
QTimer::singleShot(10,this,SLOT(timeout()));
@@ -163,26 +177,26 @@ void Scope::chartUpdate(void)
{
//读取新数据,如果没有,那就保持
setSerieData("sin",sin(timeseries));
setSerieData("cos",cos(timeseries));
setSerieData("tan",tan(timeseries));
//setSerieData("sin",sin(timeseries));
//setSerieData("cos",cos(timeseries));
//setSerieData("tan",tan(timeseries));
//setSerieData("acos",acos(timeseries));
//setSerieData("asin",asin(timeseries));
//setSerieData("atan",atan(timeseries));
setSerieData("x1",1 * timeseries + 1);
setSerieData("x2",timeseries * timeseries + 1);
setSerieData("x3",timeseries * timeseries * timeseries + 1);
setSerieData("sqrt",sqrt(timeseries));
//setSerieData("x1",1 * timeseries + 1);
//setSerieData("x2",timeseries * timeseries + 1);
//setSerieData("x3",timeseries * timeseries * timeseries + 1);
//setSerieData("sqrt",sqrt(timeseries));
//setSerieData("pow",pow(timeseries,2));
//setSerieData("log",log(timeseries + 1));
//setSerieData("log10",log10(timeseries));
//setSerieData("exp",exp(timeseries));
setSerieData("tan+1",tan(timeseries + 1));
//setSerieData("tan+1",tan(timeseries + 1));
//setSerieData("log2",log2(timeseries));
setSerieData("timeseries",timeseries);
setSerieData("12",timeseries * log(timeseries));
//setSerieData("timeseries",timeseries);
//setSerieData("12",timeseries * log(timeseries));
//滚动显示器
//当到达最大时(0.95),开始滚动
@@ -200,6 +214,12 @@ void Scope::chartUpdate(void)
}
void Scope::setUseOpenGL(const bool &value)
{
isOpenGL= value;
}
bool Scope::addSeries(QString name = tr("new"))
{
//查找有没有这个名字的序列
@@ -219,7 +239,7 @@ bool Scope::addSeries(QString name = tr("new"))
s->setColor(ColorMap::Color[ChannelIndex]);
s->setName(name);
s->append(timeseries,0);
s->setUseOpenGL(true);
s->setUseOpenGL(isOpenGL);
chartView->chart()->addSeries(s);
chartView->chart()->setAxisX(chartView->chart()->axisX(),s);
chartView->chart()->setAxisY(chartView->chart()->axisY(),s);
@@ -262,7 +282,7 @@ bool Scope::addSeries(QString name = tr("new"), int index = 0)
s->setColor(ColorMap::Color[ChannelIndex]);
s->setName(name);
s->append(timeseries,0);
//s->setUseOpenGL(true);
s->setUseOpenGL(isOpenGL);
chartView->chart()->addSeries(s);
chartView->chart()->setAxisX(chartView->chart()->axisX(),s);
chartView->chart()->setAxisY(chartView->chart()->axisY(),s);
@@ -299,7 +319,7 @@ bool Scope::addSeries(QString name = tr("new"),QColor color = QColor("#FFFFFF"))
s->setColor(color);
s->setName(name);
s->append(timeseries,0);
s->setUseOpenGL(true);
s->setUseOpenGL(isOpenGL);
chartView->chart()->addSeries(s);
chartView->chart()->setAxisX(chartView->chart()->axisX(),s);
chartView->chart()->setAxisY(chartView->chart()->axisY(),s);
@@ -398,6 +418,8 @@ void Scope::on_pushButton_Clear_clicked()
}
}
emit clearall();
}
void Scope::on_pushButton_Flag1_clicked()
@@ -409,3 +431,13 @@ void Scope::on_pushButton_Flag2_clicked()
{
}
void Scope::on_pushButton_Close_clicked()
{
delete ui;
emit willcloase();
this->deleteLater();
this->close();
}
+9
View File
@@ -67,7 +67,13 @@ protected:
void wheelEvent(QWheelEvent *e);
void resizeEvent(QResizeEvent *e);
signals:
void clearall(void);
void willcloase(void);
public slots:
void setUseOpenGL(const bool &value);
bool addSeries(QString name);
bool addSeries(QString name,int index);
bool addSeries(QString name, QColor color);
@@ -88,6 +94,8 @@ private slots:
void on_pushButton_Flag2_clicked();
void on_pushButton_Close_clicked();
private:
Ui::Scope *ui;
@@ -96,6 +104,7 @@ private:
qreal timeseries = 0;//时间基准,注意时间长度,可能会出现时间反转的情况
bool isOpenGL = false;
bool isScroll = true;
bool isPress = false;
+4 -17
View File
@@ -1,23 +1,10 @@
QListWidget {
background-color: #F0FFFF;
border-width: 2px;
border-color: darkkhaki;
border-style: solid;
border-radius: 5;
padding: 3px;
font: 20px;
.QWidget {
background-color: #FFFFFF;
}
QListWidget::Item {
height: 60;
}
QScrollBar{
width:60;
background-color:palegoldenrod;
QFrame {
background-color: #FFFFFF;
}
.QPushButton {
+110 -64
View File
@@ -14,47 +14,46 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton_Pause">
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Pause</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Clear">
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_Flag1">
<property name="minimumSize">
<size>
@@ -73,7 +72,64 @@
</property>
</widget>
</item>
<item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_Pause">
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Pause</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="pushButton_Close">
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_Clear">
<property name="minimumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_Flag2">
<property name="minimumSize">
<size>
@@ -92,31 +148,21 @@
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>72</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="1">
<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="0" column="0" rowspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
BIN
View File
Binary file not shown.
+36 -9
View File
@@ -4,14 +4,12 @@
<context>
<name>About</name>
<message>
<location filename="About/About.ui" line="16"/>
<source>Form</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="About/About.cpp" line="9"/>
<source>About</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
</context>
<context>
@@ -623,14 +621,12 @@
<context>
<name>Help</name>
<message>
<location filename="Help/Help.ui" line="16"/>
<source>Form</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
<message>
<location filename="Help/Help.cpp" line="9"/>
<source>Help</source>
<translation></translation>
<translation type="vanished"></translation>
</message>
</context>
<context>
@@ -874,7 +870,7 @@
</message>
<message>
<location filename="ToolsUI/tools_Index0/MAVLinkInspector/MAVLinkInspector.cc" line="68"/>
<location filename="ToolsUI/tools_Index0/MAVLinkInspector/MAVLinkInspector.cc" line="309"/>
<location filename="ToolsUI/tools_Index0/MAVLinkInspector/MAVLinkInspector.cc" line="311"/>
<source>Vehicle %1</source>
<translation> %1</translation>
</message>
@@ -1183,6 +1179,37 @@
<source>Form</source>
<translation></translation>
</message>
<message>
<location filename="ComponentUI/Scope/Scope.ui" line="52"/>
<location filename="ComponentUI/Scope/Scope.cpp" line="387"/>
<source>Pause</source>
<translation></translation>
</message>
<message>
<location filename="ComponentUI/Scope/Scope.ui" line="71"/>
<source>Clear</source>
<translation></translation>
</message>
<message>
<location filename="ComponentUI/Scope/Scope.ui" line="90"/>
<source>Flag1</source>
<translation>1</translation>
</message>
<message>
<location filename="ComponentUI/Scope/Scope.ui" line="109"/>
<source>Flag2</source>
<translation>2</translation>
</message>
<message>
<location filename="ComponentUI/Scope/Scope.ui" line="128"/>
<source>Close</source>
<translation></translation>
</message>
<message>
<location filename="ComponentUI/Scope/Scope.cpp" line="383"/>
<source>Scroll</source>
<translation></translation>
</message>
</context>
<context>
<name>Selector</name>
@@ -105,10 +105,10 @@ void ConnectDialog::setInit(QVariant inter, QVariant device)
}
else if(m_Type.toString() == tr("UDP"))
{
m_Param1 = tr("192.168.0.1");
m_Param2 = tr("6060");
m_Param3 = tr("192.168.0.1");
m_Param4 = tr("6061");
m_Param1 = tr("127.0.0.1");
m_Param2 = tr("6061");
m_Param3 = tr("127.0.0.1");
m_Param4 = tr("6060");
}
}
@@ -109,10 +109,48 @@ void MAVLinkInspector::rebuildComponentList()
void MAVLinkInspector::on_pushButton_system_clicked()
{
if(ui->pushButton_system->text().size())
{
ui->pushButton_system->hide();
ui->clearButton->hide();
}
if(!scope)
{
scope = new Scope(this);
connect(scope,SIGNAL(willcloase()),
this,SLOT(ScopeClose()));
connect(scope,SIGNAL(clearall()),
this,SLOT(ScopeClearall()));
ui->gridLayout->addWidget(scope,0,0,1,1);
scope->show();
}
}
void MAVLinkInspector::ScopeClose(void)//可能有点问题
{
//qDebug() << "cloase";
//ui->gridLayout->addWidget(scope,0,0,1,1);
//qDebug() << ui->gridLayout->children();
//ui->gridLayout->removeWidget();
ui->pushButton_system->show();
ui->clearButton->show();
}
void MAVLinkInspector::ScopeClearall(void)
{
clearView();
//qDebug() << "ScopeClearall";
}
@@ -274,8 +312,8 @@ void MAVLinkInspector::refreshView()
for (unsigned int i = 0; i < msgInfo->num_fields; ++i)
{
QTreeWidgetItem* field = new QTreeWidgetItem();
field->setCheckState(0,Qt::PartiallyChecked);
widget->setCheckState(0,Qt::PartiallyChecked);
field->setCheckState(0,Qt::Unchecked);
//widget->setCheckState(0,Qt::PartiallyChecked);
widget->addChild(field);
}
msgTreeItems->insert(msg->msgid,widget);
@@ -715,6 +753,12 @@ void MAVLinkInspector::updateField(mavlink_message_t* msg, const mavlink_message
}
break;
}
if(item->checkState(0) == Qt::Checked)
{
scope->setSerieData(item->data(0,Qt::DisplayRole).toString(),item->data(1,Qt::DisplayRole).toFloat());
}
}
@@ -759,8 +803,11 @@ void MAVLinkInspector::on_treeWidget_itemChanged(QTreeWidgetItem *item, int colu
}
else
{
updateParentItem(item);
//updateParentItem(item);
}
}
else if (item->checkState(0) == Qt::Unchecked)
{
@@ -774,7 +821,7 @@ void MAVLinkInspector::on_treeWidget_itemChanged(QTreeWidgetItem *item, int colu
}
else
{
updateParentItem(item);
//updateParentItem(item);
}
}
}
@@ -11,7 +11,7 @@
#include "mavlink.h"
#include "mavlink_get_info.h"
#include "Scope.h"
#ifdef QtMavlinkInspector
#include <mavlinkinspectorglobal.h>
@@ -83,6 +83,10 @@ protected:
static const float updateHzLowpass; ///< The low-pass filter value for the frequency of each message
private slots:
void ScopeClose(void);
void ScopeClearall(void);
void _vehicleAdded(quint32 id);
void on_pushButton_system_clicked();
@@ -96,6 +100,7 @@ private slots:
private:
Ui::MAVLinkInspector *ui;
Scope *scope = nullptr;
};
#endif // QGCMAVLINKINSPECTOR_H
@@ -26,20 +26,20 @@
<property name="bottomMargin">
<number>6</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="clearButton">
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_system">
<property name="minimumSize">
<size>
<width>120</width>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="text">
<string>Clear</string>
<string/>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<widget class="QTreeWidget" name="treeWidget">
<property name="headerHidden">
<bool>true</bool>
@@ -64,16 +64,16 @@
</column>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_system">
<item row="0" column="1">
<widget class="QPushButton" name="clearButton">
<property name="minimumSize">
<size>
<width>0</width>
<width>120</width>
<height>60</height>
</size>
</property>
<property name="text">
<string/>
<string>Clear</string>
</property>
</widget>
</item>
+6 -1
View File
@@ -19,7 +19,9 @@ Tools_Index0::Tools_Index0(QWidget *parent) :
mavlinkinspector->setParent(this);
mavlinkinspector->show();
//scope = new Scope(this);
//scope->setGeometry(ui->frame->geometry());
//scope->show();
}
@@ -36,6 +38,9 @@ void Tools_Index0::resizeEvent(QResizeEvent *event)
{
mavlinkinspector->setGeometry(0,0,ui->frame->width(),ui->frame->height());
}
update();
}
+3 -1
View File
@@ -9,6 +9,8 @@
#include "MAVLinkInspector.h"
//#include "Scope.h"
namespace Ui {
class Tools_Index0;
}
@@ -40,7 +42,7 @@ private:
Ui::Tools_Index0 *ui;
QWidget *Inspect = nullptr;
//Scope *scope = nullptr;
};
+4 -4
View File
@@ -16,9 +16,9 @@ Tools_Index1::Tools_Index1(QWidget *parent) :
file.close();
scope = new Scope(this);
scope->setGeometry(ui->frame->geometry());
scope->show();
//scope = new Scope(this);
//scope->setGeometry(ui->frame->geometry());
//scope->show();
}
Tools_Index1::~Tools_Index1()
@@ -29,7 +29,7 @@ Tools_Index1::~Tools_Index1()
void Tools_Index1::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event)
scope->setGeometry(ui->frame->geometry());
//scope->setGeometry(ui->frame->geometry());
update();
}
+2 -2
View File
@@ -6,7 +6,7 @@
#include "QTextStream"
#include "QDebug"
#include "Scope.h"
//#include "Scope.h"
namespace Ui {
@@ -26,7 +26,7 @@ public:
private:
Ui::Tools_Index1 *ui;
Scope *scope = nullptr;
//Scope *scope = nullptr;
};
#endif // INDEX1_H