2025-04-15T16:02:59
This commit is contained in:
parent
3a6c5fb642
commit
4b8027eb49
@ -20,6 +20,7 @@ include(thirdparty\QtXlsxWriter-0.3.0\src\xlsx\qtxlsx.pri)
|
||||
SOURCES += \
|
||||
data/filemanager.cpp \
|
||||
data/pointcalculate.cpp \
|
||||
data/txthandler.cpp \
|
||||
global.cpp \
|
||||
logger/logger.cpp \
|
||||
ui/aboutform.cpp \
|
||||
@ -44,6 +45,7 @@ SOURCES += \
|
||||
data/xlsxhandler.cpp
|
||||
|
||||
HEADERS += \
|
||||
data/txthandler.h \
|
||||
global.h \
|
||||
data/filemanager.h \
|
||||
data/pointcalculate.h \
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "filemanager.h"
|
||||
|
||||
|
||||
#if 0
|
||||
namespace FileManager {
|
||||
|
||||
Global::ExperimentInfo _expeInfo;
|
||||
@ -17,6 +17,7 @@ void writeExperimentFile(const CommonData &cd)
|
||||
|
||||
createExperimentFile();
|
||||
}
|
||||
|
||||
QTextStream out(&_expeFile);
|
||||
out.setRealNumberPrecision(3); // 设置精度为三位小数
|
||||
out.setRealNumberNotation(QTextStream::FixedNotation);
|
||||
@ -67,7 +68,6 @@ void close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void readExperimentFile(const QString fileName, QVector<Global::ExperimentData> &dataVtr)
|
||||
{
|
||||
if(fileName.isEmpty()){
|
||||
@ -101,5 +101,11 @@ void readExperimentFile(const QString fileName, QVector<Global::ExperimentData>
|
||||
_expeFile.close();
|
||||
}
|
||||
|
||||
void writeFile()
|
||||
{
|
||||
createExperimentFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,15 +9,13 @@
|
||||
#include "protocol.h"
|
||||
#include "global.h"
|
||||
|
||||
#if 0
|
||||
namespace FileManager{
|
||||
const QString ExperimentDirPath = QDir::currentPath()+"/../experiment_data";
|
||||
const QString SampleDataFloder = ExperimentDirPath + "/sample_data";
|
||||
const QString BaseLineFolder = ExperimentDirPath + "/base_line";
|
||||
const QString AnalysisStateFolder = ExperimentDirPath + "/analysis_state";
|
||||
|
||||
extern Global::ExperimentInfo _expeInfo;
|
||||
extern QFile _expeFile;
|
||||
|
||||
void writeFile();
|
||||
|
||||
void createExperimentFile();
|
||||
void writeExperimentFile(const CommonData&);
|
||||
void close();
|
||||
@ -26,5 +24,6 @@ void readExperimentFile(const QString fileName,QVector<Global::ExperimentData>&)
|
||||
|
||||
void test();
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
2
src/data/txthandler.cpp
Normal file
2
src/data/txthandler.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "txthandler.h"
|
||||
|
8
src/data/txthandler.h
Normal file
8
src/data/txthandler.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef TXTHANDLER_H
|
||||
#define TXTHANDLER_H
|
||||
|
||||
namespace TxtHandler {
|
||||
|
||||
}
|
||||
|
||||
#endif // TXTHANDLER_H
|
@ -3,33 +3,39 @@
|
||||
|
||||
void XlsxHandler::test()
|
||||
{
|
||||
#if 0
|
||||
QString sourceFilePath = QDir::currentPath() + "/sample.xlsx";
|
||||
qDebug() << "fileName:" << sourceFilePath;
|
||||
readFile(sourceFilePath);
|
||||
#endif
|
||||
QString sourceFilePath = QDir::currentPath() + "/sample-save.xlsx";
|
||||
writeFile(sourceFilePath);
|
||||
}
|
||||
void XlsxHandler::readFile(const QString sourceFilePath)
|
||||
int XlsxHandler::readFile(const QString sourceFilePath, Global::CurveFileData &cfd)
|
||||
{
|
||||
// 检查文件是否存在
|
||||
if(!QFile::exists(sourceFilePath))
|
||||
{
|
||||
qDebug() << "xlsx file not existed:" << sourceFilePath;
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
QFileInfo fileInfo(sourceFilePath);
|
||||
|
||||
// 获取文件的后缀名并转换为小写,方便比较
|
||||
QString fileSuffix = fileInfo.suffix().toLower();
|
||||
|
||||
// 判断后缀名是否为 "xlsx"
|
||||
if (fileSuffix != "xlsx") {
|
||||
std::cout << "该文件的后缀不是 xlsx" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// 尝试打开文件
|
||||
QXlsx::Document xlsx(sourceFilePath);
|
||||
|
||||
#if 0
|
||||
// 获取所有工作表名称
|
||||
QStringList sheetNames = xlsx.sheetNames();
|
||||
qDebug() << "工作表名称:" << sheetNames;
|
||||
#endif
|
||||
|
||||
QXlsx::Worksheet *workSheet = xlsx.currentWorksheet();
|
||||
if(!workSheet)
|
||||
{
|
||||
qDebug() << "current sheet is empty.";
|
||||
return;
|
||||
logde << "current sheet is empty.";
|
||||
return 3;
|
||||
}
|
||||
|
||||
// 获取工作表的行数和列数
|
||||
@ -40,9 +46,9 @@ void XlsxHandler::readFile(const QString sourceFilePath)
|
||||
logde << "0:" << workSheet->cellAt(1, 1)->value().toString().toStdString();
|
||||
qDebug() << workSheet->cellAt(1, 1)->value().toString();
|
||||
|
||||
|
||||
int index = 2;
|
||||
Global::ExperimentInfo ei;
|
||||
//
|
||||
int index = 2;
|
||||
Global::ExperimentInfo& ei = cfd.ei;
|
||||
ei.sampleName = workSheet->cellAt(index++, 2)->value().toString();
|
||||
ei.sampleWeight = workSheet->cellAt(index++, 2)->value().toString();
|
||||
index++; // skip crucible weight.
|
||||
@ -51,7 +57,7 @@ void XlsxHandler::readFile(const QString sourceFilePath)
|
||||
index++; // skip measure type.
|
||||
ei.phaseSize = workSheet->cellAt(index++, 2)->value().toInt();
|
||||
|
||||
QVector<Global::PhaseTotalInfo> phaseTotalVtr;
|
||||
QVector<Global::PhaseTotalInfo>& phaseTotalVtr = cfd.phaseTotalVtr;
|
||||
int startLineIndex = 9;
|
||||
for(int i = 0; i < ei.phaseSize; i++)
|
||||
{
|
||||
@ -61,6 +67,7 @@ void XlsxHandler::readFile(const QString sourceFilePath)
|
||||
readPhaseData(workSheet, startLineIndex, phaseTotal);
|
||||
phaseTotalVtr.push_back(phaseTotal);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex,
|
||||
@ -90,14 +97,15 @@ void XlsxHandler::readPhaseData(QXlsx::Worksheet *workSheet, int &startLineIndex
|
||||
}
|
||||
}
|
||||
|
||||
void XlsxHandler::writeFile()
|
||||
void XlsxHandler::writeFile(const QString filePath)
|
||||
{
|
||||
Global::ExperimentInfo& ei = Global::_experimentInfo;
|
||||
|
||||
QXlsx::Document xlsx;
|
||||
xlsx.addSheet("Sheet1"); // 添加一个新的工作表
|
||||
|
||||
int row = 0;
|
||||
// Write experiment info.
|
||||
int row = 1;
|
||||
xlsx.write(row++ , 1, ConFileDataInfo);
|
||||
|
||||
xlsx.write(row , 1, ConSampleName);
|
||||
@ -130,7 +138,7 @@ void XlsxHandler::writeFile()
|
||||
xlsx.write(row , 2, ei.phaseVtr.size());
|
||||
row++;
|
||||
|
||||
// write phase data
|
||||
// Write phase data.
|
||||
int dataSizeRow = 0;
|
||||
for(int i = 0; i < ei.phaseVtr.size();i++){
|
||||
const Phase& phase = ei.phaseVtr.at(i);
|
||||
@ -176,13 +184,30 @@ void XlsxHandler::writeFile()
|
||||
row++;
|
||||
|
||||
// phase data.
|
||||
|
||||
const QVector<Global::ExperimentData>& edVtr =
|
||||
Global::_curveExperimentDataVtr.at(i).dataVtr;
|
||||
// phase data size.
|
||||
dataSizeRow = row;
|
||||
xlsx.write(row , 1, ConPhaseDataSize);
|
||||
xlsx.write(row , 2, 0);
|
||||
xlsx.write(row , 2, edVtr.size());
|
||||
row++;
|
||||
|
||||
for(int index = 0;index < edVtr.size();index++){
|
||||
const Global::ExperimentData & ed = edVtr.at(index);
|
||||
|
||||
xlsx.write(row , 1, index);
|
||||
xlsx.write(row , 2, ed.runTime);
|
||||
xlsx.write(row , 3, ed.constantTempTime);
|
||||
xlsx.write(row , 4, ed.sampleTemp);
|
||||
xlsx.write(row , 5, ed.dsc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!xlsx.saveAs(filePath)) {
|
||||
logde<<"Save xlsx failed.";
|
||||
return ;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// 创建一个新的 Excel 文档
|
||||
@ -213,3 +238,4 @@ void XlsxHandler::writeFile()
|
||||
return ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,19 @@
|
||||
|
||||
namespace XlsxHandler {
|
||||
void test();
|
||||
void readFile(const QString filePath);
|
||||
/**
|
||||
* @brief readFile
|
||||
* @param filePath
|
||||
* @return
|
||||
* 0:Succ;
|
||||
* 1:File not existed;
|
||||
* 2:File not xlsx;
|
||||
* 3:Sheet is empty.
|
||||
*/
|
||||
int readFile(const QString filePath,Global::CurveFileData&);
|
||||
void readPhaseData(QXlsx::Worksheet*,int& startLineIndex,Global::PhaseTotalInfo&);
|
||||
|
||||
void writeFile();
|
||||
void writeFile(const QString filePath);
|
||||
|
||||
const QString ConUnitMg = "mg";
|
||||
const QString ConUnitDegreeCentigrade = "℃";
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include "global.h"
|
||||
|
||||
namespace Global {
|
||||
ExperimentInfo _experimentInfo;
|
||||
Mode _mode;
|
||||
|
||||
QVector<QPair<QCPCurve*,QVector<Global::ExperimentData>>> _curveDataVtr;
|
||||
QVector<CurveFileData> _curveFileDataVtr;
|
||||
|
||||
ExperimentInfo _experimentInfo;
|
||||
QVector<CurveExperimentData> _curveExperimentDataVtr;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
39
src/global.h
39
src/global.h
@ -8,6 +8,11 @@
|
||||
#include "protocol.h"
|
||||
|
||||
namespace Global {
|
||||
const QString ExperimentDirPath = QDir::currentPath()+"/../experiment_data";
|
||||
const QString SampleDataFloder = ExperimentDirPath + "/sample_data";
|
||||
const QString BaseLineFolder = ExperimentDirPath + "/base_line";
|
||||
const QString AnalysisStateFolder = ExperimentDirPath + "/analysis_state";
|
||||
|
||||
enum Mode{
|
||||
Analysis,
|
||||
ConnectedToDev,
|
||||
@ -50,12 +55,26 @@ struct PhaseTotalInfo{
|
||||
int phaseIndex; // from 1 to 6.
|
||||
Phase phase;
|
||||
QVector<ExperimentData> dataVtr;
|
||||
QCPCurve * curve;
|
||||
};
|
||||
|
||||
//
|
||||
extern QVector<QPair<QCPCurve*,QVector<Global::ExperimentData>>> _curveDataVtr;
|
||||
extern ExperimentInfo _experimentInfo;
|
||||
struct CurveFileData{
|
||||
Global::ExperimentInfo ei;
|
||||
QVector<Global::PhaseTotalInfo> phaseTotalVtr;
|
||||
};
|
||||
|
||||
struct CurveExperimentData{
|
||||
QCPCurve * curve;
|
||||
QVector<Global::ExperimentData> dataVtr;
|
||||
};
|
||||
|
||||
// Soft mode.
|
||||
extern Mode _mode;
|
||||
// Xlsx file data.
|
||||
extern QVector<CurveFileData> _curveFileDataVtr;
|
||||
// Experiment setting data.
|
||||
extern ExperimentInfo _experimentInfo;
|
||||
extern QVector<CurveExperimentData> _curveExperimentDataVtr;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -92,13 +111,13 @@ public:
|
||||
float dsc;
|
||||
};
|
||||
|
||||
// struct ExpeInfo
|
||||
// {
|
||||
// QString sampleName;
|
||||
// float sampleWeight;
|
||||
// QString date;
|
||||
// QString userName;
|
||||
// };
|
||||
// struct ExpeInfo
|
||||
// {
|
||||
// QString sampleName;
|
||||
// float sampleWeight;
|
||||
// QString date;
|
||||
// QString userName;
|
||||
// };
|
||||
|
||||
enum TestType{
|
||||
OIT,
|
||||
|
@ -22,10 +22,10 @@ int main(int argc, char *argv[])
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 启用高DPI缩放
|
||||
QApplication a(argc, argv);
|
||||
|
||||
// MainWindow w;
|
||||
// w.show();
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
XlsxHandler::test();
|
||||
// XlsxHandler::test();
|
||||
|
||||
|
||||
// FileManager::test();
|
||||
|
@ -52,11 +52,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
_degreeOfCureForm->setWindowFlags(_degreeOfCureForm->windowFlags()|
|
||||
Qt::Dialog);
|
||||
_instrumentCoefficientForm->setWindowFlags(_instrumentCoefficientForm->windowFlags()|
|
||||
Qt::Dialog);
|
||||
Qt::Dialog);
|
||||
_OITAutoAnalysisParamForm->setWindowFlags(_OITAutoAnalysisParamForm->windowFlags()|
|
||||
Qt::Dialog);
|
||||
// _degreeOfCrystallinityForm->setWindowFlags(_degreeOfCrystallinityForm->windowFlags()|
|
||||
// Qt::Dialog);
|
||||
Qt::Dialog);
|
||||
// _degreeOfCrystallinityForm->setWindowFlags(_degreeOfCrystallinityForm->windowFlags()|
|
||||
// Qt::Dialog);
|
||||
|
||||
// 设置子窗口为模态对话框
|
||||
_degreeOfCrystallinityForm->setWindowModality(Qt::ApplicationModal);
|
||||
@ -87,7 +87,6 @@ MainWindow::~MainWindow()
|
||||
// 假设 Ui::MainWindow 不是 QObject 派生类
|
||||
delete ui;
|
||||
|
||||
FileManager::close();
|
||||
}
|
||||
|
||||
void MainWindow::slotContextMenuShow(const QPoint point)
|
||||
@ -116,8 +115,8 @@ void MainWindow::connections()
|
||||
#endif
|
||||
|
||||
// mode
|
||||
// connect(Global::instance(), &Global::sigModeModify,
|
||||
// _centralWidget, &CentralWidget::slotModeModify);
|
||||
// connect(Global::instance(), &Global::sigModeModify,
|
||||
// _centralWidget, &CentralWidget::slotModeModify);
|
||||
//analysis
|
||||
connect(_leftWidget,&LeftWidget::sigSendAnalysisFileName,
|
||||
_centralWidget,&CentralWidget::slotRecvAnalysisFileName);
|
||||
@ -171,9 +170,10 @@ void MainWindow::on_actionStop_triggered()
|
||||
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
||||
SerialPort::instance()->slotSendData(ba);
|
||||
|
||||
FileManager::close();
|
||||
// Save data.
|
||||
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
|
||||
// Global::instance()->setMode(Global::Mode::Analysis);
|
||||
Global::_mode = Global::Mode::Analysis;
|
||||
}
|
||||
|
||||
@ -190,16 +190,14 @@ void MainWindow::on_actionStart_triggered()
|
||||
qDebug() << "on_actionStart_triggered info (hex):" << hexData;
|
||||
|
||||
SerialPort::instance()->slotSendData(ba);
|
||||
//
|
||||
FileManager::createExperimentFile();
|
||||
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
Global::_mode = Global::Mode::ExperimentStart;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionReadOnly_triggered()
|
||||
{
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
// Global::instance()->setMode(Global::Mode::ExperimentStart);
|
||||
Global::_mode = Global::Mode::ExperimentStart;
|
||||
SerialPort::instance()->openSp();
|
||||
}
|
||||
@ -214,7 +212,7 @@ void MainWindow::on_actionConnectToDev_triggered()
|
||||
if (SerialPort::instance()->openSp())
|
||||
{
|
||||
setActionEnable(true);
|
||||
// Global::instance()->setMode(Global::Mode::ConnectedToDev);
|
||||
// Global::instance()->setMode(Global::Mode::ConnectedToDev);
|
||||
Global::_mode = Global::Mode::ConnectedToDev;
|
||||
|
||||
QByteArray ba = DataParser::inquirePhaseInfo();
|
||||
@ -274,7 +272,7 @@ void MainWindow::on_actionSpecificHeatCompMethod_triggered()
|
||||
|
||||
void MainWindow::on_actionDegreeOfCrystallinity_triggered()
|
||||
{
|
||||
// QMessageBox::warning(this, "warnning", "结晶度.");
|
||||
// QMessageBox::warning(this, "warnning", "结晶度.");
|
||||
_degreeOfCrystallinityForm->show();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ AnalysisSettingForm::AnalysisSettingForm(QWidget *parent) :
|
||||
|
||||
QFormLayout *editLayout = new QFormLayout();
|
||||
editLayout->addRow("左边界:",_leftBorderSpinBox);
|
||||
editLayout->addRow("有边界:",_rightBorderSpinBox);
|
||||
editLayout->addRow("右边界:",_rightBorderSpinBox);
|
||||
editLayout->addRow("阈值:",_thresholdLineEdit);
|
||||
|
||||
QGridLayout *buttonLayout = new QGridLayout();
|
||||
@ -40,9 +40,9 @@ AnalysisSettingForm::AnalysisSettingForm(QWidget *parent) :
|
||||
layout->addLayout(editLayout);
|
||||
layout->addSpacerItem(spacer);
|
||||
layout->addLayout(buttonLayout);
|
||||
layout->addLayout(editLayout);
|
||||
// layout->addLayout(editLayout);
|
||||
// layout->setSpacing(1);
|
||||
layout->addLayout(buttonLayout);
|
||||
// layout->addLayout(buttonLayout);
|
||||
layout->addStretch(1);
|
||||
//
|
||||
#if 0
|
||||
|
@ -8,10 +8,11 @@
|
||||
#include "filemanager.h"
|
||||
#include "pointcalculate.h"
|
||||
#include "logger.h"
|
||||
#include "xlsxhandler.h"
|
||||
|
||||
CentralWidget::CentralWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
_customPlot(new QCustomPlot(this))
|
||||
: QWidget(parent)
|
||||
,_customPlot(new QCustomPlot(this))
|
||||
,_analysisMode(AnalysisMode::None)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
@ -46,7 +47,8 @@ CentralWidget::CentralWidget(QWidget *parent)
|
||||
|
||||
_customPlot->installEventFilter(_eventHandler);
|
||||
// _customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
_customPlot->setInteractions( QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
// _customPlot->setInteractions( QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
_customPlot->setInteractions(QCP::iSelectPlottables);
|
||||
|
||||
connect(_eventHandler,&EventHandler::sigSendLineXCoord,
|
||||
this,&CentralWidget::sigSendLineXCoord);
|
||||
@ -75,7 +77,6 @@ CentralWidget::CentralWidget(QWidget *parent)
|
||||
|
||||
CentralWidget::~CentralWidget()
|
||||
{
|
||||
FileManager::close();
|
||||
}
|
||||
|
||||
void CentralWidget::setAnalysisMode(const CentralWidget::AnalysisMode mode)
|
||||
@ -121,7 +122,6 @@ void CentralWidget::slotModeModify(const Global::Mode mode)
|
||||
else if (Global::Mode::Analysis == mode)
|
||||
{
|
||||
qDebug() << "file close...";
|
||||
FileManager::close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,15 +131,25 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
|
||||
if(!_currentCurve){
|
||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||
|
||||
Global::_curveDataVtr.clear();
|
||||
|
||||
Global::_curveDataVtr.push_back(qMakePair<QCPCurve*, QVector<Global::ExperimentData>>(
|
||||
_currentCurve, QVector<Global::ExperimentData>()
|
||||
));
|
||||
}
|
||||
// Update curve.
|
||||
_currentCurve->addData(cd.sample_temp, cd.dsc);
|
||||
|
||||
QVector<Global::ExperimentData>& edVtr = Global::_curveDataVtr.first().second;
|
||||
_customPlot->rescaleAxes();
|
||||
_customPlot->replot();
|
||||
|
||||
// Record data.
|
||||
QVector<Global::ExperimentData>* pEdVtr = nullptr; // 声明指针变量
|
||||
for(auto item:Global::_curveExperimentDataVtr){
|
||||
if(item.curve == _currentCurve){
|
||||
pEdVtr = &item.dataVtr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!pEdVtr){
|
||||
Global::_curveExperimentDataVtr.push_back({_currentCurve, {}});
|
||||
pEdVtr = &Global::_curveExperimentDataVtr.back().dataVtr;
|
||||
}
|
||||
|
||||
Global::ExperimentData ed;
|
||||
ed.dsc = cd .dsc;
|
||||
@ -147,19 +157,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
ed.runTime = cd.add_run_time;
|
||||
ed.constantTempTime = cd.add_constan_temp_time;
|
||||
|
||||
edVtr.push_back(ed);
|
||||
|
||||
_currentCurve->addData(cd.sample_temp, cd.dsc);
|
||||
|
||||
// customPlot->xAxis->rescale();
|
||||
// customPlot->yAxis->rescale();
|
||||
|
||||
// _customPlot->graph(0)->addData(cd.sample_temp, cd.dsc); // 添加数据到曲线
|
||||
|
||||
_customPlot->rescaleAxes();
|
||||
_customPlot->replot();
|
||||
//
|
||||
FileManager::writeExperimentFile(cd);
|
||||
pEdVtr->push_back(ed);
|
||||
}
|
||||
|
||||
void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
||||
@ -167,49 +165,43 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
||||
qDebug() << "slotRecvAnalysisFileName" << fileName;
|
||||
|
||||
// todo.禁止重复文件添加。
|
||||
Global::CurveFileData cfd;
|
||||
XlsxHandler::readFile(fileName,cfd);
|
||||
|
||||
_dataVtr.clear();
|
||||
FileManager::readExperimentFile(fileName, _dataVtr);
|
||||
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
|
||||
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
|
||||
|
||||
PointCalculate::setExperimentData(pti.dataVtr);
|
||||
QPair<QPointF,QPointF>startEndPointPair = PointCalculate::getStartAndEndPoint();
|
||||
|
||||
QPointF endPoint = startEndPointPair.second;
|
||||
_customPlot->xAxis->setRange(0, endPoint.x() / 3 * 4);
|
||||
|
||||
QPointF peakPoint = PointCalculate::getPeakPoint();
|
||||
float absY = std::abs(peakPoint.y());
|
||||
_customPlot->yAxis->setRange(- absY * 2,absY *2);
|
||||
|
||||
// 设置坐标轴标签
|
||||
_customPlot->yAxis->setLabel("DSC/mW");
|
||||
_customPlot->xAxis->setLabel("Temp/℃");
|
||||
|
||||
QVector<double> 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.dsc);
|
||||
}
|
||||
|
||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||
_currentCurve->setData(tVtr, xVtr, yVtr);
|
||||
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
||||
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
||||
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||
// _currentCurve->setSelectable(QCP::stPlottable); // 设置曲线可选
|
||||
|
||||
if (_dataVtr.size() < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//
|
||||
// _customPlot->xAxis->setRange(0, 500);
|
||||
// _customPlot->yAxis->setRange(-20, 20);
|
||||
PointCalculate::setExperimentData(_dataVtr);
|
||||
QPair<QPointF,QPointF>startEndPointPair = PointCalculate::getStartAndEndPoint();
|
||||
|
||||
QPointF endPoint = startEndPointPair.second;
|
||||
_customPlot->xAxis->setRange(0, endPoint.x() / 3 * 4);
|
||||
|
||||
QPointF peakPoint = PointCalculate::getPeakPoint();
|
||||
float absY = std::abs(peakPoint.y());
|
||||
_customPlot->yAxis->setRange(- absY * 2,absY *2);
|
||||
|
||||
// 设置坐标轴标签
|
||||
_customPlot->yAxis->setLabel("DSC/mW");
|
||||
_customPlot->xAxis->setLabel("Temp/℃");
|
||||
|
||||
QVector<double> tVtr,xVtr, yVtr;
|
||||
int index = 0;
|
||||
for (Global::ExperimentData &ed : _dataVtr)
|
||||
{
|
||||
tVtr.push_back(index++);
|
||||
xVtr.push_back(ed.sampleTemp);
|
||||
yVtr.push_back(ed.dsc);
|
||||
}
|
||||
|
||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||
_currentCurve->setData(tVtr, xVtr, yVtr);
|
||||
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
||||
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
||||
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||
// _currentCurve->setSelectable(QCP::stPlottable); // 设置曲线可选
|
||||
|
||||
Global::_curveDataVtr.push_back(qMakePair<QCPCurve*,QVector<Global::ExperimentData>>(
|
||||
_currentCurve,_dataVtr));
|
||||
|
||||
// 清除第一个图表上的数据
|
||||
#if 0
|
||||
@ -629,7 +621,7 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
||||
}
|
||||
|
||||
// Clear data.
|
||||
Global::_curveDataVtr.clear();
|
||||
Global::_curveExperimentDataVtr.clear();
|
||||
|
||||
// Set lines visiable false.
|
||||
_line1->setVisible(false);
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
// QVector<QCPGraph*> _graphVtr;
|
||||
EventHandler* _eventHandler;
|
||||
QCPItemStraightLine *_line1,*_line2;
|
||||
QVector<Global::ExperimentData> _dataVtr;
|
||||
// QVector<Global::ExperimentData> _dataVtr;
|
||||
QVector<QCPItemStraightLine*> _lineVtr;
|
||||
};
|
||||
|
||||
|
@ -34,6 +34,7 @@ ExperimentSettingForm::ExperimentSettingForm(QWidget *parent) : QWidget(parent),
|
||||
|
||||
// connect(ui->pushButton_connect_to_device,&QPushButton::clicked,
|
||||
// this,&ExperimentSettingForm::slotConnectToDevice);
|
||||
|
||||
connect(ui->pushButton_cancel, &QPushButton::clicked,
|
||||
this, &ExperimentSettingForm::slotCancel);
|
||||
}
|
||||
@ -326,7 +327,7 @@ void ExperimentSettingForm::slotPhase6StateChanged(int state)
|
||||
}
|
||||
}
|
||||
|
||||
void ExperimentSettingForm::slotConnectToDevice()
|
||||
void ExperimentSettingForm::on_pushButton_deliverData_clicked()
|
||||
{
|
||||
QVector<Phase> phaseVtr;
|
||||
if (ui->checkBox_phase_1->checkState())
|
||||
@ -401,11 +402,6 @@ void ExperimentSettingForm::slotConnectToDevice()
|
||||
|
||||
phaseVtr.push_back(phase);
|
||||
}
|
||||
|
||||
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
||||
qDebug() << "ba size:" << ba.size();
|
||||
emit sigDeliverData(ba);
|
||||
|
||||
//
|
||||
Global::ExperimentInfo& ei = Global::_experimentInfo;
|
||||
ei.phaseVtr = phaseVtr;
|
||||
@ -422,6 +418,10 @@ void ExperimentSettingForm::slotConnectToDevice()
|
||||
|
||||
ei.initialAtmosPhere = (GasType)(ui->comboBox_phase_1_atmosphere->currentIndex());
|
||||
|
||||
//
|
||||
QByteArray ba = DataParser::connectToDevice(phaseVtr);
|
||||
qDebug() << "ba size:" << ba.size();
|
||||
emit sigDeliverData(ba);
|
||||
hide();
|
||||
}
|
||||
|
||||
@ -484,16 +484,6 @@ void ExperimentSettingForm::slotPhaseCheck()
|
||||
}
|
||||
}
|
||||
|
||||
void ExperimentSettingForm::on_pushButton_deliverData_clicked()
|
||||
{
|
||||
slotConnectToDevice();
|
||||
|
||||
FileManager::_expeInfo.sampleName = ui->sampleNameLineEdit->text();
|
||||
FileManager::_expeInfo.sampleWeight = ui->sampleWeightLineEdit->text().toInt(nullptr, 16);
|
||||
FileManager::_expeInfo.date = ui->dateTimeLineEdit->text();
|
||||
FileManager::_expeInfo.experimentor = ui->userLineEdit->text();
|
||||
}
|
||||
|
||||
void ExperimentSettingForm::slotRecvPhaseInfo(const QByteArray &ba)
|
||||
{
|
||||
QByteArray localba = ba;
|
||||
|
@ -37,9 +37,7 @@ private:
|
||||
void slotPhase5StateChanged(int state);
|
||||
void slotPhase6StateChanged(int state);
|
||||
|
||||
void slotConnectToDevice();
|
||||
void slotCancel();
|
||||
|
||||
private:
|
||||
Ui::ExperimentSettingForm *ui;
|
||||
};
|
||||
|
@ -18,11 +18,6 @@ void InstrumentCoefficientForm::on_pushButtonCalculate_clicked()
|
||||
|
||||
}
|
||||
|
||||
void InstrumentCoefficientForm::on_pushButtonExit_clicked()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InstrumentCoefficientForm::on_pushButtonCancel_clicked()
|
||||
{
|
||||
hide();
|
||||
|
@ -18,8 +18,6 @@ public:
|
||||
private slots:
|
||||
void on_pushButtonCalculate_clicked();
|
||||
|
||||
void on_pushButtonExit_clicked();
|
||||
|
||||
void on_pushButtonCancel_clicked();
|
||||
|
||||
private:
|
||||
|
@ -29,9 +29,9 @@ LeftWidget::LeftWidget(QWidget *parent ): QDockWidget(parent)
|
||||
setWidget(_treeWidget);
|
||||
|
||||
//init file name.
|
||||
initFileName(_sampleDataItem,FileManager::SampleDataFloder);
|
||||
initFileName(_baseLineItem,FileManager::BaseLineFolder);
|
||||
initFileName(_analysisStateItem,FileManager::AnalysisStateFolder);
|
||||
initFileName(_sampleDataItem,Global::SampleDataFloder);
|
||||
initFileName(_baseLineItem,Global::BaseLineFolder);
|
||||
initFileName(_analysisStateItem,Global::AnalysisStateFolder);
|
||||
|
||||
expandAll(_sampleDataItem);
|
||||
expandAll(_baseLineItem);
|
||||
@ -88,11 +88,11 @@ void LeftWidget::slotTreeWidgetItemClicked(QTreeWidgetItem *item, int column){
|
||||
if (parentItem) {
|
||||
qDebug() << "parent item text:" << parentItem->text(0);
|
||||
if(parentItem == _sampleDataItem){
|
||||
fileName =FileManager::SampleDataFloder + "/" + item->text(0);
|
||||
fileName =Global::SampleDataFloder + "/" + item->text(0);
|
||||
}else if(parentItem == _baseLineItem){
|
||||
fileName =FileManager::BaseLineFolder + "/" +item->text(0);
|
||||
fileName =Global::BaseLineFolder + "/" +item->text(0);
|
||||
}else if(parentItem == _analysisStateItem){
|
||||
fileName =FileManager::AnalysisStateFolder + "/" +item->text(0);
|
||||
fileName =Global::AnalysisStateFolder + "/" +item->text(0);
|
||||
}
|
||||
} else {
|
||||
qDebug() << "item has no parent (it is a top-level item)";
|
||||
|
@ -82,18 +82,18 @@ void SpecificHeatComparisonMethodForm::slotSetCurve(const int type, QCPCurve *c
|
||||
|
||||
void SpecificHeatComparisonMethodForm::on_pushButtonCalculate_clicked()
|
||||
{
|
||||
auto& curveDataVtr = Global::_curveDataVtr;
|
||||
auto& curveDataVtr = Global::_curveExperimentDataVtr;
|
||||
QVector<Global::ExperimentData> *baseLineDataVtr = nullptr,
|
||||
*standardSampleDataVtr = nullptr,
|
||||
*sampleDataVtr = nullptr;
|
||||
|
||||
for (auto& pair : curveDataVtr) {
|
||||
if(pair.first == _baseLineCurve){
|
||||
baseLineDataVtr = &(pair.second);
|
||||
}else if(pair.first == _standardSampleCurve){
|
||||
standardSampleDataVtr = &(pair.second);
|
||||
}else if(pair.first == _sampleCurve){
|
||||
sampleDataVtr = &(pair.second);
|
||||
for (auto& item : curveDataVtr) {
|
||||
if(item.curve == _baseLineCurve){
|
||||
baseLineDataVtr = &(item.dataVtr);
|
||||
}else if(item.curve == _standardSampleCurve){
|
||||
standardSampleDataVtr = &(item.dataVtr);
|
||||
}else if(item.curve == _sampleCurve){
|
||||
sampleDataVtr = &(item.dataVtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user