2025-05-26T14:32:01
This commit is contained in:
parent
dd3d99a8a2
commit
cfcf8b0ecf
@ -133,3 +133,6 @@ RESOURCES += \
|
||||
|
||||
DISTFILES += \
|
||||
logger/log.conf
|
||||
|
||||
TRANSLATIONS = language/cn.ts \
|
||||
language/en.ts
|
||||
|
1
src/FvbVvC.json
Normal file
1
src/FvbVvC.json
Normal file
File diff suppressed because one or more lines are too long
@ -12,7 +12,7 @@ void ConfigHandler::reader()
|
||||
{
|
||||
// 检查文件是否已经存在
|
||||
if (QFile::exists(ConConfigFilePath)) {
|
||||
logde << "config config file existed. ";
|
||||
logde << "config file existed. ";
|
||||
}else{
|
||||
writer(false);
|
||||
}
|
||||
|
@ -748,10 +748,10 @@ QPair<Global::ExperimentData, Global::ExperimentData> PointCalculate::calculateS
|
||||
{
|
||||
QPair<QPointF,QPointF> leftAndRightPair = calculateStartAndEndPoint();
|
||||
|
||||
ExperimentData leftEd = getClosestDataByTemperature(leftAndRightPair.first.x());
|
||||
ExperimentData rightEd = getClosestDataByTemperature(leftAndRightPair.second.x());
|
||||
ExperimentData leftEd = getClosestDataByTemperature(leftAndRightPair.first.x());
|
||||
ExperimentData rightEd = getClosestDataByTemperature(leftAndRightPair.second.x());
|
||||
|
||||
return qMakePair<Global::ExperimentData, Global::ExperimentData> (leftEd,rightEd);
|
||||
return qMakePair<Global::ExperimentData, Global::ExperimentData> (leftEd,rightEd);
|
||||
}
|
||||
|
||||
QPair<float, float> PointCalculate::getMinAndMaxOfRunTime()
|
||||
@ -770,6 +770,59 @@ QPair<float, float> PointCalculate::getMinAndMaxOfRunTime()
|
||||
|
||||
return qMakePair<float,float>(runTimeMin,runTimeMax);
|
||||
}
|
||||
Global::ExperimentData PointCalculate::findOnSetDataByTemperature(const double x1,const double x2)
|
||||
{
|
||||
Global::ExperimentData resultEd;
|
||||
|
||||
QVector<Global::ExperimentData> edVtr = getDataInXRange(x1,x2);
|
||||
if(edVtr.empty()){
|
||||
return resultEd;
|
||||
}
|
||||
|
||||
double maxDsc = std::numeric_limits<float>::min();
|
||||
for(Global::ExperimentData& ed:edVtr){
|
||||
if(ed.dsc > maxDsc){
|
||||
maxDsc = ed.dsc;
|
||||
}
|
||||
}
|
||||
|
||||
// 从后往前遍历,找到第一个 dsc 与 standardDsc 相等的 ExperimentData
|
||||
for (auto it = edVtr.rbegin(); it != edVtr.rend(); ++it) {
|
||||
if(std::abs(it->dsc - maxDsc) < Global::OnsetAndEndSetRate * maxDsc){
|
||||
resultEd = *it; // 找到匹配项,返回该值
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resultEd;
|
||||
}
|
||||
|
||||
Global::ExperimentData PointCalculate::findEndSetDataByTemperature(const double x1, const double x2)
|
||||
{
|
||||
Global::ExperimentData resultEd;
|
||||
|
||||
QVector<Global::ExperimentData> edVtr = getDataInXRange(x1,x2);
|
||||
if(edVtr.empty()){
|
||||
return resultEd;
|
||||
}
|
||||
|
||||
double maxDsc = std::numeric_limits<float>::min();
|
||||
for(Global::ExperimentData& ed:edVtr){
|
||||
if(ed.dsc > maxDsc){
|
||||
maxDsc = ed.dsc;
|
||||
}
|
||||
}
|
||||
|
||||
// 从后往前遍历,找到第一个 dsc 与 standardDsc 相等的 ExperimentData
|
||||
for (auto it = edVtr.begin(); it != edVtr.end(); ++it) {
|
||||
if(std::abs(it->dsc - maxDsc) < Global::OnsetAndEndSetRate * maxDsc){
|
||||
resultEd = *it; // 找到匹配项,返回该值
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resultEd;
|
||||
}
|
||||
|
||||
QPair<float, float> PointCalculate::getMinAndMaxOfDSC()
|
||||
{
|
||||
@ -820,3 +873,5 @@ QString PointCalculate::textFormatGlassTranstionWithTime(const float t1, const f
|
||||
.arg(QString::number(tg, 'f', 3))
|
||||
.arg(QString::number(t2, 'f', 3));
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,6 +41,10 @@ QPair<ExperimentData,ExperimentData> calculateStartAndEndData();
|
||||
float calculateArea();
|
||||
double obtainTimeValueBasedOnTemperatureValue(const double sampleTemp);
|
||||
|
||||
ExperimentData findOnSetDataByTemperature(const double x1,const double x2);
|
||||
ExperimentData findEndSetDataByTemperature(const double x1,const double x2);
|
||||
|
||||
|
||||
// text format
|
||||
QString textFormatPeakPoint(const float enthalpyValue,
|
||||
const float peakValue,
|
||||
|
@ -18,6 +18,8 @@ QVector<double> _enthalpyCoefficientVtr;
|
||||
|
||||
bool _displayTimeValue = false;
|
||||
|
||||
LanguageType _languageType = LanguageType::Chinese;
|
||||
|
||||
QString converDoubleToStr(const double num)
|
||||
{
|
||||
return QString::number(num,'f',3);
|
||||
|
12
src/global.h
12
src/global.h
@ -30,8 +30,16 @@ const QString RateStr("rate");
|
||||
|
||||
//
|
||||
const double DefaultParamter = 8.177;
|
||||
|
||||
const double OnsetAndEndSetRate = 0.01;
|
||||
//
|
||||
enum LanguageType{
|
||||
Chinese,
|
||||
English
|
||||
};
|
||||
|
||||
const QString EnglishStr("English");
|
||||
const QString ChineseStr("中文");
|
||||
|
||||
enum Mode{
|
||||
None,
|
||||
Analysis,
|
||||
@ -110,6 +118,8 @@ extern bool _enthalpyCoefficientEnableFlag;
|
||||
extern QVector<double> _enthalpyCoefficientVtr;
|
||||
// peak comprehensive ananlysis
|
||||
extern bool _displayTimeValue;
|
||||
//
|
||||
extern LanguageType _languageType;
|
||||
|
||||
// common func
|
||||
QString converDoubleToStr(const double);
|
||||
|
1364
src/language/cn.ts
Normal file
1364
src/language/cn.ts
Normal file
File diff suppressed because it is too large
Load Diff
1364
src/language/en.ts
Normal file
1364
src/language/en.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -514,3 +514,15 @@ void MainWindow::on_actionSaveas_triggered()
|
||||
saveFile(Global::_experimentInfo.sampleName,Global::Mode::None);
|
||||
_leftWidget->reloadFileName();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLanguage_triggered()
|
||||
{
|
||||
if(Global::_languageType == Global::LanguageType::Chinese){
|
||||
Global::_languageType = Global::LanguageType::English;
|
||||
ui->actionLanguage->setText(Global::EnglishStr);
|
||||
}else{
|
||||
Global::_languageType = Global::LanguageType::Chinese;
|
||||
ui->actionLanguage->setText(Global::ChineseStr);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ private slots:
|
||||
|
||||
void on_actionSaveas_triggered();
|
||||
|
||||
void on_actionLanguage_triggered();
|
||||
|
||||
private:
|
||||
void connections();
|
||||
void setActionEnable(const bool);
|
||||
|
@ -78,6 +78,7 @@
|
||||
<property name="title">
|
||||
<string>语言</string>
|
||||
</property>
|
||||
<addaction name="actionLanguage"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_7">
|
||||
<property name="title">
|
||||
@ -335,6 +336,11 @@
|
||||
<string>另存为</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLanguage">
|
||||
<property name="text">
|
||||
<string>language</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
|
@ -7,8 +7,6 @@ AxisSettingForm::AxisSettingForm(QWidget *parent) :
|
||||
ui(new Ui::AxisSettingForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
AxisSettingForm::~AxisSettingForm()
|
||||
|
@ -184,7 +184,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
|
||||
_currentCurve->addData(index++,cd.sample_temp, cd.dsc);
|
||||
|
||||
// _customPlot->rescaleAxes();
|
||||
// _customPlot->rescaleAxes();
|
||||
_customPlot->replot();
|
||||
|
||||
// return;
|
||||
@ -211,6 +211,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
logde<<"_currentCurveExperimentDataPtr dataVtr size:"
|
||||
<<Global::_currentCurveExperimentDataPtr->dataVtr.size();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
||||
@ -232,56 +233,6 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
||||
|
||||
//
|
||||
uiLoadXlsxFileData();
|
||||
|
||||
#if 0
|
||||
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
|
||||
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
|
||||
|
||||
PointCalculate::setAnalysisData(pti.dataVtr);
|
||||
|
||||
QPair<QPointF,QPointF>startEndPointPair = PointCalculate::getStartAndEndPoint();
|
||||
|
||||
QPointF endPoint = startEndPointPair.second;
|
||||
_customPlot->xAxis->setRange(0, endPoint.x() / 3 * 4);
|
||||
|
||||
QPair<float, float> maxMinPair = PointCalculate::getMaxMinValue();
|
||||
float absY = std::abs(maxMinPair.first - maxMinPair.second);
|
||||
_customPlot->yAxis->setRange(- absY * 2,absY *2);
|
||||
|
||||
_customPlot->yAxis->setLabel("DSC/mW");
|
||||
_customPlot->xAxis->setLabel("Temp/℃");
|
||||
|
||||
QVector<Global::ExperimentData> dataVtr;
|
||||
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->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||
_currentCurve->setLineStyle(QCPCurve::lsLine); // 线性连接
|
||||
|
||||
_currentCurve->setObjectName(filePath);
|
||||
|
||||
pti.curve = _currentCurve;
|
||||
}
|
||||
|
||||
// Add analysis operation data.
|
||||
if(cfd.analysisOperationVtr.size() > 0){
|
||||
for(AnaOpRecorder::AnalysisOperation& ao
|
||||
:cfd.analysisOperationVtr){
|
||||
loadAnalysisData(ao.mode,ao.x1,ao.x2,filePath);
|
||||
}
|
||||
}
|
||||
// Refresh ui.
|
||||
_customPlot->rescaleAxes();
|
||||
_customPlot->replot();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CentralWidget::slotAnalysisSettingApply()
|
||||
@ -796,30 +747,26 @@ PointCalculate::Line CentralWidget::calculateLinearRegression(const QVector<doub
|
||||
return line;
|
||||
}
|
||||
|
||||
QPointF CentralWidget::OnsetTemperaturePointHandle(const double x1,const double x2)
|
||||
QPointF CentralWidget::onsetTemperaturePointHandle(const double x1,const double x2)
|
||||
{
|
||||
QVector<QPointF> rowPointVtr = PointCalculate::getPointVtrInXRange(x1,x2);
|
||||
Global::ExperimentData ed = PointCalculate::findOnSetDataByTemperature(x1,x2);
|
||||
|
||||
QVector<QPointF> pointVtr = PointCalculate::movingAveragePoint(rowPointVtr,5);
|
||||
|
||||
QVector<double> xVtr,yVtr;
|
||||
for (QPointF &point : pointVtr) {
|
||||
xVtr.push_back(point.x());
|
||||
yVtr.push_back(point.y());
|
||||
if(_axisMode == AxisMode::SingleY){
|
||||
return QPointF(ed.sampleTemp,ed.dsc);
|
||||
}else{
|
||||
return QPointF(ed.runTime,ed.dsc);
|
||||
}
|
||||
}
|
||||
|
||||
double coeff[3] = {0};
|
||||
Global::quadraticLeastSquaresFit(xVtr.data(),yVtr.data(),xVtr.size(),coeff);
|
||||
QPointF CentralWidget::endSetTemperaturePointHandle(const double x1, const double x2)
|
||||
{
|
||||
Global::ExperimentData ed = PointCalculate::findEndSetDataByTemperature(x1,x2);
|
||||
|
||||
// derivative
|
||||
double a = coeff[0] * 2;
|
||||
double b = coeff[1];
|
||||
|
||||
double targetX = Global::findNegativeStartPoint(a,b,pointVtr.first().x(),pointVtr.last().x());
|
||||
logde<<"traget x:"<<targetX;
|
||||
|
||||
// QPointF targetPoint = PointCalculate::getClosestPointByX(targetX);
|
||||
return PointCalculate::getClosestPointByX(targetX);
|
||||
if(_axisMode == AxisMode::SingleY){
|
||||
return QPointF(ed.sampleTemp,ed.dsc);
|
||||
}else{
|
||||
return QPointF(ed.runTime,ed.dsc);
|
||||
}
|
||||
}
|
||||
|
||||
// 二次多项式拟合函数
|
||||
@ -884,6 +831,7 @@ void CentralWidget::setEventHandlerEnable(const bool flag)
|
||||
_line2->point1->setCoords(xRight,_line2->point1->coords().y());
|
||||
_line2->point2->setCoords(xRight,_line2->point2->coords().y());
|
||||
#endif
|
||||
|
||||
lineVisiableFunc(_line1);
|
||||
if(AnalysisMode::NumericalLabel != _analysisMode){
|
||||
lineVisiableFunc(_line2);
|
||||
@ -901,8 +849,7 @@ QPointF CentralWidget::getTheCoordinatesOfTheTextBox(const QPointF point)
|
||||
|
||||
QVector<double> ticks = _customPlot->xAxis->tickVector();
|
||||
int numTicks = ticks.size();
|
||||
logde<<"ticks:"<<numTicks;
|
||||
|
||||
// logde<<"ticks:"<<numTicks;
|
||||
|
||||
double distance = (xMax - xMin) / ticks.size();
|
||||
|
||||
@ -1033,7 +980,7 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
||||
QCPAbstractPlottable* plottable = _customPlot->plottable(i);
|
||||
if (auto curve = dynamic_cast<QCPCurve*>(plottable)) {
|
||||
logde<<"clear data,curve object Name:"<<curve->objectName().toStdString();
|
||||
if(curve->objectName() == ItemManager::TemporaryStr){
|
||||
if(curve->objectName().contains( ItemManager::TemporaryStr)){
|
||||
_customPlot->removePlottable(curve);
|
||||
|
||||
ItemManager::removeItem(curve);
|
||||
@ -1045,7 +992,7 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
||||
for (int i = _customPlot->graphCount() - 1; i >= 0; --i) {
|
||||
QCPGraph *graph = _customPlot->graph(i);
|
||||
logde<<"clear data,graph object Name:"<<graph->objectName().toStdString();
|
||||
if(graph && graph->objectName() == ItemManager::TemporaryStr){
|
||||
if(graph && graph->objectName().contains(ItemManager::TemporaryStr)){
|
||||
_customPlot->removeGraph(graph);
|
||||
|
||||
ItemManager::removeItem(graph);
|
||||
@ -1060,7 +1007,7 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
||||
QCPAbstractItem *item = _customPlot->item(i);
|
||||
logde<<"item data,graph object Name:"<<item->objectName().toStdString();
|
||||
if(item && !itemsToKeep.contains(item)
|
||||
&& item->objectName() == ItemManager::TemporaryStr){
|
||||
&& item->objectName().contains(ItemManager::TemporaryStr)){
|
||||
_customPlot->removeItem(item);
|
||||
|
||||
ItemManager::removeItem(item);
|
||||
@ -1324,21 +1271,21 @@ void CentralWidget::loadAnalysisData(
|
||||
break;
|
||||
}
|
||||
case AnalysisMode::OnsetTemperaturePoint:{
|
||||
#if 0
|
||||
QPointF point = OnsetTemperaturePointHandle(x1,x2);
|
||||
QPointF point = onsetTemperaturePointHandle(x1,x2);
|
||||
logde<<"onset point:"<<point.x()<<","<<point.y();
|
||||
|
||||
QString str = QString::number(point.y(),'f',3);
|
||||
|
||||
drawText(point,str);
|
||||
#endif
|
||||
|
||||
QPointF point = OnsetTemperaturePointHandle(x1,x2);
|
||||
QString str = QString::number(point.x(),'f',3);
|
||||
drawText(point,str,objectName);
|
||||
|
||||
break;
|
||||
}
|
||||
case AnalysisMode::EndsetTemperaturePoint:{
|
||||
QPointF point = endSetTemperaturePointHandle(x1,x2);
|
||||
|
||||
QString str = QString::number(point.x(),'f',3);
|
||||
logde<<"object name:"<<objectName.toStdString();
|
||||
drawText(point,str,objectName);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -86,7 +86,8 @@ private:
|
||||
PointCalculate::Line calculateLinearRegression(const QVector<double>& x,
|
||||
const QVector<double>& y);
|
||||
|
||||
QPointF OnsetTemperaturePointHandle(const double x1,const double x2);
|
||||
QPointF onsetTemperaturePointHandle(const double x1,const double x2);
|
||||
QPointF endSetTemperaturePointHandle(const double x1,const double x2);
|
||||
|
||||
void setEventHandlerEnable(const bool);
|
||||
QPointF getTheCoordinatesOfTheTextBox(const QPointF point);
|
||||
|
Loading…
Reference in New Issue
Block a user