Merge pull request #8654 from OPM/filter_wheelevents

Summary Multiplot: page scroll and zoom fixes
This commit is contained in:
jonjenssen
2022-03-10 13:13:44 +01:00
committed by GitHub
parent 0d45b88d09
commit c9b762fb16
13 changed files with 244 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
version="1.1"
id="svg22083"
sodipodi:docname="DisableZoom.svg"
inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs22087">
<symbol
id="NoEntry">
<title
id="title24865">No Entry</title>
<circle
cx="36"
cy="36"
r="27"
style="stroke:none"
id="circle24867" />
<rect
x="14"
y="32"
width="44"
height="8"
style="fill:white;stroke:none"
id="rect24869" />
</symbol>
</defs>
<sodipodi:namedview
id="namedview22085"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="77.485677"
inkscape:cx="8.0079316"
inkscape:cy="8.0079316"
inkscape:window-width="2560"
inkscape:window-height="1351"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg22083" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M 12.028 6.149 C 12.123 7.566 11.668 8.967 10.758 10.058 L 15.018 14.318 L 14.318 15.028 L 10.058 10.758 C 8.967 11.668 7.566 12.123 6.149 12.028 C 4.731 11.932 3.404 11.293 2.446 10.244 C 1.487 9.195 0.969 7.817 1.001 6.396 C 1.033 4.975 1.612 3.622 2.617 2.617 C 3.622 1.612 4.975 1.033 6.396 1.001 C 7.817 0.969 9.195 1.487 10.244 2.446 C 11.293 3.404 11.932 4.731 12.028 6.149 Z M 6.578 11.038 C 7.77 11.035 8.914 10.561 9.758 9.718 L 9.718 9.738 C 10.145 9.321 10.485 8.823 10.718 8.274 C 10.952 7.725 11.074 7.134 11.078 6.538 C 11.078 5.648 10.814 4.778 10.319 4.038 C 9.825 3.298 9.122 2.721 8.3 2.38 C 7.477 2.039 6.573 1.95 5.7 2.124 C 4.827 2.298 4.025 2.726 3.396 3.356 C 2.766 3.985 2.338 4.787 2.164 5.66 C 1.99 6.533 2.08 7.437 2.42 8.26 C 2.761 9.082 3.337 9.785 4.077 10.279 C 4.817 10.774 5.688 11.038 6.578 11.038 Z"
style="fill: rgb(128, 128, 128);"
id="path22079" />
<use
xlink:href="#NoEntry"
style="fill:#aa0000;stroke:#000000"
id="use26176"
x="0"
y="0"
width="100%"
height="100%"
transform="matrix(0.11406361,0,0,0.11457168,2.4058544,2.4641851)" />
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -258,6 +258,7 @@
<file>view-snapshots.svg</file>
<file>well-log-plot.svg</file>
<file>window-management.svg</file>
<file>DisableZoom.png</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>

View File

