diff --git a/ChaosDataPlayer/Adddeviceform.ui b/ChaosDataPlayer/Adddeviceform.ui index bc1d717..6279a34 100644 --- a/ChaosDataPlayer/Adddeviceform.ui +++ b/ChaosDataPlayer/Adddeviceform.ui @@ -95,6 +95,9 @@ text-align:center; 31 + + 查找 + background-image: url(:/images/images/imgModelAction/Search.png); diff --git a/ChaosDataPlayer/BaseWgt.cpp b/ChaosDataPlayer/BaseWgt.cpp index 17e7a03..2a32b44 100644 --- a/ChaosDataPlayer/BaseWgt.cpp +++ b/ChaosDataPlayer/BaseWgt.cpp @@ -361,7 +361,7 @@ void BaseWgt::maximumBtnClickedSlot() this->setGeometry(m_screenRect); m_pMaxBtn->setProperty("maxState", true); - m_pMaxBtn->setToolTip("restore"); + m_pMaxBtn->setToolTip("最大化"); } else { diff --git a/ChaosDataPlayer/Calculation.cpp b/ChaosDataPlayer/Calculation.cpp index 3db04ba..1435f48 100644 --- a/ChaosDataPlayer/Calculation.cpp +++ b/ChaosDataPlayer/Calculation.cpp @@ -441,8 +441,8 @@ void Calculation::_Integration(QVector & vecData,QVector& retDat qDebug()<< imageshiftfft.size() << endl; for(int k = 1; k < realshiftfft.size()+1;k++){ - realvalue.push_back((realshiftfft.at(k-1)/(k*2*3.14))*1000 * 2);//单位转换mm/s,*1000 *2 精度损失 - imagevalue.push_back((imageshiftfft.at(k-1)/(k*2*3.14))*1000 * 2);//单位转换mm/s,*1000 + realvalue.push_back((realshiftfft.at(k-1)/(k*2*PI))*1000 * 2);//单位转换mm/s,*1000 *2 精度损失 + imagevalue.push_back((imageshiftfft.at(k-1)/(k*2*PI))*1000 * 2);//单位转换mm/s,*1000 } _iFFT(realvalue,imagevalue,retData); @@ -722,6 +722,51 @@ QVector Calculation::filter(QVector&x, QVector& coeff_b, void Calculation::ButterWorth(QVector&inData,double *FrequencyBands,QVector& outData) { int FiltOrd = 4; +// double s = inData.size(); +// double a = cos(M_PI*(FrequencyBands[0]+FrequencyBands[1])/s)/cos(M_PI*(FrequencyBands[0]-FrequencyBands[1])/s); +// double a2 = a*a; +// double b = tan(M_PI*(FrequencyBands[0]-FrequencyBands[1])/s); +// double b2 = b*b; +// double r; +// int n = FiltOrd/4; +// double *A = (double *)malloc(n*sizeof(double)); +// double *d1 = (double *)malloc(n*sizeof(double)); +// double *d2 = (double *)malloc(n*sizeof(double)); +// double *d3 = (double *)malloc(n*sizeof(double)); +// double *d4 = (double *)malloc(n*sizeof(double)); +// double *w0 = (double *)calloc(n, sizeof(double)); +// double *w1 = (double *)calloc(n, sizeof(double)); +// double *w2 = (double *)calloc(n, sizeof(double)); +// double *w3 = (double *)calloc(n, sizeof(double)); +// double *w4 = (double *)calloc(n, sizeof(double)); +// double x; + +// for(int i=0; i a,b; a = ComputeDenCoeffs(FiltOrd, FrequencyBands[0], FrequencyBands[1]); diff --git a/ChaosDataPlayer/Calculation.hpp b/ChaosDataPlayer/Calculation.hpp index b7f306b..a5e3bf4 100644 --- a/ChaosDataPlayer/Calculation.hpp +++ b/ChaosDataPlayer/Calculation.hpp @@ -95,7 +95,7 @@ public: QVector ComputeHP(int FilterOrder); //vector filter(int ord, vector a, vector b, int np, vector x); - //巴特沃斯滤波 + //巴特沃斯滤波(带通) QVector filter(QVector&x, QVector& coeff_b, QVector& coeff_a); void ButterWorth(QVector& inData,double *FrequencyBands,QVector& outData); diff --git a/ChaosDataPlayer/ChildForm.cpp b/ChaosDataPlayer/ChildForm.cpp index 2800712..090c982 100644 --- a/ChaosDataPlayer/ChildForm.cpp +++ b/ChaosDataPlayer/ChildForm.cpp @@ -35,14 +35,13 @@ #define CHANNELID_ROLE (Qt::UserRole + 2) #define CHANNELTYPE_ROLE (Qt::UserRole + 3) -ChildForm::ChildForm(FormType iType,QString m_strName,DEVICE_INFO* DeviceInfo,QWidget *parent) : +ChildForm::ChildForm(FormType iType,QString m_strName,DEVICE_INFO* DeviceInfo,int iCurCount,QWidget *parent) : BaseWgt(parent), ui(new Ui::ChildForm), m_pChartView(nullptr), m_iFormType(iType), m_bAttach(false), m_pLegendForm(nullptr), - m_iRealTimer(0), m_bDC(false), //m_client(nullptr), m_bRpm(false), @@ -55,9 +54,10 @@ ChildForm::ChildForm(FormType iType,QString m_strName,DEVICE_INFO* DeviceInfo,QW m_isPause(false), m_isStop(true) { - m_position = 0; + m_position = iCurCount; m_nStart = 0; m_nEnd = 0; + m_strFilter = ","; ui->setupUi(m_pMainWgt); SetFormType(iType); setWindowTitle(m_strName); @@ -75,8 +75,8 @@ ChildForm::ChildForm(FormType iType,QString m_strName,DEVICE_INFO* DeviceInfo,QW // connect(ui->measureBtn, SIGNAL(clicked()), this, SLOT(MeasureBtnSlot())); connect(ui->ChannelBtn, SIGNAL(clicked()), this, SLOT(ChannelBtnSlot())); //打开通道选择 - connect(ui->zoomBtn_hand, SIGNAL(clicked()), this, SLOT(ZoomBtnSlot_Hand())); - connect(ui->Btn_Zoom, SIGNAL(clicked()), this, SLOT(Btn_ZoomSlot())); + connect(ui->zoomBtn_hand, SIGNAL(clicked()), this, SLOT(ScalesBtnSlot_Hand())); + connect(ui->Btn_Zoom, SIGNAL(clicked()), this, SLOT(Btn_ScalesSlot())); connect(ui->Btn_setScales, SIGNAL(clicked()), this, SLOT(SetScales())); connect(ui->temBtn_4, SIGNAL(clicked()), this, SLOT(SetFilter())); connect(ui->Btn_AC_DC, SIGNAL(clicked()), this, SLOT(SetDC())); @@ -339,24 +339,27 @@ void ChildForm::InitIntegration() } void ChildForm::InitWidget() { - QMenu *ZoomMenu = new QMenu(); - ZoomMenu->setWindowFlags(ZoomMenu->windowFlags() | Qt::FramelessWindowHint); - QAction *Zoom_xy = new QAction(ZoomMenu); - QAction * Zoom_x= new QAction(ZoomMenu); - QAction *Zoom_y = new QAction(ZoomMenu); + ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); + ui->tableWidget->setDragEnabled(true); - ZoomMenu->addAction(Zoom_xy); - ZoomMenu->addAction(Zoom_x); - ZoomMenu->addAction(Zoom_y); + QMenu *ScalesMenu = new QMenu(); + ScalesMenu->setWindowFlags(ScalesMenu->windowFlags() | Qt::FramelessWindowHint); + QAction *Scales_xy = new QAction(ScalesMenu); + QAction * Scales_x= new QAction(ScalesMenu); + QAction *Scales_y = new QAction(ScalesMenu); - Zoom_xy->setIcon(QIcon(":/images/images/imgModelAction/Zoom_xy.png")); - Zoom_x->setIcon(QIcon(":/images/images/imgModelAction/axisX.png")); - Zoom_y->setIcon(QIcon(":/images/images/imgModelAction/axisY.png")); + ScalesMenu->addAction(Scales_xy); + ScalesMenu->addAction(Scales_x); + ScalesMenu->addAction(Scales_y); - Zoom_xy->setText(tr(" 自动缩放XY")); - Zoom_x->setText(tr(" 自动缩放X")); - Zoom_y->setText(tr(" 自动缩放Y")); - ui->Btn_ZoomMenu->setMenu(ZoomMenu); + Scales_xy->setIcon(QIcon(":/images/images/imgModelAction/Zoom_xy.png")); + Scales_x->setIcon(QIcon(":/images/images/imgModelAction/axisX.png")); + Scales_y->setIcon(QIcon(":/images/images/imgModelAction/axisY.png")); + + Scales_xy->setText(tr(" 自动缩放XY")); + Scales_x->setText(tr(" 自动缩放X")); + Scales_y->setText(tr(" 自动缩放Y")); + ui->Btn_ScalesMenu->setMenu(ScalesMenu); QMenu *HzMenu = new QMenu(); HzMenu->setWindowFlags(HzMenu->windowFlags() | Qt::FramelessWindowHint); @@ -406,37 +409,37 @@ void ChildForm::InitWidget() connect(differentiation, SIGNAL(triggered()), this, SLOT(DifferentiationSlot())); connect(doubleDifferentiation, SIGNAL(triggered()), this, SLOT(DoubleDifferentiationSlot())); - connect(Zoom_xy, SIGNAL(triggered()), this, SLOT(ZoomBtnSlot_XY())); - connect(Zoom_x, SIGNAL(triggered()), this, SLOT(ZoomBtnSlot_X())); - connect(Zoom_y, SIGNAL(triggered()), this, SLOT(ZoomBtnSlot_Y())); + connect(Scales_xy, SIGNAL(triggered()), this, SLOT(ScalesBtnSlot_XY())); + connect(Scales_x, SIGNAL(triggered()), this, SLOT(ScalesBtnSlot_X())); + connect(Scales_y, SIGNAL(triggered()), this, SLOT(ScalesBtnSlot_Y())); connect(Rad, SIGNAL(triggered()), this, SLOT(ToRpm())); - QMenu *ScaleMenu = new QMenu(); - ScaleMenu->setWindowFlags(ScaleMenu->windowFlags() | Qt::FramelessWindowHint); - QAction *Scale_X = new QAction(ScaleMenu); - QAction *ScaleMenu_Y = new QAction(ScaleMenu); - QAction *ScaleMenu_XY = new QAction(ScaleMenu); - QAction *ScaleMenu_Box = new QAction(ScaleMenu); + QMenu *ZoomMenu = new QMenu(); + ZoomMenu->setWindowFlags(ZoomMenu->windowFlags() | Qt::FramelessWindowHint); + QAction *Zoom_X = new QAction(ZoomMenu); + QAction *ZoomMenu_Y = new QAction(ZoomMenu); + QAction *ZoomMenu_XY = new QAction(ZoomMenu); + QAction *ZoomMenu_Box = new QAction(ZoomMenu); - ScaleMenu->addAction(Scale_X); - ScaleMenu->addAction(ScaleMenu_Y); - ScaleMenu->addAction(ScaleMenu_XY); - ScaleMenu->addAction(ScaleMenu_Box); + ZoomMenu->addAction(Zoom_X); + ZoomMenu->addAction(ZoomMenu_Y); + ZoomMenu->addAction(ZoomMenu_XY); + ZoomMenu->addAction(ZoomMenu_Box); - Scale_X->setIcon(QIcon(":/images/images/imgModelAction/Zoom_X.png")); - ScaleMenu_Y->setIcon(QIcon(":/images/images/imgModelAction/Zoom_Y.png")); - ScaleMenu_XY->setIcon(QIcon(":/images/images/imgModelAction/Zoom-XY.png")); - ScaleMenu_Box->setIcon(QIcon(":/images/images/imgModelAction/Zoom_Box.png")); - Scale_X->setText(tr(" 放大X")); - ScaleMenu_Y->setText(tr(" 放大Y")); - ScaleMenu_XY->setText(tr(" 放大XY")); - ScaleMenu_Box->setText(tr(" 框选放大")); - ui->Btn_Zoom->setMenu(ScaleMenu); + Zoom_X->setIcon(QIcon(":/images/images/imgModelAction/Zoom_X.png")); + ZoomMenu_Y->setIcon(QIcon(":/images/images/imgModelAction/Zoom_Y.png")); + ZoomMenu_XY->setIcon(QIcon(":/images/images/imgModelAction/Zoom-XY.png")); + ZoomMenu_Box->setIcon(QIcon(":/images/images/imgModelAction/Zoom_Box.png")); + Zoom_X->setText(tr(" 放大X")); + ZoomMenu_Y->setText(tr(" 放大Y")); + ZoomMenu_XY->setText(tr(" 放大XY")); + ZoomMenu_Box->setText(tr(" 框选放大")); + ui->Btn_Zoom->setMenu(ZoomMenu); - connect(Scale_X, SIGNAL(triggered()), this, SLOT(ScalesX())); - connect(ScaleMenu_Y, SIGNAL(triggered()), this, SLOT(ScalesY())); - connect(ScaleMenu_XY, SIGNAL(triggered()), this, SLOT(ScalesXY())); - connect(ScaleMenu_Box, SIGNAL(triggered()), this, SLOT(ScalesBox())); + connect(Zoom_X, SIGNAL(triggered()), this, SLOT(ZoomX())); + connect(ZoomMenu_Y, SIGNAL(triggered()), this, SLOT(ZoomY())); + connect(ZoomMenu_XY, SIGNAL(triggered()), this, SLOT(ZoomXY())); + connect(ZoomMenu_Box, SIGNAL(triggered()), this, SLOT(ZoomBox())); QMenu *CursorMenu = new QMenu(); @@ -466,7 +469,7 @@ void ChildForm::InitWidget() connect(Cursor, SIGNAL(triggered()), this, SLOT(Cursor())); - ui->Btn_ZoomMenu->setStyleSheet("QPushButton::menu-indicator{image:none;}"); + ui->Btn_ScalesMenu->setStyleSheet("QPushButton::menu-indicator{image:none;}"); ui->Btn_Zoom->setStyleSheet("QPushButton::menu-indicator{image:none;}"); ui->Btn_Cursor->setStyleSheet("QPushButton::menu-indicator{image:none;}"); @@ -504,8 +507,12 @@ void ChildForm::InitWidget() QPushButton:pressed{border-image:url(:/images/images/imgModelAction/lvbo-p.png) 5; }\ QPushButton:checked{border-image:url(:/images/images/imgModelAction/lvbo.png) 5; } " ); + ui->realTimeDataBtn->setStyleSheet(" QPushButton{ border-image:url(:/images/images/imgModelAction/realTime.png) 5; }\ + QPushButton:hover{ border-image:url(:/images/images/imgModelAction/realTime-h.png) 5; }\ + QPushButton:pressed{border-image:url(:/images/images/imgModelAction/realTime-p.png) 5; }\ + QPushButton:checked{border-image:url(:/images/images/imgModelAction/realTime-p.png) 5; } "); ui->temBtn_4->setEnabled(true); - + ui->realTimeDataBtn->setEnabled(true); ui->Btn_AC_DC->setEnabled(true); ui->Btn_Sound->setEnabled(true); ui->Btn_differentiation->setEnabled(true); @@ -533,8 +540,22 @@ void ChildForm::InitWidget() doubleIntegration->setEnabled(false); differentiation->setEnabled(false); doubleDifferentiation->setEnabled(false); + }else if(m_iFormType == TimeWavePlot){ + + + ui->Btn_Cursor->setEnabled(false); + }else if(m_iFormType == PolarPlot){ + + ui->Btn_Zoom->setEnabled(false); + ui->Btn_ScalesMenu->setEnabled(false); + ui->Btn_setScales->setEnabled(false); + ui->Btn_Cursor->setEnabled(false); + + }else if(m_iFormType == BodePlot){ + }else if(m_iFormType == ShaftCenterline /*|| m_iFormType == BodePlot*/ || m_iFormType == PolarPlot || m_iFormType == OrbitPlot || m_iFormType ==WaterFallPlot){ + Cursor->setEnabled(false); } @@ -556,7 +577,7 @@ QCPGraph* ChildForm::MultiyAxis(QString strID,QString sensorType,QString sensorE qDebug() << "contains" << endl; if(mapMultiGraph.size() == 0){ qDebug() << "mapMultiGraph1" << sensorEngineeringUnit << endl; - graph = ui->widget->addGraph(ui->widget->xAxis, Axis[0]); + graph = ui->widget->addGraph(ui->widget->xAxis, Axis[0] ); ui->widget->yAxis->setLabel( sensorEngineeringUnit); Axis[0]->setVisible(true); mapGraph.insert(strID,Axis[0]); @@ -611,7 +632,6 @@ QCPGraph* ChildForm::MultiyAxis(QString strID,QString sensorType,QString sensorE } } - QMap>::iterator iter = mapMultiGraph.begin(); for(; iter != mapMultiGraph.end();iter++){ if(iter.key() == sensorType){ @@ -654,21 +674,9 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY waveShowData.Key.push_back(f); waveShowData.wavedata_DC.push_back(waveData.waveDataRealTime.at(j)); } -<<<<<<< HEAD - if(m_bIntegration){ - QVector retValue; - double RMS = 0.0; - pCalculation->_Integration(waveShowData.wavedata,retValue,RMS); - QVector().swap(waveShowData.wavedata); - waveShowData.wavedata = retValue; - waveShowData.RMS = RMS; - } -======= ->>>>>>> master - qDebug() << "waveShowData.wavedata_DC" << waveShowData.wavedata_DC.size()<< endl; }else{ - QVector vecOutData; + QVector vecOutData,vecOutData2; for(int j = 0 ; j < waveData.wavesize;j++){ waveShowData.wavedata.push_back(waveData.waveData.at(j)-waveData.mean); f += gap; @@ -676,10 +684,13 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY waveShowData.wavedata_DC.push_back(waveData.waveData.at(j)); } if(m_nStart > 0 && m_nEnd > 0){ - double FrequencyBands[2] = { (double)m_nStart/waveData.SamleRate*2, (double)m_nEnd/waveData.SamleRate*2 }; - pCalculation->ButterWorth(waveShowData.wavedata,FrequencyBands,vecOutData); + // double FrequencyBands[2] = { (double)m_nEnd ,(double)m_nStart}; + // pCalculation->ButterWorth(waveShowData.wavedata,FrequencyBands,vecOutData); + double FrequencyBands2[2] = { (double)m_nStart/(double)waveData.SamleRate*2, (double)m_nEnd/(double)waveData.SamleRate*2}; + pCalculation->ButterWorth(waveShowData.wavedata,FrequencyBands2,vecOutData2); + QVector().swap(waveShowData.wavedata); - waveShowData.wavedata = vecOutData; + waveShowData.wavedata = vecOutData2; } } if(m_bIntegration){ @@ -760,19 +771,66 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY WAVE_DISPALYDATA WaveDisplay; QVector vecFFTSpecData; QVector vecData; - for(int j = 0; j < waveData.wavesize;j++){ - float fData = waveData.waveData.at(j)-waveData.mean; - vecData.push_back(fData); + if(m_bRealTime){ + + double sum = std::accumulate(std::begin(waveData.waveDataRealTime), std::end(waveData.waveDataRealTime), 0.0); + float size = waveData.SamleRateRealTime; + double mean = sum/size; + for(int j = 0 ; j < waveData.SamleRateRealTime;j++){ + + vecData.push_back(waveData.waveDataRealTime.at(j)-mean); + } + + }else{ + for(int j = 0; j < waveData.wavesize;j++){ + float fData = waveData.waveData.at(j)-waveData.mean; + vecData.push_back(fData); + } } QVector vecOutData; if(m_nStart > 0 && m_nEnd > 0){ - double FrequencyBands[2] = { (double)m_nStart/waveData.SamleRate*2, (double)m_nEnd/waveData.SamleRate*2 }; + double FrequencyBands[2] = { (double)m_nStart/(double)waveData.SamleRate*2, (double)m_nEnd/(double)waveData.SamleRate*2}; pCalculation->ButterWorth(vecData,FrequencyBands,vecOutData); QVector().swap(vecData); vecData = vecOutData; } + if(m_bIntegration){ + QVector retValue; + double RMS = 0.0; + pCalculation->_Integration(vecData,retValue,RMS); + QVector().swap(vecData); + vecData = retValue; + } + if(m_bDoubleIntegration){ + QVector retValue,retValue2; + double RMS = 0.0; + pCalculation->_Integration(vecData,retValue,RMS); + pCalculation->_Integration(retValue,retValue2,RMS); + QVector().swap(vecData); + vecData = retValue2; + } + if(m_bDifferentiation){ + QVector diffValue; + pCalculation->_Differentiation(vecData,diffValue); + QVector().swap(vecData); + vecData = diffValue; + } + if(m_bDoubleDifferentiation){ + QVector diffValue,yValue,diffValue2,yValue2; + pCalculation->_Differentiation(vecData,diffValue); + + for(int ii = 0; ii < diffValue.size();ii++){ + yValue.push_back(diffValue[ii]/(double)10000); + } + pCalculation->_Differentiation(yValue,diffValue2); + for(int i = 0 ; i < diffValue2.size();i++){ + yValue2.push_back(diffValue2[i]/(double)10000); + } + QVector().swap(vecData); + vecData = diffValue2; + } pCalculation->FFTSpec(vecData,vecFFTSpecData);//每一秒的FFT qDebug() << vecData.size() <widget->xAxis->setLabel("Frequency(Hz)"); }else if(m_iFormType == EnvChartPlot){ @@ -799,20 +858,19 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY }else{ pCalculation->envSpec(vecData,vecEnvSpecData,m_nStart,m_nEnd); } - for(int jj = 0 ; jj < vecEnvSpecData.size();jj++){ - waveShowData.Key.push_back(jj); - } - waveShowData.wavedataEnv = vecEnvSpecData; - waveShowData.wavedata = vecData; - waveShowData.linColor = waveData.linColor; - //wavetempData.push_back(vecEnvSpecData); - waveShowData.channelType = waveData.sensorType; - waveShowData.sensorEngineeringUnit = waveData.sensorEngineeringUnit; - ui->widget->xAxis->setLabel("Frequency(Hz)"); + for(int jj = 0 ; jj < vecEnvSpecData.size();jj++){ + waveShowData.Key.push_back(jj); + } + waveShowData.wavedataEnv = vecEnvSpecData; + waveShowData.wavedata = vecData; + waveShowData.linColor = waveData.linColor; + waveShowData.channleName = waveData.channelName; + //wavetempData.push_back(vecEnvSpecData); + waveShowData.channelType = waveData.sensorType; + waveShowData.sensorEngineeringUnit = waveData.sensorEngineeringUnit; + ui->widget->xAxis->setLabel("Frequency(Hz)"); } - - if(mapWaveDisplayData.contains(strID)){ mapWaveDisplayData[strID] = waveShowData; @@ -824,12 +882,20 @@ void ChildForm::SecondData(const QString& strID,WAVE_DATA& waveData,WAVE_DISPALY void ChildForm::UpdateDiffMenu() { if(m_iFormType == TimeDomainPlot || m_iFormType == FrequencyDomainPlot){ - if(mapMultiGraph.contains("VELOCITY") && mapMultiGraph.contains("ACCELEROMETER")){ + if(mapMultiGraph.contains("VELOCITY") && mapMultiGraph.contains("ACCELEROMETER") + && !mapMultiGraph.contains("THRUST") && !mapMultiGraph.contains("PROXIMETER") + && !(mapMultiGraph.contains("MICROPHONE")) && !(mapMultiGraph.contains("FAST_VOLTAGE")) + && !(mapMultiGraph.contains("SLOW_CURRENT")) + && !(mapMultiGraph.contains("TACHOMETER"))){ Integration->setEnabled(true); doubleIntegration->setEnabled(false); differentiation->setEnabled(false); doubleDifferentiation->setEnabled(false); - }else if(mapMultiGraph.contains("VELOCITY") && mapMultiGraph.contains("ACCELEROMETER")){ + }else if(mapMultiGraph.contains("VELOCITY") && !mapMultiGraph.contains("ACCELEROMETER") + && (mapMultiGraph.contains("THRUST") || mapMultiGraph.contains("PROXIMETER")) + && !(mapMultiGraph.contains("MICROPHONE")) && !(mapMultiGraph.contains("FAST_VOLTAGE")) + && !(mapMultiGraph.contains("SLOW_CURRENT")) + && !(mapMultiGraph.contains("TACHOMETER"))){ Integration->setEnabled(false); doubleIntegration->setEnabled(false); differentiation->setEnabled(true); @@ -884,7 +950,7 @@ void ChildForm::UpdateDiffMenu() void ChildForm::AddSeries(QString strID, QVector& waveData) { //InitDisPaly(); - qDebug() << "AddSeries"<& waveData) //qDebug() << "Time" << Time << endl; QVector().swap(x); QVector wavetempTrendData; - for(int i = 0; i < Time;i++){//平方和除以点数再开根 + for(int i = 1; i <= Time;i++){//平方和除以点数再开根 // float Sum = 0.0; // for(int j = 0; j < waveData[i].SamleRate;j++){ @@ -958,7 +1024,7 @@ void ChildForm::AddSeries(QString strID, QVector& waveData) x.push_back(i); //wavetempTrendData.push_back(rms); } - ui->widget->xAxis->setRange(0, Time); + ui->widget->xAxis->setRange(1, Time); ui->widget->xAxis->setLabel("Time(s)"); waveTrendData.insert(strID,wavetempTrendData); QString stryLabel = waveData[m_position].sensorType + "(" + waveData[m_position].sensorEngineeringUnit +")"; @@ -1066,6 +1132,38 @@ void ChildForm::AddSeries(QString strID, QVector& waveData) ui->widget->xAxis->setLabel("Frequency(Hz)"); ui->widget->yAxis->setLabel(waveData[0].sensorType + "(" + waveData[0].sensorEngineeringUnit+")"); + }else if(m_iFormType == TimeWavePlot){ + foreach (auto ID, listChannelID){ + if(ID != strID){ + m_mapChannelIDtoLabel[ID]->setCheckState(Qt::Unchecked); + m_mapChannelIDtoLabel[ID]->setSelected(false); + } + } + int Time = waveData.size(); + ui->widget->xAxis->setRange(1, Time); + ui->widget->xAxis->setLabel("Time(s)"); + QVector key,value; + double gap = (double)1/(double)waveData[0].waveData.size(); + double f = 0.0; + for(int i = 0; i < Time;i++){ + QVector().swap(key); + QVector().swap(value); + for(int j = 0; j < waveData[i].waveData.size();j++){ + f += gap; + key.push_back(f); + value.push_back(waveData[i].waveData[j]); + } + ui->widget->addGraph(ui->widget->xAxis, ui->widget->yAxis); + ui->widget->graph(i)->setData(key, value); + QPen pen; + pen.setColor(waveData.at(i).linColor); + pen.setStyle(Qt::SolidLine); + ui->widget->graph(i)->setPen(pen); + } + + QString stryLabel = waveData[m_position].sensorType + "(" + waveData[m_position].sensorEngineeringUnit +")"; + ui->widget->yAxis->setLabel( stryLabel); + ui->widget->graph(line)->setName(waveData[0].channelName); } if(m_iFormType != WaterFallPlot){//设置通道颜色 ui->widget->graph(line)->rescaleValueAxis(); @@ -1083,7 +1181,7 @@ void ChildForm::AddSeries(QString strID, QVector& waveData) line++; } ui->widget->replot(); - ZoomBtnSlot_XY(); + ScalesBtnSlot_XY(); } void ChildForm::UpdateEnvSerises(QString Start,QString End) @@ -1091,7 +1189,8 @@ void ChildForm::UpdateEnvSerises(QString Start,QString End) ui->widget->clearGraphs(); InitDisPaly(); - if(Start.toInt() < 10 || End.toInt() > 131072){ + if(Start.toInt() < 10 || End.toInt() > 131072) + { MyMsgBox(QMessageBox::Warning,"警告","请输入正确信息!"); return; } @@ -1142,6 +1241,7 @@ void ChildForm::UpdateEnvSerises(QString Start,QString End) } void ChildForm::handlePlayWave(double position,double size ) { + m_position = position; if(m_iFormType == WaterFallPlot){ int graphCount = ui->widget->graphCount(); if(graphCount < 1) @@ -1165,15 +1265,16 @@ void ChildForm::handlePlayWave(double position,double size ) }else { - int graphCount = ui->widget->clearGraphs(); + ui->widget->clearGraphs(); } if(m_iFormType != TrendChartPlot) QMap().swap(waveGraph); - m_position = position; + //使键轴范围与数据一起滚动: if(m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot || m_iFormType == TimeDomainPlot){ + qDebug() << "m_position" << position <setData(waveShowData.Key, waveShowData.wavedata); } } - graph->rescaleValueAxis(); + //graph->rescaleValueAxis(); xRange = waveShowData.Key.size(); graph->setName(waveShowData.channleName); QPen pen; @@ -1288,19 +1389,19 @@ void ChildForm::handlePlayWave(double position,double size ) } fermatSpiral1->data()->set(dataSpiral1, true); fermatSpiral1->setPen(QPen(OrbitYWave[0].linColor)); - fermatSpiral1->rescaleAxes(); + //fermatSpiral1->rescaleAxes(); QCPGraph* dwPoints = new QCPGraph(wideAxisRectOrbit->axis(QCPAxis::atBottom), wideAxisRectOrbit->axis(QCPAxis::atLeft)); dwPoints->setAdaptiveSampling(false); dwPoints->setLineStyle(QCPGraph::lsNone); dwPoints->setScatterStyle(QCPScatterStyle::ssDot); - dwPoints->setPen(QPen(QBrush(Qt::white), 2)); + dwPoints->setPen(QPen(QBrush(Qt::red), 5)); dwPoints->addData(vecKeyPhasor[position].key, vecKeyPhasor[position].value); }else { return; } - ZoomBtnSlot_XY(); + ScalesBtnSlot_XY(); ui->widget->replot(QCustomPlot::rpImmediateRefresh); } @@ -1323,7 +1424,25 @@ QPixmap ChildForm::GetSerise(QString& strImagePath) break; case EnvChartPlot: PicName = "EnvChart"; - break; + break; + case WaterFallPlot: + PicName = "WaterFall"; + break; + case OrbitPlot: + PicName = "Orbit"; + break; + case PolarPlot: + PicName = "Polar"; + break; + case BodePlot: + PicName = "Bode"; + break; + case ShaftCenterline: + PicName = "ShaftCenterline"; + break; + case AllWavePlot: + PicName = "AllWave"; + break; } strImagePath = QCoreApplication::applicationDirPath() + "\\report\\" + PicName + ".png"; ui->widget->savePng(strImagePath,600,400); @@ -1390,6 +1509,7 @@ void ChildForm::AddShaftCenterlineSeries(QString strID, const QVector void ChildForm::AddBodeSeries(QString strID, const QVector& waveData,const QVector& waveSpeedData) { + ui->widget->setInteractions(QCP::iRangeDrag | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables); /*mapBodeData.insert(strID,waveData); if(mapBodeData.size() < 2){ MyMsgBox(QMessageBox::Warning,"警告","请选择两条通道进行伯德图分析!"); @@ -1454,11 +1574,11 @@ void ChildForm::AddBodeSeries(QString strID, const QVector& waveData, wideAxisRect1->setMarginGroup(QCP::msLeft, marginGroup); wideAxisRect2->setMarginGroup(QCP::msLeft, marginGroup); - QCPGraph *mainGraph1 = ui->widget->addGraph(wideAxisRect1->axis(QCPAxis::atBottom), wideAxisRect1->axis(QCPAxis::atLeft)); + mainGraph1 = ui->widget->addGraph(wideAxisRect1->axis(QCPAxis::atBottom), wideAxisRect1->axis(QCPAxis::atLeft)); mainGraph1->rescaleAxes(); mainGraph1->setPen(QPen(QColor(Qt::green), 2)); - QCPGraph *mainGraph2 = ui->widget->addGraph(wideAxisRect2->axis(QCPAxis::atBottom), wideAxisRect2->axis(QCPAxis::atLeft)); + mainGraph2 = ui->widget->addGraph(wideAxisRect2->axis(QCPAxis::atBottom), wideAxisRect2->axis(QCPAxis::atLeft)); mainGraph2->rescaleAxes(); mainGraph2->setPen(QPen(QColor(Qt::green), 2)); @@ -1499,8 +1619,7 @@ void ChildForm::AddBodeSeries(QString strID, const QVector& waveData, QVector vecmainGraph1; QVector vecmainGraph2; QVector vecSpeed; - double sum = 0.0; - qDebug() << "=====Speed=====" << vecSpeedTime[99] << vecSpeedTime[100] << endl; + //qDebug() << "=====Speed=====" << vecSpeedTime[99] << vecSpeedTime[100] << endl; { for(int j = 1;j < vecSpeedTime.size();j++){ @@ -1526,15 +1645,15 @@ void ChildForm::AddBodeSeries(QString strID, const QVector& waveData, // qDebug() << "=====iter=====" << vecSpeed[i].key < 10){//增速 - RPM rpmData; - rpmData.key1 = vecSpeed[i-1].key1; - rpmData.key2 = vecSpeed[i-1].key2; - rpmData.fSpeed = vecSpeed[i-1].fSpeed; - vecIncreaseSpeed.push_back(rpmData); + + RPM rpmData; + rpmData.key1 = vecSpeed[i-1].key1; + rpmData.key2 = vecSpeed[i-1].key2; + rpmData.fSpeed = vecSpeed[i-1].fSpeed; + vecIncreaseSpeed.push_back(rpmData); + - } } QVector VibrateData;//(waveVibrateData.size() * waveVibrateData[0].SamleRate); VibrateData.reserve(waveData.size() * waveData[0].SamleRate); @@ -1551,35 +1670,49 @@ void ChildForm::AddBodeSeries(QString strID, const QVector& waveData, for (int i = Time1; i < Time2 ; i++) { vecPP.push_back(VibrateData[i]); } - qDebug() << "pp" << vecPP.size() << endl; + //qDebug() << "pp" << vecPP.size() << endl; auto p1 = std::max_element(std::begin(vecPP), std::end(vecPP)); auto p2 = std::min_element(std::begin(vecPP), std::end(vecPP)); float Max = *p1; float Min = *p2; - qDebug() << "=====Max====="<< *p1 << "===Min===" << *p2 << endl; + //qDebug() << "=====Max====="<< *p1 << "===Min===" << *p2 << endl; QCPGraphData data; data.key = vecIncreaseSpeed[i].fSpeed; data.value = Max - Min; vecmainGraph2.push_back(data); double Phase = pCalculation->Phase(vecPP); - qDebug() << "=====Phase1====="<< Phase << endl; + //qDebug() << "=====Phase1====="<< Phase << endl; QCPGraphData data1; data1.key = vecIncreaseSpeed[i].fSpeed; data1.value = Phase; vecmainGraph1.push_back(data1); } +// QVector x1(50), y1(50), y1err(50); +// QVector dataCos(21), dataGauss(50), dataRandom(100); +// QVector x3, y3; +// std::srand(3); +// for (int i=0; iwidget->addGraph(wideAxisRect1->axis(QCPAxis::atBottom), wideAxisRect1->axis(QCPAxis::atLeft)); mainGraph1->data()->set(vecmainGraph1); - mainGraph1->rescaleKeyAxis(); + mainGraph1->rescaleAxes(); mainGraph1->setPen(QPen(QColor(waveData[0].linColor), 1)); - mainGraph1->setName("1"); + mainGraph1->setName("相位"); mainGraph2 = ui->widget->addGraph(wideAxisRect2->axis(QCPAxis::atBottom), wideAxisRect2->axis(QCPAxis::atLeft)); mainGraph2->data()->set(vecmainGraph2); - mainGraph2->rescaleKeyAxis(); + mainGraph2->rescaleAxes(); mainGraph2->setPen(QPen(QColor(waveData[0].linColor), 1)); - mainGraph2->setName("2"); + mainGraph2->setName("峰峰值"); ui->widget->replot(); } @@ -1601,6 +1734,7 @@ void ChildForm::AddOrbitSeries(QString strID, const QVector& wavexDat OrbitXWave = wavexData; OrbitYWave = waveyData; ui->widget->plotLayout()->clear(); + ui->widget->replot(QCustomPlot::rpImmediateRefresh); wideAxisRect1 = new QCPAxisRect(ui->widget); wideAxisRect2 = new QCPAxisRect(ui->widget); @@ -1683,8 +1817,8 @@ void ChildForm::AddOrbitSeries(QString strID, const QVector& wavexDat fermatSpiral1->rescaleAxes(); QVector> vecSpeedTime; - qDebug() << "=====Time====="<< waveSpeedData[0].Time << endl; - qDebug() << "=====wavexData size====="<< wavexData.size() << endl; + //qDebug() << "=====Time====="<< waveSpeedData[0].Time << endl; + //qDebug() << "=====wavexData size====="<< wavexData.size() << endl; int iTime = 0; if(wavexData.size() <= waveSpeedData[0].Time)//防止Dat文件数据丢失,取实际读到的秒数 iTime = wavexData.size(); @@ -1692,7 +1826,7 @@ void ChildForm::AddOrbitSeries(QString strID, const QVector& wavexDat { QVector vecTemp; int flag = 0; - qDebug() << "=====size====="<< waveSpeedData.at(i).waveData.size() << endl; + //qDebug() << "=====size====="<< waveSpeedData.at(i).waveData.size() << endl; for(int j = 1; j < waveSpeedData.at(0).waveData.size();j++) { if(waveSpeedData.at(0).iTrigger == 0){ @@ -1709,10 +1843,10 @@ void ChildForm::AddOrbitSeries(QString strID, const QVector& wavexDat } } vecSpeedTime.push_back(vecTemp); - qDebug() << "=====vecSpeedTime====="<< vecSpeedTime.size()<< endl; + //qDebug() << "=====vecSpeedTime====="<< vecSpeedTime.size()<< endl; } - qDebug() << "=====vecSpeedTime====="<< vecSpeedTime[10][10]<< endl; + //qDebug() << "=====vecSpeedTime====="<< vecSpeedTime[10][10]<< endl; QVector key,value; for(int j = 0;j < vecSpeedTime.size();j++) { @@ -1741,7 +1875,7 @@ void ChildForm::AddOrbitSeries(QString strID, const QVector& wavexDat dwPoints->setAdaptiveSampling(false); dwPoints->setLineStyle(QCPGraph::lsNone); dwPoints->setScatterStyle(QCPScatterStyle::ssDot); - dwPoints->setPen(QPen(QBrush(Qt::white), 2)); + dwPoints->setPen(QPen(QBrush(Qt::red), 5)); dwPoints->addData(vecKeyPhasor[0].key, vecKeyPhasor[0].value); //dwPoints->rescaleAxes(); @@ -1800,7 +1934,7 @@ void ChildForm::AddPolarPlotSeries(QString strID, const QVector& wave rpmData.fSpeed = Speed; vecSpeed.push_back(rpmData); SumRPM += Speed; - qDebug() << "=====Speed=====" << Speed << vecSpeedTime.at(j) << vecSpeedTime.at(j-1) << endl; + //qDebug() << "=====Speed=====" << Speed << vecSpeedTime.at(j) << vecSpeedTime.at(j-1) << endl; } double MeanRPM = SumRPM/(double)vecSpeed.size(); vecMeanRPM.push_back(MeanRPM); @@ -1846,7 +1980,7 @@ void ChildForm::AddPolarPlotSeries(QString strID, const QVector& wave double real = vecFFTrealData[(int)hz]; double image = vecFFTimageData[(int)hz]; - double phase = atan2(image,real)*180/3.14; + double phase = atan2(image,real)*180/3.1415926; ValueAmp.push_back(rms); keyPhase.push_back(phase); @@ -1891,7 +2025,7 @@ void ChildForm::AddPolarPlotSeries(QString strID, const QVector& wave angularAxis->setRange(0, 360); angularAxis->radialAxis()->setRange(-10, 10); //坐标轴为白色 - angularAxis->setBasePen(QPen(Qt::white, 1)); + angularAxis->setBasePen(QPen(Qt::white, 3)); //坐标轴的提示信息为白色 angularAxis->setTickLabelColor(Qt::white); @@ -1900,7 +2034,7 @@ void ChildForm::AddPolarPlotSeries(QString strID, const QVector& wave angularAxis->radialAxis()->setLabelColor(Qt::white); angularAxis->radialAxis()->setTickLabelColor(Qt::white); - g1->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::red, 1.5), QBrush(Qt::red), 3));//散列点 + g1->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::red, 1.5), QBrush(Qt::red), 1.5));//散列点 ui->widget->replot(); } void ChildForm::ChannelBtnSlot() @@ -1967,7 +2101,7 @@ QTableWidgetItem * ChildForm::AddTableWgtItem(QString strText, QString clolor, Q pLabel->setFixedSize(20, 20); pLabel->setStyleSheet(QString("QLabel{background: rgb(%1)}").arg(clolor)); pLayout->addWidget(pLabel); - pLayout->setMargin(0); //设置边缘距离 否则会很难看 + pLayout->setMargin(0); pLayout->setAlignment(pLabel, Qt::AlignCenter); @@ -2055,15 +2189,16 @@ void ChildForm::SetDataIDs(const QStringList &strIDList, QString strTitle,const strColor = "205, 205, 0"; break; case 13: - strColor = "198, 226, 255"; + strColor = "153,51, 250"; break; case 14: strColor = "255, 218, 185"; break; case 15: - strColor = "255, 20, 147"; + strColor = "0, 199 ,140"; break; default: + strColor = "0,255,0"; break; } i++; @@ -2074,11 +2209,16 @@ void ChildForm::SetDataIDs(const QStringList &strIDList, QString strTitle,const connect(ui->tableWidget, SIGNAL(itemPressed(QTableWidgetItem *)), this, SLOT(ItemPressSlot(QTableWidgetItem *))); connect(ui->tableWidget, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(ItemChangedSlot(QTableWidgetItem *))); - m_mapChannelIDtoLabel[strIDList[0]]->setSelected(true); - m_mapChannelIDtoLabel[strIDList[0]]->setCheckState(Qt::Checked); + if(m_iFormType == TimeDomainPlot || m_iFormType == FrequencyDomainPlot ||\ + m_iFormType == TrendChartPlot || m_iFormType == SpecChartPlot || \ + m_iFormType == EnvChartPlot || m_iFormType == TimeWavePlot || m_iFormType == WaterFallPlot){ + m_mapChannelIDtoLabel[strIDList[0]]->setSelected(true); + m_mapChannelIDtoLabel[strIDList[0]]->setCheckState(Qt::Checked); + listChannelID.push_back(strIDList[0]); + emit ItemCheckStateSignal(strIDList[0], true); + } + - listChannelID.push_back(strIDList[0]); - emit ItemCheckStateSignal(strIDList[0], true); } void ChildForm::RemoveSeries(QString strID) { @@ -2086,22 +2226,32 @@ void ChildForm::RemoveSeries(QString strID) qDebug()<<"::ChildForm::waveGraph" <widget->plotLayout()->clear(); return; } } + QMap>::Iterator iter1 = mapBodeData.begin(); + for (;iter1 != mapBodeData.end() ; iter1++) { + if(strID == iter1.key()){ + QVector().swap(iter1.value()); + mapBodeData.erase(iter1); + } + } ui->widget->clearGraphs(); ui->widget->clearPlottables(); qDebug() << ui->widget->graphCount() << endl; line = 0; - }else if(m_iFormType == TrendChartPlot || m_iFormType == TimeDomainPlot || m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot){ - QMap>::Iterator itermultiGraph = mapMultiGraph.begin(); + }else if(m_iFormType == TrendChartPlot || m_iFormType == TimeDomainPlot || + m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot){ + QMap>::Iterator itermultiGraph = mapMultiGraph.begin(); for(;itermultiGraph != mapMultiGraph.end();itermultiGraph++){ int flag = 0; QMap::Iterator iterGraph = itermultiGraph.value().begin(); @@ -2191,48 +2341,36 @@ void ChildForm::RemoveSeries(QString strID) } } - QMap>::Iterator iter1 = mapBodeData.begin(); - for (;iter1 != mapBodeData.end() ; iter1++) { - if(strID == iter1.key()){ - QVector().swap(iter1.value()); - mapBodeData.erase(iter1); - } - } + } - if(m_bIntegration) - m_bIntegration = false; - - if(m_bDifferentiation) - m_bDifferentiation = false; - if(m_bRpm) m_bRpm = false; ui->widget->replot(); - if(tracerLabel->visible()) + if(tracerLabel) tracerLabel->setVisible(false); - if(tracerLabel2->visible()) + if(tracerLabel2) tracerLabel2->setVisible(false); - if(tracerLabel3->visible()) + if(tracerLabel3) tracerLabel3->setVisible(false); - if(tracerLabel4->visible()) + + if(tracerLabel4) tracerLabel4->setVisible(false); - if(tracerLabel5->visible()) + + if(tracerLabel5) tracerLabel5->setVisible(false); - - //disconnect(dismove); disconnect(disPress); - ZoomBtnSlot_XY(); + ScalesBtnSlot_XY(); UpdateDiffMenu(); } void ChildForm::ItemPressSlot(QTableWidgetItem *item) { if(m_bRealTime){ - realTimeData(); + //realTimeData(); MyMsgBox(QMessageBox::Information,"提示","请先暂停实时数据播放!"); return; } @@ -2249,7 +2387,7 @@ void ChildForm::ItemPressSlot(QTableWidgetItem *item) m_iFormType == TrendChartPlot || m_iFormType == SpecChartPlot || m_iFormType == EnvChartPlot)){ - + MyMsgBox(QMessageBox::Information,"提示","最大支持三条曲线"); item->setCheckState(Qt::Unchecked); item->setSelected(false); return; @@ -2259,18 +2397,24 @@ void ChildForm::ItemPressSlot(QTableWidgetItem *item) item->setSelected(false); return; - }else if(m_iFormType == BodePlot && strType != "ACCELEROMETER"){ + }else if(m_iFormType == BodePlot && strType != "ACCELEROMETER" /*&& strType != "TACHOMETER"*/){ item->setCheckState(Qt::Unchecked); item->setSelected(false); return; } + listChannelID.push_back(strID); item->setCheckState(Qt::Checked); emit ItemCheckStateSignal(strID, true); - listChannelID.push_back(strID); + } else if(item->checkState() && !item->isSelected()) { + if(listChannelID.size() == 1 && m_iFormType == PolarPlot){ + item->setCheckState(Qt::Checked); + item->setSelected(true); + return; + } item->setCheckState(Qt::Unchecked); emit ItemCheckStateSignal(strID, false); listChannelID.removeOne(strID); @@ -2281,7 +2425,8 @@ void ChildForm::ItemPressSlot(QTableWidgetItem *item) void ChildForm::ItemChangedSlot(QTableWidgetItem *item) { if(m_bRealTime){ - realTimeData(); + //realTimeData(); + MyMsgBox(QMessageBox::Information,"提示","请先暂停实时数据播放!"); return; } if(!item) return; @@ -2297,7 +2442,7 @@ void ChildForm::ItemChangedSlot(QTableWidgetItem *item) item->setSelected(false); return; - }else if(m_iFormType == BodePlot && strType != "ACCELEROMETER"){ + }else if(m_iFormType == BodePlot && strType != "ACCELEROMETER" && strType != "TACHOMETER"){ item->setCheckState(Qt::Unchecked); item->setSelected(false); return; @@ -2321,19 +2466,25 @@ void ChildForm::ItemChangedSlot(QTableWidgetItem *item) item->setSelected(false); return; - }else if(m_iFormType == BodePlot && strType != "ACCELEROMETER"){ + }else if(m_iFormType == BodePlot && strType != "ACCELEROMETER"/* && strType != "TACHOMETER"*/){ item->setCheckState(Qt::Unchecked); item->setSelected(false); return; } + listChannelID.push_back(strID); item->setCheckState(Qt::Checked); item->setSelected(true); emit ItemCheckStateSignal(strID, true); - listChannelID.push_back(strID); + } else if(!item->checkState() && item->isSelected()) { + if(listChannelID.size() == 1 && m_iFormType == PolarPlot){ + item->setCheckState(Qt::Checked); + item->setSelected(true); + return; + } item->setCheckState(Qt::Unchecked); item->setSelected(false); emit ItemCheckStateSignal(strID, false); @@ -2359,67 +2510,50 @@ void ChildForm::mouseMoveEvent(QMouseEvent *event) //for (int i = 0; i < graphCount; ++i) { - //显示锚点 - QCPGraph *mGraph = ui->widget->graph(0); - tracer->setVisible(true); - tracerLabel->setVisible(true); - tracerLabel->setPositionAlignment(Qt::AlignLeft); - tracerLabel->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位) - tracerLabel->position->setCoords(0, 0); - tracer->setGraph(mGraph);//将锚点设置到被选中的曲线上 - { - tracer->setGraphKey(x); - //tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得 - tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效 + //显示锚点 + QCPGraph *mGraph = ui->widget->graph(0); + tracer->setVisible(true); + tracer->setGraph(mainGraph1);//将锚点设置到被选中的曲线上 + tracer->setGraphKey(x); + //tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得 + tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效 - double y = ui->widget->axisRect(0)->axis(QCPAxis::atLeft)->pixelToCoord(event->pos().y()); + //double yValue = ui->widget->axisRect(0)->axis(QCPAxis::atLeft)->pixelToCoord(event->pos().y()); - double xValue = tracer->position->key(); - double yValue = y; - //显示tip框 - QCPDataContainer::const_iterator coorPoint = ui->widget->graph(0)->data().data()->findBegin(x, true);//true代表向左搜索 - tracer->setGraphKey(coorPoint->key); - //tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得 - tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效 + double xValue = tracer->position->key(); + double yValue = tracer->position->value(); + //显示tip框 + //QCPDataContainer::const_iterator coorPoint = mainGraph1->data().data()->findBegin(x, true);//true代表向左搜索 + //tracerLabel->setText(QString("%1 X: %2 Y: %3").arg(mGraph->name()).arg( QString::number(xValue)).arg(QString::number(yValue))); - tracerLabel->setText(QString("%1 X: %2 Y: %3").arg(mGraph->name()).arg( QString::number(x)).arg(QString::number(yValue))); - } //显示锚点 QCPGraph *mGraph2 = ui->widget->graph(1); tracerLabel3->setVisible(true); - tracerLabel3->setPositionAlignment(Qt::AlignVCenter); + tracerLabel3->setPositionAlignment(Qt::AlignLeft); tracerLabel3->position->setType(QCPItemPosition::ptAxisRectRatio);//位置类型(当前轴范围的比例为单位/实际坐标为单位) tracerLabel3->position->setCoords(10, 20); - tracer->setGraph(mGraph2);//将锚点设置到被选中的曲线上 - { - tracer->setGraphKey(x); - //tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得 - tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效 + tracerLabel3->setTextAlignment(Qt::AlignLeft); - double y2 = ui->widget->axisRect(1)->axis(QCPAxis::atLeft)->pixelToCoord(event->pos().y()); + double yValue2 = ui->widget->axisRect(1)->axis(QCPAxis::atLeft)->pixelToCoord(event->pos().y()); - double xValue = tracer->position->key(); - double yValue2 = y2; - //显示tip框 - QCPDataContainer::const_iterator coorPoint = ui->widget->graph(1)->data().data()->findBegin(x, true);//true代表向左搜索 - tracer->setGraphKey(coorPoint->key); - //tracer->setInterpolating(true); //游标的纵坐标可以通过曲线数据线性插值自动获得 - tracer->updatePosition(); //使得刚设置游标的横纵坐标位置生效 + //显示tip框 + QCPDataContainer::const_iterator coorPoint = mainGraph2->data().data()->findBegin(x, true);//true代表向左搜索 + + tracerLabel3->setText(QString("%1 X: %2 Y: %3 \n%4 X: %5 Y: %6 ").arg(mainGraph1->name()).arg( QString::number(xValue))\ + .arg(QString::number(yValue)).arg(mainGraph2->name()).arg( QString::number(xValue)).arg(QString::number(coorPoint->value))); - tracerLabel3->setText(QString("%1 X: %2 Y: %3").arg(mGraph2->name()).arg( QString::number(x)).arg(QString::number(yValue2))); - } } }else{ x = ui->widget->xAxis->pixelToCoord(event->pos().x()); //遍历曲线 - for (int i = 0; i < graphCount; ++i) + for (int i = 0; i < graphCount && tracer->visible(); ++i) { //显示锚点 QCPGraph *mGraph = ui->widget->graph(i); - tracer->setVisible(true); + //tracer->setVisible(true); tracer->setGraph(mGraph);//将锚点设置到被选中的曲线上 @@ -2533,14 +2667,14 @@ void ChildForm::CalculateRPM() int flag = 0; qDebug() << "wavedata.size()" << iter.value().wavedata_DC.size(); for(int i = 0; i < iter.value().wavedata_DC.size();i++){ - if(iter.value().iTrigger == 0){//上升沿 if((iter.value().wavedata_DC[i]) > iter.value().iTriggerValue && flag == 0){ flag = i; - }else if (iter.value().wavedata_DC[i] < (iter.value().iTriggerValue - iter.value().iHysteresis) && flag > 0){ + }else if (iter.value().wavedata_DC[i] < (iter.value().iTriggerValue - iter.value().iHysteresis)\ + && flag > 0){ vecSpeedTime.push_back(flag); flag = 0; @@ -2608,7 +2742,7 @@ void ChildForm::CalculateRPM() } ui->widget->xAxis->setRange(0, 1, Qt::AlignLeft); ui->widget->replot(QCustomPlot::rpImmediateRefresh); - ZoomBtnSlot_XY(); + ScalesBtnSlot_XY(); } void ChildForm::ToRpm() { @@ -2623,8 +2757,7 @@ void ChildForm::ToRpm() if(listChannelID.size() > 1) return; - qDebug() << global::rotatingSpeed.iTriggerValue << global::rotatingSpeed.iKeyCount \ - << global::rotatingSpeed.iHysteresis<< global::rotatingSpeed.iTrigger << endl; + ui->widget->clearGraphs(); QMap().swap(waveGraph); if(m_bRpm){ @@ -2646,7 +2779,7 @@ void ChildForm::ToRpm() } } -void ChildForm::ZoomBtnSlot_X() +void ChildForm::ScalesBtnSlot_X() { ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone); int graphCount = ui->widget->graphCount(); @@ -2663,7 +2796,7 @@ void ChildForm::ZoomBtnSlot_X() } ui->widget->replot(); } -void ChildForm::ZoomBtnSlot_Y() +void ChildForm::ScalesBtnSlot_Y() { ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone); int graphCount = ui->widget->graphCount(); @@ -2680,7 +2813,7 @@ void ChildForm::ZoomBtnSlot_Y() } ui->widget->replot(); } -void ChildForm::ZoomBtnSlot_XY() +void ChildForm::ScalesBtnSlot_XY() { ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone); int graphCount = ui->widget->graphCount(); @@ -2694,11 +2827,8 @@ void ChildForm::ZoomBtnSlot_XY() } } -void ChildForm::ZoomBtnSlot_Hand() +void ChildForm::ScalesBtnSlot_Hand() { - - - // ui->widget->setMultiSelectModifier(Qt::ControlModifier);// 使用ctrl键来多选 // ui->widget->xAxis->setSelectableParts(QCPAxis::spAxis | QCPAxis::spAxisLabel | QCPAxis::spTickLabels); // 轴的三个部分都可以被选择 // ui->widget->yAxis->setSelectableParts(QCPAxis::spAxis | QCPAxis::spAxisLabel | QCPAxis::spTickLabels); @@ -2721,7 +2851,7 @@ void ChildForm::ZoomBtnSlot_Hand() ui->widget->setInteractions(QCP::iNone); } } -void ChildForm::Btn_ZoomSlot() +void ChildForm::Btn_ScalesSlot() { if(ui->Btn_Zoom->isChecked()){ ui->widget->setInteractions(QCP::iRangeDrag); @@ -2731,15 +2861,16 @@ void ChildForm::Btn_ZoomSlot() } } -void ChildForm::ScalesX() +void ChildForm::ZoomX() { ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone); ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag); - ui->widget->axisRect()->setRangeZoomFactor(1.2,1); + ui->widget->axisRect()->setRangeZoomFactor(1.2,1); ui->widget->axisRect()->setRangeZoomAxes(ui->widget->xAxis,ui->widget->yAxis); + } -void ChildForm::ScalesY() +void ChildForm::ZoomY() { ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone); ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag|QCP::iSelectAxes); @@ -2750,7 +2881,7 @@ void ChildForm::ScalesY() } //ui->widget->axisRect()->setRangeZoomAxis(ui->widget->xAxis,ui->widget->yAxis); } -void ChildForm::ScalesXY() +void ChildForm::ZoomXY() { ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmNone); ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag|QCP::iSelectAxes); @@ -2761,7 +2892,7 @@ void ChildForm::ScalesXY() } //ui->widget->axisRect()->setRangeZoomAxis(ui->widget->xAxis,ui->widget->yAxis); } -void ChildForm::ScalesBox() +void ChildForm::ZoomBox() { ui->widget->setSelectionRectMode(QCP::SelectionRectMode::srmZoom); ui->widget->selectionRect()->setPen(QPen(Qt::black,1,Qt::DashLine));//虚线 @@ -2769,19 +2900,30 @@ void ChildForm::ScalesBox() } void ChildForm::Cursor() { - if(tracer->visible()) + if(tracer->visible()){ tracer->setVisible(false); - else + disconnect(ui->widget, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*))); + UpdateTracerLabel(); + } + else{ tracer->setVisible(true); + connect(ui->widget, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*))); + } ui->widget->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag); - dismove = connect(ui->widget, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*))); + disDoubleclick = connect(ui->widget, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(mouseDoubleClickEvent(QMouseEvent*))); disPress = connect(ui->widget, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheelEvent(QWheelEvent*))); + + ui->widget->replot(); } void ChildForm::SetScales() { - pSetScales = new SetScalesForm(this); //将类指针实例化 + QCPRange xRange = ui->widget->xAxis->range(); + QCPRange yRange = ui->widget->yAxis->range(); + + m_strSacles = QString("%1,%2,%3,%4").arg(xRange.lower).arg(xRange.upper).arg(yRange.lower).arg(yRange.upper); + pSetScales = new SetScalesForm(m_strSacles,this); //将类指针实例化 connect(pSetScales, SIGNAL(sgSetScales(QString)), this, SLOT(slotSetScales(QString))); pSetScales->setWindowModality(Qt::ApplicationModal); pSetScales->show(); @@ -2795,28 +2937,29 @@ void ChildForm::slotSetScales(QString str) int j = 0,ii = 0; for(int i = 0; i < Axis.size();i++){ - if(Axis[i]->visible()){ - j ++; - ii = i; +// if(Axis[i]->visible()){ +// j ++; +// ii = i; - } - if (Axis[i]->selectedParts().testFlag(QCPAxis::spAxis) && j > 1){ +// } + if (Axis[i]->selectedParts().testFlag(QCPAxis::spAxis)/* && j > 1*/){ Axis[i]->setRange(strList[2].toFloat(), strList[3].toFloat()-strList[2].toFloat(), Qt::AlignLeft); } } - if(j == 1){ - Axis[ii]->setRange(strList[2].toFloat(), strList[3].toFloat()-strList[2].toFloat(), Qt::AlignLeft); - } +// if(j == 1){ +// Axis[ii]->setRange(strList[2].toFloat(), strList[3].toFloat()-strList[2].toFloat(), Qt::AlignLeft); +// } ui->widget->replot(QCustomPlot::rpImmediateRefresh); } void ChildForm::slotSetFilter(QString str) { + m_strFilter = str; QStringList strList = str.split(","); UpdateEnvSerises(strList[0],strList[1]); } void ChildForm::SetFilter() { - pSetFilter = new FilterForm(this); //将类指针实例化 + pSetFilter = new FilterForm(m_strFilter,this); //将类指针实例化 connect(pSetFilter, SIGNAL(sgSetFilter(QString)), this, SLOT(slotSetFilter(QString))); pSetFilter->setWindowModality(Qt::ApplicationModal); pSetFilter->show(); @@ -2896,7 +3039,8 @@ void ChildForm::RealTimeWave(QByteArray payLoad) graph->setData(waveShowData.Key, waveShowData.wavedata); } }else if(m_iFormType == FrequencyDomainPlot){ - graph->setData(waveShowData.Key, waveShowData.wavedata); + graph->setData(waveShowData.Key, waveShowData.wavedataFre); + qDebug() << waveShowData.wavedataFre.size() << waveShowData.wavedataFre[50]<< endl; } } @@ -2909,16 +3053,16 @@ void ChildForm::RealTimeWave(QByteArray payLoad) ui->widget->xAxis->setLabel(strRMS); } - graph->rescaleValueAxis(); + //graph->rescaleValueAxis(); graph->setName(waveShowData.channleName); QPen pen; pen.setColor(waveShowData.linColor); pen.setStyle(Qt::SolidLine); pen.setWidth(0); graph->setPen(pen); - if(m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot){ - ui->widget->xAxis->setRange(0, 1000); - } +// if(m_iFormType == FrequencyDomainPlot || m_iFormType == EnvChartPlot){ +// ui->widget->xAxis->setRange(0, 1000); +// } waveGraph.insert(QString(waveContain.channelId),graph); ui->widget->replot(QCustomPlot::rpImmediateRefresh); @@ -3140,9 +3284,8 @@ void ChildForm::SetDC() // } // } - int graphCount = ui->widget->clearGraphs(); + ui->widget->clearGraphs(); QMap().swap(waveGraph); - qDebug() << "graphCount" << graphCount<< endl; if(!ui->Btn_AC_DC->isChecked()){ m_bDC = false; @@ -3157,10 +3300,7 @@ void ChildForm::CalculateIntegration(bool isDoubleIntegration) QMap().swap(waveGraph); QVector x,y; QVector temDCWave; -<<<<<<< HEAD -======= QString strLabel; ->>>>>>> master QMap::Iterator iter = mapWaveDisplayData.begin(); for (int i = 0; i < listChannelID.size(); ++i){ for(iter = mapWaveDisplayData.begin();iter != mapWaveDisplayData.end();iter++){ @@ -3173,26 +3313,35 @@ void ChildForm::CalculateIntegration(bool isDoubleIntegration) } double rms = 0.0; double f = 0.0; + QVector realvalue; pCalculation->_Integration(temDCWave,y,rms); - if(isDoubleIntegration){ m_bDoubleIntegration = true; QVector key,Proximeter; pCalculation->_Integration(y,Proximeter,rms); - double gap = (double)1/(double)Proximeter.size(); - for(int ii = 0; ii < Proximeter.size();ii++){ - f += gap; - key.push_back(f); + if(m_iFormType == FrequencyDomainPlot){ + pCalculation->FFTSpec(Proximeter,realvalue); + QVector().swap(Proximeter); + Proximeter = realvalue; + ui->widget->xAxis->setLabel("Frequency(Hz)"); + for(int ii = 0; ii < Proximeter.size();ii++){ + key.push_back(ii); + } + }else{ + ui->widget->xAxis->setRange(0, 1); + ui->widget->xAxis->setLabel("Time(s)"); + double gap = (double)1/(double)Proximeter.size(); + for(int ii = 0; ii < Proximeter.size();ii++){ + f += gap; + key.push_back(f); + } } -<<<<<<< HEAD -======= if(iter.value().channelType =="ACCELEROMETER"){ strLabel = "PROXIMETER(um)"; } QCPGraph* graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel); ->>>>>>> master - ui->widget->xAxis->setRange(0, 1); + graph->setData(key, Proximeter); // let the ranges scale themselves so graph 0 fits perfectly in the visible area: graph->rescaleValueAxis(); @@ -3202,25 +3351,33 @@ void ChildForm::CalculateIntegration(bool isDoubleIntegration) pen.setStyle(Qt::SolidLine); pen.setWidth(0); graph->setPen(pen); - // give the Axis some labels: - ui->widget->xAxis->setLabel("Time(s)"); }else{ + if(m_iFormType == FrequencyDomainPlot){ + pCalculation->FFTSpec(y,realvalue); + QVector().swap(y); + y = realvalue; - double gap = (double)1/(double)y.size(); - for(int ii = 0; ii < y.size();ii++){ - f += gap; - x.push_back(f); + for(int ii = 0; ii < y.size();ii++){ + x.push_back(ii); + } + }else{ + ui->widget->xAxis->setRange(0, 1); + qDebug() <<"y.size()" <widget->xAxis->setRange(0, 1); - //QCPGraph* graph = ui->widget->addGraph(); + graph->setData(x, y); // let the ranges scale themselves so graph 0 fits perfectly in the visible area: graph->rescaleValueAxis(); @@ -3229,27 +3386,12 @@ void ChildForm::CalculateIntegration(bool isDoubleIntegration) pen.setColor(iter.value().linColor); pen.setStyle(Qt::SolidLine); pen.setWidth(0); -<<<<<<< HEAD - ui->widget->graph(i)->setPen(pen); - // give the axes some labels: - // QString strRMS = QString("Time(s) %1: %2").arg( "RMS" ).arg(rms); - - ui->widget->xAxis->setLabel("Time(s)"); - if(iter.value().channelType =="VELOCITY"){ - ui->widget->yAxis->setLabel("PROXIMETER(um)"); - }else if(iter.value().channelType =="ACCELEROMETER"){ - ui->widget->yAxis->setLabel("Velocity(mm/s)"); - } - waveGraph.insert(listChannelID.at(i), graph); -======= graph->setPen(pen); // give the Axis some labels: - QString strRMS = QString("Time(s) %1: %2").arg( "RMS" ).arg(rms); +// QString strRMS = QString("Time(s) %1: %2 mm/s").arg( "RMS" ).arg(rms); - ui->widget->xAxis->setLabel(strRMS); +// ui->widget->xAxis->setLabel(strRMS); - //waveGraph.insert(listChannelID.at(i), graph); ->>>>>>> master } ui->widget->replot(QCustomPlot::rpImmediateRefresh); @@ -3263,20 +3405,20 @@ void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation) { QVector key,value,yValue,key2,yValue2; QVector temDCWave,diffValue,diffValue2; -<<<<<<< HEAD -======= QString strLabel; QCPGraph* graph = NULL; qDebug() << mapWaveDisplayData.size() << endl; ->>>>>>> master QMap::Iterator iter = mapWaveDisplayData.begin(); for (int i = 0; i < listChannelID.size(); ++i){ for(iter = mapWaveDisplayData.begin();iter != mapWaveDisplayData.end();iter++){ if(listChannelID.at(i) == iter.key()){ double gap,f; f= 0.0; + QVector realvalue; QVector().swap(temDCWave); QVector().swap(diffValue); + QVector().swap(yValue); + QVector().swap(yValue2); gap = (double)1/(double)iter.value().SamleRate; for(int j = 0; j < iter.value().SamleRate;j++){ temDCWave.push_back(iter.value().wavedata.at(j) - iter.value().mean); @@ -3300,21 +3442,36 @@ void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation) f += gap; key2.push_back(f); } + if(m_iFormType == FrequencyDomainPlot){ + pCalculation->FFTSpec(yValue2,realvalue); + QVector().swap(yValue2); + QVector().swap(key2); + yValue2 = realvalue; + for(int i = 0 ; i < yValue2.size();i++){ + key2.push_back(i); + } + ui->widget->xAxis->setLabel("Frequency(Hz)"); + }else{ + ui->widget->xAxis->setLabel("Time(s)"); + } strLabel = "ACCELEROMETER(m/s^2)"; graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel); - ui->widget->xAxis->setRange(0, 1); graph->setData(key2, yValue2); + }else{ - ui->widget->xAxis->setRange(0, 1); -<<<<<<< HEAD - ui->widget->graph(i)->setData(key, yValue); - if(iter.value().channelType == "VELOCITY") - ui->widget->yAxis->setLabel("ACCELEROMETER(mm/s)"); - else if(iter.value().channelType == "THRUST" || - iter.value().channelType == "PROXIMETER") - ui->widget->yAxis->setLabel("Velocity(mm/s)"); -======= + if(m_iFormType == FrequencyDomainPlot){ + pCalculation->FFTSpec(yValue,realvalue); + QVector().swap(yValue); + QVector().swap(key); + yValue = realvalue; + for(int i = 0 ; i < yValue.size();i++){ + key.push_back(i); + } + ui->widget->xAxis->setLabel("Frequency(Hz)"); + }else{ + ui->widget->xAxis->setLabel("Time(s)"); + } if(iter.value().channelType == "VELOCITY") strLabel = "ACCELEROMETER(m/s^2)"; @@ -3323,7 +3480,7 @@ void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation) strLabel = "Velocity(mm/s)"; graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel); graph->setData(key, yValue); ->>>>>>> master + graph->setName(iter.value().channleName); } // let the ranges scale themselves so graph 0 fits perfectly in the visible area: @@ -3334,13 +3491,8 @@ void ChildForm::CalculateDifferentiation(bool isDoubleDifferentiation) pen.setWidth(0); graph->setPen(pen); graph->setName(iter.value().channleName); - // give the axes some labels: - ui->widget->xAxis->setLabel("Time(s)"); -<<<<<<< HEAD -======= qDebug() << listChannelID.at(i) << endl; ->>>>>>> master ui->widget->replot(QCustomPlot::rpImmediateRefresh); } } @@ -3361,7 +3513,8 @@ void ChildForm::DoubleDifferentiationSlot() }else{ m_bDoubleDifferentiation = true; m_bDifferentiation = false; - if(m_iFormType == TimeDomainPlot){ + //if(m_iFormType == TimeDomainPlot) + { CalculateDifferentiation(true); } } @@ -3381,7 +3534,8 @@ void ChildForm::DifferentiationSlot() m_bDifferentiation = true; m_bDoubleDifferentiation = false; m_bIntegration = false; - if(m_iFormType == TimeDomainPlot){ + //if(m_iFormType == TimeDomainPlot) + { CalculateDifferentiation(); } } @@ -3400,7 +3554,8 @@ void ChildForm::DoubleIntegrationSlot() }else{ m_bDoubleIntegration = true; m_bIntegration = false; - if(m_iFormType == TimeDomainPlot){ + //if(m_iFormType == TimeDomainPlot) + { CalculateIntegration(true); } } @@ -3421,64 +3576,63 @@ void ChildForm::IntegrationSlot() m_bDifferentiation = false; QVector x,y,y1,realvalue,imagevalue; QVector temDCWave; + CalculateIntegration(); +// if(m_iFormType == TimeDomainPlot){ +// CalculateIntegration(); +// }else if(m_iFormType == FrequencyDomainPlot){ +// QMap::Iterator iter = mapWaveDisplayData.begin(); +// for (int i = 0; i < listChannelID.size(); ++i){ +// for(;iter != mapWaveDisplayData.end();iter++){ +// if(listChannelID.at(i) == iter.key()){ +// QVector().swap(x); +// QVector().swap(y); +// QVector().swap(temDCWave); +// for(int j = 0; j < iter.value().SamleRate;j++){ +// double f = iter.value().wavedata.at(j) - iter.value().mean; +// temDCWave.push_back(f); +// } - if(m_iFormType == TimeDomainPlot){ - CalculateIntegration(); - }else if(m_iFormType == FrequencyDomainPlot){ - QMap::Iterator iter = mapWaveDisplayData.begin(); - for (int i = 0; i < listChannelID.size(); ++i){ - for(;iter != mapWaveDisplayData.end();iter++){ - if(listChannelID.at(i) == iter.key()){ - QVector().swap(x); - QVector().swap(y); - QVector().swap(temDCWave); - for(int j = 0; j < iter.value().SamleRate;j++){ - double f = iter.value().wavedata.at(j) - iter.value().mean; - temDCWave.push_back(f); - } +// double rms = 0.0; +// pCalculation->_Integration(temDCWave,y,rms); +// pCalculation->FFTSpec(y,realvalue); +// for(int jj = 0 ; jj < realvalue.size();jj++){ +// x.push_back(jj); +// } - double rms = 0.0; - pCalculation->_Integration(temDCWave,y,rms); - pCalculation->FFTSpec(y,realvalue); - for(int jj = 0 ; jj < realvalue.size();jj++){ - x.push_back(jj); - } +// ui->widget->xAxis->setRange(0, realvalue.size()); +// QString strLabel = ""; +// if(iter.value().channelType == "ACCELEROMETER") +// strLabel = "Velocity(mm/s)"; +// else if(iter.value().channelType == "VELOCITY") +// strLabel = "PROXIMETER(um)"; +// QCPGraph* graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel); +// //QCPGraph* graph = ui->widget->addGraph(); +// ui->widget->graph(i)->setData(x, realvalue); +// // let the ranges scale themselves so graph 0 fits perfectly in the visible area: +// ui->widget->graph(i)->rescaleValueAxis(); +// QPen pen; +// pen.setColor(iter.value().linColor); +// pen.setStyle(Qt::SolidLine); +// pen.setWidth(0); +// ui->widget->graph(i)->setPen(pen); +// // give the axes some labels: +// ui->widget->xAxis->setLabel("Frequency(Hz)"); +// ui->widget->replot(QCustomPlot::rpImmediateRefresh); - ui->widget->xAxis->setRange(0, realvalue.size()); - QString strLabel = ""; - if(iter.value().channelType == "ACCELEROMETER") - strLabel = "Velocity(mm/s)"; - else if(iter.value().channelType == "VELOCITY") - strLabel = "PROXIMETER(um)"; - QCPGraph* graph = MultiyAxis(iter.key(),iter.value().channelType,strLabel); - //QCPGraph* graph = ui->widget->addGraph(); - ui->widget->graph(i)->setData(x, realvalue); - // let the ranges scale themselves so graph 0 fits perfectly in the visible area: - ui->widget->graph(i)->rescaleValueAxis(); - QPen pen; - pen.setColor(iter.value().linColor); - pen.setStyle(Qt::SolidLine); - pen.setWidth(0); - ui->widget->graph(i)->setPen(pen); - // give the axes some labels: - ui->widget->xAxis->setLabel("Frequency(Hz)"); - ui->widget->replot(QCustomPlot::rpImmediateRefresh); - - //waveGraph.insert(listChannelID.at(i), graph); - } - } - } - } +// } +// } +// } +// } } ui->widget->replot(QCustomPlot::rpImmediateRefresh); } void ChildForm::EnableBtn() { - if(m_iFormType == TimeDomainPlot){ + if(m_iFormType == TimeDomainPlot || m_iFormType == FrequencyDomainPlot){ if(ui->Btn_Sound->isChecked()){ ui->Btn_Zoom->setEnabled(false); - ui->Btn_ZoomMenu->setEnabled(false); + ui->Btn_ScalesMenu->setEnabled(false); ui->Btn_setScales->setEnabled(false); ui->measureBtn->setEnabled(false); ui->Btn_Hz->setEnabled(false); @@ -3492,7 +3646,7 @@ void ChildForm::EnableBtn() }else if(ui->realTimeDataBtn->isChecked()){ ui->zoomBtn_hand->setEnabled(false); ui->Btn_Zoom->setEnabled(false); - ui->Btn_ZoomMenu->setEnabled(false); + ui->Btn_ScalesMenu->setEnabled(false); ui->Btn_setScales->setEnabled(false); ui->measureBtn->setEnabled(false); ui->Btn_Hz->setEnabled(false); @@ -3506,7 +3660,7 @@ void ChildForm::EnableBtn() }else{ ui->zoomBtn_hand->setEnabled(true); ui->Btn_Zoom->setEnabled(true); - ui->Btn_ZoomMenu->setEnabled(true); + ui->Btn_ScalesMenu->setEnabled(true); ui->Btn_setScales->setEnabled(true); ui->Btn_AC_DC->setEnabled(true); ui->Btn_differentiation->setEnabled(true); @@ -3516,6 +3670,19 @@ void ChildForm::EnableBtn() } } } +void ChildForm::UpdateTracerLabel() +{ + if(tracerLabel->visible()) + tracerLabel->setVisible(false); + if(tracerLabel2->visible()) + tracerLabel2->setVisible(false); + if(tracerLabel3->visible()) + tracerLabel3->setVisible(false); + if(tracerLabel4->visible()) + tracerLabel4->setVisible(false); + if(tracerLabel5->visible()) + tracerLabel5->setVisible(false); +} //选点处理函数 void ChildForm::OnPlotClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event) { diff --git a/ChaosDataPlayer/ChildForm.h b/ChaosDataPlayer/ChildForm.h index e17be8b..91f7b45 100644 --- a/ChaosDataPlayer/ChildForm.h +++ b/ChaosDataPlayer/ChildForm.h @@ -31,7 +31,8 @@ enum FormType PolarPlot, //极坐标 BodePlot, //伯德图 ShaftCenterline, //轴心位置图 - AllWavePlot //全谱图 + AllWavePlot , //全谱图 + TimeWavePlot //时域长波形 }; @@ -58,7 +59,7 @@ class ChildForm : public BaseWgt Q_OBJECT public: - explicit ChildForm(FormType iType,QString m_strName = "",DEVICE_INFO* DeviceInfo = NULL, QWidget *parent = nullptr); + explicit ChildForm(FormType iType,QString m_strName = "",DEVICE_INFO* DeviceInfo = NULL,int iCurCount = 0, QWidget *parent = nullptr); ~ChildForm(); void SetName(QString strName) @@ -103,6 +104,7 @@ public: void EnableBtn(); void UpdateDiffMenu(); void InitIntegration(); + void UpdateTracerLabel(); QVector childWave; QVector OrbitXWave,OrbitYWave; QVector vecKeyPhasor; @@ -126,20 +128,20 @@ signals: protected: public slots: - void ZoomBtnSlot_X(); - void ZoomBtnSlot_Y(); - void ZoomBtnSlot_XY(); - void ZoomBtnSlot_Hand(); + void ScalesBtnSlot_X(); + void ScalesBtnSlot_Y(); + void ScalesBtnSlot_XY(); + void ScalesBtnSlot_Hand(); void ToRpm(); - void Btn_ZoomSlot(); + void Btn_ScalesSlot(); void IntegrationSlot(); void DoubleIntegrationSlot(); void DifferentiationSlot(); void DoubleDifferentiationSlot(); - void ScalesBox(); - void ScalesX(); - void ScalesY(); - void ScalesXY(); + void ZoomBox(); + void ZoomX(); + void ZoomY(); + void ZoomXY(); void Cursor(); void SetScales(); void SetFilter(); @@ -170,7 +172,8 @@ private: std::condition_variable m_cv; std::mutex mu; WAVE_CSVDATA m_vecCsvData[32]; - + QString m_strFilter; + QString m_strSacles; int m_nStart; int m_nEnd; QMenu *remove_menu; @@ -180,6 +183,7 @@ private: QAction *Ord; QAction *Rad; + QCPAxis *yAxis3; QList Axis; QCPItemTracer *tracer; //游标 diff --git a/ChaosDataPlayer/ChildForm.ui b/ChaosDataPlayer/ChildForm.ui index 2eb2749..6bf718c 100644 --- a/ChaosDataPlayer/ChildForm.ui +++ b/ChaosDataPlayer/ChildForm.ui @@ -17,11 +17,11 @@ Form - #Btn_ZoomMenu { border-image:url(:/images/images/imgModelAction/Zoom_xy.png) 1; } -#Btn_ZoomMenu:hover { border-image:url(:/images/images/imgModelAction/Zoom-xy-h.png) 1; } -#Btn_ZoomMenu:pressed { border-image:url(:/images/images/imgModelAction/Zoom-xy-p.png) 1; } -#Btn_ZoomMenu:checked { border-image:url(:/images/images/imgModelAction/Zoom_xy.png) 1; } -#Btn_ZoomMenu::menu-indicator{image:none;} + #Btn_ScalesMenu { border-image:url(:/images/images/imgModelAction/Zoom_xy.png) 1; } +#Btn_ScalesMenu:hover { border-image:url(:/images/images/imgModelAction/Zoom-xy-h.png) 1; } +#Btn_ScalesMenu:pressed { border-image:url(:/images/images/imgModelAction/Zoom-xy-p.png) 1; } +#Btn_ScalesMenu:checked { border-image:url(:/images/images/imgModelAction/Zoom_xy.png) 1; } +#Btn_ScalesMenu::menu-indicator{image:none;} #Btn_setScales { border-image:url(:/images/images/imgModelAction/setScales.png) 5; } #Btn_setScales:hover { border-image:url(:/images/images/imgModelAction/setScales-h.png) 5; } @@ -98,7 +98,7 @@ #measureBtn:pressed {border-image:url(:/images/images/imgModelAction/measure-p.png) 5; } #measureBtn:checked {border-image:url(:/images/images/imgModelAction/measure-p.png) 5; } -#realTimeDataBtn { border-image:url(:/images/images/imgModelAction/realTime.png) 5; } +#realTimeDataBtn { border-image:url(:/images/images/imgModelAction/realTime-d.png) 5; } #realTimeDataBtn:hover { border-image:url(:/images/images/imgModelAction/realTime-h.png) 5; } #realTimeDataBtn:pressed {border-image:url(:/images/images/imgModelAction/realTime-p.png) 5; } #realTimeDataBtn:checked {border-image:url(:/images/images/imgModelAction/realTime-p.png) 5; } @@ -338,7 +338,7 @@ 41 - + 90 @@ -473,7 +473,7 @@ - true + false @@ -979,7 +979,7 @@ Btn_Cursor Btn_Zoom line_5 - Btn_ZoomMenu + Btn_ScalesMenu Btn_setScales line_6 Btn_Annotation diff --git a/ChaosDataPlayer/CreateReport.cpp b/ChaosDataPlayer/CreateReport.cpp index eb14382..9380efe 100644 --- a/ChaosDataPlayer/CreateReport.cpp +++ b/ChaosDataPlayer/CreateReport.cpp @@ -73,6 +73,18 @@ bool CreateReport::CreateWord()//创建word m_wordOperate->SetText("趋势图"); if(_strImagePathList.at(i).contains("EnvChart")) m_wordOperate->SetText("包络图"); + if(_strImagePathList.at(i).contains("Orbit")) + m_wordOperate->SetText("轴心轨迹图"); + if(_strImagePathList.at(i).contains("WaterFall")) + m_wordOperate->SetText("瀑布图"); + if(_strImagePathList.at(i).contains("Polar")) + m_wordOperate->SetText("极坐标图"); + if(_strImagePathList.at(i).contains("ShaftCenterline")) + m_wordOperate->SetText("轴心位置图"); + if(_strImagePathList.at(i).contains("Bode")) + m_wordOperate->SetText("伯德图"); + if(_strImagePathList.at(i).contains("AllWave")) + m_wordOperate->SetText("全频图"); m_wordOperate->insertEnter(); } DrawTable(); diff --git a/ChaosDataPlayer/FilterForm.cpp b/ChaosDataPlayer/FilterForm.cpp index bc29344..74c2ccb 100644 --- a/ChaosDataPlayer/FilterForm.cpp +++ b/ChaosDataPlayer/FilterForm.cpp @@ -4,7 +4,7 @@ #include #include "msgbox.h" -FilterForm::FilterForm(QWidget *parent) : +FilterForm::FilterForm(QString strFilter, QWidget *parent) : BaseWgt(parent), ui(new Ui::FilterForm) { @@ -17,6 +17,10 @@ FilterForm::FilterForm(QWidget *parent) : QRegExpValidator *validator = new QRegExpValidator(rx, this); ui->lineEdit->setValidator(validator); ui->lineEdit_2->setValidator(validator); + QStringList strList = strFilter.split(","); + ui->lineEdit->setText(strList[0]); + ui->lineEdit_2->setText(strList[1]); + } FilterForm::~FilterForm() diff --git a/ChaosDataPlayer/FilterForm.h b/ChaosDataPlayer/FilterForm.h index 9c543e6..59e867a 100644 --- a/ChaosDataPlayer/FilterForm.h +++ b/ChaosDataPlayer/FilterForm.h @@ -14,7 +14,7 @@ class FilterForm : public BaseWgt Q_OBJECT public: - explicit FilterForm(QWidget *parent = nullptr); + explicit FilterForm(QString strFilter,QWidget *parent = nullptr); ~FilterForm(); private: diff --git a/ChaosDataPlayer/MainWidget.cpp b/ChaosDataPlayer/MainWidget.cpp index 86b7325..8e9304f 100644 --- a/ChaosDataPlayer/MainWidget.cpp +++ b/ChaosDataPlayer/MainWidget.cpp @@ -130,6 +130,7 @@ void MainWidget::InitSignalandSlot() connect(ui->modelBtn_5, SIGNAL(clicked()), this, SLOT(BodePlotSlot())); connect(ui->modelBtn_6, SIGNAL(clicked()), this, SLOT(ShaftCenterlinePlotSlot())); connect(ui->modelBtn_12, SIGNAL(clicked()), this, SLOT(View3D())); + connect(ui->modelBtn_TimeWave, SIGNAL(clicked()), this, SLOT(TimeWave())); connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(Dat2Csv())); connect(ui->refreshBtn, SIGNAL(clicked()), this, SLOT(RefreshBtnSlot()));//刷新终端列表 @@ -248,6 +249,11 @@ void MainWidget::SearchSlot(QString strIP,bool AutoSearch) } void MainWidget::RefreshBtnSlot() { + + ui->refreshBtn->setEnabled(false); + QTimer::singleShot(1000, this, [=]() { + ui->refreshBtn->setEnabled(true); + }); ui->treeWidget->clear(); InitDevList(); /*QString tablename = "t_Device"; @@ -631,7 +637,6 @@ void MainWidget::addChildItem(QTreeWidgetItem *pDataItem,QTreeWidgetItem *pNoIte else if ("manu" == strFlag) { pManulItem = pItem; - } } @@ -687,7 +692,7 @@ void MainWidget::addChildItem(QTreeWidgetItem *pDataItem,QTreeWidgetItem *pNoIte QIcon icon(":/images/images/imgTreeIcon/remove6.png"); pNewItem->setIcon(0, icon); pNewItem->setData(0,FILE_ROLE,0); - pSizeItem->addChild(pNewItem); + pTimeItem->addChild(pNewItem); }else{ QIcon icon(":/images/images/imgTreeIcon/remove2.png"); pNewItem->setIcon(0, icon); @@ -696,16 +701,17 @@ void MainWidget::addChildItem(QTreeWidgetItem *pDataItem,QTreeWidgetItem *pNoIte } } - else if (sfileName.contains("DELTA_EU") || sfileName.contains("DELTA_SPPEED")) + else if (sfileName.contains("DELTA_EU") || sfileName.contains("DELTA_SPEED")) { datpath = QCoreApplication::applicationDirPath() + "\\Dat\\" + strNo + "\\" + "change" + "\\"; filename = datpath + sfileName; QFileInfo file(filename); + qDebug() << filename << endl; if(file.exists()){ QIcon icon(":/images/images/imgTreeIcon/remove6.png"); pNewItem->setIcon(0, icon); pNewItem->setData(0,FILE_ROLE,0); - pSizeItem->addChild(pNewItem); + pChangeItem->addChild(pNewItem); }else{ QIcon icon(":/images/images/imgTreeIcon/remove2.png"); pNewItem->setIcon(0, icon); @@ -1028,7 +1034,7 @@ void MainWidget::OutPDF(QStringList strResult,QString filePath) break; case FormType::FrequencyDomainPlot: pPdfPainter->setPen(QColor(0,0,0)); - pPdfPainter->drawText(iLeft+290 + i * 610,iTop+600,"频谱图"); + pPdfPainter->drawText(iLeft+290 + i * 610,iTop+600,"频域图"); break; case FormType::EnvChartPlot: pPdfPainter->setPen(QColor(0,0,0)); @@ -1162,7 +1168,8 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked) if(pChild->GetFormType() == FrequencyDomainPlot || pChild->GetFormType() == TimeDomainPlot || pChild->GetFormType() == EnvChartPlot || pChild->GetFormType() == SpecChartPlot - || pChild->GetFormType() == TrendChartPlot || pChild->GetFormType() == WaterFallPlot) + || pChild->GetFormType() == TrendChartPlot || pChild->GetFormType() == WaterFallPlot + || pChild->GetFormType() == TimeWavePlot) {//频域图,时域图,包络图,频谱图 QString strChannelID = strID; QMap>::Iterator iter = mapWaveData.begin(); @@ -1217,23 +1224,27 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked) QMap>::Iterator iter = mapWaveData.begin(); for (; iter != mapWaveData.end(); ++iter){ if((iter.key() == strChannelID)){ - + qDebug() << strChannelID << endl; pChild->mapBodeData.insert(strID,iter.value()); + qDebug() << pChild->mapBodeData.size() << endl; if(pChild->mapBodeData.size() < 2){ QString ChannelID = iter.value().at(0).speedRefChannelId; + qDebug() << "speedRefChannelId" <mapBodeData.insert(strID,mapWaveData[ChannelID]); pChild->AddBodeSeries(strChannelID, iter.value(),mapWaveData[ChannelID]); return; } }else{ + qDebug() << 2 << strChannelID << endl; QVector waveSpeedData; //转速 QVector waveVibrateData; //加速度 QMap>::Iterator iter = pChild->mapBodeData.begin(); for (;iter != pChild->mapBodeData.end() ; iter++) { + qDebug() << iter.value()[0].sensorType << endl; if(iter.value()[0].sensorType != "ACCELEROMETER" && iter.value()[0].sensorType != "TACHOMETER"){ MyMsgBox(QMessageBox::Warning,"警告","请选择转速和振动通道进行伯德图分析"); return; @@ -1257,7 +1268,7 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked) QString ChannelID = iter.value().at(0).pairChannelID; QString ChannelType = iter.value().at(0).sensorType; if((ChannelType != "PROXIMETER") /*&& (ChannelID == "NONE" || ChannelID == "")*/){ - MyMsgBox(QMessageBox::Warning,"警告","请选择径向位移通道"); + //MyMsgBox(QMessageBox::Warning,"警告","请选择径向位移通道"); return; } pChild->AddShaftCenterlineSeries(strChannelID, iter.value(),mapWaveData[ChannelID]); @@ -1276,7 +1287,7 @@ void MainWidget::ItemCheckStateSlot(QString strID, bool bChecked) if(strChannelType != "PROXIMETER") return; if(speedChannelID == "NONE" || speedChannelID == ""){ - MyMsgBox(QMessageBox::Warning,"警告","当前文件中没有转速通道数据"); + //MyMsgBox(QMessageBox::Warning,"警告","当前文件中没有转速通道数据"); return; } @@ -1330,7 +1341,11 @@ void MainWidget::TrendChartPlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::TrendChartPlot,tr("趋势图"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::TrendChartPlot,tr("趋势图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("趋势图")); @@ -1379,7 +1394,12 @@ void MainWidget::TimeDomainPlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::TimeDomainPlot,tr("时域图"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + + ChildForm *pChild = new ChildForm(FormType::TimeDomainPlot,tr("时域图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); @@ -1430,7 +1450,11 @@ void MainWidget::FrequencyDomainPlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::FrequencyDomainPlot,tr("频域图"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::FrequencyDomainPlot,tr("频域图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("频域图")); @@ -1478,7 +1502,11 @@ void MainWidget::EnvelopeAnalysisPlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::EnvChartPlot,tr("包络图"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::EnvChartPlot,tr("包络图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("包络图")); @@ -1526,7 +1554,11 @@ void MainWidget::WaterFallPlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::WaterFallPlot,tr("瀑布图"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::WaterFallPlot,tr("瀑布图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("瀑布图")); @@ -1583,7 +1615,11 @@ void MainWidget::BodePlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::BodePlot,tr("Bode"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::BodePlot,tr("伯德图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("伯德图")); @@ -1629,7 +1665,11 @@ void MainWidget::OrbitPlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::OrbitPlot,tr("轴心轨迹图"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::OrbitPlot,tr("轴心轨迹图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("轴心轨迹图")); @@ -1677,7 +1717,11 @@ void MainWidget::ShaftCenterlinePlotSlot() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - ChildForm *pChild = new ChildForm(FormType::ShaftCenterline,tr("轴心位置图"),&m_DeviceInfo,this); + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::ShaftCenterline,tr("轴心位置图"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("轴心位置图")); @@ -1721,7 +1765,15 @@ void MainWidget::ShaftCenterlinePlotSlot() } void MainWidget::PolarplotSlot() { - ChildForm *pChild = new ChildForm(FormType::PolarPlot,tr("极坐标"),&m_DeviceInfo,this); + if(mapWaveData.size() < 1){ + MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); + return; + } + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::PolarPlot,tr("极坐标"),&m_DeviceInfo,m_iCurCount-1,this); pChild->setCloseBtnVisible(true); pChild->hideTopWgt(); pChild->SetName(tr("极坐标")); @@ -1763,6 +1815,58 @@ void MainWidget::PolarplotSlot() ui->tabWidget->setCurrentWidget(pChild); } +void MainWidget::TimeWave() +{ + if(mapWaveData.size() < 1){ + MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); + return; + } + if( ui->tabWidget->count() == 10){ + MyMsgBox(QMessageBox::Warning,"警告","最大支持打开10张图谱"); + return; + } + ChildForm *pChild = new ChildForm(FormType::TimeWavePlot,tr("时域长波形"),&m_DeviceInfo,m_iCurCount-1,this); + pChild->setCloseBtnVisible(true); + pChild->hideTopWgt(); + pChild->SetName(tr("时域长波形")); + pChild->SetFormType(FormType::TimeWavePlot); + + QIcon icon(":/images/images/imgDatamodel/wave.png"); + ui->tabWidget->addTab(pChild, icon, pChild->GetName()); + //pChild->AddPolarPlotSeries(); + QPushButton *pCustomButton = new QPushButton(); + pCustomButton->setFixedSize(14, 14); + pCustomButton->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgDatamodel/tabclose.png) 5; }\ + QPushButton:hover { border-image:url(:/images/images/imgDatamodel/tabclose-h.png) 5; }\ + QPushButton:pressed {border-image:url(:/images/images/imgDatamodel/tabclose-p.png) 5; }"); + ((QTabBar*)(ui->tabWidget->tabBar()))->setTabButton(ui->tabWidget->indexOf(pChild),QTabBar::RightSide,pCustomButton); + connect(pCustomButton, SIGNAL(clicked()), this, SLOT(TabBarCloseSlot())); + m_mapTabBtnToForm[pCustomButton] = pChild; + + connect(pChild, SIGNAL(OutSig()), this, SLOT(OutSlot())); + connect(pChild, SIGNAL(ReturnSig()), this, SLOT(ReturnSlot())); + connect(pChild, SIGNAL(ItemCheckStateSignal(QString, bool)), this, SLOT(ItemCheckStateSlot(QString, bool))); + // connect(pChild, &ChildForm::sigRealTimeData, this, &MainWidget::slotRealTimeData); + + m_vecChildForm.push_back(pChild); + + QStringList strIDList,strChannleType,strChannleNameList; +// QVector::Iterator iter = m_vecPushData.begin(); + QMap>::Iterator iter = mapWaveData.begin(); + for (; iter != mapWaveData.end(); iter ++) + { + if(!strIDList.contains(iter.key())) + strIDList.push_back(iter.key()); + strChannleType.push_back(iter.value()[0].sensorType); + strChannleNameList.push_back(iter.value()[0].channelName); + } + if(mapWaveData.size() > 8) + pChild->SetDataIDs(strIDList, tr("Data Watch "),strChannleType,strChannleNameList); + else + pChild->SetDataIDs(strIDList, tr("Data Watch "),strChannleType,strChannleNameList); + + ui->tabWidget->setCurrentWidget(pChild); +} void MainWidget::View3D() { /* Child3DFrom *pChild = new Child3DFrom(this); @@ -1776,7 +1880,7 @@ void MainWidget::Dat2Csv() MyMsgBox(QMessageBox::Warning,"警告","请先打开数据文件!"); return; } - QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("选择目录"), "./", QFileDialog::ShowDirsOnly); + QString dirpath = QFileDialog::getExistingDirectory(this, QStringLiteral("请选择保存CSV文件路径"), "./", QFileDialog::ShowDirsOnly); if(dirpath.isEmpty()) return; if(mapWaveData.size() < 1){ @@ -1816,7 +1920,8 @@ void MainWidget::Dat2Csv() } QDateTime time = QDateTime::fromTime_t(m_strCollectTime.toUInt()); QString DevicemCollectTime = time.toString("yyyy-MM-dd_hhmmss"); - QString filename = QString(dirName + "%1-%2-%3.csv").arg(iter.key()).arg(iter.value().at(0).sensorType).arg(DevicemCollectTime); + QString filename = QString(dirName + "%1-%2-%3-%4.csv").arg(iter.key()).arg(iter.value().at(0).sensorType)\ + .arg(iter.value().at(0).SamleRate).arg(DevicemCollectTime); QFile file(filename); qDebug()<< "filename = "<sensorType == "TACHOMETER"){ wave.TimeStamp = m_WaveChnData[i].TimeStamp; - qDebug()<< "iCount" <modelBtn_TimeWave->setEnabled(false); + ui->modelBtn_TimeWave->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgDatamodel/wave-p.png) 1; }\ + QPushButton:hover { border-image:url(:/images/images/imgDatamodel/wave-h.png) 1; }\ + QPushButton:pressed {border-image:url(:/images/images/imgDatamodel/wave-p.png) 1; }\ + QPushButton:checked {border-image:url(:/images/images/imgDatamodel/wave-p.png) 1; }"); }else{ ui->modelBtn_TrendChart->setEnabled(true); ui->modelBtn_TrendChart->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgDatamodel/M1.png) 1; }\ @@ -2898,6 +3010,12 @@ void MainWidget::EnableGraph(bool isOpen) QPushButton:hover { border-image:url(:/images/images/imgDatamodel/M8-h.png) 1; }\ QPushButton:pressed {border-image:url(:/images/images/imgDatamodel/M8-p.png) 1; }\ QPushButton:checked {border-image:url(:/images/images/imgDatamodel/M8-p.png) 1; }"); + + ui->modelBtn_TimeWave->setEnabled(true); + ui->modelBtn_TimeWave->setStyleSheet(" QPushButton { border-image:url(:/images/images/imgDatamodel/wave.png) 1; }\ + QPushButton:hover { border-image:url(:/images/images/imgDatamodel/wave-h.png) 1; }\ + QPushButton:pressed {border-image:url(:/images/images/imgDatamodel/wave-p.png) 1; }\ + QPushButton:checked {border-image:url(:/images/images/imgDatamodel/wave-p.png) 1; }"); } // ui->modelBtn_11->setEnabled(true); diff --git a/ChaosDataPlayer/MainWidget.h b/ChaosDataPlayer/MainWidget.h index 790cf47..01a3aeb 100644 --- a/ChaosDataPlayer/MainWidget.h +++ b/ChaosDataPlayer/MainWidget.h @@ -56,6 +56,7 @@ public slots: void PolarplotSlot(); void BodePlotSlot(); void ShaftCenterlinePlotSlot(); + void TimeWave(); void OutSlot(); void ReturnSlot(); void View3D(); diff --git a/ChaosDataPlayer/MainWidget.ui b/ChaosDataPlayer/MainWidget.ui index 0824d54..8fa9d15 100644 --- a/ChaosDataPlayer/MainWidget.ui +++ b/ChaosDataPlayer/MainWidget.ui @@ -79,6 +79,7 @@ #modelBtn_TrendChart{border-image:url(:/images/images/imgDatamodel/M1-p.png);} #modelBtn_TimeDomain{border-image:url(:/images/images/imgDatamodel/M2-p.png);} +#modelBtn_TimeWave{border-image:url(:/images/images/imgDatamodel/wave-p.png);} #modelBtn_FrequencyDomain{border-image:url(:/images/images/imgDatamodel/M3-p.png);} #modelBtn_4{border-image:url(:/images/images/imgDatamodel/M4-p.png);} #modelBtn_5{border-image:url(:/images/images/imgDatamodel/M5-p.png);} @@ -92,6 +93,7 @@ #modelBtn_TrendChart:hover{border-image:url(:/images/images/imgDatamodel/M1-h.png);} #modelBtn_TimeDomain:hover{border-image:url(:/images/images/imgDatamodel/M2-h.png);} +#modelBtn_TimeWave:hover{border-image:url(:/images/images/imgDatamodel/wave-h.png);} #modelBtn_FrequencyDomain:hover{border-image:url(:/images/images/imgDatamodel/M3-h.png);} #modelBtn_4:hover{border-image:url(:/images/images/imgDatamodel/M4-h.png);} #modelBtn_5:hover{border-image:url(:/images/images/imgDatamodel/M5-h.png);} @@ -105,6 +107,7 @@ #modelBtn_TrendChart:pressed{border-image:url(:/images/images/imgDatamodel/M1-p.png);} #modelBtn_TimeDomain:pressed{border-image:url(:/images/images/imgDatamodel/M2-p.png);} +#modelBtn_TimeWave:pressed{border-image:url(:/images/images/imgDatamodel/wave-p.png);} #modelBtn_FrequencyDomain:pressed{border-image:url(:/images/images/imgDatamodel/M3-p.png);} #modelBtn_4:pressed{border-image:url(:/images/images/imgDatamodel/M4-p.png);} #modelBtn_5:pressed{border-image:url(:/images/images/imgDatamodel/M5-p.png);} @@ -289,28 +292,6 @@ - - - - - 18 - 18 - - - - - 18 - 18 - - - - 退出当前DAT文件 - - - - - - @@ -333,6 +314,28 @@ + + + + + 18 + 18 + + + + + 18 + 18 + + + + 退出当前DAT文件 + + + + + + @@ -668,6 +671,31 @@ + + + + false + + + + 36 + 36 + + + + + 36 + 36 + + + + 时域长波形 + + + + + + diff --git a/ChaosDataPlayer/SetScalesForm.ui b/ChaosDataPlayer/SetScalesForm.ui index f03ec33..49a5bf3 100644 --- a/ChaosDataPlayer/SetScalesForm.ui +++ b/ChaosDataPlayer/SetScalesForm.ui @@ -25,9 +25,9 @@ - 170 + 150 50 - 51 + 91 31 @@ -41,7 +41,7 @@ text-align:center; - 113 + 93 50 31 31 @@ -54,9 +54,9 @@ text-align:center; - 300 + 280 50 - 51 + 91 31 @@ -70,10 +70,10 @@ text-align:center; - 240 + 250 60 - 54 - 12 + 21 + 16 @@ -83,9 +83,9 @@ text-align:center; - 170 + 150 100 - 51 + 91 31 @@ -99,7 +99,7 @@ text-align:center; - 113 + 93 100 31 31 @@ -112,9 +112,9 @@ text-align:center; - 300 + 280 100 - 51 + 91 31 @@ -128,10 +128,10 @@ text-align:center; - 240 + 250 110 - 54 - 12 + 21 + 16 diff --git a/ChaosDataPlayer/SetScalesform.cpp b/ChaosDataPlayer/SetScalesform.cpp index ec8c965..6c5feac 100644 --- a/ChaosDataPlayer/SetScalesform.cpp +++ b/ChaosDataPlayer/SetScalesform.cpp @@ -3,7 +3,7 @@ #include "QMessageBox" #include -SetScalesForm::SetScalesForm(QWidget *parent) : +SetScalesForm::SetScalesForm(QString m_strSacles,QWidget *parent) : BaseWgt(parent), ui(new Ui::SetScalesForm) { @@ -18,6 +18,11 @@ SetScalesForm::SetScalesForm(QWidget *parent) : ui->lineEdit_2->setValidator(validator); ui->lineEdit_3->setValidator(validator); ui->lineEdit_4->setValidator(validator); + QStringList strList = m_strSacles.split(","); + ui->lineEdit->setText(strList[0]); + ui->lineEdit_2->setText(strList[1]); + ui->lineEdit_3->setText(strList[2]); + ui->lineEdit_4->setText(strList[3]); } SetScalesForm::~SetScalesForm() diff --git a/ChaosDataPlayer/SetScalesform.h b/ChaosDataPlayer/SetScalesform.h index b8b727f..155a8a0 100644 --- a/ChaosDataPlayer/SetScalesform.h +++ b/ChaosDataPlayer/SetScalesform.h @@ -15,7 +15,7 @@ class SetScalesForm : public BaseWgt Q_OBJECT public: - explicit SetScalesForm(QWidget *parent = nullptr); + explicit SetScalesForm(QString m_strSacles,QWidget *parent = nullptr); ~SetScalesForm(); private: Ui::SetScalesForm *ui; diff --git a/ChaosDataPlayer/global.h b/ChaosDataPlayer/global.h index 80fdf62..c5df306 100644 --- a/ChaosDataPlayer/global.h +++ b/ChaosDataPlayer/global.h @@ -124,8 +124,8 @@ typedef struct{ double sensorSensitivity; int iTrigger; int iKeyCount; - int iTriggerValue; - int iHysteresis; + double iTriggerValue; + double iHysteresis; }WAVE_INFO; typedef struct tag_DEVICE_INFO{ diff --git a/ChaosDataPlayer/images/B7-h.png b/ChaosDataPlayer/images/B7-h.png new file mode 100644 index 0000000..950623a Binary files /dev/null and b/ChaosDataPlayer/images/B7-h.png differ diff --git a/ChaosDataPlayer/images/B7.png b/ChaosDataPlayer/images/B7.png new file mode 100644 index 0000000..2c50189 Binary files /dev/null and b/ChaosDataPlayer/images/B7.png differ diff --git a/ChaosDataPlayer/images/M2-h.png b/ChaosDataPlayer/images/M2-h.png new file mode 100644 index 0000000..52fef33 Binary files /dev/null and b/ChaosDataPlayer/images/M2-h.png differ diff --git a/ChaosDataPlayer/images/M2-p.png b/ChaosDataPlayer/images/M2-p.png new file mode 100644 index 0000000..a8f461e Binary files /dev/null and b/ChaosDataPlayer/images/M2-p.png differ diff --git a/ChaosDataPlayer/images/M2.png b/ChaosDataPlayer/images/M2.png new file mode 100644 index 0000000..160d2b6 Binary files /dev/null and b/ChaosDataPlayer/images/M2.png differ diff --git a/ChaosDataPlayer/images/ico.rar b/ChaosDataPlayer/images/ico.rar deleted file mode 100644 index 76c9b29..0000000 Binary files a/ChaosDataPlayer/images/ico.rar and /dev/null differ diff --git a/ChaosDataPlayer/images/imgDatamodel/wave-h.png b/ChaosDataPlayer/images/imgDatamodel/wave-h.png new file mode 100644 index 0000000..b0be3d5 Binary files /dev/null and b/ChaosDataPlayer/images/imgDatamodel/wave-h.png differ diff --git a/ChaosDataPlayer/images/imgDatamodel/wave-p.png b/ChaosDataPlayer/images/imgDatamodel/wave-p.png new file mode 100644 index 0000000..e5e45da Binary files /dev/null and b/ChaosDataPlayer/images/imgDatamodel/wave-p.png differ diff --git a/ChaosDataPlayer/images/imgDatamodel/wave.png b/ChaosDataPlayer/images/imgDatamodel/wave.png new file mode 100644 index 0000000..e325df7 Binary files /dev/null and b/ChaosDataPlayer/images/imgDatamodel/wave.png differ diff --git a/ChaosDataPlayer/images/加载条.gif.zip b/ChaosDataPlayer/images/加载条.gif.zip deleted file mode 100644 index 7e415be..0000000 Binary files a/ChaosDataPlayer/images/加载条.gif.zip and /dev/null differ diff --git a/ChaosDataPlayer/images/加载条.gif/__MACOSX/._加载条.gif b/ChaosDataPlayer/images/加载条.gif/__MACOSX/._加载条.gif deleted file mode 100644 index 2e91f3e..0000000 Binary files a/ChaosDataPlayer/images/加载条.gif/__MACOSX/._加载条.gif and /dev/null differ diff --git a/ChaosDataPlayer/images/加载条.gif/loading.gif b/ChaosDataPlayer/images/加载条.gif/loading.gif deleted file mode 100644 index 4117934..0000000 Binary files a/ChaosDataPlayer/images/加载条.gif/loading.gif and /dev/null differ diff --git a/ChaosDataPlayer/images/加载条.gif/loading1.gif b/ChaosDataPlayer/images/加载条.gif/loading1.gif deleted file mode 100644 index d78e18b..0000000 Binary files a/ChaosDataPlayer/images/加载条.gif/loading1.gif and /dev/null differ diff --git a/ChaosDataPlayer/qrc.qrc b/ChaosDataPlayer/qrc.qrc index 0360cd9..ac454bc 100644 --- a/ChaosDataPlayer/qrc.qrc +++ b/ChaosDataPlayer/qrc.qrc @@ -175,6 +175,9 @@ images/imgModelAction/realTime-d.png images/logo1.png images/loading.gif + images/imgDatamodel/wave.png + images/imgDatamodel/wave-h.png + images/imgDatamodel/wave-p.png mainui.css