2025-04-27T15:27:06

This commit is contained in:
yuntang 2025-04-27 15:27:07 +08:00
parent b923eddcfd
commit d64d48f0e6
8 changed files with 51 additions and 9 deletions

View File

@ -145,6 +145,9 @@ void MainWindow::connections()
connect(_centralWidget,&CentralWidget::sigRightDockWidgetHide, connect(_centralWidget,&CentralWidget::sigRightDockWidgetHide,
[&](){ _rightWidget->hide(); }); [&](){ _rightWidget->hide(); });
connect(_degreeOfCrystallinityForm,&DegreeOfCrystallinityForm::sigDrawCustomText,
_centralWidget,&CentralWidget::slotDrawCustomText);
//SpecificHeatComparisonMethodForm //SpecificHeatComparisonMethodForm
connect(_eventHandler,&EventHandler::sigSetCurve, connect(_eventHandler,&EventHandler::sigSetCurve,
_specificHeatComparisonMethodForm, _specificHeatComparisonMethodForm,

View File

@ -360,6 +360,28 @@ void CentralWidget::slotAnalysisSettingLineXPoint(const int index, const double)
} }
void CentralWidget::slotDrawCustomText(const QString str)
{
QCPItemText* customLegendItem = new QCPItemText(_customPlot);
customLegendItem->position->setTypeX(QCPItemPosition::ptAbsolute);
customLegendItem->position->setTypeY(QCPItemPosition::ptAbsolute);
customLegendItem->position->setCoords(150, 50); // 稍微向下移动
customLegendItem->setText(str);
QFont font("Arial", 10);
customLegendItem->setFont(font);
// 设置边框和背景
customLegendItem->setPen(QPen(Qt::black));
customLegendItem->setBrush(QBrush(Qt::white));
// 禁止点选
customLegendItem->setSelectable(false);
customLegendItem->setObjectName("fixed");
_customPlot->replot();
}
void CentralWidget::timerEvent(QTimerEvent *event) void CentralWidget::timerEvent(QTimerEvent *event)
{ {
_customPlot->replot(); _customPlot->replot();

View File

@ -51,6 +51,8 @@ public slots:
void slotAnalysisSettingCancel(); void slotAnalysisSettingCancel();
void slotAnalysisSettingLineXPoint(const int index,const double); void slotAnalysisSettingLineXPoint(const int index,const double);
void slotDrawCustomText(const QString);
protected: protected:
void timerEvent(QTimerEvent* event); void timerEvent(QTimerEvent* event);
void contextMenuEvent(QContextMenuEvent *event); void contextMenuEvent(QContextMenuEvent *event);
@ -67,6 +69,7 @@ private:
void drawText(const QPointF,const QString); void drawText(const QPointF,const QString);
void fillGraph(const double x1,const double x2); void fillGraph(const double x1,const double x2);
enum ClearDataMode{ enum ClearDataMode{
All, All,
Undo Undo
@ -75,14 +78,14 @@ private:
private: private:
AnalysisMode _analysisMode; AnalysisMode _analysisMode;
LocalCustomPlot *_customPlot; LocalCustomPlot *_customPlot;
// QCustomPlot*_customPlot; // QCustomPlot*_customPlot;
QCPCurve *_currentCurve; QCPCurve *_currentCurve;
// QVector<QCPCurve *> _curveVtr; // QVector<QCPCurve *> _curveVtr;
// QCPGraph* _currentGraph; // QCPGraph* _currentGraph;
// QVector<QCPGraph*> _graphVtr; // QVector<QCPGraph*> _graphVtr;
EventHandler* _eventHandler; EventHandler* _eventHandler;
QCPItemStraightLine *_line1,*_line2; QCPItemStraightLine *_line1,*_line2;
// QVector<Global::ExperimentData> _dataVtr; // QVector<Global::ExperimentData> _dataVtr;
QVector<QCPItemStraightLine*> _lineVtr; QVector<QCPItemStraightLine*> _lineVtr;
}; };

View File

@ -6,6 +6,7 @@ DegreeOfCrystallinityForm::DegreeOfCrystallinityForm(QWidget *parent) :
ui(new Ui::DegreeOfCrystallinityForm) ui(new Ui::DegreeOfCrystallinityForm)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowTitle("结晶度");
} }
DegreeOfCrystallinityForm::~DegreeOfCrystallinityForm() DegreeOfCrystallinityForm::~DegreeOfCrystallinityForm()
@ -18,9 +19,13 @@ void DegreeOfCrystallinityForm::on_pushButtonCalculate_clicked()
float enthalpy = ui->LineEditEnthalpyOfCrystallization->text().toFloat(); float enthalpy = ui->LineEditEnthalpyOfCrystallization->text().toFloat();
float enthalpyCold = ui->LineEditEnthalpyOfColdCrystallization->text().toFloat(); float enthalpyCold = ui->LineEditEnthalpyOfColdCrystallization->text().toFloat();
float enthalpyTheory = ui->LineEditTheoreticalEnthalpy->text().toFloat(); float enthalpyTheory = ui->LineEditTheoreticalEnthalpy->text().toFloat();
float Xc = (enthalpy - enthalpyCold) / enthalpyTheory / 100; float Xc = (enthalpy - enthalpyCold) / enthalpyTheory * 100;
ui->xcLineEditDegreedOfCrystallinity->setText(QString::number(Xc,'f',3)); QString xcStr = QString::number(Xc,'f',3);
ui->xcLineEditDegreedOfCrystallinity->setText(xcStr);
QString str = QString("结晶度Xc(%)= %1%").arg(xcStr);
emit sigDrawCustomText(str);
} }
void DegreeOfCrystallinityForm::on_pushButtonQuit_clicked() void DegreeOfCrystallinityForm::on_pushButtonQuit_clicked()

