Skip to content

Commit c49b698

Browse files
committed
CorrelationReportPlot: Refinements, fixes, and simplifications
- Use RimViewWindow in RiuCorrelationReportPlotWidget constructor - Update default dock layout to match desired screenshot - Generalize context menu selection fixer to use caf::PdmObject - Simplify code, fix event filter lifetime, plot titles, and disable summary plot zoom RiuSummaryQwtPlot: Add missing override keyword to setZoomEnabled
1 parent 3fa91d2 commit c49b698

File tree

9 files changed

+79
-35
lines changed

9 files changed

+79
-35
lines changed

ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.cpp

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include "RimTimeAxisAnnotation.h"
3939

4040
#include "RiuInterfaceToViewWindow.h"
41+
42+
#include "RimViewWindow.h"
4143
#include "RiuPlotWidget.h"
4244
#include "RiuQwtPlotWidget.h"
4345

@@ -62,7 +64,8 @@
6264
#include <QStringList>
6365
#include <QVBoxLayout>
6466

65-
static const char* DOCK_LAYOUT_REGISTRY_KEY = "CorrelationReportPlot/defaultDockLayout";
67+
static const char* DOCK_LAYOUT_REGISTRY_KEY = "CorrelationReportPlot/defaultDockLayout";
68+
static const cvf::Color3f TRACKING_ANNOTATION_COLOR = cvf::Color3f( 0.6f, 0.4f, 0.08f );
6669

6770
//--------------------------------------------------------------------------------------------------
6871
/// Thin wrapper around CDockManager that implements RiuInterfaceToViewWindow so that
@@ -71,19 +74,19 @@ static const char* DOCK_LAYOUT_REGISTRY_KEY = "CorrelationReportPlot/defaultDock
7174
class RiuCorrelationReportPlotWidget : public QFrame, public RiuInterfaceToViewWindow
7275
{
7376
public:
74-
RiuCorrelationReportPlotWidget( RimCorrelationReportPlot* plot, QWidget* parent = nullptr )
77+
RiuCorrelationReportPlotWidget( RimViewWindow* viewWindow, QWidget* parent = nullptr )
7578
: QFrame( parent )
76-
, m_plot( plot )
79+
, m_viewWindow( viewWindow )
7780
{
7881
setLayout( new QVBoxLayout );
7982
layout()->setContentsMargins( 0, 0, 0, 0 );
8083
layout()->setSpacing( 0 );
8184
}
8285

83-
RimViewWindow* ownerViewWindow() const override { return m_plot; }
86+
RimViewWindow* ownerViewWindow() const override { return m_viewWindow; }
8487

8588
private:
86-
RimCorrelationReportPlot* m_plot;
89+
RimViewWindow* m_viewWindow;
8790
};
8891

8992
//--------------------------------------------------------------------------------------------------
@@ -115,7 +118,7 @@ class TimeReadoutPicker : public QwtPlotPicker
115118
timeAxisProps->removeAnnotation( m_trackingAnnotation );
116119
m_trackingAnnotation = nullptr;
117120
}
118-
auto* anno = RimTimeAxisAnnotation::createTimeAnnotation( timeTValue, cvf::Color3f( 0.6f, 0.4f, 0.08f ) );
121+
auto* anno = RimTimeAxisAnnotation::createTimeAnnotation( timeTValue, TRACKING_ANNOTATION_COLOR );
119122
anno->setPenStyle( Qt::DashLine );
120123
timeAxisProps->appendAnnotation( anno );
121124
m_trackingAnnotation = anno;
@@ -152,23 +155,23 @@ namespace
152155
// Ensures the correlation report plot is selected in CAF whenever a context menu event is dispatched
153156
// anywhere within the dock manager — so feature availability checks in RiuContextMenuLauncher
154157
// see the correct item (mirrors what RiuMultiPlotPage::contextMenuEvent did explicitly).
155-
class ReportPlotContextMenuFilter : public QObject
158+
class SelectionFixerOnContextMenu : public QObject
156159
{
157160
public:
158-
ReportPlotContextMenuFilter( RimCorrelationReportPlot* plot, QObject* parent )
161+
SelectionFixerOnContextMenu( caf::PdmObject* item, QObject* parent )
159162
: QObject( parent )
160-
, m_plot( plot )
163+
, m_item( item )
161164
{
162165
}
163166

164167
bool eventFilter( QObject*, QEvent* event ) override
165168
{
166-
if ( event->type() == QEvent::ContextMenu ) caf::SelectionManager::instance()->setSelectedItem( m_plot );
169+
if ( event->type() == QEvent::ContextMenu ) caf::SelectionManager::instance()->setSelectedItem( m_item );
167170
return false; // never consume the event
168171
}
169172

170173
private:
171-
RimCorrelationReportPlot* m_plot;
174+
caf::PdmObject* m_item;
172175
};
173176
} // namespace
174177

