2025-03-13 09:27:31 +00:00
|
|
|
#include <qmessagebox.h>
|
|
|
|
|
|
2025-03-05 09:33:46 +00:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
2025-03-12 09:29:52 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
#include "serialport.h"
|
2025-03-13 09:27:31 +00:00
|
|
|
#include "dataparser.h"
|
2025-03-17 13:16:16 +00:00
|
|
|
#include "filemanager.h"
|
2025-03-05 09:33:46 +00:00
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
2025-03-21 09:28:36 +00:00
|
|
|
: QMainWindow(parent),
|
|
|
|
|
ui(new Ui::MainWindow),
|
|
|
|
|
_centralWidget(new CentralWidget(this)),
|
|
|
|
|
_leftWidget(new LeftWidget(this)),
|
|
|
|
|
_expertmentSettingForm(new ExperimentSettingForm(this)),
|
|
|
|
|
_realTimeDataForm(new RealTimeDataForm(this)),
|
|
|
|
|
_rightWidget(new QDockWidget(this))
|
|
|
|
|
,_analysisSettingWidget(new AnalysisSettingForm(this))
|
|
|
|
|
,_contextMenu(new QMenu(this))
|
2025-03-05 09:33:46 +00:00
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
this->setToolTip(".....");
|
|
|
|
|
|
|
|
|
|
setCentralWidget(_centralWidget);
|
2025-03-12 09:29:52 +00:00
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
|
2025-03-21 09:28:36 +00:00
|
|
|
addDockWidget(Qt::RightDockWidgetArea, _rightWidget);
|
|
|
|
|
|
|
|
|
|
_rightWidget->setWidget(_analysisSettingWidget);
|
|
|
|
|
_rightWidget->hide();
|
2025-03-14 08:58:08 +00:00
|
|
|
//
|
|
|
|
|
ui->statusbar->showMessage("showMessage show temp message!");
|
|
|
|
|
// permenent show
|
|
|
|
|
QLabel *permenentLabel = new QLabel(this);
|
|
|
|
|
permenentLabel->setText("Permanent show!");
|
|
|
|
|
ui->statusbar->addPermanentWidget(permenentLabel);
|
|
|
|
|
//
|
2025-03-12 09:29:52 +00:00
|
|
|
connections();
|
2025-03-14 08:58:08 +00:00
|
|
|
//
|
2025-03-21 09:28:36 +00:00
|
|
|
_expertmentSettingForm->setWindowFlags(_expertmentSettingForm->windowFlags()| Qt::Dialog);
|
|
|
|
|
_realTimeDataForm->setWindowFlags(_realTimeDataForm->windowFlags()| Qt::Dialog);
|
|
|
|
|
|
|
|
|
|
// _realTimeDataForm->show();
|
|
|
|
|
setActionEnable(true);
|
|
|
|
|
|
2025-03-05 09:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
|
{
|
2025-03-21 09:28:36 +00:00
|
|
|
// 删除非QObject派生类的对象
|
|
|
|
|
// 假设 Ui::MainWindow 不是 QObject 派生类
|
2025-03-05 09:33:46 +00:00
|
|
|
delete ui;
|
2025-03-21 09:28:36 +00:00
|
|
|
|
|
|
|
|
FileManager::close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slotContextMenuShow(const QPoint point)
|
|
|
|
|
{
|
|
|
|
|
_contextMenu->exec(point);
|
2025-03-05 09:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-12 09:29:52 +00:00
|
|
|
void MainWindow::connections()
|
|
|
|
|
{
|
2025-03-18 03:43:14 +00:00
|
|
|
// ui
|
|
|
|
|
connect(_expertmentSettingForm, &ExperimentSettingForm::sigDeliverData,
|
|
|
|
|
SerialPort::instance(), &SerialPort::slotDeliverData);
|
2025-03-14 08:58:08 +00:00
|
|
|
#if 1
|
2025-03-18 03:43:14 +00:00
|
|
|
// dynamic data
|
|
|
|
|
connect(SerialPort::instance(), &SerialPort::sigSendCommonData,
|
2025-03-19 07:19:45 +00:00
|
|
|
_centralWidget, &CentralWidget::slotRecvCommonData);
|
2025-03-18 03:43:14 +00:00
|
|
|
connect(SerialPort::instance(), &SerialPort::sigSendCommonData,
|
|
|
|
|
_realTimeDataForm, &RealTimeDataForm::slotRevCommonData);
|
|
|
|
|
|
|
|
|
|
connect(SerialPort::instance(), &SerialPort::sigSendCommonDataToRealDataForm,
|
|
|
|
|
_realTimeDataForm, &RealTimeDataForm::slotRevCommonData);
|
|
|
|
|
|
|
|
|
|
connect(SerialPort::instance(), &SerialPort::sigSendPhaseInfo,
|
|
|
|
|
_expertmentSettingForm, &ExperimentSettingForm::slotRecvPhaseInfo);
|
|
|
|
|
|
2025-03-14 08:58:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
2025-03-18 03:43:14 +00:00
|
|
|
// mode
|
|
|
|
|
connect(Global::instance(), &Global::sigModeModify,
|
|
|
|
|
_centralWidget, &CentralWidget::slotModeModify);
|
2025-03-19 07:19:45 +00:00
|
|
|
//analysis
|
|
|
|
|
connect(_leftWidget,&LeftWidget::sigSendAnalysisFileName,
|
|
|
|
|
_centralWidget,&CentralWidget::slotRecvAnalysisFileName);
|
2025-03-21 09:28:36 +00:00
|
|
|
connect(_centralWidget,&CentralWidget::sigSendLineXCoord,
|
|
|
|
|
_analysisSettingWidget,&AnalysisSettingForm::slotRecvLineXCoord);
|
|
|
|
|
|
|
|
|
|
connect(_analysisSettingWidget,&AnalysisSettingForm::sigApply,
|
|
|
|
|
_centralWidget,&CentralWidget::slotAnalysisSettingApply);
|
|
|
|
|
connect(_analysisSettingWidget,&AnalysisSettingForm::sigConfirm,
|
|
|
|
|
_centralWidget,&CentralWidget::slotAnalysisSettingConfirm);
|
2025-03-24 09:30:42 +00:00
|
|
|
connect(_analysisSettingWidget,&AnalysisSettingForm::sigUndo,
|
|
|
|
|
_centralWidget,&CentralWidget::slotAnalysisSettingUndo);
|
|
|
|
|
connect(_analysisSettingWidget,&AnalysisSettingForm::sigCancel,
|
|
|
|
|
_centralWidget,&CentralWidget::slotAnalysisSettingCancel);
|
2025-03-12 09:29:52 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-13 09:27:31 +00:00
|
|
|
void MainWindow::setActionEnable(const bool flag)
|
|
|
|
|
{
|
2025-03-18 03:43:14 +00:00
|
|
|
if (flag)
|
|
|
|
|
{
|
2025-03-13 09:27:31 +00:00
|
|
|
ui->actionNew->setEnabled(true);
|
|
|
|
|
ui->actionStart->setEnabled(true);
|
|
|
|
|
ui->actionStop->setEnabled(true);
|
|
|
|
|
ui->actionRealTimeWidget->setEnabled(true);
|
2025-03-18 03:43:14 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-03-13 09:27:31 +00:00
|
|
|
ui->actionNew->setEnabled(false);
|
|
|
|
|
ui->actionStart->setEnabled(false);
|
|
|
|
|
ui->actionStop->setEnabled(false);
|
|
|
|
|
ui->actionRealTimeWidget->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionStop_triggered()
|
|
|
|
|
{
|
|
|
|
|
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Stop);
|
|
|
|
|
SerialPort::instance()->slotSendData(ba);
|
2025-03-18 09:28:40 +00:00
|
|
|
|
2025-03-21 09:28:36 +00:00
|
|
|
FileManager::close();
|
2025-03-24 09:30:42 +00:00
|
|
|
|
|
|
|
|
Global::instance()->setMode(Global::Mode::Analysis);
|
2025-03-13 09:27:31 +00:00
|
|
|
}
|
2025-03-12 09:29:52 +00:00
|
|
|
|
2025-03-13 09:27:31 +00:00
|
|
|
void MainWindow::on_actionNew_triggered()
|
2025-03-12 09:29:52 +00:00
|
|
|
{
|
2025-03-13 09:27:31 +00:00
|
|
|
_expertmentSettingForm->show();
|
|
|
|
|
}
|
2025-03-12 09:29:52 +00:00
|
|
|
|
2025-03-13 09:27:31 +00:00
|
|
|
void MainWindow::on_actionStart_triggered()
|
|
|
|
|
{
|
|
|
|
|
QByteArray ba = DataParser::setDeviceStartStop(DeviceStartMode::Start);
|
2025-03-14 08:58:08 +00:00
|
|
|
|
|
|
|
|
QString hexData = ba.toHex(' '); // ' ' 作为分隔符,可选参数
|
|
|
|
|
qDebug() << "on_actionStart_triggered info (hex):" << hexData;
|
|
|
|
|
|
2025-03-13 09:27:31 +00:00
|
|
|
SerialPort::instance()->slotSendData(ba);
|
2025-03-17 13:16:16 +00:00
|
|
|
//
|
|
|
|
|
FileManager::createExperimentFile();
|
2025-03-24 09:30:42 +00:00
|
|
|
|
|
|
|
|
Global::instance()->setMode(Global::Mode::ExperimentStart);
|
2025-03-13 09:27:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionReadOnly_triggered()
|
|
|
|
|
{
|
|
|
|
|
Global::instance()->setMode(Global::Mode::ExperimentStart);
|
|
|
|
|
SerialPort::instance()->openSp();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionRealTimeWidget_triggered()
|
|
|
|
|
{
|
|
|
|
|
_realTimeDataForm->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionConnectToDev_triggered()
|
|
|
|
|
{
|
2025-03-18 03:43:14 +00:00
|
|
|
if (SerialPort::instance()->openSp())
|
|
|
|
|
{
|
2025-03-18 09:28:40 +00:00
|
|
|
setActionEnable(true);
|
2025-03-13 09:27:31 +00:00
|
|
|
Global::instance()->setMode(Global::Mode::ConnectedToDev);
|
2025-03-19 03:19:52 +00:00
|
|
|
|
2025-03-18 09:28:40 +00:00
|
|
|
QByteArray ba = DataParser::inquirePhaseInfo();
|
|
|
|
|
SerialPort::instance()->sendData(ba);
|
2025-03-18 03:43:14 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-03-13 09:27:31 +00:00
|
|
|
QMessageBox::warning(this, "warnning", "Serial Port open failed.");
|
|
|
|
|
}
|
2025-03-12 09:29:52 +00:00
|
|
|
}
|
2025-03-20 09:28:22 +00:00
|
|
|
|
|
|
|
|
void MainWindow::on_actionStartPoint_triggered()
|
|
|
|
|
{
|
2025-03-25 08:45:16 +00:00
|
|
|
_rightWidget->show();
|
|
|
|
|
_centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::StartPoint);
|
2025-03-20 09:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionStopPoint_triggered()
|
|
|
|
|
{
|
2025-03-25 08:45:16 +00:00
|
|
|
_rightWidget->show();
|
|
|
|
|
_centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::StopPoint);
|
2025-03-20 09:28:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_actionNumericalLabel_triggered()
|
|
|
|
|
{
|
2025-03-21 09:28:36 +00:00
|
|
|
_rightWidget->show();
|
|
|
|
|
_centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::NumericalLabel);
|
2025-03-20 09:28:22 +00:00
|
|
|
}
|
2025-03-24 09:30:42 +00:00
|
|
|
|
|
|
|
|
void MainWindow::on_actionPeakSynthesisAnalysis_triggered()
|
|
|
|
|
{
|
|
|
|
|
//峰综合分析
|
|
|
|
|
_rightWidget->show();
|
|
|
|
|
_centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::PeakSynthesisAnalysis);
|
|
|
|
|
}
|
2025-03-25 08:45:16 +00:00
|
|
|
|
|
|
|
|
void MainWindow::on_actionClearAllData_triggered()
|
|
|
|
|
{
|
|
|
|
|
_centralWidget->clearAllData();
|
|
|
|
|
}
|