View File

@ -14,7 +14,8 @@ class DegreeOfCrystallinityForm : public QWidget
public: public:
explicit DegreeOfCrystallinityForm(QWidget *parent = nullptr); explicit DegreeOfCrystallinityForm(QWidget *parent = nullptr);
~DegreeOfCrystallinityForm(); ~DegreeOfCrystallinityForm();
signals:
void sigDrawCustomText(const QString);
private slots: private slots:
void on_pushButtonCalculate_clicked(); void on_pushButtonCalculate_clicked();

View File

@ -6,6 +6,8 @@ DegreeOfCureForm::DegreeOfCureForm(QWidget *parent) :
ui(new Ui::DegreeOfCureForm) ui(new Ui::DegreeOfCureForm)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowTitle("固化度");
} }
DegreeOfCureForm::~DegreeOfCureForm() DegreeOfCureForm::~DegreeOfCureForm()
@ -18,7 +20,7 @@ void DegreeOfCureForm::on_pushButtonCalculate_clicked()
float precure = ui->LineEditPrecure->text().toFloat(); float precure = ui->LineEditPrecure->text().toFloat();
float afterCuring = ui->jGLineEditAfterCuring->text().toFloat(); float afterCuring = ui->jGLineEditAfterCuring->text().toFloat();
float degree = (precure - afterCuring)/afterCuring/100; float degree = (precure - afterCuring)/afterCuring * 100;
ui->LineEditDegreeOfCure->setText(QString::number(degree,'f',3)); ui->LineEditDegreeOfCure->setText(QString::number(degree,'f',3));
} }

View File

@ -15,6 +15,7 @@ public:
explicit DegreeOfCureForm(QWidget *parent = nullptr); explicit DegreeOfCureForm(QWidget *parent = nullptr);
~DegreeOfCureForm(); ~DegreeOfCureForm();
private slots: private slots:
void on_pushButtonCalculate_clicked(); void on_pushButtonCalculate_clicked();

View File

@ -19,6 +19,11 @@ void LocalCustomPlot::mousePressEvent(QMouseEvent *event)
{ {
if (QCPItemText* textItem = qobject_cast<QCPItemText*>(item(i))) if (QCPItemText* textItem = qobject_cast<QCPItemText*>(item(i)))
{ {
#if 1
if(textItem->objectName() == "fixed"){
continue;
}
#endif
QRectF rect = getTextBoundingRect(textItem); QRectF rect = getTextBoundingRect(textItem);
if(rect.contains(event->pos())) if(rect.contains(event->pos()))
{ {