@@ -1,5 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M 12.028 6.149 C 12.123 7.566 11.668 8.967 10.758 10.058 L 15.018 14.318 L 14.318 15.028 L 10.058 10.758 C 8.967 11.668 7.566 12.123 6.149 12.028 C 4.731 11.932 3.404 11.293 2.446 10.244 C 1.487 9.195 0.969 7.817 1.001 6.396 C 1.033 4.975 1.612 3.622 2.617 2.617 C 3.622 1.612 4.975 1.033 6.396 1.001 C 7.817 0.969 9.195 1.487 10.244 2.446 C 11.293 3.404 11.932 4.731 12.028 6.149 Z M 6.578 11.038 C 7.77 11.035 8.914 10.561 9.758 9.718 L 9.718 9.738 C 10.145 9.321 10.485 8.823 10.718 8.274 C 10.952 7.725 11.074 7.134 11.078 6.538 C 11.078 5.648 10.814 4.778 10.319 4.038 C 9.825 3.298 9.122 2.721 8.3 2.38 C 7.477 2.039 6.573 1.95 5.7 2.124 C 4.827 2.298 4.025 2.726 3.396 3.356 C 2.766 3.985 2.338 4.787 2.164 5.66 C 1.99 6.533 2.08 7.437 2.42 8.26 C 2.761 9.082 3.337 9.785 4.077 10.279 C 4.817 10.774 5.688 11.038 6.578 11.038 Z" style="fill: rgb(128, 128, 128);"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M 9.01749 7.0376 L 9.01749 6.0376 L 7.01749 6.0376 L 7.01749 4.0376 L 6.01749 4.0376 L 6.01749 6.0376 L 4.01749 6.0376 L 4.01749 7.0376 L 6.01749 7.0376 L 6.01749 9.0376 L 7.01749 9.0376 L 7.01749 7.0376 L 9.01749 7.0376 Z" style="fill: rgb(174, 78, 151);"/>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
version="1.1"
id="svg22083"
sodipodi:docname="ZoomAll.svg"
inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs22087" />
<sodipodi:namedview
id="namedview22085"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="77.485677"
inkscape:cx="8.0079316"
inkscape:cy="8.0079316"
inkscape:window-width="2560"
inkscape:window-height="1351"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg22083" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M 12.028 6.149 C 12.123 7.566 11.668 8.967 10.758 10.058 L 15.018 14.318 L 14.318 15.028 L 10.058 10.758 C 8.967 11.668 7.566 12.123 6.149 12.028 C 4.731 11.932 3.404 11.293 2.446 10.244 C 1.487 9.195 0.969 7.817 1.001 6.396 C 1.033 4.975 1.612 3.622 2.617 2.617 C 3.622 1.612 4.975 1.033 6.396 1.001 C 7.817 0.969 9.195 1.487 10.244 2.446 C 11.293 3.404 11.932 4.731 12.028 6.149 Z M 6.578 11.038 C 7.77 11.035 8.914 10.561 9.758 9.718 L 9.718 9.738 C 10.145 9.321 10.485 8.823 10.718 8.274 C 10.952 7.725 11.074 7.134 11.078 6.538 C 11.078 5.648 10.814 4.778 10.319 4.038 C 9.825 3.298 9.122 2.721 8.3 2.38 C 7.477 2.039 6.573 1.95 5.7 2.124 C 4.827 2.298 4.025 2.726 3.396 3.356 C 2.766 3.985 2.338 4.787 2.164 5.66 C 1.99 6.533 2.08 7.437 2.42 8.26 C 2.761 9.082 3.337 9.785 4.077 10.279 C 4.817 10.774 5.688 11.038 6.578 11.038 Z"
style="fill: rgb(128, 128, 128);"
id="path22079" />
<g
id="g4"
transform="matrix(0.00557746,0,0,0.00543996,3.0168927,3.201711)"
style="fill:#008000;stroke-width:55.37117685;stroke-miterlimit:4;stroke-dasharray:none;stroke:#00ad00;stroke-opacity:1">
<path
fill="#1a1a1a"
stroke="#1a1a1a"
stroke-miterlimit="10"
d="m 1084.549,475.525 -0.172,0.029 c -2.313,-15.392 -15.47,-27.231 -31.506,-27.231 -17.665,0 -31.985,14.32 -31.985,31.985 0,0.783 0.175,1.517 0.23,2.287 l -0.382,0.02 0.699,3.117 c 0.145,0.848 0.347,1.664 0.558,2.486 l 3.693,16.469 c 6.98,31.137 10.519,63.201 10.519,95.309 0,240.526 -195.678,436.21 -436.198,436.21 -240.526,0 -436.207,-195.684 -436.207,-436.21 0,-240.526 195.681,-436.204 436.207,-436.204 101.091,0 199.179,35.515 277.265,100.012 l -46.019,57.057 180.673,21.307 -55.121,-176.973 -39.496,48.969 C 827.914,140.541 715.628,99.999 600.004,99.999 c -275.703,0 -500.003,224.297 -500.003,499.997 0,275.706 224.301,500.003 500.003,500.003 275.697,0 499.994,-224.298 499.994,-500.003 0,-35.659 -3.888,-71.536 -11.553,-106.629 z"
id="path2"
style="fill:#008000;stroke-width:55.37117685;stroke-miterlimit:4;stroke-dasharray:none;stroke:#00ad00;stroke-opacity:1" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -1687,11 +1687,16 @@ bool RiaGuiApplication::notify( QObject* receiver, QEvent* event )
{
if ( event->type() == QEvent::KeyPress )
{
QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
RimPlotWindow* plot = dynamic_cast<RimPlotWindow*>( activePlotWindow() );
QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
RimPlotWindow* plot = dynamic_cast<RimPlotWindow*>( activePlotWindow() );
if ( plot ) done = plot->handleGlobalKeyEvent( keyEvent );
}
else if ( event->type() == QEvent::Wheel )
{
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>( event );
RimPlotWindow* plot = dynamic_cast<RimPlotWindow*>( activePlotWindow() );
if ( plot ) done = plot->handleGlobalWheelEvent( wheelEvent );
}
if ( !done )
{
done = QApplication::notify( receiver, event );

View File

@@ -906,3 +906,14 @@ void RimMultiPlot::cleanupBeforeClose()
m_viewer = nullptr;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMultiPlot::isMouseCursorInsidePlot()
{
if ( !m_viewer ) return false;
QPoint curpos = m_viewer->mapFromGlobal( QCursor::pos() );
return ( m_viewer->rect().contains( curpos ) );
}

View File

@@ -141,6 +141,8 @@ protected:
virtual void updatePlotWindowTitle();
bool isMouseCursorInsidePlot();
private:
void cleanupBeforeClose();
void doUpdateLayout() override;

View File

@@ -344,3 +344,11 @@ bool RimPlotWindow::handleGlobalKeyEvent( QKeyEvent* keyEvent )
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimPlotWindow::handleGlobalWheelEvent( QWheelEvent* wheelEvent )
{
return false;
}

View File

@@ -32,6 +32,7 @@ class RiuQwtPlotWidget;
class QwtPlotCurve;
class QKeyEvent;
class QWheelEvent;
class QPaintDevice;
//==================================================================================================
@@ -76,6 +77,7 @@ public:
QPageLayout pageLayout() const;
virtual bool handleGlobalKeyEvent( QKeyEvent* keyEvent );
virtual bool handleGlobalWheelEvent( QWheelEvent* wheelEvent );
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;

View File

@@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimMultiPlot.h"
#include "RimSummaryMultiPlot.h"
#include "RiaSummaryAddressAnalyzer.h"
#include "RiaSummaryStringTools.h"
@@ -31,7 +31,7 @@
#include "RimSummaryCurve.h"
#include "RimSummaryPlotControls.h"
#include "RimSummaryMultiPlot.h"
#include "RimMultiPlot.h"
#include "RimSummaryPlot.h"
#include "RimSummaryPlotNameHelper.h"
#include "RimSummaryPlotSourceStepping.h"
@@ -43,6 +43,8 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeSelectionEditor.h"
#include <QKeyEvent>
CAF_PDM_SOURCE_INIT( RimSummaryMultiPlot, "MultiSummaryPlot" );
//--------------------------------------------------------------------------------------------------
///
@@ -60,6 +62,11 @@ RimSummaryMultiPlot::RimSummaryMultiPlot()
m_syncAxisRanges.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_syncAxisRanges.uiCapability()->setUiIconFromResourceString( ":/AxesSync16x16.png" );
CAF_PDM_InitField( &m_disableWheelZoom, "DisableWheelZoom", true, "", "", "Disable Mouse Wheel Zooming in Multi Summary Plot" );
m_disableWheelZoom.xmlCapability()->disableIO();
m_disableWheelZoom.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
m_disableWheelZoom.uiCapability()->setUiIconFromResourceString( ":/DisableZoom.png" );
CAF_PDM_InitFieldNoDefault( &m_sourceStepping, "SourceStepping", "" );
m_sourceStepping = new RimSummaryPlotSourceStepping;
m_sourceStepping->setSourceSteppingType( RimSummaryDataSourceStepping::Axis::Y_AXIS );
@@ -388,6 +395,7 @@ std::vector<caf::PdmFieldHandle*> RimSummaryMultiPlot::fieldsToShowInToolbar()
{
std::vector<caf::PdmFieldHandle*> toolBarFields;
toolBarFields.push_back( &m_disableWheelZoom );
toolBarFields.push_back( &m_syncAxisRanges );
auto& sourceObject = m_sourceStepping();
@@ -405,7 +413,48 @@ std::vector<caf::PdmFieldHandle*> RimSummaryMultiPlot::fieldsToShowInToolbar()
//--------------------------------------------------------------------------------------------------
bool RimSummaryMultiPlot::handleGlobalKeyEvent( QKeyEvent* keyEvent )
{
return RimSummaryPlotControls::handleKeyEvents( m_sourceStepping(), keyEvent );
if ( !RimSummaryPlotControls::handleKeyEvents( m_sourceStepping(), keyEvent ) )
{
if ( isMouseCursorInsidePlot() )
{
if ( keyEvent->key() == Qt::Key_PageUp )
{
m_viewer->goToPrevPage();
return true;
}
else if ( keyEvent->key() == Qt::Key_PageDown )
{
m_viewer->goToNextPage();
return true;
}
}
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryMultiPlot::handleGlobalWheelEvent( QWheelEvent* wheelEvent )
{
if ( m_disableWheelZoom )
{
if ( isMouseCursorInsidePlot() )
{
if ( wheelEvent->angleDelta().y() > 0 )
{
m_viewer->goToPrevPage();
}
else if ( wheelEvent->angleDelta().y() < 0 )
{
m_viewer->goToNextPage();
}
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------

View File

@@ -63,6 +63,7 @@ public:
protected:
bool handleGlobalKeyEvent( QKeyEvent* keyEvent ) override;
bool handleGlobalWheelEvent( QWheelEvent* wheelEvent ) override;
private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
@@ -82,6 +83,7 @@ private:
caf::PdmField<bool> m_autoPlotTitles;
caf::PdmField<bool> m_autoPlotTitlesOnSubPlots;
caf::PdmField<bool> m_syncAxisRanges;
caf::PdmField<bool> m_disableWheelZoom;
caf::PdmChildField<RimSummaryPlotSourceStepping*> m_sourceStepping;

View File

@@ -99,6 +99,7 @@ RiuMultiPlotBook::RiuMultiPlotBook( RimMultiPlot* plotDefinition, QWidget* paren
, m_titleVisible( true )
, m_subTitlesVisible( true )
, m_previewMode( true )
, m_currentPageIndex( 0 )
{
const int spacing = 8;
@@ -585,3 +586,30 @@ void RiuMultiPlotBook::applyLook()
m_book->setPalette( newPalette );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::changeCurrentPage( int pageDiff )
{
m_currentPageIndex += pageDiff;
if ( m_currentPageIndex >= (int)m_pages.size() ) m_currentPageIndex = (int)m_pages.size() - 1;
if ( m_currentPageIndex < 0 ) m_currentPageIndex = 0;
if ( !m_pages.isEmpty() ) m_scrollArea->ensureWidgetVisible( m_pages[m_currentPageIndex] );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::goToNextPage()
{
changeCurrentPage( 1 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::goToPrevPage()
{
changeCurrentPage( -1 );
}

View File

@@ -86,6 +86,9 @@ public:
void renderTo( QPaintDevice* painter );
void goToNextPage();
void goToPrevPage();
protected:
void contextMenuEvent( QContextMenuEvent* ) override;
@@ -107,6 +110,9 @@ private:
const QList<QPointer<RiuMultiPlotPage>>& pages() const;
RiuMultiPlotPage* createPage();
void applyLook();
void changeCurrentPage( int pageDiff );
private slots:
virtual void performUpdate();
@@ -125,4 +131,5 @@ protected:
bool m_titleVisible;
bool m_subTitlesVisible;
bool m_previewMode;
int m_currentPageIndex;
};