diff --git a/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.cpp b/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.cpp index 84992b6074..6aa67458c5 100644 --- a/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.cpp +++ b/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.cpp @@ -43,6 +43,8 @@ #include +#include + //================================================================================================== // // @@ -67,22 +69,22 @@ public: class RiuPvtQwtPicker : public QwtPicker { public: - RiuPvtQwtPicker( QwtPlot* plot, RiuPvtTrackerTextProvider* trackerTextProvider ) + RiuPvtQwtPicker( QwtPlot* plot, std::function textProvider ) : QwtPicker( QwtPicker::NoRubberBand, QwtPicker::AlwaysOn, plot->canvas() ) - , m_trackerTextProvider( trackerTextProvider ) + , m_textProvider( textProvider ) { setStateMachine( new QwtPickerTrackerMachine ); } QwtText trackerText( const QPoint& ) const override { - QwtText text( m_trackerTextProvider->trackerText() ); + QwtText text( m_textProvider() ); text.setRenderFlags( Qt::AlignLeft ); return text; } private: - const RiuPvtTrackerTextProvider* m_trackerTextProvider; + std::function m_textProvider; }; //================================================================================================== @@ -112,7 +114,7 @@ RiuPvtPlotWidget::RiuPvtPlotWidget( RiuPvtPlotPanel* parent ) setLayout( layout ); - m_qwtPicker = new RiuPvtQwtPicker( m_qwtPlot, this ); + m_qwtPicker = new RiuPvtQwtPicker( m_qwtPlot, [this]() { return m_trackerLabel; } ); RiuGuiTheme::styleQwtItem( m_qwtPicker ); connect( m_qwtPicker, SIGNAL( activated( bool ) ), this, SLOT( slotPickerActivated( bool ) ) ); connect( m_qwtPicker, SIGNAL( moved( const QPoint& ) ), this, SLOT( slotPickerPointChanged( const QPoint& ) ) ); @@ -472,14 +474,6 @@ size_t RiuPvtPlotWidget::indexOfQwtCurve( const QwtPlotCurve* qwtCurve ) const return cvf::UNDEFINED_SIZE_T; } -//-------------------------------------------------------------------------------------------------- -/// Implements the RiuPvtTrackerTextProvider interface -//-------------------------------------------------------------------------------------------------- -QString RiuPvtPlotWidget::trackerText() const -{ - return m_trackerLabel; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.h b/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.h index a41ae2949d..91f6a4ee82 100644 --- a/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.h +++ b/ApplicationLibCode/UserInterface/RiuPvtPlotWidget.h @@ -39,19 +39,12 @@ class QwtPlot; class QwtPlotMarker; class QwtPlotCurve; -// Interface for providing our custom picker with a tracker text -class RiuPvtTrackerTextProvider -{ -public: - virtual QString trackerText() const = 0; -}; - //================================================================================================== // // // //================================================================================================== -class RiuPvtPlotWidget : public QWidget, public RiuPvtTrackerTextProvider +class RiuPvtPlotWidget : public QWidget { Q_OBJECT @@ -72,7 +65,6 @@ private: const QwtPlotCurve* closestCurveSample( const QPoint& cursorPosition, int* closestSampleIndex ) const; size_t indexOfQwtCurve( const QwtPlotCurve* qwtCurve ) const; void updateTrackerPlotMarkerAndLabelFromPicker(); - QString trackerText() const override; private slots: void slotPickerActivated( bool );