@@ -232,8 +235,8 @@ RimCorrelationReportPlot::RimCorrelationReportPlot()
232235

233236
auto* curveSet = new RimEnsembleCurveSet();
234237
curveSet->setColorMode( RimEnsembleCurveSet::ColorMode::SINGLE_COLOR );
235-
curveSet->setColor( cvf::Color3f( 0.6f, 0.4f, 0.08f ) );
236-
const_cast<RimEnsembleStatistics*>( curveSet->statisticsOptions() )->enableCurveLabels( false );
238+
curveSet->setColor( TRACKING_ANNOTATION_COLOR );
239+
curveSet->statisticsOptions()->enableCurveLabels( false );
237240
m_summaryPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
238241

239242
m_summaryAddressSelector = new RimSummaryAddressSelector();
@@ -385,13 +388,17 @@ void RimCorrelationReportPlot::recreatePlotWidgets()
385388
m_parameterResultCrossPlot->createPlotWidget( m_dockManager );
386389
m_summaryPlot->createPlotWidget( m_dockManager );
387390

388-
// Install selection fixer on each plot widget (runs first due to LIFO filter order), so that
389-
// RiuContextMenuLauncher sees the correct CAF selection when building the context menu.
390-
auto* filter = new ReportPlotContextMenuFilter( this, m_dockManager );
391-
if ( m_correlationMatrixPlot->viewer() ) m_correlationMatrixPlot->viewer()->installEventFilter( filter );
392-
if ( m_correlationPlot->viewer() ) m_correlationPlot->viewer()->installEventFilter( filter );
393-
if ( m_parameterResultCrossPlot->viewer() ) m_parameterResultCrossPlot->viewer()->installEventFilter( filter );
394-
if ( m_summaryPlot->plotWidget() ) m_summaryPlot->plotWidget()->installEventFilter( filter );
391+
// Install selection fixer on each plot widget.
392+
// Filter runs first (LIFO order) so RiuContextMenuLauncher sees the correct CAF selection.
393+
delete m_contextMenuFilter;
394+
m_contextMenuFilter = new SelectionFixerOnContextMenu( this, this );
395+
for ( RiuPlotWidget* w : std::initializer_list<RiuPlotWidget*>{ m_correlationMatrixPlot->viewer(),
396+
m_correlationPlot->viewer(),
397+
m_parameterResultCrossPlot->viewer(),
398+
m_summaryPlot->plotWidget() } )
399+
{
400+
if ( w ) w->installEventFilter( m_contextMenuFilter );
401+
}
395402

396403
// Wrap each plot in a dock widget
397404
m_matrixDockWidget = new ads::CDockWidget( "Matrix Plot", m_dockManager );
@@ -410,6 +417,9 @@ void RimCorrelationReportPlot::recreatePlotWidgets()
410417
m_summaryDockWidget->setWidget( m_summaryPlot->plotWidget(), ads::CDockWidget::ForceNoScrollArea );
411418
m_summaryDockWidget->setFeature( ads::CDockWidget::DockWidgetClosable, false );
412419

