2025-04-10T17:33:38
This commit is contained in:
parent
ff85c72be9
commit
2c303d86a9
@ -3,6 +3,9 @@
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qfile.h>
|
||||
#include <qcustomplot.h>
|
||||
|
||||
#include "filemanager.h"
|
||||
|
||||
class Global:public QObject
|
||||
{
|
||||
@ -31,6 +34,7 @@ public:
|
||||
DeviceConnectionStatus getDeviceConnectionStatus(){return _deviceConnectStatus;}
|
||||
#endif
|
||||
|
||||
QVector<QPair<QCPCurve*,QVector<FileManager::ExperimentData>>> _curveDataVtr;
|
||||
|
||||
signals:
|
||||
void sigModeModify(const Mode);
|
||||
|
@ -35,7 +35,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
permenentLabel->setText("Permanent show!");
|
||||
ui->statusbar->addPermanentWidget(permenentLabel);
|
||||
//
|
||||
connections();
|
||||
//
|
||||
_expertmentSettingForm->setWindowFlags(_expertmentSettingForm->windowFlags()| Qt::Dialog);
|
||||
_specificHeatComparisonMethodForm->setWindowFlags(_specificHeatComparisonMethodForm->windowFlags()| Qt::Dialog);
|
||||
@ -44,6 +43,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
// _realTimeDataForm->show();
|
||||
setActionEnable(true);
|
||||
|
||||
_eventHandler = _centralWidget->getEvnetHandler();
|
||||
//
|
||||
connections();
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -100,6 +104,11 @@ void MainWindow::connections()
|
||||
|
||||
connect(_centralWidget,&CentralWidget::sigRightDockWidgetHide,
|
||||
[&](){ _rightWidget->hide(); });
|
||||
|
||||
//SpecificHeatComparisonMethodForm
|
||||
connect(_eventHandler,&EventHandler::sigSetCurve,
|
||||
_specificHeatComparisonMethodForm,
|
||||
&SpecificHeatComparisonMethodForm::slotSetCurve);
|
||||
}
|
||||
|
||||
void MainWindow::setActionEnable(const bool flag)
|
||||
|
@ -71,6 +71,7 @@ private:
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
CentralWidget *_centralWidget;
|
||||
EventHandler *_eventHandler;
|
||||
LeftWidget*_leftWidget;
|
||||
QDockWidget* _rightWidget;
|
||||
ExperimentSettingForm *_expertmentSettingForm;
|
||||
|
@ -44,15 +44,14 @@ CentralWidget::CentralWidget(QWidget *parent)
|
||||
_eventHandler = new EventHandler(_customPlot, _line1, _line2, nullptr);
|
||||
_eventHandler->setEnable(true);
|
||||
|
||||
|
||||
_customPlot->installEventFilter(_eventHandler);
|
||||
_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
|
||||
connect(_eventHandler,&EventHandler::sigSendLineXCoord,
|
||||
this,&CentralWidget::sigSendLineXCoord);
|
||||
|
||||
// connect(_customPlot, &QCustomPlot::selectionChangedByUser,
|
||||
// this, &CentralWidget::slotSelectionChanged);
|
||||
// connect(_customPlot, &QCustomPlot::selectionChangedByUser,
|
||||
// this, &CentralWidget::slotSelectionChanged);
|
||||
|
||||
|
||||
setEventHandlerEnable(false);
|
||||
@ -185,7 +184,11 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
||||
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
||||
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
||||
_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
|
||||
@ -228,11 +231,11 @@ void CentralWidget::slotSelectionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
logde << "Current pen color:" << curve->pen().color().name().toStdString();
|
||||
logde << "Current pen color:" << curve->pen().color().name().toStdString();
|
||||
}
|
||||
|
||||
// _customPlot->replot();
|
||||
// _customPlot->update();
|
||||
// _customPlot->replot();
|
||||
// _customPlot->update();
|
||||
|
||||
#if 0
|
||||
for (QCPAbstractPlottable *plottable : _customPlot->plottable()) {
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
|
||||
void setAnalysisMode(const AnalysisMode);
|
||||
void clearAllData();
|
||||
|
||||
EventHandler* getEvnetHandler(){return _eventHandler;}
|
||||
signals:
|
||||
void sigContextMenuShow(const QPoint);
|
||||
void sigSendLineXCoord(const int,const double);
|
||||
@ -36,6 +38,7 @@ public slots:
|
||||
void slotRecvCommonData(const CommonData&);
|
||||
void slotRecvAnalysisFileName(const QString&);
|
||||
void slotSelectionChanged();
|
||||
|
||||
//analysis setting
|
||||
void slotAnalysisSettingLineXPoint(const int index,const double);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "eventhandler.h"
|
||||
#include "logger.h"
|
||||
#include "specificheatcomparisonmethodform.h"
|
||||
|
||||
EventHandler::EventHandler(QCustomPlot *plot,
|
||||
QCPItemStraightLine *line1,
|
||||
@ -193,17 +194,20 @@ void EventHandler::slotBaseLine()
|
||||
}
|
||||
curve->setPen(QPen(Qt::red));
|
||||
_plot->replot();
|
||||
|
||||
emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::BaseLine,curve);
|
||||
}
|
||||
|
||||
void EventHandler::slotStandardSample()
|
||||
{
|
||||
|
||||
QCPCurve *curve = qobject_cast<QCPCurve *>(_plot->selectedPlottables().front());
|
||||
if(!curve){
|
||||
return;
|
||||
}
|
||||
curve->setPen(QPen(Qt::darkGreen));
|
||||
_plot->replot();
|
||||
|
||||
emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::StandardSample,curve);
|
||||
}
|
||||
|
||||
void EventHandler::slotSample()
|
||||
@ -216,6 +220,8 @@ void EventHandler::slotSample()
|
||||
curve->setPen(QPen(Qt::black));
|
||||
_plot->replot();
|
||||
#endif
|
||||
|
||||
emit sigSetCurve(SpecificHeatComparisonMethodForm::CurveType::Sample,curve);
|
||||
}
|
||||
|
||||
void EventHandler::updateSelectedRegion()
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
void setMode(const Mode mode){ _mode = mode;}
|
||||
signals:
|
||||
void sigSendLineXCoord(const int,const double);
|
||||
void sigSetCurve(const int, QCPCurve*);
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
private slots:
|
||||
@ -45,7 +46,6 @@ private:
|
||||
int findClosestIndex(const QVector<double> &data, double target);
|
||||
void updateSelectedRegion();
|
||||
bool isNearLine(QCPItemStraightLine *line, const QPoint &pos);
|
||||
|
||||
private:
|
||||
Mode _mode;
|
||||
bool _enableFlag;
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include "specificheatcomparisonmethodform.h"
|
||||
#include "ui_specificheatcomparisonmethodform.h"
|
||||
|
||||
#include "logger.h"
|
||||
#include "global.h"
|
||||
#include "pointcalculate.h"
|
||||
|
||||
SpecificHeatComparisonMethodForm::SpecificHeatComparisonMethodForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@ -39,6 +42,19 @@ SpecificHeatComparisonMethodForm::SpecificHeatComparisonMethodForm(QWidget *pare
|
||||
ui->formLayoutDataFile->addRow("基线",baseLineLayout);
|
||||
ui->formLayoutDataFile->addRow("标样",standardSampleLayout);
|
||||
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()
|
||||
@ -46,9 +62,71 @@ SpecificHeatComparisonMethodForm::~SpecificHeatComparisonMethodForm()
|
||||
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()
|
||||
{
|
||||
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()
|
||||
@ -56,7 +134,7 @@ void SpecificHeatComparisonMethodForm::on_pushButtonQuit_clicked()
|
||||
hide();
|
||||
}
|
||||
|
||||
double calculateHeatCapacity(double theta) {
|
||||
double SpecificHeatComparisonMethodForm::calculateHeatCapacity(double theta) {
|
||||
// 系数A_i
|
||||
const double A0 = 1.12705;
|
||||
const double A1 = 0.23260;
|
||||
@ -76,8 +154,8 @@ double calculateHeatCapacity(double theta) {
|
||||
|
||||
// 计算比热容
|
||||
double Cp = A0 + A1 * x + A2 * std::pow(x, 2) + A3 * std::pow(x, 3) + A4 * std::pow(x, 4) +
|
||||
A5 * std::pow(x, 5) + A6 * std::pow(x, 6) + A7 * std::pow(x, 7) + A8 * std::pow(x, 8) +
|
||||
A9 * std::pow(x, 9) + A10 * std::pow(x, 10);
|
||||
A5 * std::pow(x, 5) + A6 * std::pow(x, 6) + A7 * std::pow(x, 7) + A8 * std::pow(x, 8) +
|
||||
A9 * std::pow(x, 9) + A10 * std::pow(x, 10);
|
||||
|
||||
return Cp;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QWidget>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <qcustomplot.h>
|
||||
|
||||
namespace Ui {
|
||||
class SpecificHeatComparisonMethodForm;
|
||||
@ -17,6 +18,13 @@ public:
|
||||
explicit SpecificHeatComparisonMethodForm(QWidget *parent = nullptr);
|
||||
~SpecificHeatComparisonMethodForm();
|
||||
|
||||
enum CurveType{
|
||||
BaseLine,
|
||||
StandardSample,
|
||||
Sample
|
||||
};
|
||||
public slots:
|
||||
void slotSetCurve(const int ,QCPCurve*);
|
||||
private slots:
|
||||
void on_pushButtonCalculate_clicked();
|
||||
|
||||
@ -29,6 +37,8 @@ private:
|
||||
QLineEdit *_baseLineLineEdit,*_standardSampleLineEdit,
|
||||
*_sampleLineEdit;
|
||||
QLabel *_baseLineLabel,*_standardSampleLabel,*_sampleLabel;
|
||||
|
||||
QCPCurve *_baseLineCurve,*_standardSampleCurve,*_sampleCurve;
|
||||
};
|
||||
|
||||
#endif // SPECIFICHEATCOMPARISONMETHODFORM_H
|
||||
|
@ -46,7 +46,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="LineEdit"/>
|
||||
<widget class="QLineEdit" name="LineEditTemperature"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="LabelCorrectionCoefficient">
|
||||
@ -56,7 +56,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="LineEdit_2"/>
|
||||
<widget class="QLineEdit" name="LineEditCorrectionCoefficient"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -113,7 +113,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="LineEditGuideSampleWeight"/>
|
||||
<widget class="QLineEdit" name="LineEditStandardSampleWeight"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="jGLabel">
|
||||
|
Loading…
Reference in New Issue
Block a user