2025-04-09T17:30:31
This commit is contained in:
parent
6cf14dfce7
commit
ba28c29ec8
1256
experiment_data/analysis_state/1-基线new 2.txt
Normal file
1256
experiment_data/analysis_state/1-基线new 2.txt
Normal file
File diff suppressed because it is too large
Load Diff
1264
experiment_data/analysis_state/1-标样new 2.txt
Normal file
1264
experiment_data/analysis_state/1-标样new 2.txt
Normal file
File diff suppressed because it is too large
Load Diff
1264
experiment_data/analysis_state/1-样品new 2.txt
Normal file
1264
experiment_data/analysis_state/1-样品new 2.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -370,7 +370,8 @@ QPointF PointCalculate::getIntersectionBySlope(const LineStruct& line1, const Li
|
|||||||
}
|
}
|
||||||
QPointF PointCalculate::getClosestPointByX(const float targetX)
|
QPointF PointCalculate::getClosestPointByX(const float targetX)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 1
|
||||||
|
QPointF resultPointF;
|
||||||
float minDiff = std::numeric_limits<float>::max();
|
float minDiff = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
for(FileManager::ExperimentData &ed:_dataVtr){
|
for(FileManager::ExperimentData &ed:_dataVtr){
|
||||||
@ -380,8 +381,11 @@ QPointF PointCalculate::getClosestPointByX(const float targetX)
|
|||||||
resultPointF = QPointF(ed.sampleTemp,ed.dsc);
|
resultPointF = QPointF(ed.sampleTemp,ed.dsc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return resultPointF;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
int left = 0;
|
int left = 0;
|
||||||
int right = _dataVtr.size() - 1;
|
int right = _dataVtr.size() - 1;
|
||||||
|
|
||||||
@ -408,6 +412,7 @@ QPointF PointCalculate::getClosestPointByX(const float targetX)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return resultPointF;
|
return resultPointF;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PointCalculate::textFormatNumbericalLabel(const QPointF point)
|
QString PointCalculate::textFormatNumbericalLabel(const QPointF point)
|
||||||
@ -469,7 +474,7 @@ QString PointCalculate::textFormatGlassTranstion(const float t1,const float tg,c
|
|||||||
{
|
{
|
||||||
return QString("T1:%1℃\n"
|
return QString("T1:%1℃\n"
|
||||||
"Tg:%2℃\n"
|
"Tg:%2℃\n"
|
||||||
"T2:%3℃\n"
|
"T2:%3℃"
|
||||||
).arg(QString::number(t1, 'f', 3))
|
).arg(QString::number(t1, 'f', 3))
|
||||||
.arg(QString::number(tg, 'f', 3))
|
.arg(QString::number(tg, 'f', 3))
|
||||||
.arg(QString::number(t2, 'f', 3));
|
.arg(QString::number(t2, 'f', 3));
|
||||||
|
|||||||
@ -196,13 +196,13 @@ void MainWindow::on_actionNumericalLabel_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionPeakSynthesisAnalysis_triggered()
|
void MainWindow::on_actionPeakSynthesisAnalysis_triggered()
|
||||||
{
|
{
|
||||||
//峰综合分析
|
|
||||||
_rightWidget->show();
|
_rightWidget->show();
|
||||||
_centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::PeakSynthesisAnalysis);
|
_centralWidget->setAnalysisMode(CentralWidget::AnalysisMode::PeakSynthesisAnalysis);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionClearAllData_triggered()
|
void MainWindow::on_actionClearAllData_triggered()
|
||||||
{
|
{
|
||||||
|
_rightWidget->hide();
|
||||||
_centralWidget->clearAllData();
|
_centralWidget->clearAllData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,9 +38,15 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
_line2->setSelectable(true);
|
_line2->setSelectable(true);
|
||||||
|
|
||||||
// 安装事件过滤器
|
// 安装事件过滤器
|
||||||
_graph = _customPlot->addGraph(0);
|
// _graph = _customPlot->addGraph(0);
|
||||||
_eventHandler = new DragLineHandler(_customPlot, _line1, _line2, _graph, nullptr);
|
// _eventHandler = new DragLineHandler(_customPlot, _line1, _line2, _graph, nullptr);
|
||||||
|
|
||||||
|
_eventHandler = new DragLineHandler(_customPlot, _line1, _line2, nullptr);
|
||||||
|
_eventHandler->setEnable(true);
|
||||||
|
|
||||||
|
|
||||||
_customPlot->installEventFilter(_eventHandler);
|
_customPlot->installEventFilter(_eventHandler);
|
||||||
|
_customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
|
||||||
|
|
||||||
connect(_eventHandler,&DragLineHandler::sigSendLineXCoord,
|
connect(_eventHandler,&DragLineHandler::sigSendLineXCoord,
|
||||||
this,&CentralWidget::sigSendLineXCoord);
|
this,&CentralWidget::sigSendLineXCoord);
|
||||||
@ -94,11 +100,13 @@ void CentralWidget::slotModeModify(const Global::Mode mode)
|
|||||||
{
|
{
|
||||||
if (Global::Mode::ExperimentStart == mode)
|
if (Global::Mode::ExperimentStart == mode)
|
||||||
{
|
{
|
||||||
if (_customPlot->graphCount() > 0 && _graph)
|
#if 0
|
||||||
|
if (_customPlot->graphCount() > 0 && _currentGraph)
|
||||||
{
|
{
|
||||||
// 清除第一个图表上的数据
|
// 清除第一个图表上的数据
|
||||||
_graph->setData(QVector<double>(), QVector<double>());
|
_currentGraph->setData(QVector<double>(), QVector<double>());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// 创建画布,设置画布上的点数据
|
// 创建画布,设置画布上的点数据
|
||||||
// _graph = _customPlot->addGraph();
|
// _graph = _customPlot->addGraph();
|
||||||
@ -133,7 +141,7 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
qDebug() << "slotRecvAnalysisFileName" << fileName;
|
qDebug() << "slotRecvAnalysisFileName" << fileName;
|
||||||
|
|
||||||
//
|
//
|
||||||
clearData(ClearDataMode::All);
|
// clearData(ClearDataMode::All);
|
||||||
//
|
//
|
||||||
_dataVtr.clear();
|
_dataVtr.clear();
|
||||||
FileManager::readExperimentFile(fileName, _dataVtr);
|
FileManager::readExperimentFile(fileName, _dataVtr);
|
||||||
@ -159,22 +167,36 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
_customPlot->yAxis->setLabel("DSC/mW");
|
_customPlot->yAxis->setLabel("DSC/mW");
|
||||||
_customPlot->xAxis->setLabel("Temp/℃");
|
_customPlot->xAxis->setLabel("Temp/℃");
|
||||||
|
|
||||||
|
QVector<double> tVtr,xVtr, yVtr;
|
||||||
QVector<double> xVtr, yVtr;
|
int index = 0;
|
||||||
for (FileManager::ExperimentData &ed : _dataVtr)
|
for (FileManager::ExperimentData &ed : _dataVtr)
|
||||||
{
|
{
|
||||||
|
tVtr.push_back(index++);
|
||||||
xVtr.push_back(ed.sampleTemp);
|
xVtr.push_back(ed.sampleTemp);
|
||||||
yVtr.push_back(ed.dsc);
|
yVtr.push_back(ed.dsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||||
|
_currentCurve->setData(tVtr, xVtr, yVtr);
|
||||||
|
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
||||||
|
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
||||||
|
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||||
|
|
||||||
// 清除第一个图表上的数据
|
// 清除第一个图表上的数据
|
||||||
|
#if 0
|
||||||
if (_customPlot->graphCount() > 0 && _graph)
|
if (_customPlot->graphCount() > 0 && _graph)
|
||||||
{
|
{
|
||||||
// 清除第一个图表上的数据
|
// 清除第一个图表上的数据
|
||||||
_graph->setData(QVector<double>(), QVector<double>());
|
_graph->setData(QVector<double>(), QVector<double>());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
_graph->addData(xVtr, yVtr);
|
#if 0
|
||||||
|
_currentGraph = _customPlot->addGraph();
|
||||||
|
_graphVtr.push_back(_currentGraph);
|
||||||
|
|
||||||
|
_currentGraph->addData(xVtr, yVtr);
|
||||||
|
#endif
|
||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +343,7 @@ void CentralWidget::glassTransitionHandle()
|
|||||||
logde<<"point1:"<<point1.x()<<","<<point1.y();
|
logde<<"point1:"<<point1.x()<<","<<point1.y();
|
||||||
logde<<"point2:"<<point2.x()<<","<<point2.y();
|
logde<<"point2:"<<point2.x()<<","<<point2.y();
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
QCPItemStraightLine *line1 = new QCPItemStraightLine(_customPlot);
|
QCPItemStraightLine *line1 = new QCPItemStraightLine(_customPlot);
|
||||||
line1->point1->setCoords(point1.x() - 5,point1.y());
|
line1->point1->setCoords(point1.x() - 5,point1.y());
|
||||||
line1->point2->setCoords(point1.x() + 5,point1.y());
|
line1->point2->setCoords(point1.x() + 5,point1.y());
|
||||||
@ -371,9 +393,9 @@ void CentralWidget::glassTransitionHandle()
|
|||||||
<<",Tg:"<<averagePoint.x()
|
<<",Tg:"<<averagePoint.x()
|
||||||
<<",T2:"<<intersection2.x();
|
<<",T2:"<<intersection2.x();
|
||||||
|
|
||||||
QString str = PointCalculate::textFormatGlassTranstion(intersection1.x(),
|
QString str = PointCalculate::textFormatGlassTranstion(intersection2.x(),
|
||||||
averagePoint.x(),
|
averagePoint.x(),
|
||||||
intersection2.x());
|
intersection1.x());
|
||||||
drawText(averagePoint,str);
|
drawText(averagePoint,str);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -390,7 +412,7 @@ void CentralWidget::glassTransitionHandle()
|
|||||||
circle->setPen(QPen(Qt::blue));
|
circle->setPen(QPen(Qt::blue));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
QCPItemStraightLine *line3 = new QCPItemStraightLine(_customPlot);
|
QCPItemStraightLine *line3 = new QCPItemStraightLine(_customPlot);
|
||||||
line3->point1->setCoords(averagePoint.x() + 1,averagePoint.y() + 1);
|
line3->point1->setCoords(averagePoint.x() + 1,averagePoint.y() + 1);
|
||||||
line3->point2->setCoords(averagePoint.x() - 1,averagePoint.y() - 1);
|
line3->point2->setCoords(averagePoint.x() - 1,averagePoint.y() - 1);
|
||||||
@ -413,7 +435,7 @@ void CentralWidget::setEventHandlerEnable(const bool flag)
|
|||||||
};
|
};
|
||||||
|
|
||||||
// todo. 当竖线隐藏时,需要设置不可选择模式。
|
// todo. 当竖线隐藏时,需要设置不可选择模式。
|
||||||
_eventHandler->setEnable(flag);
|
// _eventHandler->setEnable(flag);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
// move line to suitable position.
|
// move line to suitable position.
|
||||||
@ -480,8 +502,10 @@ void CentralWidget::fillGraph(const double x1, const double x2)
|
|||||||
// 样式配置
|
// 样式配置
|
||||||
mainGraph->setPen(QPen(Qt::red, 1));
|
mainGraph->setPen(QPen(Qt::red, 1));
|
||||||
|
|
||||||
_graph->setBrush(QBrush(Qt::lightGray));
|
#if 0
|
||||||
_graph->setChannelFillGraph(mainGraph);
|
_currentGraph->setBrush(QBrush(Qt::lightGray));
|
||||||
|
_currentGraph->setChannelFillGraph(mainGraph);
|
||||||
|
#endif
|
||||||
|
|
||||||
// customPlot->graph(0)->setChannelFillGraph(customPlot->graph(1));
|
// customPlot->graph(0)->setChannelFillGraph(customPlot->graph(1));
|
||||||
// _customPlot->graph(1);
|
// _customPlot->graph(1);
|
||||||
@ -492,26 +516,32 @@ void CentralWidget::clearData(const CentralWidget::ClearDataMode mode)
|
|||||||
{
|
{
|
||||||
if(mode == ClearDataMode::All){
|
if(mode == ClearDataMode::All){
|
||||||
// Clear the data of graph.
|
// Clear the data of graph.
|
||||||
if (_customPlot->graphCount() > 0 && _graph)
|
#if 0
|
||||||
|
if (_customPlot->graphCount() > 0 && _currentGraph)
|
||||||
{
|
{
|
||||||
_graph->setData(QVector<double>(), QVector<double>());
|
_currentGraph->setData(QVector<double>(), QVector<double>());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set lines visiable false.
|
// Set lines visiable false.
|
||||||
_line1->setVisible(false);
|
_line1->setVisible(false);
|
||||||
_line2->setVisible(false);
|
_line2->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Clear filled area.
|
// Clear filled area.
|
||||||
_graph->setBrush(QBrush(Qt::transparent));
|
if(_currentGraph){
|
||||||
|
_currentGraph->setBrush(QBrush(Qt::transparent));
|
||||||
|
}
|
||||||
|
|
||||||
// Clear graph on plot.
|
// Clear graph on plot.
|
||||||
for (int i = _customPlot->graphCount() - 1; i >= 0; --i) {
|
for (int i = _customPlot->graphCount() - 1; i >= 0; --i) {
|
||||||
QCPGraph *graph = _customPlot->graph(i);
|
QCPGraph *graph = _customPlot->graph(i);
|
||||||
if (graph != _graph) {
|
if (graph != _currentGraph) {
|
||||||
_customPlot->removeGraph(graph);
|
_customPlot->removeGraph(graph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// Delete items.
|
// Delete items.
|
||||||
QList<QCPAbstractItem *> itemsToKeep;
|
QList<QCPAbstractItem *> itemsToKeep;
|
||||||
itemsToKeep << _line1 << _line2;
|
itemsToKeep << _line1 << _line2;
|
||||||
|
|||||||
@ -59,7 +59,10 @@ private:
|
|||||||
private:
|
private:
|
||||||
AnalysisMode _analysisMode;
|
AnalysisMode _analysisMode;
|
||||||
QCustomPlot *_customPlot;
|
QCustomPlot *_customPlot;
|
||||||
QCPGraph* _graph;
|
QCPCurve *_currentCurve;
|
||||||
|
// QVector<QCPCurve *> _curveVtr;
|
||||||
|
// QCPGraph* _currentGraph;
|
||||||
|
// QVector<QCPGraph*> _graphVtr;
|
||||||
DragLineHandler* _eventHandler;
|
DragLineHandler* _eventHandler;
|
||||||
QCPItemStraightLine *_line1,*_line2;
|
QCPItemStraightLine *_line1,*_line2;
|
||||||
QVector<FileManager::ExperimentData> _dataVtr;
|
QVector<FileManager::ExperimentData> _dataVtr;
|
||||||
|
|||||||
@ -1,5 +1,19 @@
|
|||||||
#include "draglinehandler.h"
|
#include "draglinehandler.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
DragLineHandler::DragLineHandler(QCustomPlot *plot,
|
||||||
|
QCPItemStraightLine *line1,
|
||||||
|
QCPItemStraightLine *line2,
|
||||||
|
QObject *parent)
|
||||||
|
: QObject(parent), _plot(plot), _line1(line1), _line2(line2)
|
||||||
|
,_enableFlag(false),_mode(Mode::SelectTwoLines),_menu(new QMenu(_plot))
|
||||||
|
{
|
||||||
|
_plot->setInteractions(QCP::iSelectItems);
|
||||||
|
|
||||||
|
initMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
DragLineHandler::DragLineHandler(QCustomPlot *plot, QCPItemStraightLine *line1,
|
DragLineHandler::DragLineHandler(QCustomPlot *plot, QCPItemStraightLine *line1,
|
||||||
QCPItemStraightLine *line2, QCPGraph*graph,
|
QCPItemStraightLine *line2, QCPGraph*graph,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
@ -8,6 +22,7 @@ DragLineHandler::DragLineHandler(QCustomPlot *plot, QCPItemStraightLine *line1,
|
|||||||
{
|
{
|
||||||
_plot->setInteractions(QCP::iSelectItems);
|
_plot->setInteractions(QCP::iSelectItems);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DragLineHandler::~DragLineHandler()
|
DragLineHandler::~DragLineHandler()
|
||||||
{
|
{
|
||||||
@ -17,6 +32,7 @@ bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
|||||||
{
|
{
|
||||||
if(!_enableFlag){
|
if(!_enableFlag){
|
||||||
// qDebug()<<"_enableFlag false.";
|
// qDebug()<<"_enableFlag false.";
|
||||||
|
logde<<"eventFilter false.";
|
||||||
#if 0
|
#if 0
|
||||||
if(mPlot){
|
if(mPlot){
|
||||||
mPlot->setCursor(Qt::ArrowCursor);
|
mPlot->setCursor(Qt::ArrowCursor);
|
||||||
@ -66,6 +82,7 @@ bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
|||||||
{
|
{
|
||||||
// qDebug()<<"mouse press...";
|
// qDebug()<<"mouse press...";
|
||||||
|
|
||||||
|
if(Mode::SelectTwoLines == _mode){
|
||||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
|
||||||
if (mouseEvent->button() == Qt::LeftButton)
|
if (mouseEvent->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
@ -81,6 +98,22 @@ bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
|||||||
_line2->setSelected(true);
|
_line2->setSelected(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
#if 0
|
||||||
|
// 检查是否有选中的曲线
|
||||||
|
if (event->button() == Qt::LeftButton && selectedPlottables().size() > 0)
|
||||||
|
{
|
||||||
|
// 获取选中的曲线
|
||||||
|
QCPCurve *selectedCurve = qobject_cast<QCPCurve*>(selectedPlottables().first());
|
||||||
|
if (selectedCurve)
|
||||||
|
{
|
||||||
|
// 改变曲线的颜色
|
||||||
|
selectedCurve->setPen(QPen(Qt::green)); // 设置线条颜色为绿色
|
||||||
|
replot(); // 重新绘制
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (event->type() == QEvent::MouseButtonRelease)
|
else if (event->type() == QEvent::MouseButtonRelease)
|
||||||
{
|
{
|
||||||
@ -89,11 +122,50 @@ bool DragLineHandler::eventFilter(QObject *obj, QEvent *event)
|
|||||||
_draggingLine->setSelected(false);
|
_draggingLine->setSelected(false);
|
||||||
_draggingLine = nullptr;
|
_draggingLine = nullptr;
|
||||||
}
|
}
|
||||||
|
}else if (event->type() == QEvent::ContextMenu) {
|
||||||
|
logde<<"context menu...";
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (QCPAbstractPlottable *plottable : _plot->plottables()) {
|
||||||
|
if (plottable->selected()) {
|
||||||
|
std::cout << "选中的曲线: " << plottable->name().toStdString() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// for (QCPItem *item : _customPlot->selectedItems()) {
|
||||||
|
// if (item->selected()) {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(_plot->selectedItems().size() > 0){
|
||||||
|
QContextMenuEvent *contextMenuEvent = static_cast<QContextMenuEvent *>(event);
|
||||||
|
_menu->move(contextMenuEvent->globalPos());
|
||||||
|
_menu->show();
|
||||||
|
}else{
|
||||||
|
logde<<"not selected...";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DragLineHandler::initMenu()
|
||||||
|
{
|
||||||
|
_specificHeatItemAction = new QAction("比热项",_plot);
|
||||||
|
_baseLineAction = new QAction("基线",_plot);
|
||||||
|
_standardSampleAction = new QAction("标样",_plot);
|
||||||
|
_sampleAction = new QAction("样品",_plot);
|
||||||
|
|
||||||
|
_menu->addAction(_specificHeatItemAction);
|
||||||
|
|
||||||
|
QMenu *specificHeatItemMenu = new QMenu(_plot);
|
||||||
|
specificHeatItemMenu->addAction(_baseLineAction);
|
||||||
|
specificHeatItemMenu->addAction(_standardSampleAction);
|
||||||
|
specificHeatItemMenu->addAction(_sampleAction);
|
||||||
|
|
||||||
|
_specificHeatItemAction->setMenu(specificHeatItemMenu);
|
||||||
|
}
|
||||||
|
|
||||||
bool DragLineHandler::isNearLine(QCPItemStraightLine *line, const QPoint &pos)
|
bool DragLineHandler::isNearLine(QCPItemStraightLine *line, const QPoint &pos)
|
||||||
{
|
{
|
||||||
double lineX = line->point1->coords().x();
|
double lineX = line->point1->coords().x();
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include "qcustomplot.h"
|
#include "qcustomplot.h"
|
||||||
|
|
||||||
@ -14,26 +15,40 @@ class DragLineHandler : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
DragLineHandler(QCustomPlot *plot, QCPItemStraightLine *line1, QCPItemStraightLine *line2,
|
||||||
|
QObject *parent);
|
||||||
|
#if 0
|
||||||
DragLineHandler(QCustomPlot *plot, QCPItemStraightLine *line1, QCPItemStraightLine *line2,
|
DragLineHandler(QCustomPlot *plot, QCPItemStraightLine *line1, QCPItemStraightLine *line2,
|
||||||
QCPGraph*graph,QObject *parent);
|
QCPGraph*graph,QObject *parent);
|
||||||
|
#endif
|
||||||
~DragLineHandler();
|
~DragLineHandler();
|
||||||
|
|
||||||
|
void setGraph(QCPGraph* g){ _graph = g;}
|
||||||
void setEnable(const bool flag){_enableFlag = flag;}
|
void setEnable(const bool flag){_enableFlag = flag;}
|
||||||
|
enum Mode{
|
||||||
|
Null,
|
||||||
|
SelectCurve,
|
||||||
|
SelectTwoLines
|
||||||
|
};
|
||||||
|
void setMode(const Mode mode){ _mode = mode;}
|
||||||
signals:
|
signals:
|
||||||
void sigSendLineXCoord(const int,const double);
|
void sigSendLineXCoord(const int,const double);
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
private:
|
private:
|
||||||
|
void initMenu();
|
||||||
int findClosestIndex(const QVector<double> &data, double target);
|
int findClosestIndex(const QVector<double> &data, double target);
|
||||||
void updateSelectedRegion();
|
void updateSelectedRegion();
|
||||||
bool isNearLine(QCPItemStraightLine *line, const QPoint &pos);
|
bool isNearLine(QCPItemStraightLine *line, const QPoint &pos);
|
||||||
private:
|
private:
|
||||||
|
Mode _mode;
|
||||||
bool _enableFlag;
|
bool _enableFlag;
|
||||||
QCustomPlot *_plot;
|
QCustomPlot *_plot;
|
||||||
QCPItemStraightLine *_line1,*_line2;
|
QCPItemStraightLine *_line1,*_line2;
|
||||||
QCPItemStraightLine *_draggingLine = nullptr;
|
QCPItemStraightLine *_draggingLine = nullptr;
|
||||||
QCPGraph *_graph;
|
QCPGraph *_graph;
|
||||||
|
QMenu* _menu;
|
||||||
|
QAction* _specificHeatItemAction,*_baseLineAction,*_standardSampleAction,*_sampleAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user