diff --git a/experiment_data/sample_data/~$锡.xlsx b/experiment_data/sample_data/~$锡.xlsx new file mode 100644 index 0000000..d4a5841 Binary files /dev/null and b/experiment_data/sample_data/~$锡.xlsx differ diff --git a/src/global.h b/src/global.h index efd222f..6016f11 100644 --- a/src/global.h +++ b/src/global.h @@ -16,6 +16,8 @@ const QString SampleDataFloder = ExperimentDirPath + "/sample_data"; const QString BaseLineFolder = ExperimentDirPath + "/base_line"; const QString AnalysisStateFolder = ExperimentDirPath + "/analysis_state"; +const QString CurveOfTimeTypeObjectName("curve_time"); + enum Mode{ Analysis, ConnectedToDev, @@ -69,7 +71,7 @@ struct CurveFileData{ struct CurveExperimentData{ QCPCurve * curve; - QString fileName; + QString fileName; // discard QVector dataVtr; }; diff --git a/src/images.qrc b/src/images.qrc index 44c5382..160f474 100644 --- a/src/images.qrc +++ b/src/images.qrc @@ -7,5 +7,6 @@ images/real_time_widget.png images/logo.png images/logo.ico + images/axis.png diff --git a/src/images/axis.png b/src/images/axis.png new file mode 100644 index 0000000..830b8f3 Binary files /dev/null and b/src/images/axis.png differ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c015ef5..0b6b406 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -389,3 +389,8 @@ void MainWindow::on_actionEndsetTemperaturePoint_triggered() _rightWidget->show(); _centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::EndsetTemperaturePoint); } + +void MainWindow::on_actionYAxis_triggered() +{ +_centralWidget->switchAxisMode(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 86a1eda..46279d3 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -87,6 +87,8 @@ private slots: void on_actionEndsetTemperaturePoint_triggered(); + void on_actionYAxis_triggered(); + private: void connections(); void setActionEnable(const bool); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 1bb6a25..1c31be1 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -36,6 +36,7 @@ 视图 + @@ -116,6 +117,7 @@ + @@ -286,6 +288,15 @@ 打印预览 + + + + :/images/axis.png:/images/axis.png + + + Y轴 + + diff --git a/src/serialport/dataparser.cpp b/src/serialport/dataparser.cpp index 7885ad6..bc9ddc5 100644 --- a/src/serialport/dataparser.cpp +++ b/src/serialport/dataparser.cpp @@ -41,7 +41,7 @@ bool commonDataParser(const QByteArray &ba, CommonData &cd) QByteArray connectToDevice(const QVector &vtr) { -// const int phaseLength = sizeof(Phase); + // const int phaseLength = sizeof(Phase); const int phaseLength = PHASE_BYTE_SIZE; const int phaseArrayLength = vtr.size() * phaseLength; @@ -162,12 +162,15 @@ void experimentalStateSwitching(const CommonData &cd) Global::_curveExperimentDataVtr.push_back(ced); Global::_currentCurveExperimentDataPtr = &Global::_curveExperimentDataVtr.last(); - Global::_currentCurveExperimentDataPtr->fileName = Global::_experimentInfo.sampleName; +#if 1 + Global::_currentCurveExperimentDataPtr->fileName = + Global::_experimentInfo.sampleName; +#endif } -// logde<<"phase:"<<(int)cd.current_phase; -// logde<<"run type:"<<(int)cd.run_type; -// logde<<"software mode:"<yAxis2->setVisible(true); + _customPlot->yAxis2->setLabel("Time/min"); + + for(Global::CurveFileData& cfd:Global::_curveFileDataVtr){ + for(Global::PhaseTotalInfo& pti:cfd.phaseTotalVtr){ + + QVector dataVtr; + QVector tVtr,xVtr, yVtr; + int index = 0; + for (Global::ExperimentData &ed : pti.dataVtr) + { + tVtr.push_back(index++); + xVtr.push_back(ed.sampleTemp); + yVtr.push_back(ed.runTime); + } + + double yMin = yVtr.first(); + double yMax = yVtr.last(); + double tick = (yMax - yMin) / 4; + + double axisMin = yMin - tick; + double axisMax = yMax + tick; + _customPlot->yAxis2->setRange(axisMin,axisMax); + + QCPCurve* curve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis2); + curve->setData(tVtr, xVtr, yVtr); + + curve->setObjectName(Global::CurveOfTimeTypeObjectName); + } + } + + }else{ + _axisMode = AxisMode::SingleY; + + _customPlot->yAxis2->setVisible(false); + + for (int i = _customPlot->graphCount() - 1; i >= 0; --i) { + QCPGraph *graph = _customPlot->graph(i); + if(graph && graph->objectName() == Global::CurveOfTimeTypeObjectName){ + _customPlot->removeGraph(graph); + } + } + } + + _customPlot->replot(); +} + void CentralWidget::setAnalysisMode(const CentralWidget::AnalysisMode mode) { _analysisMode = mode; @@ -929,6 +986,7 @@ QPixmap CentralWidget::getPixMap() return _customPlot->toPixmap(); } + void CentralWidget::slotAxisModify(const float temp) { _customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables); diff --git a/src/ui/centralwidget.h b/src/ui/centralwidget.h index cd52e85..01cc380 100644 --- a/src/ui/centralwidget.h +++ b/src/ui/centralwidget.h @@ -35,6 +35,12 @@ public: EventHandler* getEvnetHandler(){return _eventHandler;} QPixmap getPixMap(); + + enum AxisMode{ + SingleY, + DoubleY + }; + void switchAxisMode(); signals: void sigContextMenuShow(const QPoint); void sigSendLineXCoord(const int,const double); @@ -88,6 +94,7 @@ private: QCPItemStraightLine *_line1,*_line2; // QVector _dataVtr; QVector _lineVtr; + AxisMode _axisMode; }; #endif // CENTRALWIDGET_H