2025-04-09T21:25:54
This commit is contained in:
parent
ba28c29ec8
commit
4387788970
@ -50,6 +50,10 @@ CentralWidget::CentralWidget(QWidget *parent)
|
|||||||
|
|
||||||
connect(_eventHandler,&DragLineHandler::sigSendLineXCoord,
|
connect(_eventHandler,&DragLineHandler::sigSendLineXCoord,
|
||||||
this,&CentralWidget::sigSendLineXCoord);
|
this,&CentralWidget::sigSendLineXCoord);
|
||||||
|
// 连接选中信号
|
||||||
|
connect(_customPlot, &QCustomPlot::selectionChangedByUser,
|
||||||
|
this, &CentralWidget::slotSelectionChanged);
|
||||||
|
|
||||||
|
|
||||||
setEventHandlerEnable(false);
|
setEventHandlerEnable(false);
|
||||||
//
|
//
|
||||||
@ -178,8 +182,8 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
|
|
||||||
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
_currentCurve = new QCPCurve(_customPlot->xAxis, _customPlot->yAxis);
|
||||||
_currentCurve->setData(tVtr, xVtr, yVtr);
|
_currentCurve->setData(tVtr, xVtr, yVtr);
|
||||||
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
// _currentCurve->setPen(QPen(Qt::red)); // 设置线条颜色为红色
|
||||||
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
// _currentCurve->setBrush(QBrush(QColor(255, 0, 0, 20))); // 设置填充颜色并带有透明度
|
||||||
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
_currentCurve->setSelectable(QCP::stWhole); // 设置曲线可选
|
||||||
|
|
||||||
// 清除第一个图表上的数据
|
// 清除第一个图表上的数据
|
||||||
@ -200,6 +204,50 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
|||||||
_customPlot->replot();
|
_customPlot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CentralWidget::slotSelectionChanged()
|
||||||
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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()
|
void CentralWidget::slotAnalysisSettingApply()
|
||||||
{
|
{
|
||||||
switch (_analysisMode) {
|
switch (_analysisMode) {
|
||||||
@ -435,7 +483,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.
|
||||||
|
|||||||
@ -35,6 +35,7 @@ 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&);
|
||||||
|
void slotSelectionChanged();
|
||||||
//analysis setting
|
//analysis setting
|
||||||
void slotAnalysisSettingLineXPoint(const int index,const double);
|
void slotAnalysisSettingLineXPoint(const int index,const double);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user