2025-04-10T17:33:38
This commit is contained in:
parent
ff85c72be9
commit
2c303d86a9
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qfile.h>
|
#include <qfile.h>
|
||||||
|
#include <qcustomplot.h>
|
||||||
|
|
||||||
|
#include "filemanager.h"
|
||||||
|
|
||||||
class Global:public QObject
|
class Global:public QObject
|
||||||
{
|
{
|
||||||
@ -31,6 +34,7 @@ public:
|
|||||||
DeviceConnectionStatus getDeviceConnectionStatus(){return _deviceConnectStatus;}
|
DeviceConnectionStatus getDeviceConnectionStatus(){return _deviceConnectStatus;}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QVector<QPair<QCPCurve*,QVector<FileManager::ExperimentData>>> _curveDataVtr;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sigModeModify(const Mode);
|
void sigModeModify(const Mode);
|
||||||
|
|||||||
@ -35,7 +35,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
permenentLabel->setText("Permanent show!");
|
permenentLabel->setText("Permanent show!");
|
||||||
ui->statusbar->addPermanentWidget(permenentLabel);
|
ui->statusbar->addPermanentWidget(permenentLabel);
|
||||||
//
|
//
|
||||||
connections();
|
|
||||||
//
|
//
|
||||||
_expertmentSettingForm->setWindowFlags(_expertmentSettingForm->windowFlags()| Qt::Dialog);
|
_expertmentSettingForm->setWindowFlags(_expertmentSettingForm->windowFlags()| Qt::Dialog);
|
||||||
_specificHeatComparisonMethodForm->setWindowFlags(_specificHeatComparisonMethodForm->windowFlags()| Qt::Dialog);
|
_specificHeatComparisonMethodForm->setWindowFlags(_specificHeatComparisonMethodForm->windowFlags()| Qt::Dialog);
|
||||||
@ -44,6 +43,11 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
// _realTimeDataForm->show();
|
// _realTimeDataForm->show();
|
||||||
setActionEnable(true);
|
setActionEnable(true);
|
||||||
|
|
||||||
|
_eventHandler = _centralWidget->getEvnetHandler();
|
||||||
|
//
|
||||||
|
connections();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -100,6 +104,11 @@ void MainWindow::connections()
|
|||||||
|
|
||||||
connect(_centralWidget,&CentralWidget::sigRightDockWidgetHide,
|
connect(_centralWidget,&CentralWidget::sigRightDockWidgetHide,
|
||||||
[&](){ _rightWidget->hide(); });
|
[&](){ _rightWidget->hide(); });
|
||||||
|
|
||||||
|
//SpecificHeatComparisonMethodForm
|
||||||
|
connect(_eventHandler,&EventHandler::sigSetCurve,
|
||||||
|
_specificHeatComparisonMethodForm,
|
||||||
|
&SpecificHeatComparisonMethodForm::slotSetCurve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setActionEnable(const bool flag)
|
void MainWindow::setActionEnable(const bool flag)
|
||||||
|
|||||||
@ -71,6 +71,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
CentralWidget *_centralWidget;
|
CentralWidget *_centralWidget;
|
||||||
|
EventHandler *_eventHandler;
|
||||||
LeftWidget*_leftWidget;
|
LeftWidget*_leftWidget;
|
||||||
QDockWidget* _rightWidget;
|
QDockWidget* _rightWidget;
|
||||||
ExperimentSettingForm *_expertmentSettingForm;
|
ExperimentSettingForm *_expertmentSettingForm;
|
||||||
|
|||||||
@ -44,15 +44,14 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
_eventHandler = new EventHandler(_customPlot, _line1, _line2, nullptr);
|
_eventHandler = new EventHandler(_customPlot, _line1, _line2, nullptr);
|
||||||
_eventHandler->setEnable(true);
|
_eventHandler->setEnable(true);
|
||||||
|
|
||||||
|
|
||||||
_customPlot->installEventFilter(_eventHandler);
|
_customPlot->installEventFilter(_eventHandler);
|
||||||
_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||||
|
|
||||||
connect(_eventHandler,&EventHandler::sigSendLineXCoord,
|
connect(_eventHandler,&EventHandler::sigSendLineXCoord,
|
||||||
this,&CentralWidget::sigSendLineXCoord);
|
this,&CentralWidget::sigSendLineXCoord);
|
||||||
|
|
||||||
// connect(_customPlot, &QCustomPlot::selectionChangedByUser,
|
// connect(_customPlot, &QCustomPlot::selectionChangedByUser,
|
||||||
// this, &CentralWidget::slotSelectionChanged);
|
// this, &CentralWidget::slotSelectionChanged);
|
||||||
|
|
||||||
|
|
||||||
setEventHandlerEnable(false);
|
setEventHandlerEnable(false);
|
||||||
@ -185,7 +184,11 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
||||||
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
||||||
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||||
// _currentCurve->setSelectable(QCP::stPlottable); // 设置曲线可选
|
// _currentCurve->setSelectable(QCP::stPlottable); // 设置曲线可选
|
||||||
|
|
||||||
|
Global::instance()->_curveDataVtr.push_back(
|
||||||
|
qMakePair<QCPCurve*,QVector<FileManager::ExperimentData>>(
|
||||||
|
_currentCurve,_dataVtr));
|
||||||
|
|
||||||
// 清除第一个图表上的数据
|
// 清除第一个图表上的数据
|
||||||
#if 0
|
#if 0
|
||||||
@ -231,8 +234,8 @@ void CentralWidget::slotSelectionChanged()
|
|||||||
logde << "Current pen color:" << curve->pen().color().name().toStdString();
|
logde << "Current pen color:" << curve->pen().color().name().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// _customPlot->replot();
|
// _customPlot->replot();
|
||||||
// _customPlot->update();
|
// _customPlot->update();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for (QCPAbstractPlottable *plottable : _customPlot->plottable()) {
|
for (QCPAbstractPlottable *plottable : _customPlot->plottable()) {
|
||||||
|
|||||||
@ -27,6 +27,8 @@ public:
|
|||||||
|
|
||||||
void setAnalysisMode(const AnalysisMode);
|
void setAnalysisMode(const AnalysisMode);
|
||||||
void clearAllData();
|
void clearAllData();
|
||||||
|
|
||||||
|
EventHandler* getEvnetHandler(){return _eventHandler;}
|
||||||
signals:
|
signals:
|
||||||
void sigContextMenuShow(const QPoint);
|
void sigContextMenuShow(const QPoint);
|
||||||
void sigSendLineXCoord(const int,const double);
|
void sigSendLineXCoord(const int,const double);
|
||||||
@ -36,6 +38,7 @@ public slots:
|
|||||||
void slotRecvCommonData(const CommonData&);
|
void slotRecvCommonData(const CommonData&);
|
||||||
void slotRecvAnalysisFileName(const QString&);
|
void slotRecvAnalysisFileName(const QString&);
|
||||||
void slotSelectionChanged();
|
void slotSelectionChanged();
|
||||||
|
|
||||||
//analysis setting
|
//analysis setting
|
||||||
void slotAnalysisSettingLineXPoint(const int index,const double);
|
void slotAnalysisSettingLineXPoint(const int index,const double);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "eventhandler.h"
|
#include "eventhandler.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
#include "specificheatcomparisonmethodform.h"
|
||||||
|
|
||||||
EventHandler::EventHandler(QCustomPlot *plot,
|
EventHandler::EventHandler(QCustomPlot *plot,
|
||||||
QCPItemStraightLine *line1,
|
QCPItemStraightLine *line1,
|
||||||
@ -193,17 +194,20 @@ void EventHandler::slotBaseLine()
|
|||||||
}
|
}
|
||||||
curve->setPen(QPen(Qt::red));
|
curve->setPen(QPen(Qt::red));
|
||||||
_plot->replot();
|
_plot->replot();
|
||||||
|
|
||||||
|
emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::BaseLine,curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventHandler::slotStandardSample()
|
void EventHandler::slotStandardSample()
|
||||||
{
|
{
|
||||||
|
|
||||||
QCPCurve *curve = qobject_cast<QCPCurve *>(_plot->selectedPlottables().front());
|
QCPCurve *curve = qobject_cast<QCPCurve *>(_plot->selectedPlottables().front());
|
||||||
if(!curve){
|
if(!curve){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
curve->setPen(QPen(Qt::darkGreen));
|
curve->setPen(QPen(Qt::darkGreen));
|
||||||
_plot->replot();
|
_plot->replot();
|
||||||
|
|
||||||
|
emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::StandardSample,curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventHandler::slotSample()
|
void EventHandler::slotSample()
|
||||||
@ -216,6 +220,8 @@ void EventHandler::slotSample()
|
|||||||
curve->setPen(QPen(Qt::black));
|
curve->setPen(QPen(Qt::black));
|
||||||
_plot->replot();
|
_plot->replot();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::Sample,curve);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventHandler::updateSelectedRegion()
|
void EventHandler::updateSelectedRegion()
|
||||||
|
|||||||
@ -33,6 +33,7 @@ public:
|
|||||||
void setMode(const Mode mode){ _mode = mode;}
|
void setMode(const Mode mode){ _mode = mode;}
|
||||||
signals:
|
signals:
|
||||||
void sigSendLineXCoord(const int,const double);
|
void sigSendLineXCoord(const int,const double);
|
||||||
|
void sigSetCurve(const int, QCPCurve*);
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
private slots:
|
private slots:
|
||||||
@ -45,7 +46,6 @@ private:
|
|||||||
int findClosestIndex(const QVector<double> &data, double target);
|
int findClosestIndex(const QVector<double> &data, double target);
|
||||||
void updateSelectedRegion();
|
void updateSelectedRegion();
|
||||||
bool isNearLine(QCPItemStraightLine *line, const QPoint &pos);
|
bool isNearLine(QCPItemStraightLine *line, const QPoint &pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Mode _mode;
|
Mode _mode;
|
||||||
bool _enableFlag;
|
bool _enableFlag;
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
#include "specificheatcomparisonmethodform.h"
|
#include "specificheatcomparisonmethodform.h"
|
||||||
#include "ui_specificheatcomparisonmethodform.h"
|
#include "ui_specificheatcomparisonmethodform.h"
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
|
#include "global.h"
|
||||||
|
#include "pointcalculate.h"
|
||||||
|
|
||||||
SpecificHeatComparisonMethodForm::SpecificHeatComparisonMethodForm(QWidget *parent) :
|
SpecificHeatComparisonMethodForm::SpecificHeatComparisonMethodForm(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -39,6 +42,19 @@ SpecificHeatComparisonMethodForm::SpecificHeatComparisonMethodForm(QWidget *pare
|
|||||||
ui->formLayoutDataFile->addRow("基线",baseLineLayout);
|
ui->formLayoutDataFile->addRow("基线",baseLineLayout);
|
||||||
ui->formLayoutDataFile->addRow("标样",standardSampleLayout);
|
ui->formLayoutDataFile->addRow("标样",standardSampleLayout);
|
||||||
ui->formLayoutDataFile->addRow("样品",sampleLayout);
|
ui->formLayoutDataFile->addRow("样品",sampleLayout);
|
||||||
|
|
||||||
|
//
|
||||||
|
_baseLineLineEdit->setEnabled(false);
|
||||||
|
_standardSampleLineEdit->setEnabled(false);
|
||||||
|
_sampleLineEdit->setEnabled(false);
|
||||||
|
|
||||||
|
ui->LineEditCorrectionCoefficient->setText("1.000");
|
||||||
|
ui->LineEditSampleWeight->setText("17.92");
|
||||||
|
ui->LineEditStandardSampleWeight->setText("13.92");
|
||||||
|
|
||||||
|
_baseLineCurve = nullptr;
|
||||||
|
_standardSampleCurve = nullptr;
|
||||||
|
_sampleCurve = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecificHeatComparisonMethodForm::~SpecificHeatComparisonMethodForm()
|
SpecificHeatComparisonMethodForm::~SpecificHeatComparisonMethodForm()
|
||||||
@ -46,9 +62,71 @@ SpecificHeatComparisonMethodForm::~SpecificHeatComparisonMethodForm()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpecificHeatComparisonMethodForm::slotSetCurve(const int type, QCPCurve *curve)
|
||||||
|
{
|
||||||
|
logde<<"index:"<<type;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case CurveType::BaseLine:
|
||||||
|
_baseLineCurve = curve;
|
||||||
|
break;
|
||||||
|
case CurveType::StandardSample:
|
||||||
|
_standardSampleCurve = curve;
|
||||||
|
break;
|
||||||
|
case CurveType::Sample:
|
||||||
|
_sampleCurve = curve;
|
||||||
|
break;
|
||||||
|
default:break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SpecificHeatComparisonMethodForm::on_pushButtonCalculate_clicked()
|
void SpecificHeatComparisonMethodForm::on_pushButtonCalculate_clicked()
|
||||||
{
|
{
|
||||||
|
auto& curveDataVtr = Global::instance()->_curveDataVtr;
|
||||||
|
QVector<FileManager::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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!baseLineDataVtr ||
|
||||||
|
!standardSampleDataVtr||
|
||||||
|
!sampleDataVtr){
|
||||||
|
logde<<"Base,standard,sample not selected.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
float targetTemperature = ui->LineEditTemperature->text().toFloat();
|
||||||
|
|
||||||
|
PointCalculate::setExperimentData(*baseLineDataVtr);
|
||||||
|
QPointF baseLinePoint = PointCalculate::getClosestPointByX(targetTemperature);
|
||||||
|
|
||||||
|
PointCalculate::setExperimentData(*standardSampleDataVtr);
|
||||||
|
QPointF standardSamplePoint = PointCalculate::getClosestPointByX(targetTemperature);
|
||||||
|
|
||||||
|
PointCalculate::setExperimentData(*sampleDataVtr);
|
||||||
|
QPointF samplePoint = PointCalculate::getClosestPointByX(targetTemperature);
|
||||||
|
|
||||||
|
logde<<"baseLinePoint:"<<baseLinePoint.x()<<","<<baseLinePoint.y();
|
||||||
|
logde<<"standardSamplePoint:"<<standardSamplePoint.x()<<","<<standardSamplePoint.y();
|
||||||
|
logde<<"samplePoint:"<<samplePoint.x()<<","<<samplePoint.y();
|
||||||
|
|
||||||
|
double cp = calculateHeatCapacity(100);
|
||||||
|
logde<<"cp:"<<cp;
|
||||||
|
|
||||||
|
float standardSampleWeight = ui->LineEditStandardSampleWeight->text().toFloat();
|
||||||
|
float sampleWeight = ui->LineEditSampleWeight->text().toFloat();
|
||||||
|
|
||||||
|
// double cpTarget = cp *
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpecificHeatComparisonMethodForm::on_pushButtonQuit_clicked()
|
void SpecificHeatComparisonMethodForm::on_pushButtonQuit_clicked()
|
||||||
@ -56,7 +134,7 @@ void SpecificHeatComparisonMethodForm::on_pushButtonQuit_clicked()
|
|||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
double calculateHeatCapacity(double theta) {
|
double SpecificHeatComparisonMethodForm::calculateHeatCapacity(double theta) {
|
||||||
// 系数A_i
|
// 系数A_i
|
||||||
const double A0 = 1.12705;
|
const double A0 = 1.12705;
|
||||||
const double A1 = 0.23260;
|
const double A1 = 0.23260;
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <qcustomplot.h>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class SpecificHeatComparisonMethodForm;
|
class SpecificHeatComparisonMethodForm;
|
||||||
@ -17,6 +18,13 @@ public:
|
|||||||
explicit SpecificHeatComparisonMethodForm(QWidget *parent = nullptr);
|
explicit SpecificHeatComparisonMethodForm(QWidget *parent = nullptr);
|
||||||
~SpecificHeatComparisonMethodForm();
|
~SpecificHeatComparisonMethodForm();
|
||||||
|
|
||||||
|
enum CurveType{
|
||||||
|
BaseLine,
|
||||||
|
StandardSample,
|
||||||
|
Sample
|
||||||
|
};
|
||||||
|
public slots:
|
||||||
|
void slotSetCurve(const int ,QCPCurve*);
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButtonCalculate_clicked();
|
void on_pushButtonCalculate_clicked();
|
||||||
|
|
||||||
@ -29,6 +37,8 @@ private:
|
|||||||
QLineEdit *_baseLineLineEdit,*_standardSampleLineEdit,
|
QLineEdit *_baseLineLineEdit,*_standardSampleLineEdit,
|
||||||
*_sampleLineEdit;
|
*_sampleLineEdit;
|
||||||
QLabel *_baseLineLabel,*_standardSampleLabel,*_sampleLabel;
|
QLabel *_baseLineLabel,*_standardSampleLabel,*_sampleLabel;
|
||||||
|
|
||||||
|
QCPCurve *_baseLineCurve,*_standardSampleCurve,*_sampleCurve;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SPECIFICHEATCOMPARISONMETHODFORM_H
|
#endif // SPECIFICHEATCOMPARISONMETHODFORM_H
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="LineEdit"/>
|
<widget class="QLineEdit" name="LineEditTemperature"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="LabelCorrectionCoefficient">
|
<widget class="QLabel" name="LabelCorrectionCoefficient">
|
||||||
@ -56,7 +56,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="LineEdit_2"/>
|
<widget class="QLineEdit" name="LineEditCorrectionCoefficient"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@ -113,7 +113,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="LineEditGuideSampleWeight"/>
|
<widget class="QLineEdit" name="LineEditStandardSampleWeight"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="jGLabel">
|
<widget class="QLabel" name="jGLabel">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user