2025-04-09T13:58:05

This commit is contained in:
yuntang 2025-04-09 13:58:05 +08:00
parent d349c689ac
commit 6cf14dfce7
15 changed files with 2406 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -29,8 +29,11 @@ SOURCES += \
serialport/dataparser.cpp \
serialport/serialport.cpp \
thirdparty/qcustomplot/qcustomplot.cpp \
ui/degreeofcrystallinityform.cpp \
ui/degreeofcureform.cpp \
ui/draglinehandler.cpp \
ui/experimentsettingform.cpp \
ui/instrumentcoefficientform.cpp \
ui/leftwidget.cpp \
ui/realtimedataform.cpp \
ui/specificheatcomparisonmethodform.cpp
@ -50,15 +53,21 @@ HEADERS += \
serialport/protocol.h \
serialport/serialport.h \
thirdparty/qcustomplot/qcustomplot.h \
ui/degreeofcrystallinityform.h \
ui/degreeofcureform.h \
ui/draglinehandler.h \
ui/experimentsettingform.h \
ui/instrumentcoefficientform.h \
ui/leftwidget.h \
ui/realtimedataform.h \
ui/specificheatcomparisonmethodform.h
FORMS += \
mainwindow.ui \
ui/degreeofcrystallinityform.ui \
ui/degreeofcureform.ui \
ui/experimentsettingform.ui \
ui/instrumentcoefficientform.ui \
ui/realtimedataform.ui \
ui/specificheatcomparisonmethodform.ui

View File

@ -365,7 +365,7 @@ QPair<float,float> PointCalculate::getCurveInflectionPointTangent(const float x1
QPointF PointCalculate::getIntersectionBySlope(const LineStruct& line1, const LineStruct& line2) {
float x = (line2.intercept - line1.intercept) / (line1.slope - line2.slope);
float y = line1.slope * x + line1.intercept;
// return {x, y};
// return {x, y};
return QPointF(x,y);
}
QPointF PointCalculate::getClosestPointByX(const float targetX)
@ -449,13 +449,28 @@ QString PointCalculate::textFormatEndPoint(const QPointF point)
QPointF PointCalculate::getClosestPointByY(const float left,const float right,const float valueY)
{
float minValue = 100.0;
for(FileManager::ExperimentData& ed:_dataVtr){
if(left < ed.sampleTemp && ed.sampleTemp < right){
if(std::abs(ed.dsc - valueY) < minValue){
return QPointF(ed.sampleTemp,ed.dsc);
}
}
}
return QPointF();
float minValue = std::numeric_limits<float>::infinity(); // 初始化为正无穷
QPointF closestPoint;
for (const FileManager::ExperimentData& ed : _dataVtr) {
if (left < ed.sampleTemp && ed.sampleTemp < right) {
float diff = std::abs(ed.dsc - valueY);
if (diff < minValue) {
minValue = diff;
closestPoint = QPointF(ed.sampleTemp, ed.dsc);
}
}
}
return closestPoint;
}
QString PointCalculate::textFormatGlassTranstion(const float t1,const float tg,const float t2)
{
return QString("T1%1℃\n"
"Tg%2℃\n"
"T2%3℃\n"
).arg(QString::number(t1, 'f', 3))
.arg(QString::number(tg, 'f', 3))
.arg(QString::number(t2, 'f', 3));
}

View File

@ -26,6 +26,7 @@ QString textFormatPeakPoint(const float enthalpyValue,
QString textFormatNumbericalLabel(const QPointF);
QString textFormatStartPoint(const QPointF);
QString textFormatEndPoint(const QPointF);
QString textFormatGlassTranstion(const float t1,const float tg,const float t2);
// glass transition
QPair<float,float> getCurveInflectionPointTangent(const float,const float);

View File

@ -44,7 +44,6 @@ MainWindow::MainWindow(QWidget *parent)
// _realTimeDataForm->show();
setActionEnable(true);
}
MainWindow::~MainWindow()

View File

@ -321,6 +321,7 @@ void CentralWidget::glassTransitionHandle()
logde<<"point1:"<<point1.x()<<","<<point1.y();
logde<<"point2:"<<point2.x()<<","<<point2.y();
#if 1
QCPItemStraightLine *line1 = new QCPItemStraightLine(_customPlot);
line1->point1->setCoords(point1.x() - 5,point1.y());
line1->point2->setCoords(point1.x() + 5,point1.y());
@ -336,6 +337,7 @@ void CentralWidget::glassTransitionHandle()
line2->setVisible(true);
_customPlot->replot();
#endif
//
PointCalculate::LineStruct lineStrc1,lineStrc2,tangetLineStrc;
@ -357,9 +359,11 @@ void CentralWidget::glassTransitionHandle()
//
float averageY = (point1.y() + point2.y()) /2;
logde<<"average Y:"<<averageY;
QPointF averagePoint = PointCalculate::getClosestPointByY(point1.x(),point2.x(),averageY);
// logde<<"average y:"<<averageY;
// logde<<"average y:"<<averageY;
logde<<"averagePoint x,y:"<<averagePoint.x()<<","
<<averagePoint.y();
@ -367,10 +371,15 @@ void CentralWidget::glassTransitionHandle()
<<",Tg:"<<averagePoint.x()
<<",T2:"<<intersection2.x();
QString str = PointCalculate::textFormatGlassTranstion(intersection1.x(),
averagePoint.x(),
intersection2.x());
drawText(averagePoint,str);
#if 0
// 创建一个圆形绘图项
QCPItemEllipse *circle = new QCPItemEllipse(_customPlot);
// _customPlot->addItem(circle);
// _customPlot->addItem(circle);
// 设置圆形的位置和大小
circle->topLeft->setCoords(-5, 5);
@ -381,14 +390,16 @@ void CentralWidget::glassTransitionHandle()
circle->setPen(QPen(Qt::blue));
#endif
#if 1
QCPItemStraightLine *line3 = new QCPItemStraightLine(_customPlot);
line3->point1->setCoords(averagePoint.x() + 2,averagePoint.y() + 2);
line3->point2->setCoords(averagePoint.x() - 2,averagePoint.y() - 2);
line3->point1->setCoords(averagePoint.x() + 1,averagePoint.y() + 1);
line3->point2->setCoords(averagePoint.x() - 1,averagePoint.y() - 1);
line3->setPen(QPen(Qt::black));
line3->setSelectable(false);
line3->setVisible(true);
_customPlot->replot();
#endif
}
void CentralWidget::setEventHandlerEnable(const bool flag)

