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,
|
||||
this,&CentralWidget::sigSendLineXCoord);
|
||||
// 连接选中信号
|
||||
connect(_customPlot, &QCustomPlot::selectionChangedByUser,
|
||||
this, &CentralWidget::slotSelectionChanged);
|
||||
|
||||
|
||||
setEventHandlerEnable(false);
|
||||
//
|
||||
@ -200,6 +204,50 @@ void CentralWidget::slotRecvAnalysisFileName(const QString &fileName)
|
||||
_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()
|
||||
{
|
||||
switch (_analysisMode) {
|
||||
|
||||
@ -35,6 +35,7 @@ public slots:
|
||||
void slotModeModify(const Global::Mode);
|
||||
void slotRecvCommonData(const CommonData&);
|
||||
void slotRecvAnalysisFileName(const QString&);
|
||||
void slotSelectionChanged();
|
||||
//analysis setting
|
||||
void slotAnalysisSettingLineXPoint(const int index,const double);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user