2025-03-21T17:28:35
This commit is contained in:
parent
0cc7c09f15
commit
b9d1470a6d
@ -18,6 +18,8 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
data/filemanager.cpp \
|
data/filemanager.cpp \
|
||||||
global.cpp \
|
global.cpp \
|
||||||
|
rightwidget.cpp \
|
||||||
|
ui/analysissettingform.cpp \
|
||||||
ui/centralwidget.cpp \
|
ui/centralwidget.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
@ -33,6 +35,8 @@ HEADERS += \
|
|||||||
data/filemanager.h \
|
data/filemanager.h \
|
||||||
defines.h \
|
defines.h \
|
||||||
global.h \
|
global.h \
|
||||||
|
rightwidget.h \
|
||||||
|
ui/analysissettingform.h \
|
||||||
ui/centralwidget.h \
|
ui/centralwidget.h \
|
||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
serialport/dataparser.h \
|
serialport/dataparser.h \
|
||||||
|
|||||||
@ -60,7 +60,7 @@ void test()
|
|||||||
writeExperimentFile(cd);
|
writeExperimentFile(cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fileClose()
|
void close()
|
||||||
{
|
{
|
||||||
if(_expeFile.isOpen()){
|
if(_expeFile.isOpen()){
|
||||||
_expeFile.close();
|
_expeFile.close();
|
||||||
|
|||||||
@ -29,7 +29,7 @@ extern QFile _expeFile;
|
|||||||
|
|
||||||
void createExperimentFile();
|
void createExperimentFile();
|
||||||
void writeExperimentFile(const CommonData&);
|
void writeExperimentFile(const CommonData&);
|
||||||
void fileClose();
|
void close();
|
||||||
|
|
||||||
void readExperimentFile(const QString fileName,QVector<ExperimentData>&);
|
void readExperimentFile(const QString fileName,QVector<ExperimentData>&);
|
||||||
|
|
||||||
|
|||||||
@ -8,16 +8,25 @@
|
|||||||
#include "filemanager.h"
|
#include "filemanager.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent), ui(new Ui::MainWindow), _centralWidget(new CentralWidget), _leftWidget(new LeftWidget), _expertmentSettingForm(new ExperimentSettingForm), _realTimeDataForm(new RealTimeDataForm)
|
: 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))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
setActionEnable(false);
|
|
||||||
|
|
||||||
this->setToolTip(".....");
|
this->setToolTip(".....");
|
||||||
|
|
||||||
setCentralWidget(_centralWidget);
|
setCentralWidget(_centralWidget);
|
||||||
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
|
addDockWidget(Qt::LeftDockWidgetArea, _leftWidget);
|
||||||
|
addDockWidget(Qt::RightDockWidgetArea, _rightWidget);
|
||||||
|
|
||||||
|
_rightWidget->setWidget(_analysisSettingWidget);
|
||||||
|
_rightWidget->hide();
|
||||||
//
|
//
|
||||||
ui->statusbar->showMessage("showMessage show temp message!");
|
ui->statusbar->showMessage("showMessage show temp message!");
|
||||||
// permenent show
|
// permenent show
|
||||||
@ -27,12 +36,31 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
//
|
//
|
||||||
connections();
|
connections();
|
||||||
//
|
//
|
||||||
_realTimeDataForm->show();
|
_expertmentSettingForm->setWindowFlags(_expertmentSettingForm->windowFlags()| Qt::Dialog);
|
||||||
|
_realTimeDataForm->setWindowFlags(_realTimeDataForm->windowFlags()| Qt::Dialog);
|
||||||
|
|
||||||
|
// _realTimeDataForm->show();
|
||||||
|
setActionEnable(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
// 删除非QObject派生类的对象
|
||||||
|
// 假设 Ui::MainWindow 不是 QObject 派生类
|
||||||
delete ui;
|
delete ui;
|
||||||
|
|
||||||
|
// 清理 status bar,如果它不是通过 new 创建的,则不需要删除
|
||||||
|
if (_statusBar) {
|
||||||
|
delete _statusBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileManager::close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::slotContextMenuShow(const QPoint point)
|
||||||
|
{
|
||||||
|
_contextMenu->exec(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::connections()
|
void MainWindow::connections()
|
||||||
@ -61,6 +89,13 @@ void MainWindow::connections()
|
|||||||
//analysis
|
//analysis
|
||||||
connect(_leftWidget,&LeftWidget::sigSendAnalysisFileName,
|
connect(_leftWidget,&LeftWidget::sigSendAnalysisFileName,
|
||||||
_centralWidget,&CentralWidget::slotRecvAnalysisFileName);
|
_centralWidget,&CentralWidget::slotRecvAnalysisFileName);
|
||||||
|
connect(_centralWidget,&CentralWidget::sigSendLineXCoord,
|
||||||
|
_analysisSettingWidget,&AnalysisSettingForm::slotRecvLineXCoord);
|
||||||
|
|
||||||
|
connect(_analysisSettingWidget,&AnalysisSettingForm::sigApply,
|
||||||
|
_centralWidget,&CentralWidget::slotAnalysisSettingApply);
|
||||||
|
connect(_analysisSettingWidget,&AnalysisSettingForm::sigConfirm,
|
||||||
|
_centralWidget,&CentralWidget::slotAnalysisSettingConfirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setActionEnable(const bool flag)
|
void MainWindow::setActionEnable(const bool flag)
|
||||||
@ -87,7 +122,7 @@ void MainWindow::on_actionStop_triggered()
|
|||||||
SerialPort::instance()->slotSendData(ba);
|
SerialPort::instance()->slotSendData(ba);
|
||||||
// SerialPort::instance()->slotCloseSp();
|
// SerialPort::instance()->slotCloseSp();
|
||||||
|
|
||||||
FileManager::fileClose();
|
FileManager::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionNew_triggered()
|
void MainWindow::on_actionNew_triggered()
|
||||||
@ -146,5 +181,6 @@ void MainWindow::on_actionStopPoint_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionNumericalLabel_triggered()
|
void MainWindow::on_actionNumericalLabel_triggered()
|
||||||
{
|
{
|
||||||
|
_rightWidget->show();
|
||||||
|
_centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::NumericalLabel);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,15 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
#include <QDockWidget>
|
||||||
|
|
||||||
#include "centralwidget.h"
|
#include "centralwidget.h"
|
||||||
#include "leftwidget.h"
|
#include "leftwidget.h"
|
||||||
#include "experimentsettingform.h"
|
#include "experimentsettingform.h"
|
||||||
#include "realtimedataform.h"
|
#include "realtimedataform.h"
|
||||||
#include "dataparser.h"
|
#include "dataparser.h"
|
||||||
|
#include "rightwidget.h"
|
||||||
|
#include "analysissettingform.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@ -21,13 +24,21 @@ class MainWindow : public QMainWindow
|
|||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slotContextMenuShow(const QPoint);
|
||||||
private slots:
|
private slots:
|
||||||
|
//experiment
|
||||||
void on_actionConnectToDev_triggered();
|
void on_actionConnectToDev_triggered();
|
||||||
void on_actionNew_triggered();
|
void on_actionNew_triggered();
|
||||||
void on_actionStart_triggered();
|
void on_actionStart_triggered();
|
||||||
void on_actionStop_triggered();
|
void on_actionStop_triggered();
|
||||||
void on_actionReadOnly_triggered();
|
void on_actionReadOnly_triggered();
|
||||||
void on_actionRealTimeWidget_triggered();
|
void on_actionRealTimeWidget_triggered();
|
||||||
|
//analysis
|
||||||
|
void on_actionNumericalLabel_triggered();
|
||||||
|
void on_actionStartPoint_triggered();
|
||||||
|
void on_actionStopPoint_triggered();
|
||||||
private:
|
private:
|
||||||
void connections();
|
void connections();
|
||||||
void setActionEnable(const bool);
|
void setActionEnable(const bool);
|
||||||
@ -35,8 +46,11 @@ private:
|
|||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
CentralWidget *_centralWidget;
|
CentralWidget *_centralWidget;
|
||||||
LeftWidget*_leftWidget;
|
LeftWidget*_leftWidget;
|
||||||
|
QDockWidget* _rightWidget;
|
||||||
ExperimentSettingForm *_expertmentSettingForm;
|
ExperimentSettingForm *_expertmentSettingForm;
|
||||||
RealTimeDataForm* _realTimeDataForm;
|
RealTimeDataForm* _realTimeDataForm;
|
||||||
QStatusBar *_statusBar;
|
QStatusBar *_statusBar;
|
||||||
|
QMenu* _contextMenu;
|
||||||
|
AnalysisSettingForm* _analysisSettingWidget;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|||||||
@ -44,6 +44,9 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>分析</string>
|
<string>分析</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionNumericalLabel"/>
|
||||||
|
<addaction name="actionStartPoint"/>
|
||||||
|
<addaction name="actionStopPoint"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_5">
|
<widget class="QMenu" name="menu_5">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -148,6 +151,21 @@
|
|||||||
<string>连接设备</string>
|
<string>连接设备</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionStartPoint">
|
||||||
|
<property name="text">
|
||||||
|
<string>起始点</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionStopPoint">
|
||||||
|
<property name="text">
|
||||||
|
<string>终止点</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionNumericalLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>数值标记</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="images.qrc"/>
|
<include location="images.qrc"/>
|
||||||
|
|||||||
7
src/rightwidget.cpp
Normal file
7
src/rightwidget.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "rightwidget.h"
|
||||||
|
|
||||||
|
RightWidget::RightWidget(QWidget *parent) : QDockWidget(parent)
|
||||||
|
,_analysisSettingForm(new AnalysisSettingForm(this))
|
||||||
|
{
|
||||||
|
setWidget(_analysisSettingForm);
|
||||||
|
}
|
||||||
20
src/rightwidget.h
Normal file
20
src/rightwidget.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef RIGHTWIDGET_H
|
||||||
|
#define RIGHTWIDGET_H
|
||||||
|
|
||||||
|
#include <QDockWidget>
|
||||||
|
|
||||||
|
#include "analysissettingform.h"
|
||||||
|
|
||||||
|
class RightWidget : public QDockWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit RightWidget(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private:
|
||||||
|
AnalysisSettingForm *_analysisSettingForm;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RIGHTWIDGET_H
|
||||||
93
src/ui/analysissettingform.cpp
Normal file
93
src/ui/analysissettingform.cpp
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#include <QFormLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
#include "analysissettingform.h"
|
||||||
|
|
||||||
|
AnalysisSettingForm::AnalysisSettingForm(QWidget *parent) :
|
||||||
|
QWidget(parent)
|
||||||
|
,_leftBorderSpinBox(new QDoubleSpinBox(this))
|
||||||
|
,_rightBorderSpinBox(new QDoubleSpinBox(this))
|
||||||
|
,_thresholdLineEdit(new QLineEdit(this))
|
||||||
|
,_applyButton(new QPushButton("应用",this))
|
||||||
|
,_undoButton(new QPushButton("撤销",this))
|
||||||
|
,_confirmButton(new QPushButton("确定",this))
|
||||||
|
,_cancelButton(new QPushButton("取消",this))
|
||||||
|
{
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
// 设置间距和边距
|
||||||
|
// layout->setSpacing(0); // 设置子布局之间的间距
|
||||||
|
// layout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距
|
||||||
|
|
||||||
|
QFormLayout *editLayout = new QFormLayout();
|
||||||
|
editLayout->addRow("左边界:",_leftBorderSpinBox);
|
||||||
|
editLayout->addRow("有边界:",_rightBorderSpinBox);
|
||||||
|
editLayout->addRow("阈值:",_thresholdLineEdit);
|
||||||
|
|
||||||
|
QGridLayout *buttonLayout = new QGridLayout();
|
||||||
|
|
||||||
|
buttonLayout->addWidget(_applyButton, 0, 0); // 第一行第一列
|
||||||
|
buttonLayout->addWidget(_undoButton, 0, 1); // 第一行第二列
|
||||||
|
buttonLayout->addWidget(_confirmButton, 1, 0); // 第二行第一列
|
||||||
|
buttonLayout->addWidget(_cancelButton, 1, 1); // 第二行第二列
|
||||||
|
// buttonLayout->setSpacing(0);
|
||||||
|
|
||||||
|
// 创建一个空白行
|
||||||
|
QSpacerItem *spacer =
|
||||||
|
new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
// 将 editLayout 和 buttonLayout 添加到主布局,并在它们之间添加空白行
|
||||||
|
layout->addLayout(editLayout);
|
||||||
|
layout->addSpacerItem(spacer);
|
||||||
|
layout->addLayout(buttonLayout);
|
||||||
|
layout->addLayout(editLayout);
|
||||||
|
// layout->setSpacing(1);
|
||||||
|
layout->addLayout(buttonLayout);
|
||||||
|
layout->addStretch(1);
|
||||||
|
//
|
||||||
|
connect(_applyButton,&QPushButton::click,
|
||||||
|
this,&AnalysisSettingForm::slotApply);
|
||||||
|
connect(_confirmButton,&QPushButton::click,
|
||||||
|
this,&AnalysisSettingForm::slotConfirm);
|
||||||
|
connect(_undoButton,&QPushButton::click,
|
||||||
|
this,&AnalysisSettingForm::slotUndo);
|
||||||
|
connect(_cancelButton,&QPushButton::click,
|
||||||
|
this,&AnalysisSettingForm::slotCancel);
|
||||||
|
//
|
||||||
|
_leftBorderSpinBox->setRange(0.0, 10000.0); // 设置范围
|
||||||
|
_rightBorderSpinBox->setRange(0.0, 10000.0); // 设置范围
|
||||||
|
}
|
||||||
|
|
||||||
|
AnalysisSettingForm::~AnalysisSettingForm()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalysisSettingForm::slotRecvLineXCoord(const int index, const double point)
|
||||||
|
{
|
||||||
|
if(1 == index){
|
||||||
|
_leftBorderSpinBox->setValue(point);
|
||||||
|
}else{
|
||||||
|
_rightBorderSpinBox->setValue(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalysisSettingForm::slotApply()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalysisSettingForm::slotConfirm()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalysisSettingForm::slotUndo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnalysisSettingForm::slotCancel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
35
src/ui/analysissettingform.h
Normal file
35
src/ui/analysissettingform.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef ANALYSISSETTINGFORM_H
|
||||||
|
#define ANALYSISSETTINGFORM_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
class AnalysisSettingForm : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit AnalysisSettingForm(QWidget *parent = nullptr);
|
||||||
|
~AnalysisSettingForm();
|
||||||
|
signals:
|
||||||
|
void sigApply();
|
||||||
|
void sigConfirm();
|
||||||
|
public slots:
|
||||||
|
void slotRecvLineXCoord(const int,const double);
|
||||||
|
private slots:
|
||||||
|
void slotApply();
|
||||||
|
void slotConfirm();
|
||||||
|
void slotUndo();
|
||||||
|
void slotCancel();
|
||||||
|
private:
|
||||||
|
QDoubleSpinBox *_leftBorderSpinBox,*_rightBorderSpinBox;
|
||||||
|
QLineEdit *_thresholdLineEdit;
|
||||||
|
QPushButton *_applyButton,
|
||||||
|
*_confirmButton,
|
||||||
|
*_undoButton,
|
||||||
|
*_cancelButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ANALYSISSETTINGFORM_H
|
||||||
@ -7,11 +7,15 @@
|
|||||||
CentralWidget::CentralWidget(QWidget *parent)
|
CentralWidget::CentralWidget(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
_customPlot(new QCustomPlot)
|
_customPlot(new QCustomPlot)
|
||||||
|
,_nanlysisMode(AnalysisMode::None)
|
||||||
{
|
{
|
||||||
|
setMouseTracking(true);
|
||||||
|
|
||||||
setStyleSheet("background-color: lightgray;");
|
setStyleSheet("background-color: lightgray;");
|
||||||
resize(888, 666);
|
resize(888, 666);
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout();
|
QHBoxLayout *layout = new QHBoxLayout();
|
||||||
|
layout->setMargin(0);
|
||||||
layout->addWidget(_customPlot);
|
layout->addWidget(_customPlot);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
|
||||||
@ -29,9 +33,15 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
_line2->setSelectable(true);
|
_line2->setSelectable(true);
|
||||||
|
|
||||||
// 安装事件过滤器
|
// 安装事件过滤器
|
||||||
|
_graph = _customPlot->addGraph(0);
|
||||||
_eventHandler = new DragLineHandler(_customPlot, _line1, _line2, _graph, nullptr);
|
_eventHandler = new DragLineHandler(_customPlot, _line1, _line2, _graph, nullptr);
|
||||||
_customPlot->installEventFilter(_eventHandler);
|
_customPlot->installEventFilter(_eventHandler);
|
||||||
|
|
||||||
|
connect(_eventHandler,&DragLineHandler::sigSendLineXCoord,
|
||||||
|
this,&CentralWidget::sigSendLineXCoord);
|
||||||
|
|
||||||
|
setEventHandlerEnable(false);
|
||||||
|
//
|
||||||
#if 0
|
#if 0
|
||||||
// init data
|
// init data
|
||||||
QVector<double> x(101), y(101);
|
QVector<double> x(101), y(101);
|
||||||
@ -54,12 +64,28 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
|
|
||||||
CentralWidget::~CentralWidget()
|
CentralWidget::~CentralWidget()
|
||||||
{
|
{
|
||||||
FileManager::fileClose();
|
FileManager::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::setAnalysisMode(const CentralWidget::AnalysisMode)
|
void CentralWidget::setAnalysisMode(const CentralWidget::AnalysisMode mode)
|
||||||
{
|
{
|
||||||
|
if(_nanlysisMode == mode){
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
_nanlysisMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case AnalysisMode::NumericalLabel:
|
||||||
|
setEventHandlerEnable(true);
|
||||||
|
break;
|
||||||
|
case AnalysisMode::None:
|
||||||
|
setEventHandlerEnable(false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::slotModeModify(const Global::Mode mode)
|
void CentralWidget::slotModeModify(const Global::Mode mode)
|
||||||
@ -79,13 +105,14 @@ void CentralWidget::slotModeModify(const Global::Mode mode)
|
|||||||
else if (Global::Mode::Analysis == mode)
|
else if (Global::Mode::Analysis == mode)
|
||||||
{
|
{
|
||||||
qDebug() << "file close...";
|
qDebug() << "file close...";
|
||||||
FileManager::fileClose();
|
FileManager::close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
void CentralWidget::slotRecvCommonData(const CommonData &cd)
|
||||||
{
|
{
|
||||||
qDebug() << "slotRevCommonData";
|
qDebug() << "slotRevCommonData";
|
||||||
|
|
||||||
_customPlot->graph(0)->addData(cd.sample_temp, cd.dsc); // 添加数据到曲线
|
_customPlot->graph(0)->addData(cd.sample_temp, cd.dsc); // 添加数据到曲线
|
||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
//
|
//
|
||||||
@ -99,14 +126,18 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
QVector<FileManager::ExperimentData> dataVtr;
|
QVector<FileManager::ExperimentData> dataVtr;
|
||||||
FileManager::readExperimentFile(fileName, dataVtr);
|
FileManager::readExperimentFile(fileName, dataVtr);
|
||||||
|
|
||||||
if(dataVtr.size() < 0){
|
if (dataVtr.size() < 0)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
//判断界面上是不是有曲线,有的话先删除。
|
//判断界面上是不是有曲线,有的话先删除。
|
||||||
_customPlot->clearGraphs();
|
_customPlot->clearGraphs();
|
||||||
|
|
||||||
// 创建画布,设置画布上的点数据
|
// 创建画布,设置画布上的点数据
|
||||||
_customPlot->addGraph();
|
_customPlot->addGraph();
|
||||||
|
#endif
|
||||||
|
|
||||||
// 设置坐标轴标签
|
// 设置坐标轴标签
|
||||||
_customPlot->yAxis->setLabel("DSC/mW");
|
_customPlot->yAxis->setLabel("DSC/mW");
|
||||||
@ -116,15 +147,33 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
_customPlot->yAxis->setRange(-20, 20);
|
_customPlot->yAxis->setRange(-20, 20);
|
||||||
|
|
||||||
QVector<double> xVtr, yVtr;
|
QVector<double> xVtr, yVtr;
|
||||||
for(FileManager::ExperimentData &ed:dataVtr){
|
for (FileManager::ExperimentData &ed : dataVtr)
|
||||||
|
{
|
||||||
xVtr.push_back(ed.sampleTemp);
|
xVtr.push_back(ed.sampleTemp);
|
||||||
yVtr.push_back(ed.dsc);
|
yVtr.push_back(ed.dsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
_customPlot->graph(0)->addData(xVtr,yVtr);
|
// 清除第一个图表上的数据
|
||||||
|
if (_customPlot->graphCount() > 0 && _graph)
|
||||||
|
{
|
||||||
|
// 清除第一个图表上的数据
|
||||||
|
_graph->setData(QVector<double>(), QVector<double>());
|
||||||
|
}
|
||||||
|
|
||||||
|
_graph->addData(xVtr, yVtr);
|
||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CentralWidget::slotAnalysisSettingApply()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CentralWidget::slotAnalysisSettingConfirm()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CentralWidget::timerEvent(QTimerEvent *event)
|
void CentralWidget::timerEvent(QTimerEvent *event)
|
||||||
{
|
{
|
||||||
// key的单位是秒
|
// key的单位是秒
|
||||||
@ -151,22 +200,19 @@ void CentralWidget::timerEvent(QTimerEvent *event)
|
|||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::analysisMode(const bool flag)
|
void CentralWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
qDebug()<<"left menu...";
|
||||||
|
QPoint point = event->globalPos();
|
||||||
|
emit sigContextMenuShow(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CentralWidget::setEventHandlerEnable(const bool flag)
|
||||||
{
|
{
|
||||||
_line1->setVisible(flag);
|
|
||||||
_line2->setVisible(flag);
|
|
||||||
_eventHandler->setEnable(flag);
|
_eventHandler->setEnable(flag);
|
||||||
|
_line1->setVisible(flag);
|
||||||
#if 0
|
if(AnalysisMode::NumericalLabel != _nanlysisMode){
|
||||||
if(flag){
|
_line2->setVisible(flag);
|
||||||
_line1->setVisible(true);
|
|
||||||
_line2->setVisible(true);
|
|
||||||
_eventHandler->setEnable(true);
|
|
||||||
}else{
|
|
||||||
_line1->setVisible(true);
|
|
||||||
_line2->setVisible(true);
|
|
||||||
_eventHandler->setEnable(true);
|
|
||||||
}
|
}
|
||||||
#endif
|
_customPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define CENTRALWIDGET_H
|
#define CENTRALWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include "qcustomplot.h"
|
#include "qcustomplot.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
@ -22,16 +23,24 @@ public:
|
|||||||
~CentralWidget();
|
~CentralWidget();
|
||||||
|
|
||||||
void setAnalysisMode(const AnalysisMode);
|
void setAnalysisMode(const AnalysisMode);
|
||||||
|
signals:
|
||||||
|
void sigContextMenuShow(const QPoint);
|
||||||
|
void sigSendLineXCoord(const int,const double);
|
||||||
public slots:
|
public slots:
|
||||||
void slotModeModify(const Global::Mode);
|
void slotModeModify(const Global::Mode);
|
||||||
void slotRecvCommonData(const CommonData&);
|
void slotRecvCommonData(const CommonData&);
|
||||||
void slotRecvAnalysisFileName(const QString&);
|
void slotRecvAnalysisFileName(const QString&);
|
||||||
|
//analysis setting
|
||||||
|
void slotAnalysisSettingApply();
|
||||||
|
void slotAnalysisSettingConfirm();
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent* event);
|
void timerEvent(QTimerEvent* event);
|
||||||
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
private:
|
private:
|
||||||
void analysisMode(const bool);
|
void setEventHandlerEnable(const bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
AnalysisMode _nanlysisMode;
|
||||||
QCustomPlot *_customPlot;
|
QCustomPlot *_customPlot;
|
||||||
QCPGraph* _graph;
|
QCPGraph* _graph;
|
||||||
DragLineHandler* _eventHandler;
|
DragLineHandler* _eventHandler;
|
||||||
|
|||||||
@ -12,12 +12,16 @@ DragLineHandler::DragLineHandler(QCustomPlot *plot, QCPItemStraightLine *line1,
|
|||||||
bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
if(!_enableFlag){
|
if(!_enableFlag){
|
||||||
|
qDebug()<<"_enableFlag false.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj == mPlot)
|
if (obj == mPlot)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::MouseMove)
|
if (event->type() == QEvent::MouseMove)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"mouse move...";
|
||||||
|
|
||||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||||
QPoint mousePos = mouseEvent->pos();
|
QPoint mousePos = mouseEvent->pos();
|
||||||
qDebug()<<"x:"<<mousePos.x();
|
qDebug()<<"x:"<<mousePos.x();
|
||||||
@ -41,6 +45,11 @@ bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
|||||||
if (mDraggingLine)
|
if (mDraggingLine)
|
||||||
{
|
{
|
||||||
double x = mPlot->xAxis->pixelToCoord(mousePos.x());
|
double x = mPlot->xAxis->pixelToCoord(mousePos.x());
|
||||||
|
if(mDraggingLine == mLine1){
|
||||||
|
emit sigSendLineXCoord(1,x);
|
||||||
|
}else{
|
||||||
|
emit sigSendLineXCoord(2,x);
|
||||||
|
}
|
||||||
mDraggingLine->point1->setCoords(x, mPlot->yAxis->range().lower);
|
mDraggingLine->point1->setCoords(x, mPlot->yAxis->range().lower);
|
||||||
mDraggingLine->point2->setCoords(x, mPlot->yAxis->range().upper);
|
mDraggingLine->point2->setCoords(x, mPlot->yAxis->range().upper);
|
||||||
mPlot->replot();
|
mPlot->replot();
|
||||||
@ -49,6 +58,8 @@ bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
|||||||
}
|
}
|
||||||
else if (event->type() == QEvent::MouseButtonPress)
|
else if (event->type() == QEvent::MouseButtonPress)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"mouse press...";
|
||||||
|
|
||||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||||
if (mouseEvent->button() == Qt::LeftButton)
|
if (mouseEvent->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -18,6 +18,8 @@ public:
|
|||||||
QCPGraph*graph,QObject *parent);
|
QCPGraph*graph,QObject *parent);
|
||||||
|
|
||||||
void setEnable(const bool flag){_enableFlag = flag;}
|
void setEnable(const bool flag){_enableFlag = flag;}
|
||||||
|
signals:
|
||||||
|
void sigSendLineXCoord(const int,const double);
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "filemanager.h"
|
#include "filemanager.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
LeftWidget::LeftWidget()
|
LeftWidget::LeftWidget(QWidget *parent ): QDockWidget(parent)
|
||||||
{
|
{
|
||||||
// setStyleSheet("background-color: yellow;");
|
// setStyleSheet("background-color: yellow;");
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class LeftWidget:public QDockWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LeftWidget();
|
LeftWidget(QWidget *parent = nullptr);
|
||||||
private:
|
private:
|
||||||
void initData();
|
void initData();
|
||||||
void initFileName(QTreeWidgetItem*,const QString &folderPath);
|
void initFileName(QTreeWidgetItem*,const QString &folderPath);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user