View File

@ -0,0 +1,14 @@
#include "degreeofcrystallinityform.h"
#include "ui_degreeofcrystallinityform.h"
DegreeOfCrystallinityForm::DegreeOfCrystallinityForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::DegreeOfCrystallinityForm)
{
ui->setupUi(this);
}
DegreeOfCrystallinityForm::~DegreeOfCrystallinityForm()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef DEGREEOFCRYSTALLINITYFORM_H
#define DEGREEOFCRYSTALLINITYFORM_H
#include <QWidget>
namespace Ui {
class DegreeOfCrystallinityForm;
}
class DegreeOfCrystallinityForm : public QWidget
{
Q_OBJECT
public:
explicit DegreeOfCrystallinityForm(QWidget *parent = nullptr);
~DegreeOfCrystallinityForm();
private:
Ui::DegreeOfCrystallinityForm *ui;
};
#endif // DEGREEOFCRYSTALLINITYFORM_H

View File

@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DegreeOfCrystallinityForm</class>
<widget class="QWidget" name="DegreeOfCrystallinityForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>368</width>
<height>399</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>281</width>
<height>81</height>
</rect>
</property>
<property name="title">
<string>计算公式:</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>23</x>
<y>32</y>
<width>231</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Xc = (结晶焓 - 冷结晶焓) / 理论热焓</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>30</x>
<y>120</y>
<width>281</width>
<height>121</height>
</rect>
</property>
<property name="title">
<string>参数:</string>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>231</width>
<height>81</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="Label">
<property name="text">
<string>结晶焓(J/g):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="LineEditEnthalpyOfCrystallization"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="jGLabel">
<property name="text">
<string>冷结晶焓(J/g):</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="LineEditEnthalpyOfColdCrystallization"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="jGLabel_2">
<property name="text">
<string>理论热焓(J/g)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="LineEditTheoreticalEnthalpy"/>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>30</x>
<y>250</y>
<width>281</width>
<height>71</height>
</rect>
</property>
<property name="title">
<string>计算结果:</string>
</property>
<widget class="QWidget" name="formLayoutWidget_2">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>231</width>
<height>31</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="1">
<widget class="QLineEdit" name="xcLineEditDegreedOfCrystallinity"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="xcLabel">
<property name="text">
<string>结晶度Xc(%)</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,14 @@
#include "degreeofcureform.h"
#include "ui_degreeofcureform.h"
DegreeOfCureForm::DegreeOfCureForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::DegreeOfCureForm)
{
ui->setupUi(this);
}
DegreeOfCureForm::~DegreeOfCureForm()
{
delete ui;
}

