diff --git a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp index bc446996cf..a6f530175e 100644 --- a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.cpp @@ -67,14 +67,12 @@ RiuGridCrossQwtPlot::RiuGridCrossQwtPlot( RimPlotInterface* plotDefinition, QWid m_zoomerLeft->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerLeft->setTrackerPen( QColor( Qt::black ) ); m_zoomerLeft->initMousePattern( 1 ); - m_zoomerLeft->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier ); // Attach a zoomer for the right axis m_zoomerRight = new RiuQwtPlotZoomer( canvas() ); m_zoomerRight->setAxis( xTop, yRight ); m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerRight->initMousePattern( 1 ); - m_zoomerRight->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier ); // MidButton for the panning QwtPlotPanner* panner = new QwtPlotPanner( canvas() ); @@ -541,6 +539,23 @@ void RiuGridCrossQwtPlot::applyFontSizeToOverlayItem( caf::TitledOverlayFrame* o overlayItem->setFont( cafFont.p() ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuGridCrossQwtPlot::isZoomerActive() const +{ + return m_zoomerLeft->isActiveAndValid() || m_zoomerRight->isActiveAndValid(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuGridCrossQwtPlot::endZoomOperations() +{ + m_zoomerLeft->endZoomOperation(); + m_zoomerRight->endZoomOperation(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h index 43fe73cedc..2a63f47384 100644 --- a/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuGridCrossQwtPlot.h @@ -78,6 +78,8 @@ protected: void clearPointSelection() override; bool curveText( const QwtPlotCurve* curve, QString* curveTitle, QString* xParamName, QString* yParamName ) const; void applyFontSizeToOverlayItem( caf::TitledOverlayFrame* overlayItem ); + bool isZoomerActive() const override; + void endZoomOperations() override; private slots: void onZoomedSlot(); diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp index 734e0df1d0..9aaec9e273 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -473,9 +474,7 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) QMouseEvent* mouseEvent = dynamic_cast( event ); if ( mouseEvent ) { - // Shift is the zoom modifier and is reserved for QwtZoomPickers - bool zoomModifierApplied = ( mouseEvent->modifiers() & Qt::ShiftModifier ) != 0; - if ( zoomModifierApplied ) return false; + if ( isZoomerActive() ) return false; bool toggleItemInSelection = ( mouseEvent->modifiers() & Qt::ControlModifier ) != 0; @@ -520,6 +519,7 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) else { selectPlotOwner( toggleItemInSelection ); + endZoomOperations(); return true; } } @@ -530,6 +530,7 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event ) !m_clickPosition.isNull() ) { selectClosestCurve( mouseEvent->pos(), toggleItemInSelection ); + endZoomOperations(); return true; } } @@ -590,6 +591,19 @@ void RiuQwtPlotWidget::selectPoint( QwtPlotCurve* curve, int pointNumber ) {} //-------------------------------------------------------------------------------------------------- void RiuQwtPlotWidget::clearPointSelection() {} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuQwtPlotWidget::isZoomerActive() const +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// Empty default implementation +//-------------------------------------------------------------------------------------------------- +void RiuQwtPlotWidget::endZoomOperations() {} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -613,7 +627,7 @@ RiuWidgetStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const { QColor backgroundColor = QColor( "white" ); QColor highlightColor = QApplication::palette().highlight().color(); - QColor blendedHighlightColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 5 ); + QColor blendedHighlightColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 10 ); QColor nearlyBackgroundColor = RiaColorTools::blendQColors( highlightColor, backgroundColor, 1, 30 ); RiuWidgetStyleSheet styleSheet; @@ -625,7 +639,7 @@ RiuWidgetStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const if ( m_draggable ) { QString backgroundGradient = QString( QString( "qlineargradient( x1 : 1, y1 : 0, x2 : 1, y2 : 1," - "stop: 0 %1, stop: 0.02 %2, stop:1 %3 )" ) + "stop: 0 %1, stop: 0.015 %2, stop:1 %3 )" ) .arg( blendedHighlightColor.name() ) .arg( nearlyBackgroundColor.name() ) .arg( backgroundColor.name() ) ); diff --git a/ApplicationCode/UserInterface/RiuQwtPlotWidget.h b/ApplicationCode/UserInterface/RiuQwtPlotWidget.h index 47ea3d259b..05e5c0da8a 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotWidget.h +++ b/ApplicationCode/UserInterface/RiuQwtPlotWidget.h @@ -41,6 +41,7 @@ class QwtPlotMarker; class QwtPlotPicker; class QEvent; +class QLabel; //================================================================================================== // @@ -113,6 +114,8 @@ protected: virtual void selectPoint( QwtPlotCurve* curve, int pointNumber ); virtual void clearPointSelection(); + virtual bool isZoomerActive() const; + virtual void endZoomOperations(); private: void setDefaults(); diff --git a/ApplicationCode/UserInterface/RiuQwtPlotZoomer.h b/ApplicationCode/UserInterface/RiuQwtPlotZoomer.h index 1f7c318ffa..18f797e97f 100644 --- a/ApplicationCode/UserInterface/RiuQwtPlotZoomer.h +++ b/ApplicationCode/UserInterface/RiuQwtPlotZoomer.h @@ -19,6 +19,8 @@ #include "qwt_plot_zoomer.h" +#include + class RiuQwtPlotZoomer : public QwtPlotZoomer { public: @@ -35,6 +37,11 @@ public: return accept( currentSelection ); } + void endZoomOperation() + { + reset(); + } + protected: QSizeF minZoomSize() const override { diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 4cab2374db..6bca64d47e 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -101,14 +101,12 @@ RiuSummaryQwtPlot::RiuSummaryQwtPlot( RimPlotInterface* plotDefinition, QWidget* m_zoomerLeft->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerLeft->setTrackerPen( QColor( Qt::black ) ); m_zoomerLeft->initMousePattern( 1 ); - m_zoomerLeft->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier ); // Attach a zoomer for the right axis m_zoomerRight = new RiuQwtPlotZoomer( canvas() ); m_zoomerRight->setAxis( xTop, yRight ); m_zoomerRight->setTrackerMode( QwtPicker::AlwaysOff ); m_zoomerRight->initMousePattern( 1 ); - m_zoomerRight->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier ); // MidButton for the panning QwtPlotPanner* panner = new QwtPlotPanner( canvas() ); @@ -296,6 +294,23 @@ void RiuSummaryQwtPlot::updateLayout() updateLegendLayout(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuSummaryQwtPlot::isZoomerActive() const +{ + return m_zoomerLeft->isActiveAndValid() || m_zoomerRight->isActiveAndValid(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::endZoomOperations() +{ + m_zoomerLeft->endZoomOperation(); + m_zoomerRight->endZoomOperation(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 2a1e6f5f30..45a38687b2 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -63,6 +63,8 @@ protected: void contextMenuEvent( QContextMenuEvent* ) override; void setDefaults(); void updateLayout() override; + bool isZoomerActive() const override; + void endZoomOperations() override; private slots: void onZoomedSlot();