2025-04-25T17:20:33
This commit is contained in:
parent
71c308ac2d
commit
b923eddcfd
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@
|
||||
TO_FILE = true
|
||||
TO_STANDARD_OUTPUT = true
|
||||
FORMAT = "[%datetime] %msg"
|
||||
FILENAME = "log-sdk/%datetime{%Y%M%d}.log"
|
||||
FILENAME = "log/%datetime{%Y%M%d}.log"
|
||||
MILLISECONDS_WIDTH = 3
|
||||
PERFORMANCE_TRACKING = false
|
||||
MAX_LOG_FILE_SIZE = 104857600
|
||||
|
36
AnalysisTool-release/bin/log/20250425.log
Normal file
36
AnalysisTool-release/bin/log/20250425.log
Normal file
@ -0,0 +1,36 @@
|
||||
[2025-04-25 10:01:03,940] main...
|
||||
[2025-04-25 10:01:03,940] config config file existed.
|
||||
[2025-04-25 10:01:03,962] setEventHandlerEnable...0
|
||||
[2025-04-25 10:04:14,605] main...
|
||||
[2025-04-25 10:04:14,605] config config file existed.
|
||||
[2025-04-25 10:04:14,621] setEventHandlerEnable...0
|
||||
[2025-04-25 10:05:25,021] main...
|
||||
[2025-04-25 10:05:25,021] config config file existed.
|
||||
[2025-04-25 10:05:25,047] setEventHandlerEnable...0
|
||||
[2025-04-25 15:50:27,686] main...
|
||||
[2025-04-25 15:50:27,686] config config file existed.
|
||||
[2025-04-25 15:50:27,707] setEventHandlerEnable...0
|
||||
[2025-04-25 15:50:44,842] main...
|
||||
[2025-04-25 15:50:44,842] config config file existed.
|
||||
[2025-04-25 15:50:44,868] setEventHandlerEnable...0
|
||||
[2025-04-25 15:50:53,142] xlsx sample weight:13.9200000762939
|
||||
[2025-04-25 15:50:53,142] startLineIndex:11
|
||||
[2025-04-25 15:50:53,146] data Vtr size:1820
|
||||
[2025-04-25 15:52:13,232] main...
|
||||
[2025-04-25 15:52:13,232] config config file existed.
|
||||
[2025-04-25 15:52:13,251] setEventHandlerEnable...0
|
||||
[2025-04-25 15:55:33,439] main...
|
||||
[2025-04-25 15:55:33,439] config config file existed.
|
||||
[2025-04-25 15:55:33,461] setEventHandlerEnable...0
|
||||
[2025-04-25 15:55:44,430] main...
|
||||
[2025-04-25 15:55:44,430] config config file existed.
|
||||
[2025-04-25 15:55:44,458] setEventHandlerEnable...0
|
||||
[2025-04-25 15:55:53,772] main...
|
||||
[2025-04-25 15:55:53,772] config config file existed.
|
||||
[2025-04-25 15:55:53,794] setEventHandlerEnable...0
|
||||
[2025-04-25 16:04:08,270] main...
|
||||
[2025-04-25 16:04:08,270] config config file existed.
|
||||
[2025-04-25 16:04:08,292] setEventHandlerEnable...0
|
||||
[2025-04-25 16:05:03,992] main...
|
||||
[2025-04-25 16:05:03,993] config config file existed.
|
||||
[2025-04-25 16:05:04,014] setEventHandlerEnable...0
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -30,6 +30,8 @@ SOURCES += \
|
||||
ui/aboutform.cpp \
|
||||
ui/coefficientselectionform.cpp \
|
||||
ui/enthalpydatacorrectionform.cpp \
|
||||
ui/localcustomplot.cpp \
|
||||
ui/printpreviewform.cpp \
|
||||
ui/rightwidget.cpp \
|
||||
thirdparty/easylogging/easylogging++.cc \
|
||||
ui/analysissettingform.cpp \
|
||||
@ -61,6 +63,8 @@ HEADERS += \
|
||||
ui/aboutform.h \
|
||||
ui/coefficientselectionform.h \
|
||||
ui/enthalpydatacorrectionform.h \
|
||||
ui/localcustomplot.h \
|
||||
ui/printpreviewform.h \
|
||||
ui/rightwidget.h \
|
||||
thirdparty/easylogging/easylogging++.h \
|
||||
ui/analysissettingform.h \
|
||||
@ -91,6 +95,7 @@ FORMS += \
|
||||
ui/experimentsettingform.ui \
|
||||
ui/instrumentcoefficientform.ui \
|
||||
ui/oitautoanalysisparamform.ui \
|
||||
ui/printpreviewform.ui \
|
||||
ui/realtimedataform.ui \
|
||||
ui/specificheatcomparisonmethodform.ui
|
||||
|
||||
|
@ -62,6 +62,7 @@ struct PhaseTotalInfo{
|
||||
};
|
||||
|
||||
struct CurveFileData{
|
||||
QString fileName;
|
||||
Global::ExperimentInfo ei;
|
||||
QVector<Global::PhaseTotalInfo> phaseTotalVtr;
|
||||
};
|
||||
|
@ -6,5 +6,6 @@
|
||||
<file>images/new.png</file>
|
||||
<file>images/real_time_widget.png</file>
|
||||
<file>images/logo.png</file>
|
||||
<file>images/logo.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
src/images/logo.ico
Normal file
BIN
src/images/logo.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 303 KiB |
14
src/main.cpp
14
src/main.cpp
@ -41,12 +41,22 @@ int main(int argc, char *argv[])
|
||||
//
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // 启用高DPI缩放
|
||||
QApplication a(argc, argv);
|
||||
a.setWindowIcon(QIcon(":/images/logo.png"));
|
||||
|
||||
QIcon icon;
|
||||
icon.addFile(":/images/logo.ico", QSize(16, 16));
|
||||
icon.addFile(":/images/logo.ico", QSize(32, 32));
|
||||
icon.addFile(":/images/logo.ico", QSize(64, 64));
|
||||
|
||||
a.setWindowIcon(icon);
|
||||
|
||||
// a.setWindowIcon(QIcon(":/images/logo.png"));
|
||||
|
||||
|
||||
#if 1
|
||||
MainWindow w;
|
||||
w.setWindowTitle("Analysis Tool");
|
||||
w.setWindowIcon(QIcon(":/images/logo.png"));
|
||||
// w.setWindowIcon(QIcon(":/images/logo.png"));
|
||||
w.setWindowIcon(icon);
|
||||
w.show();
|
||||
#endif
|
||||
|
||||
|
@ -27,6 +27,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
,_aboutForm(new AboutForm(this))
|
||||
,_enthalpyDataCorrectionForm(new EnthalpyDataCorrectionForm(this))
|
||||
,_coefficientSelectionForm(new CoefficientSelectionForm(this))
|
||||
,_printPreviewForm(new PrintPreviewForm(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setToolTip(".....");
|
||||
@ -54,7 +55,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
setSubWidgetAttribute(_aboutForm);
|
||||
setSubWidgetAttribute(_enthalpyDataCorrectionForm);
|
||||
setSubWidgetAttribute(_coefficientSelectionForm);
|
||||
|
||||
setSubWidgetAttribute(_printPreviewForm);
|
||||
//
|
||||
setActionEnable(true);
|
||||
|
||||
@ -78,9 +79,9 @@ void MainWindow::slotContextMenuShow(const QPoint point)
|
||||
_contextMenu->exec(point);
|
||||
}
|
||||
|
||||
void MainWindow::slotStatusbarMesg(const QString)
|
||||
void MainWindow::slotUpdateStatusbarMsg(const QString msg)
|
||||
{
|
||||
|
||||
ui->statusbar->showMessage(msg);
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
@ -116,6 +117,10 @@ void MainWindow::connections()
|
||||
|
||||
connect(SerialPort::instance(), &SerialPort::sigAxisModify,
|
||||
_centralWidget, &CentralWidget::slotAxisModify);
|
||||
|
||||
connect(SerialPort::instance(), &SerialPort::sigUpdateStatusbarMsg,
|
||||
this,&MainWindow::slotUpdateStatusbarMsg);
|
||||
|
||||
#endif
|
||||
|
||||
// mode
|
||||
@ -368,3 +373,9 @@ void MainWindow::on_actionSaveExperimentData_triggered()
|
||||
_leftWidget->reloadFileName();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionPrintPreview_triggered()
|
||||
{
|
||||
_printPreviewForm->setPixmap(_centralWidget->getPixMap());
|
||||
_printPreviewForm->show();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QStatusBar>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "printpreviewform.h"
|
||||
#include "centralwidget.h"
|
||||
#include "leftwidget.h"
|
||||
#include "experimentsettingform.h"
|
||||
@ -35,7 +36,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void slotContextMenuShow(const QPoint);
|
||||
void slotStatusbarMesg(const QString);
|
||||
void slotUpdateStatusbarMsg(const QString);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
private slots:
|
||||
@ -84,6 +85,8 @@ private slots:
|
||||
|
||||
void on_actionSaveExperimentData_triggered();
|
||||
|
||||
void on_actionPrintPreview_triggered();
|
||||
|
||||
private:
|
||||
void connections();
|
||||
void setActionEnable(const bool);
|
||||
@ -107,5 +110,6 @@ private:
|
||||
AboutForm *_aboutForm;
|
||||
EnthalpyDataCorrectionForm* _enthalpyDataCorrectionForm;
|
||||
CoefficientSelectionForm * _coefficientSelectionForm;
|
||||
PrintPreviewForm *_printPreviewForm;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -29,6 +29,7 @@
|
||||
</property>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionSaveExperimentData"/>
|
||||
<addaction name="actionPrintPreview"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_2">
|
||||
<property name="title">
|
||||
@ -274,6 +275,11 @@
|
||||
<string>保存实验数据</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPrintPreview">
|
||||
<property name="text">
|
||||
<string>打印预览</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="images.qrc"/>
|
||||
|
@ -165,9 +165,9 @@ void experimentalStateSwitching(const CommonData &cd)
|
||||
Global::_currentCurveExperimentDataPtr->fileName = Global::_experimentInfo.sampleName;
|
||||
}
|
||||
|
||||
logde<<"phase:"<<(int)cd.current_phase;
|
||||
logde<<"run type:"<<(int)cd.run_type;
|
||||
logde<<"software mode:"<<Global::_mode;
|
||||
// logde<<"phase:"<<(int)cd.current_phase;
|
||||
// logde<<"run type:"<<(int)cd.run_type;
|
||||
// logde<<"software mode:"<<Global::_mode;
|
||||
}
|
||||
|
||||
unsigned short modbusCRC16(unsigned char *data, unsigned short length)
|
||||
|
@ -129,7 +129,7 @@ void SerialPort::slotReadData()
|
||||
{
|
||||
DataParser::experimentalStateSwitching(cd);
|
||||
setAxis();
|
||||
updateStatusbarMsg();
|
||||
updateStatusbarMsg(cd);
|
||||
|
||||
if (spp->addr == 0)
|
||||
{
|
||||
@ -142,9 +142,42 @@ void SerialPort::slotReadData()
|
||||
}
|
||||
}
|
||||
|
||||
void SerialPort::updateStatusbarMsg()
|
||||
void SerialPort::updateStatusbarMsg(const CommonData &cd)
|
||||
{
|
||||
#if 1
|
||||
logde<<"phase:"<<(int)cd.current_phase;
|
||||
logde<<"run type:"<<(int)cd.run_type;
|
||||
logde<<"software mode:"<<Global::_mode;
|
||||
#endif
|
||||
|
||||
bool experimentEnded = false;
|
||||
QString devRunModeStr;
|
||||
switch(cd.run_type){
|
||||
case DeviceRunStatus::Heat:
|
||||
devRunModeStr = "升温";
|
||||
experimentEnded = true;
|
||||
break;
|
||||
case DeviceRunStatus::ConstantTemp:
|
||||
devRunModeStr = "实验";
|
||||
experimentEnded = true;
|
||||
break;
|
||||
case DeviceRunStatus::Idle:
|
||||
case DeviceRunStatus::Cooling:
|
||||
devRunModeStr = "冷却";
|
||||
experimentEnded = false;
|
||||
break;
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
QString msg;
|
||||
if(experimentEnded){
|
||||
msg = QString("设备运行状态:%2 实验阶段:%3 实验进行中").arg(devRunModeStr).arg(cd.current_phase);
|
||||
}else{
|
||||
msg = QString("设备运行状态:%2 实验阶段:%3 实验结束").arg(devRunModeStr).arg(cd.current_phase);
|
||||
}
|
||||
|
||||
emit sigUpdateStatusbarMsg(msg);
|
||||
}
|
||||
|
||||
void SerialPort::commonDataParser(const int dataLength, const u16 addr,
|
||||
|
@ -35,6 +35,7 @@ signals:
|
||||
void sigSendCommonDataToRealDataForm(const CommonData &);
|
||||
void sigSendPhaseInfo(const QByteArray &);
|
||||
void sigAxisModify(const float temp);
|
||||
void sigUpdateStatusbarMsg(const QString &);
|
||||
public slots:
|
||||
void slotDeliverData(const QByteArray &);
|
||||
// void slotConnectToDevice(const QByteArray&);
|
||||
@ -44,7 +45,7 @@ private slots:
|
||||
void slotReadData();
|
||||
|
||||
private:
|
||||
void updateStatusbarMsg();
|
||||
void updateStatusbarMsg(const CommonData &cd);
|
||||
void commonDataParser(const int dataLength, const u16 addr, const CommonData &cd);
|
||||
void to_hex(char *in_char, int char_length, char *out_char);
|
||||
void displayPortInfo();
|
||||
|
@ -20,7 +20,7 @@ AboutForm::AboutForm(QWidget *parent) :
|
||||
ui->labelTitle->setText(QString("<p style=\"font-size: 18px;\">关于差示扫描量热仪数据分析软件</p>"));
|
||||
|
||||
|
||||
QString ConCompleTime = QString("编译时间:%1 %2").arg(__DATE__).arg(__TIME__);
|
||||
QString ConCompleTime = QString("%1 %2").arg(__DATE__).arg(__TIME__);
|
||||
|
||||
QString aboutText = QString(
|
||||
"<p>软件版本:%1</p>"
|
||||
@ -36,6 +36,8 @@ AboutForm::AboutForm(QWidget *parent) :
|
||||
ui->labelContent->setText(aboutText);
|
||||
ui->labelContent->setStyleSheet("p { line-height: 1em; }");
|
||||
ui->labelContent->setOpenExternalLinks(true); // 允许用户点击链接
|
||||
|
||||
ui->pushButtonClose->setToolTip(ConCompleTime);
|
||||
}
|
||||
|
||||
AboutForm::~AboutForm()
|
||||
|
@ -13,7 +13,8 @@
|
||||
|
||||
CentralWidget::CentralWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
,_customPlot(new QCustomPlot(this))
|
||||
,_customPlot(new LocalCustomPlot(this))
|
||||
// ,_customPlot(new QCustomPlot(this))
|
||||
,_analysisMode(AnalysisMode::Null)
|
||||
,_currentCurve(nullptr)
|
||||
{
|
||||
@ -150,7 +151,7 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||
}
|
||||
|
||||
logde<<"temp:"<<cd.sample_temp<<",dsc:"<<cd.dsc;
|
||||
// logde<<"temp:"<<cd.sample_temp<<",dsc:"<<cd.dsc;
|
||||
|
||||
_currentCurve->addData(index++,cd.sample_temp, cd.dsc);
|
||||
|
||||
@ -160,14 +161,10 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
// return;
|
||||
|
||||
// Record data.
|
||||
// logde<<"record data...";
|
||||
|
||||
if(!Global::_currentCurveExperimentDataPtr){
|
||||
logde<<"_currentCurveExperimentDataPtr is nullptr.";
|
||||
loger<<"_currentCurveExperimentDataPtr is nullptr.";
|
||||
exit(0);
|
||||
}else{
|
||||
// logde<<"add ed...";
|
||||
|
||||
Global::ExperimentData ed;
|
||||
ed.dsc = cd .dsc;
|
||||
ed.sampleTemp = cd.sample_temp;
|
||||
@ -177,29 +174,6 @@ void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||
Global::_currentCurveExperimentDataPtr->dataVtr.push_back(ed);
|
||||
Global::_currentCurveExperimentDataPtr->curve = _currentCurve;
|
||||
}
|
||||
|
||||
#if 0
|
||||
logde<<"record data...";
|
||||
QVector<Global::ExperimentData>* pEdVtr = nullptr; // 声明指针变量
|
||||
for(auto item:Global::_curveExperimentDataVtr){
|
||||
if(item.curve == _currentCurve){
|
||||
pEdVtr = &item.dataVtr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!pEdVtr){
|
||||
Global::_curveExperimentDataVtr.push_back({_currentCurve, {}});
|
||||
pEdVtr = &Global::_curveExperimentDataVtr.back().dataVtr;
|
||||
}
|
||||
|
||||
Global::ExperimentData ed;
|
||||
ed.dsc = cd .dsc;
|
||||
ed.sampleTemp = cd.sample_temp;
|
||||
ed.runTime = cd.add_run_time;
|
||||
ed.constantTempTime = cd.add_constan_temp_time;
|
||||
|
||||
pEdVtr->push_back(ed);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
||||
@ -214,6 +188,9 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
||||
return;
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(filePath);
|
||||
cfd.fileName = fileInfo.fileName();
|
||||
|
||||
for(int i = 0;i < cfd.phaseTotalVtr.size();i++){
|
||||
Global::PhaseTotalInfo& pti = cfd.phaseTotalVtr[i];
|
||||
|
||||
@ -248,93 +225,16 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &filePath)
|
||||
_currentCurve->setData(tVtr, xVtr, yVtr);
|
||||
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||
|
||||
// Add data to global parameter.
|
||||
QFileInfo fileInfo(filePath);
|
||||
|
||||
pti.curve = _currentCurve;
|
||||
}
|
||||
|
||||
// Add data to global parameter.
|
||||
Global::_curveFileDataVtr.push_back(cfd);
|
||||
|
||||
_customPlot->rescaleAxes();
|
||||
_customPlot->replot();
|
||||
}
|
||||
|
||||
// discard
|
||||
void CentralWidget::slotSelectionChanged()
|
||||
{
|
||||
logde<<"selectedPlottables:"<< _customPlot->selectedPlottables().size();
|
||||
logde<<"selectedGraphs:"<< _customPlot->selectedGraphs().size();
|
||||
logde<<"selectedItems:"<< _customPlot->selectedItems().size();
|
||||
|
||||
logde<<"plottableCount:"<< _customPlot->plottableCount();
|
||||
|
||||
return;
|
||||
|
||||
for(int i = 0;i < _customPlot->plottableCount(); i++) {
|
||||
QCPCurve *curve = qobject_cast<QCPCurve *>(_customPlot->plottable(i));
|
||||
if(curve){
|
||||
if (curve->selected()) {
|
||||
logde<<"selected...";
|
||||
curve->setPen(QPen(Qt::green));
|
||||
_customPlot->replot();
|
||||
} else {
|
||||
curve->setPen(QPen(Qt::blue));
|
||||
_customPlot->replot();
|
||||
}
|
||||
}
|
||||
|
||||
logde << "Current pen color:" << curve->pen().color().name().toStdString();
|
||||
}
|
||||
|
||||
// _customPlot->replot();
|
||||
// _customPlot->update();
|
||||
|
||||
#if 0
|
||||
for (QCPAbstractPlottable *plottable : _customPlot->plottable()) {
|
||||
QCPCurve *curve = qobject_cast<QCPCurve *>(plottable);
|
||||
if (curve) {
|
||||
if (curve->selected()) {
|
||||
// 曲线被选中,设置为橙色
|
||||
curve->setPen(QPen(Qt::green));
|
||||
} else {
|
||||
#if 0
|
||||
// 曲线未被选中,恢复默认颜色
|
||||
if (curve == _curve1) {
|
||||
curve->setPen(QPen(Qt::blue));
|
||||
} else if (curve == _curve2) {
|
||||
curve->setPen(QPen(Qt::red));
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// 检查是否有曲线被选中
|
||||
if (_customPlot->selectedPlottables().size() > 0) {
|
||||
QCPCurve *selectedCurve = qobject_cast<QCPCurve *>(_customPlot->selectedPlottables().first());
|
||||
if (selectedCurve) {
|
||||
selectedCurve->setPen(QPen(Qt::green));
|
||||
#if 0
|
||||
// 弹出颜色选择对话框
|
||||
QColor color = QColorDialog::getColor(selectedCurve->pen().color(), this);
|
||||
if (color.isValid()) {
|
||||
// 改变曲线颜色
|
||||
selectedCurve->setPen(QPen(color));
|
||||
}
|
||||
#endif
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CentralWidget::slotAnalysisSettingApply()
|
||||
{
|
||||
switch (_analysisMode) {
|
||||
@ -849,11 +749,11 @@ void CentralWidget::setEventHandlerEnable(const bool flag)
|
||||
double xMax = _customPlot->xAxis->range().upper;
|
||||
double xMin = _customPlot->xAxis->range().lower;
|
||||
|
||||
// logde<<"xMax:"<<xMax;
|
||||
// logde<<"xMax:"<<xMax;
|
||||
|
||||
// QVector<double> ticks = _customPlot->xAxis->tickVector();
|
||||
// int numTicks = ticks.size();
|
||||
// logde<<"ticks:"<<numTicks;
|
||||
// QVector<double> ticks = _customPlot->xAxis->tickVector();
|
||||
// int numTicks = ticks.size();
|
||||
// logde<<"ticks:"<<numTicks;
|
||||
|
||||
double range = xMax - xMin;
|
||||
double xLeft = xMin + range / 3;
|
||||
@ -892,19 +792,19 @@ QPointF CentralWidget::getTheCoordinatesOfTheTextBox(const QPointF point)
|
||||
|
||||
void CentralWidget::drawText(const QPointF point, const QString text)
|
||||
{
|
||||
|
||||
QPointF textBoxPoint = getTheCoordinatesOfTheTextBox(point);
|
||||
|
||||
// 创建标注文字(QCPItemText)
|
||||
QCPItemText *textLabel = new QCPItemText(_customPlot);
|
||||
textLabel->setPositionAlignment(Qt::AlignBottom | Qt::AlignHCenter); // 对齐方式
|
||||
textLabel->setPositionAlignment(Qt::AlignCenter); // 对齐方式
|
||||
textLabel->position->setType(QCPItemPosition::ptPlotCoords); // 使用数据坐标
|
||||
textLabel->position->setCoords(textBoxPoint.x(),textBoxPoint.y()); // 设置文本位置在指定点上方
|
||||
|
||||
textLabel->setText(text); // 设置文本内容
|
||||
// textLabel->setFont(QFont("Arial", 10));
|
||||
textLabel->setPen(QPen(Qt::lightGray)); // 文字边框
|
||||
textLabel->setBrush(Qt::white); // 文字背景
|
||||
QFont font(QFont("Arial", 10));
|
||||
textLabel->setFont(font);
|
||||
textLabel->setSelectedFont(font);
|
||||
textLabel->setSelectable(true); // 设置为可选
|
||||
|
||||
// 创建指向点的线段(QCPItemLine)
|
||||
QCPItemLine *arrow = new QCPItemLine(_customPlot);
|
||||
@ -1002,6 +902,11 @@ void CentralWidget::clearAllData()
|
||||
clearData(ClearDataMode::All);
|
||||
}
|
||||
|
||||
QPixmap CentralWidget::getPixMap()
|
||||
{
|
||||
return _customPlot->toPixmap();
|
||||
}
|
||||
|
||||
void CentralWidget::slotAxisModify(const float temp)
|
||||
{
|
||||
_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "eventhandler.h"
|
||||
#include "filemanager.h"
|
||||
#include "pointcalculate.h"
|
||||
#include "localcustomplot.h"
|
||||
|
||||
class CentralWidget:public QWidget
|
||||
{
|
||||
@ -30,6 +31,8 @@ public:
|
||||
void clearAllData();
|
||||
|
||||
EventHandler* getEvnetHandler(){return _eventHandler;}
|
||||
|
||||
QPixmap getPixMap();
|
||||
signals:
|
||||
void sigContextMenuShow(const QPoint);
|
||||
void sigSendLineXCoord(const int,const double);
|
||||
@ -40,7 +43,6 @@ public slots:
|
||||
void slotModeModify(const Global::Mode);
|
||||
void slotRecvCommonData(const CommonData&);
|
||||
void slotRecvAnalysisFileName(const QString&);
|
||||
void slotSelectionChanged();
|
||||
|
||||
//analysis setting
|
||||
void slotAnalysisSettingApply();
|
||||
@ -72,7 +74,8 @@ private:
|
||||
void clearData(const ClearDataMode);
|
||||
private:
|
||||
AnalysisMode _analysisMode;
|
||||
QCustomPlot *_customPlot;
|
||||
LocalCustomPlot *_customPlot;
|
||||
// QCustomPlot*_customPlot;
|
||||
QCPCurve *_currentCurve;
|
||||
// QVector<QCPCurve *> _curveVtr;
|
||||
// QCPGraph* _currentGraph;
|
||||
|
83
src/ui/localcustomplot.cpp
Normal file
83
src/ui/localcustomplot.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include "localcustomplot.h"
|
||||
|
||||
LocalCustomPlot::LocalCustomPlot(QWidget *parent)
|
||||
: QCustomPlot(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 鼠标按下事件
|
||||
void LocalCustomPlot::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
// 先取消所有选中的项
|
||||
for (auto* item : selectedItems())
|
||||
{
|
||||
item->setSelected(false);
|
||||
}
|
||||
|
||||
for(int i = 0; i < itemCount();i++)
|
||||
{
|
||||
if (QCPItemText* textItem = qobject_cast<QCPItemText*>(item(i)))
|
||||
{
|
||||
QRectF rect = getTextBoundingRect(textItem);
|
||||
if(rect.contains(event->pos()))
|
||||
{
|
||||
_draggedTextItem = textItem;
|
||||
_draggedTextItem->setSelected(true); // 手动选择这个项
|
||||
_lastMousePos = event->pos();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QCustomPlot::mousePressEvent(event);
|
||||
}
|
||||
|
||||
// 鼠标释放事件
|
||||
void LocalCustomPlot::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
_draggedTextItem = nullptr; // 清除拖动状态
|
||||
|
||||
QCustomPlot::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
// 鼠标移动事件
|
||||
void LocalCustomPlot::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (_draggedTextItem)
|
||||
{
|
||||
double dx = event->pos().x() - _lastMousePos.x();
|
||||
double dy = event->pos().y() - _lastMousePos.y();
|
||||
|
||||
_draggedTextItem->position->setType(QCPItemPosition::ptAbsolute); // 使用屏幕坐标系
|
||||
_draggedTextItem->position->setCoords(
|
||||
_draggedTextItem->position->key() + dx,
|
||||
_draggedTextItem->position->value() + dy
|
||||
);
|
||||
|
||||
_lastMousePos = event->pos();
|
||||
replot(); // 刷新图表
|
||||
}else{
|
||||
QCustomPlot::mouseMoveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
QRectF LocalCustomPlot::getTextBoundingRect(QCPItemText* textItem) {
|
||||
textItem->position->setType(QCPItemPosition::ptAbsolute); // 使用屏幕坐标系
|
||||
// 获取文本的字体
|
||||
QFont font = textItem->font();
|
||||
|
||||
// 使用 QFontMetrics 获取字体的尺寸
|
||||
QFontMetrics fontMetrics(font);
|
||||
|
||||
// 获取文本的矩形边界
|
||||
QRectF textRect = fontMetrics.boundingRect(textItem->text());
|
||||
|
||||
// 获取文本框的位置
|
||||
QPointF textPosition = textItem->position->coords();
|
||||
|
||||
// 设置文本矩形的位置,将其居中到文本框的实际位置
|
||||
textRect.moveCenter(textPosition.toPoint());
|
||||
|
||||
return textRect;
|
||||
}
|
22
src/ui/localcustomplot.h
Normal file
22
src/ui/localcustomplot.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef LOCALCUSTOMPLOT_H
|
||||
#define LOCALCUSTOMPLOT_H
|
||||
|
||||
#include <qcustomplot.h>
|
||||
|
||||
class LocalCustomPlot : public QCustomPlot
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LocalCustomPlot(QWidget *parent = nullptr);
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
private:
|
||||
QRectF getTextBoundingRect(QCPItemText* textItem);
|
||||
|
||||
QCPItemText* _draggedTextItem = nullptr;
|
||||
QPoint _lastMousePos;
|
||||
};
|
||||
|
||||
#endif // LOCALCUSTOMPLOT_H
|
23
src/ui/printpreviewform.cpp
Normal file
23
src/ui/printpreviewform.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "printpreviewform.h"
|
||||
#include "ui_printpreviewform.h"
|
||||
|
||||
PrintPreviewForm::PrintPreviewForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PrintPreviewForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
PrintPreviewForm::~PrintPreviewForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrintPreviewForm::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
QPixmap localPixmap = pixmap;
|
||||
localPixmap.scaled(ui->labelPixmap->size());
|
||||
ui->labelPixmap->setPixmap(pixmap);
|
||||
}
|
24
src/ui/printpreviewform.h
Normal file
24
src/ui/printpreviewform.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef PRINTPREVIEWFORM_H
|
||||
#define PRINTPREVIEWFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class PrintPreviewForm;
|
||||
}
|
||||
|
||||
class PrintPreviewForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrintPreviewForm(QWidget *parent = nullptr);
|
||||
~PrintPreviewForm();
|
||||
|
||||
void setPixmap(const QPixmap &);
|
||||
private:
|
||||
Ui::PrintPreviewForm *ui;
|
||||
|
||||
};
|
||||
|
||||
#endif // PRINTPREVIEWFORM_H
|
32
src/ui/printpreviewform.ui
Normal file
32
src/ui/printpreviewform.ui
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrintPreviewForm</class>
|
||||
<widget class="QWidget" name="PrintPreviewForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>776</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="labelPixmap">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>691</width>
|
||||
<height>371</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -87,8 +87,12 @@ void SpecificHeatComparisonMethodForm::slotSetCurve(const int type, QCPCurve *c
|
||||
|
||||
void SpecificHeatComparisonMethodForm::showEvent(QShowEvent *event)
|
||||
{
|
||||
#if 0
|
||||
auto& curveDataVtr = Global::_curveExperimentDataVtr;
|
||||
// QVector<Global::ExperimentData> *baseLineDataVtr = nullptr,
|
||||
|
||||
logde<<"curve data vtr size:"<<Global::_curveExperimentDataVtr.size();
|
||||
|
||||
// QVector<Global::ExperimentData> *baseLineDataVtr = nullptr,
|
||||
// *standardSampleDataVtr = nullptr,
|
||||
// *sampleDataVtr = nullptr;
|
||||
|
||||
@ -104,6 +108,22 @@ void SpecificHeatComparisonMethodForm::showEvent(QShowEvent *event)
|
||||
_sampleDataVtr = &(item.dataVtr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for(auto& cfd:Global::_curveFileDataVtr){
|
||||
for(auto& item:cfd.phaseTotalVtr){
|
||||
if(item.curve == _baseLineCurve){
|
||||
_baseLineLineEdit->setText(cfd.fileName);
|
||||
_baseLineDataVtr = &(item.dataVtr);
|
||||
}else if(item.curve == _standardSampleCurve){
|
||||
_standardSampleLineEdit->setText(cfd.fileName);
|
||||
_standardSampleDataVtr = &(item.dataVtr);
|
||||
}else if(item.curve == _sampleCurve){
|
||||
_sampleLineEdit->setText(cfd.fileName);
|
||||
_sampleDataVtr = &(item.dataVtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!_baseLineDataVtr ||!_standardSampleDataVtr||
|
||||
!_sampleDataVtr){
|
||||
|
Loading…
Reference in New Issue
Block a user