22
src/ui/degreeofcureform.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef DEGREEOFCUREFORM_H
#define DEGREEOFCUREFORM_H
#include <QWidget>
namespace Ui {
class DegreeOfCureForm;
}
class DegreeOfCureForm : public QWidget
{
Q_OBJECT
public:
explicit DegreeOfCureForm(QWidget *parent = nullptr);
~DegreeOfCureForm();
private:
Ui::DegreeOfCureForm *ui;
};
#endif // DEGREEOFCUREFORM_H

209
src/ui/degreeofcureform.ui Normal file
View File

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DegreeOfCureForm</class>
<widget class="QWidget" name="DegreeOfCureForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>331</width>
<height>364</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>301</width>
<height>91</height>
</rect>
</property>
<property name="title">
<string>计算公式:</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>41</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>固化度=</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>70</x>
<y>60</y>
<width>161</width>
<height>1</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>1</height>
</size>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>80</x>
<y>40</y>
<width>151</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>固化前热焓 - 固化后热焓</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>110</x>
<y>60</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>固化前热焓</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>240</x>
<y>50</y>
<width>51</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>X 100%</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>301</width>
<height>91</height>
</rect>
</property>
<property name="title">
<string>参数:</string>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>271</width>
<height>52</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="jGLabel">
<property name="text">
<string>固化前热焓(J/g)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="jGLineEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="jGLabel_2">
<property name="text">
<string>固化后热焓(J/g)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="jGLineEdit_2"/>
</item>
</layout>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_3">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>301</width>
<height>71</height>
</rect>
</property>
<property name="title">
<string>计算结果:</string>
</property>
<widget class="QWidget" name="formLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>261</width>
<height>41</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="Label">
<property name="text">
<string>固化度(%):</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="LineEditDegreeOfCure"/>
</item>
</layout>
</widget>
</widget>
<widget class="QPushButton" name="pushButtonCalculate">
<property name="geometry">
<rect>
<x>100</x>
<y>310</y>
<width>80</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>计算</string>
</property>
</widget>
<widget class="QPushButton" name="pushButtonQuit">
<property name="geometry">
<rect>
<x>210</x>
<y>310</y>
<width>80</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>退出</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,24 @@
#include "instrumentcoefficientform.h"
#include "ui_instrumentcoefficientform.h"
InstrumentCoefficientForm::InstrumentCoefficientForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::InstrumentCoefficientForm)
{
ui->setupUi(this);
}
InstrumentCoefficientForm::~InstrumentCoefficientForm()
{
delete ui;
}
void InstrumentCoefficientForm::on_pushButtonCalculate_clicked()
{
}
void InstrumentCoefficientForm::on_pushButtonExit_clicked()
{
}

View File

@ -0,0 +1,27 @@
#ifndef INSTRUMENTCOEFFICIENTFORM_H
#define INSTRUMENTCOEFFICIENTFORM_H
#include <QWidget>
namespace Ui {
class InstrumentCoefficientForm;
}
class InstrumentCoefficientForm : public QWidget
{
Q_OBJECT
public:
explicit InstrumentCoefficientForm(QWidget *parent = nullptr);
~InstrumentCoefficientForm();
private slots:
void on_pushButtonCalculate_clicked();
void on_pushButtonExit_clicked();
private:
Ui::InstrumentCoefficientForm *ui;
};
#endif // INSTRUMENTCOEFFICIENTFORM_H

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InstrumentCoefficientForm</class>
<widget class="QWidget" name="InstrumentCoefficientForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>244</width>
<height>356</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
</widget>
<resources/>
<connections/>
</ui>