3500/WaveDisplay.cpp

693 lines
23 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "WaveDisplay.h"
#include "ui_WaveDisplay.h"
#include "NetMgr.h"
#include <QNetworkRequest>
#include <QListView>
#include "log.h"
CWaveDisPlay::CWaveDisPlay(QWidget *parent) :
QWidget(parent),
ui(new Ui::CWaveDisPlay)
{
ui->setupUi(this);
m_ChannelID = "";
m_PackgNum = 1;
bFlag = false;
m_Times = 0;
m_Count = 0;
OneSecond = true;
ui->widget->setProperty("flag", "Title");
ui->widget_4->setProperty("flag", "normal");
ui->widget_wave->plotLayout()->insertRow(0);
QString strTitle = QString("1倍频频率 %1Hz1倍频幅值 %2相位角 %3").arg(0).arg(0).arg(0);
customLogMessageHandler(QtDebugMsg,strTitle);
m_title = new QCPTextElement(ui->widget_wave, strTitle);
ui->widget_wave->plotLayout()->addElement(0, 0, m_title);
// QAbstractItemView* view = ui->comboBox_channel_2->view();
// QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect;
// effect->setBlurRadius(6);
// effect->setColor(Qt::black);
// effect->setOffset(0, 0);
// view->setGraphicsEffect(effect);
// view->update();
// static_cast<QWidget*>(view->parent())
// ->setStyleSheet(
// "QWidget{border:none;background-color: rgb(255, 255, 255);}");
// QWidget* container = static_cast<QWidget*>(view->parent());
// container->setAttribute(Qt::WA_TranslucentBackground);
// container->setWindowFlag(Qt::FramelessWindowHint);
// container->setWindowFlag(Qt::NoDropShadowWindowHint);
InitWindows();
}
CWaveDisPlay::~CWaveDisPlay()
{
delete ui;
}
void CWaveDisPlay::InitWindows()
{
m_pNetMgr = new NetMgr(this);
ui->Btn_Timewave->setStyleSheet(" QPushButton{ border-image:url(:/image/Btn/timewave.png) 5; }\
QPushButton:hover{ border-image:url(:/image/Btn/timewave-p.png) 5; }\
QPushButton:pressed{border-image:url(:/image/Btn/timewave-p.png) 5; }\
QPushButton:checked{border-image:url(:/image/Btn/timewave-p.png) 5; } " );
ui->Btn_Timewave->setChecked(true);
ui->pushButton_1S->setStyleSheet(" QPushButton{ border-image:url(:/image/Btn/normal_Btn.png); color:#1f5188 }\
QPushButton:hover{ border-image:url(:/image/Btn/normal_Btn_p.png); color:#ffffff }\
QPushButton:pressed{border-image:url(:/image/Btn/normal_Btn_p.png); color:#ffffff }\
QPushButton:checked{border-image:url(:/image/Btn/normal_Btn_p.png); color:#ffffff } " );
ui->pushButton_1S->setChecked(true);
//绑定HTTP消息响应
connect(m_pNetMgr,SIGNAL(sigNetMgr(QString, const QVariant&)), this, SLOT(slotNetMgr(QString,const QVariant&)));
on_comboBox_channel_2_currentTextChanged("");
tracer = new QCPItemTracer(ui->widget_wave);
tracer->setStyle(QCPItemTracer::tsCrosshair);
tracer->setPen(QPen(Qt::red));
tracer->setBrush(Qt::red);
tracer->setSize(6);
tracer->setVisible(false);
tracer->setInterpolating(false);
QFont font;
font.setPixelSize(20);
tracerLabel = new QCPItemText(ui->widget_wave);
tracerLabel->setLayer("overlay");
tracerLabel->setPen(QPen(Qt::white));
tracerLabel->setBrush(QColor(64, 156, 225));
tracerLabel->setPadding(QMargins(2,2,2,2));//边界宽度
tracerLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignLeft);//文字布局:顶、左对齐
tracerLabel->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位)
tracerLabel->position->setCoords(0, 0);
tracerLabel->setFont(font);
tracerLabel->setText("");
ui->comboBox_channel_2->clear();
ui->comboBox_channel_2->addItem("请选择通道...");
for (int i = 0; i < g_ChannelBaseInfo.size(); i++) {
ui->comboBox_channel_2->addItem(g_ChannelBaseInfo[i].channelName);
}
ui->comboBox_channel_2->setView(new QListView());
ui->comboBox_channel_2->setCurrentText("请选择通道...");
Cursor();
}
void CWaveDisPlay::on_Btn_Hand_clicked()
{
ui->widget_wave->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
if(ui->Btn_Hand->isChecked()){
//交互设置
ui->widget_wave->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iMultiSelect);
ui->Btn_Zoom->setChecked(false);
}else if(!ui->Btn_Hand->isChecked()){
ui->widget_wave->setInteractions(QCP::iNone);
}
}
void CWaveDisPlay::on_Btn_Zoom_clicked()
{
if(ui->Btn_Zoom->isChecked()){
ui->Btn_Hand->setChecked(false);
ui->widget_wave->setSelectionRectMode(QCP::SelectionRectMode::srmZoom);
ui->widget_wave->selectionRect()->setPen(QPen(Qt::black,1,Qt::DashLine));//虚线
ui->widget_wave->selectionRect()->setBrush(QBrush(QColor(255, 222, 173,50)));//NavajoWhite
}
else if(!ui->Btn_Zoom->isChecked()){
ui->widget_wave->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
}
}
void CWaveDisPlay::on_Btn_Scales_clicked()
{
ui->widget_wave->setSelectionRectMode(QCP::SelectionRectMode::srmNone);
ui->widget_wave->rescaleAxes(true);
ui->widget_wave->replot();
}
void CWaveDisPlay::on_comboBox_channel_currentTextChanged(const QString &arg1)
{
}
void CWaveDisPlay::ParseDataTimeWave(QJsonObject & objContent)
{
int packageMax = objContent["packageMax"].toInt();
int package = objContent["package"].toInt();
if(packageMax > 1 && m_PackgNum < packageMax /*&& package + 1 <= packageMax*/ && !bFlag ){
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "30");
cmdBody.insert("package",m_PackgNum);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
m_PackgNum += 1;
}
QString data = objContent["Data"].toString();
if(package + 1 == packageMax){
// if(!OneSecond){
// m_Count ++;
// m_WaveData = m_WaveData + data ;
// qDebug() << "4S" <<"package" <<package << "packageMax" <<packageMax << endl;
// m_PackgNum = 1;
// QStringList waveData;
// waveData = m_WaveData.split(",");
// m_ListWaveData.append(waveData);
// if(m_Count == 4){
// ui->widget_wave->xAxis->setRange(0, 4);
// ui->widget_wave->xAxis->setLabel("Time(s)");
// double gap = (double)4/(double)m_ListWaveData.size();
// QVector<double> x,y;
// double f = 0.0;
// QCPGraph* graph = ui->widget_wave->addGraph(ui->widget_wave->xAxis, ui->widget_wave->yAxis);
// for(int i = 0; i < m_ListWaveData.size();i++){
// x.push_back(f);
// y.push_back(m_ListWaveData[i].toDouble());
// f += gap;
// }
// qDebug() << "x" <<x.size() << "y" << y.size() << endl;
// graph->setData(x,y);
// ui->widget_wave->xAxis->setRange(0, 1);
// on_Btn_Scales_clicked();
// ui->widget_wave->replot();
// m_ListWaveData.clear();
// m_Count = 0;
// }
// m_WaveData = "";
// }else
{
m_WaveData = m_WaveData + data;
qDebug() << "package" <<package << "packageMax" <<packageMax << endl;
m_PackgNum = 1;
bFlag = true;
m_ListWaveData = m_WaveData.split(",");
ui->widget_wave->xAxis->setLabel("Time(s)");
QString str = QString("wave size = %1").arg(m_ListWaveData.size());
customLogMessageHandler(QtDebugMsg,str);
double gap = 0.0;
if(OneSecond){
ui->widget_wave->xAxis->setRange(0, 1);
gap = (double)1/(double)m_ListWaveData.size();
}else{
ui->widget_wave->xAxis->setRange(0, 4);
gap = (double)4/(double)m_ListWaveData.size();
}
double f = 0.0;
QVector<double> x,y,x2,y2;
QCPGraph* graph = ui->widget_wave->addGraph(ui->widget_wave->xAxis, ui->widget_wave->yAxis);
for(int i = 0; i < m_ListWaveData.size();i++){
x.push_back(f);
y.push_back(m_ListWaveData[i].toDouble());
f += gap;
}
QVector<double>::iterator max = std::max_element(std::begin(y), std::end(y));
double biggest = *max;
qDebug() << "x" << x.size() << "y" << y.size() << endl;
graph->setData(x,y);
ui->widget_wave->yAxis->setRange(-1,biggest+2);
on_Btn_Scales_clicked();
ui->widget_wave->replot();
}
if(ui->pushButton_1S->isChecked() && (m_ChannelType == "TACHOMETER" || (m_speedRefChannelId != "" && m_speedRefChannelId != "- -"))){
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "92");//获取键相
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
//ui->widget_wave->plotLayout()->clear();
//
}
}else{
m_WaveData = m_WaveData + data + ",";
}
}
void CWaveDisPlay::ParseDataFsWave(QJsonObject & objContent)
{
int packageMax = objContent["packageMax"].toInt();
int package = objContent["package"].toInt();
if(packageMax > 1 && m_PackgNum < packageMax && package + 1 <= packageMax && !bFlag ){
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "32");
cmdBody.insert("package",m_PackgNum);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
m_PackgNum += 1;
}
QString data = objContent["Data"].toString();
qDebug() << data << endl;
m_WaveData = m_WaveData + data + ",";
if(m_PackgNum == packageMax){
m_PackgNum = 1;
bFlag = true;
m_ListWaveData = m_WaveData.split(",");
//qDebug() << m_ListWaveData << endl;
ui->widget_wave->xAxis->setRange(0, 1);
ui->widget_wave->xAxis->setLabel("Fs(Hz)");
//ui->widget_wave->yAxis->setLabel("um");
QVector<double> x,y;
QCPGraph* graph = ui->widget_wave->addGraph(ui->widget_wave->xAxis, ui->widget_wave->yAxis);
float gap = 0;
for(int i = 0; i < m_ListWaveData.size();i++){
x.push_back(gap);
y.push_back(m_ListWaveData[i].toDouble());
if(g_strFre == "1")
gap += 1;
else if(g_strFre == "0.25")
gap += 0.25;
}
y[0] = 0;
//qDebug() << "x" <<x.size() << "y" << y.size() << endl;
graph->setData(x,y);
ui->widget_wave->xAxis->setRange(0, y.size());
on_Btn_Scales_clicked();
ui->widget_wave->replot();
}
}
void CWaveDisPlay::ParseDataKeyPhase(QJsonObject& objContent)
{
m_ListKeyPhaseData.clear();
ui->widget_wave->plotLayout()->remove(m_title);
m_title = NULL;
QString data = objContent["Data"].toString();
double PhaseAngle = objContent["PhaseAngle"].toDouble();
double amp1x = objContent["1xamp"].toDouble();
double freq1x = objContent["1xfreq"].toDouble();
m_ListKeyPhaseData = data.split(",");
qDebug() << "m_ListKeyPhaseData" << m_ListKeyPhaseData << endl;
QString strTitle = QString("1倍频频率 %1Hz1倍频幅值 %2相位角 %3").arg(freq1x).arg(amp1x).arg(PhaseAngle);
customLogMessageHandler(QtDebugMsg,strTitle);
m_title = new QCPTextElement(ui->widget_wave, strTitle);
ui->widget_wave->plotLayout()->addElement(0, 0, m_title);
QVector<double> x,y,x2,y2;
double f = 0;
double gap = (double)1/(double)m_ListWaveData.size();
for(int i = 0; i < m_ListWaveData.size();i++){
for(int j = 0; j < m_ListKeyPhaseData.size();j++){
if(m_ListKeyPhaseData[j].toInt() == i){
x2.push_back(f);
y2.push_back(m_ListWaveData[i].toDouble());
}
}
f += gap;
}
QCPGraph* dwPoints = new QCPGraph(ui->widget_wave->xAxis, ui->widget_wave->yAxis);
dwPoints->setAdaptiveSampling(false);
dwPoints->setLineStyle(QCPGraph::lsNone);
dwPoints->setScatterStyle(QCPScatterStyle::ssDot);
dwPoints->setPen(QPen(QBrush(Qt::red), 5));
dwPoints->addData(x2, y2);
ui->widget_wave->replot();
}
void CWaveDisPlay::slotNetMgr(QString sAddr, const QVariant &msg)
{
QJsonObject objec = msg.value<QJsonObject>();
if(!objec["success"].toBool()){
QString strMessage = objec["message"].toString();
if(strMessage.isEmpty())
QMessageBox::information(this, QStringLiteral("提示"), "连接失败!");
else
QMessageBox::information(this, QStringLiteral("提示"), strMessage);
return;
}
if(objec.contains("cmd"))
{
QJsonValue arrays_value = objec.take("cmd");
qDebug()<<"cmd ="<<arrays_value.toString();
if(arrays_value.toString() == "30" || arrays_value.toString() == "89"){
QJsonObject objValue = objec["content"].toObject();
ParseDataTimeWave(objValue);
}else if(arrays_value.toString() == "32"){
QJsonObject objValue = objec["content"].toObject();
ParseDataFsWave(objValue);
}else if(arrays_value.toString() == "92"){
QJsonObject objValue = objec["content"].toObject();
ParseDataKeyPhase(objValue);
}
}
}
void CWaveDisPlay::InitGraph()
{
m_PackgNum = 1;
bFlag = false;
ui->widget_wave->clearGraphs();
ui->widget_wave->clearPlottables();
ui->widget_wave->replot();
m_WaveData = "";
m_ListWaveData.clear();
}
void CWaveDisPlay::on_Btn_Timewave_clicked()
{
ui->Btn_Fswave->setChecked(false);
if(!ui->Btn_Timewave->isChecked()){
InitGraph();
return;
}
InitGraph();
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "30");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}
void CWaveDisPlay::on_Btn_Fswave_clicked()
{
if(ui->pushButton_4S->isChecked()){
QMessageBox::information(this, QStringLiteral("提示"), "请切换到1S波形");
ui->Btn_Fswave->setChecked(false);
return;
}
ui->Btn_Timewave->setChecked(false);
if(!ui->Btn_Fswave->isChecked()){
InitGraph();
return;
}
InitGraph();
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "32");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}
void CWaveDisPlay::mouseMoveEvent(QMouseEvent *event)
{
tracer->setVisible(true);
tracerLabel->setVisible(true);
//将像素点转换成qcustomplot中的坐标值并通过setGraphKey将锚点值设为真实数据值。tracer->setGraphKey(xAxis->pixelToCoord(event->pos().x()));
int graphCount = ui->widget_wave->graphCount();
if(graphCount < 1)
return;
//获得鼠标位置处对应的横坐标数据x
double x = ui->widget_wave->xAxis->pixelToCoord(event->pos().x());
//遍历曲线
//for (int i = 0; i < graphCount && tracer->visible(); ++i)
{
//显示锚点
QCPGraph *mGraph = ui->widget_wave->graph(0);
tracer->setGraph(mGraph);//将锚点设置到被选中的曲线上
tracer->setGraphKey(x); //将游标横坐标设置成刚获得的横坐标数据x
tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效
double xValue = tracer->position->key();
double yValue = tracer->position->value();
tracerLabel->setVisible(true);
tracerLabel->setText(QString("X: %1 Y: %2").arg( QString::number(xValue)).arg(QString::number(yValue)));
//显示tip框
QCPDataContainer<QCPGraphData>::const_iterator coorPoint = ui->widget_wave->graph(0)->data().data()->findBegin(xValue, true);//true代表向左搜索
}
//重绘
ui->widget_wave->replot();
}
void CWaveDisPlay::Cursor()
{
tracer->setVisible(false);
tracerLabel->setVisible(false);
connect(ui->widget_wave, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*)));
ui->widget_wave->replot();
}
void CWaveDisPlay::on_pushButton_refresh_clicked()
{
// ui->comboBox_channel_2->clear();
// ui->comboBox_channel_2->addItem("请选择通道...");
// for (int i = 0; i < g_ChannelBaseInfo.size(); i++) {
// ui->comboBox_channel_2->addItem(g_ChannelBaseInfo[i].channelName);
// }
// ui->comboBox_channel_2->setView(new QListView());
// //ui->comboBox_channel_2->setCurrentText("请选择通道...");
on_comboBox_channel_2_currentTextChanged("");
}
void CWaveDisPlay::on_comboBox_channel_2_currentTextChanged(const QString &arg1)
{
if(ui->comboBox_channel_2->count() < 1)
return;
m_PackgNum = 1;
bFlag = false;
ui->widget_wave->clearGraphs();
ui->widget_wave->clearPlottables();
ui->widget_wave->replot();
m_WaveData = "";
m_ListWaveData.clear();
QString strChannelName = ui->comboBox_channel_2->currentText();
if(strChannelName == "请选择通道..."){
return;
}
int i = 0;
for (i = 0; i < g_ChannelBaseInfo.size(); i++) {
if(strChannelName == g_ChannelBaseInfo[i].channelName){
break;
}
}
m_ChannelID = g_ChannelBaseInfo[i].channelID;
m_ChannelType = g_ChannelBaseInfo[i].channelType;
m_speedRefChannelId = g_ChannelBaseInfo[i].speedRefChannelId;
if(ui->Btn_Timewave->isChecked())
{
m_Times = 0;
if(ui->pushButton_4S->isChecked()){
OneSecond = false;
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "89");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}else if(ui->pushButton_1S->isChecked()){
OneSecond = true;
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "30");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
QString str = QString("当前通道 %1,通道类型 %2转速参考通道 %3").arg(m_ChannelID).arg(m_ChannelType).arg(m_speedRefChannelId);
customLogMessageHandler(QtDebugMsg,str);
}
}
else if(ui->Btn_Fswave->isChecked())
{
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "32");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}
}
void CWaveDisPlay::timerEvent(QTimerEvent *ev)
{
if(ev->timerId() == id1)
{
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "30");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
m_Times = m_Times + 1;
qDebug() << "m_Times" << m_Times << endl;
if(m_Times == 4){
killTimer(id1);
m_Times = 0;
}
}
if(ev->timerId() == id2){
m_PackgNum = 1;
bFlag = false;
ui->widget_wave->clearGraphs();
ui->widget_wave->clearPlottables();
ui->widget_wave->replot();
m_WaveData = "";
m_ListWaveData.clear();
if(ui->Btn_Timewave->isChecked()){
OneSecond = true;
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "30");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}else if(ui->Btn_Fswave->isChecked())
{
QJsonObject allObj,cmdBody;
allObj.insert("cmd", "32");
cmdBody.insert("package",0);
cmdBody.insert("channelId",m_ChannelID);
allObj["cmdBody"] = cmdBody;
QNetworkRequest req;
QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
req.setUrl(sUrl);
m_pNetMgr->PostJson(req,allObj);
}
}
}
void CWaveDisPlay::on_pushButton_1S_clicked()
{
OneSecond = true;
ui->pushButton_4S->setChecked(false);
if(ui->pushButton_1S->isChecked()){
on_comboBox_channel_2_currentTextChanged("");
return;
}
}
void CWaveDisPlay::on_pushButton_4S_clicked()
{
if(ui->Btn_Fswave->isChecked()){
QMessageBox::information(this, QStringLiteral("提示"), "请切换到时域图!");
ui->pushButton_4S->setChecked(false);
return;
}
OneSecond = false;
m_Times = 0;
ui->pushButton_1S->setChecked(false);
if(ui->pushButton_4S->isChecked()){
on_comboBox_channel_2_currentTextChanged("");
return;
}
}
void CWaveDisPlay::on_pushButton_refreshauto_clicked()
{
if(ui->comboBox_channel_2->count() < 1)
return;
m_PackgNum = 1;
bFlag = false;
ui->widget_wave->clearGraphs();
ui->widget_wave->clearPlottables();
ui->widget_wave->replot();
m_WaveData = "";
m_ListWaveData.clear();
QString strChannelName = ui->comboBox_channel_2->currentText();
if(strChannelName == "请选择通道..."){
return;
}
if(ui->pushButton_4S->isChecked()){
QMessageBox::information(this, QStringLiteral("提示"), "请切换到1秒时域图");
ui->pushButton_refreshauto->setChecked(false);
return;
}
if(ui->pushButton_refreshauto->isChecked()){
ui->pushButton_refreshauto->setText("关闭");
id2 = startTimer(2000); //参数1 间隔 单位 毫秒
//定时器第二种方式
QTimer * timer = new QTimer(this);
//启动定时器
timer->start(500);
}
if(!ui->pushButton_refreshauto->isChecked() && ui->pushButton_1S->isChecked()){
ui->pushButton_refreshauto->setText("自动刷新");
killTimer(id2);
return;
}
}