420+
// Disable zoom — clicks are used for time step selection, not zooming
421+
if ( m_summaryPlot->summaryPlotWidget() ) m_summaryPlot->summaryPlotWidget()->setZoomEnabled( false );
422+
413423
// Connect summary plot click → time step update; add time tracking readout
414424
auto* summaryWidget = dynamic_cast<RiuQwtPlotWidget*>( m_summaryPlot->plotWidget() );
415425
if ( summaryWidget )
@@ -440,14 +450,12 @@ void RimCorrelationReportPlot::recreatePlotWidgets()
440450
}
441451
else
442452
{
443-
// Hard-coded default: matrix on left, corr top-right, cross bottom-right, summary far right
444-
auto* matrixArea = m_dockManager->addDockWidget( ads::LeftDockWidgetArea, m_matrixDockWidget );
445-
auto* corrArea = m_dockManager->addDockWidget( ads::RightDockWidgetArea, m_correlationDockWidget );
446-
auto* crossArea = m_dockManager->addDockWidget( ads::BottomDockWidgetArea, m_crossPlotDockWidget, corrArea );
447-
m_dockManager->addDockWidget( ads::RightDockWidgetArea, m_summaryDockWidget, corrArea );
448-
449-
(void)matrixArea;
450-
(void)crossArea;
453+
// Hard-coded default: matrix left (full height), corr top-right, cross bottom-right,
454+
// summary spanning full width at bottom
455+
auto* corrArea = m_dockManager->addDockWidget( ads::CenterDockWidgetArea, m_correlationDockWidget );
456+
m_dockManager->addDockWidget( ads::LeftDockWidgetArea, m_matrixDockWidget );
457+
m_dockManager->addDockWidget( ads::BottomDockWidgetArea, m_crossPlotDockWidget, corrArea );
458+
m_dockManager->addDockWidget( ads::BottomDockWidgetArea, m_summaryDockWidget );
451459

452460
m_summaryDockWidget->toggleView( m_showSummaryPlot() );
453461
}
@@ -607,7 +615,7 @@ void RimCorrelationReportPlot::onLoadDataAndUpdate()
607615
auto* timeAxisProps = m_summaryPlot->timeAxisProperties();
608616
if ( timeAxisProps )
609617
{
610-
timeAxisProps->appendAnnotation( RimTimeAxisAnnotation::createTimeAnnotation( timeStep, cvf::Color3f( 0.6f, 0.4f, 0.08f ) ) );
618+
timeAxisProps->appendAnnotation( RimTimeAxisAnnotation::createTimeAnnotation( timeStep, TRACKING_ANNOTATION_COLOR ) );
611619
m_summaryPlot->updateAnnotationsInPlotWidget();
612620
}
613621
}

ApplicationLibCode/ProjectDataModel/CorrelationPlots/RimCorrelationReportPlot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class RimCorrelationReportPlot : public QObject, public RimPlotWindow
105105
caf::PdmField<QString> m_dockState;
106106

107107
QWidget* m_viewWidget = nullptr;
108+
QObject* m_contextMenuFilter = nullptr;
108109
ads::CDockManager* m_dockManager = nullptr;
109110
ads::CDockWidget* m_matrixDockWidget = nullptr;
110111
ads::CDockWidget* m_correlationDockWidget = nullptr;

ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,6 +2586,14 @@ const RimEnsembleStatistics* RimEnsembleCurveSet::statisticsOptions() const
25862586
return m_statistics();
25872587
}
25882588

2589+
//--------------------------------------------------------------------------------------------------
2590+
///
2591+
//--------------------------------------------------------------------------------------------------
2592+
RimEnsembleStatistics* RimEnsembleCurveSet::statisticsOptions()
2593+
{
2594+
return m_statistics();
2595+
}
2596+
25892597
//--------------------------------------------------------------------------------------------------
25902598
///
25912599
//--------------------------------------------------------------------------------------------------

ApplicationLibCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class RimEnsembleCurveSet : public caf::PdmObject, public RimEnsembleCurveSetInt
166166
bool hasPercentileData( int p ) const override;
167167

168168
const RimEnsembleStatistics* statisticsOptions() const;
169+
RimEnsembleStatistics* statisticsOptions();
169170

170171
void appendColorGroup( caf::PdmUiOrdering& uiOrdering );
171172
void appendOptionItemsForSummaryAddresses( QList<caf::PdmOptionItemInfo>* options, RimSummaryEnsemble* summaryCaseGroup );

ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ RiuPlotWidget* RimSummaryPlot::plotWidget()
312312
return m_summaryPlot->plotWidget();
313313
}
314314

315+
//--------------------------------------------------------------------------------------------------
316+
///
317+
//--------------------------------------------------------------------------------------------------
318+
RiuSummaryPlot* RimSummaryPlot::summaryPlotWidget() const
319+
{
320+
return m_summaryPlot;
321+
}
322+
315323
//--------------------------------------------------------------------------------------------------
316324
///
317325
//--------------------------------------------------------------------------------------------------

ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,13 @@ class RimSummaryPlot : public RimPlot, public RimSummaryDataSourceStepping
174174

175175
RimSummaryPlotSourceStepping* sourceSteppingObjectForKeyEventHandling() const;
176176

177-
void setAutoScaleXEnabled( bool enabled ) override;
178-
void setAutoScaleYEnabled( bool enabled ) override;
179-
RiuPlotWidget* plotWidget() override;
180-
void zoomAll() override;
181-
void updatePlotWidgetFromAxisRanges() override;
182-
void updateAxisRangesFromPlotWidget() override;
177+
void setAutoScaleXEnabled( bool enabled ) override;
178+
void setAutoScaleYEnabled( bool enabled ) override;
179+
RiuPlotWidget* plotWidget() override;
180+
RiuSummaryPlot* summaryPlotWidget() const;
181+
void zoomAll() override;
182+
void updatePlotWidgetFromAxisRanges() override;
183+
void updateAxisRangesFromPlotWidget() override;
183184

184185
void onAxisSelected( RiuPlotAxis axis, bool toggle ) override;
185186

ApplicationLibCode/UserInterface/RiuSummaryPlot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class RiuSummaryPlot : public QObject
5353
virtual RiuPlotWidget* plotWidget() const = 0;
5454

5555
virtual void enableCurvePointTracking( bool enable ) {};
56+
virtual void setZoomEnabled( bool enable ) {};
5657

5758
public slots:
5859
void showContextMenu( QPoint );

ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,21 @@ void RiuSummaryQwtPlot::enableCurvePointTracking( bool enable )
295295
m_curvePointTracker->setEnabled( enable );
296296
}
297297

298+
//--------------------------------------------------------------------------------------------------
299+
///
300+
//--------------------------------------------------------------------------------------------------
301+
void RiuSummaryQwtPlot::setZoomEnabled( bool enable )
302+
{
303+
if ( m_plotZoomer ) m_plotZoomer->setEnabled( enable );
304+
if ( m_wheelZoomer && m_plotWidget && m_plotWidget->qwtPlot() )
305+
{
306+
if ( enable )
307+
m_plotWidget->qwtPlot()->canvas()->installEventFilter( m_wheelZoomer );
308+
else
309+
m_plotWidget->qwtPlot()->canvas()->removeEventFilter( m_wheelZoomer );
310+
}
311+
}
312+
298313
//--------------------------------------------------------------------------------------------------
299314
///
300315
//--------------------------------------------------------------------------------------------------

ApplicationLibCode/UserInterface/RiuSummaryQwtPlot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class RiuSummaryQwtPlot : public RiuSummaryPlot
6161
RiuPlotWidget* plotWidget() const override;
6262

6363
void enableCurvePointTracking( bool enable ) override;
64+
void setZoomEnabled( bool enable ) override;
6465

6566
protected:
6667
void setDefaults();

0 commit comments

Comments
 (0)