mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4983 Fix drag zoom on Summary and Grid cross plots
This commit is contained in:
parent
7d817d0277
commit
c7b5957571
@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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();
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QLabel>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollArea>
|
||||
@ -473,9 +474,7 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
|
||||
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>( 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() ) );
|
||||
|
@ -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();
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "qwt_plot_zoomer.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
class RiuQwtPlotZoomer : public QwtPlotZoomer
|
||||
{
|
||||
public:
|
||||
@ -35,6 +37,11 @@ public:
|
||||
return accept( currentSelection );
|
||||
}
|
||||
|
||||
void endZoomOperation()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
protected:
|
||||
QSizeF minZoomSize() const override
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user