mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-05 21:56:46 -06:00
#12203 Improve selection and highlight of curves in summary plot
Skip distance check when clicking in the plot, always select closest curve When pressing CTRL, toggle highlighted curves Allow multi select of realizations in Project Tree Avoid curve highlight operation during zoom Make sure wheel zoom works for a single plot
This commit is contained in:
1 parent
8c9da1c87b
commit
c728979bc1
12 files changed
+186
-55
No files matched your search
@@ -137,7 +137,7 @@ protected:
|
||||
void updateZoom();
|
||||
void recreatePlotWidgets();
|
||||
|
||||
void onPlotAdditionOrRemoval();
|
||||
virtual void onPlotAdditionOrRemoval();
|
||||
|
||||
bool isMouseCursorInsidePlot();
|
||||
|
||||
|
||||
@@ -300,6 +300,14 @@ bool RimPlot::isCurveHighlightSupported() const
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::any RimPlot::valueForKey( std::string key ) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
#include <any>
|
||||
|
||||
class QPaintDevice;
|
||||
class QWheelEvent;
|
||||
class RiuPlotWidget;
|
||||
@@ -104,6 +106,8 @@ public:
|
||||
virtual std::vector<RimPlotCurve*> visibleCurvesForLegend();
|
||||
virtual bool isCurveHighlightSupported() const;
|
||||
|
||||
virtual std::any valueForKey( std::string key ) const;
|
||||
|
||||
protected:
|
||||
virtual RiuPlotWidget* doCreatePlotViewWidget( QWidget* parent ) = 0;
|
||||
|
||||
|
||||
@@ -349,36 +349,54 @@ bool RimSummaryEnsembleTools::isEnsembleCurve( RimPlotCurve* sourceCurve )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryEnsembleTools::highlightCurvesForSameRealizationFromCurve( RimPlotCurve* sourceCurve )
|
||||
std::vector<RimSummaryCase*> RimSummaryEnsembleTools::summaryCasesFromCurves( const std::vector<RimPlotCurve*>& sourceCurves )
|
||||
{
|
||||
auto sourceSummaryCurve = dynamic_cast<RimSummaryCurve*>( sourceCurve );
|
||||
if ( !sourceSummaryCurve ) return;
|
||||
std::vector<RimSummaryCase*> sourceCases;
|
||||
|
||||
auto ensembleCurveSet = sourceSummaryCurve->firstAncestorOfType<RimEnsembleCurveSet>();
|
||||
if ( !ensembleCurveSet ) return;
|
||||
|
||||
auto sourceCase = sourceSummaryCurve->summaryCaseY();
|
||||
if ( !sourceCase ) return;
|
||||
|
||||
// Select the realization object in Data Sources Tree view
|
||||
if ( auto mainWindow = RiuPlotMainWindow::instance() )
|
||||
for ( auto sourceCurve : sourceCurves )
|
||||
{
|
||||
if ( auto treeView = mainWindow->getTreeViewWithItem( sourceCase ) )
|
||||
{
|
||||
treeView->selectAsCurrentItem( sourceCase );
|
||||
}
|
||||
auto sourceSummaryCurve = dynamic_cast<RimSummaryCurve*>( sourceCurve );
|
||||
if ( !sourceSummaryCurve ) continue;
|
||||
|
||||
auto ensembleCurveSet = sourceSummaryCurve->firstAncestorOfType<RimEnsembleCurveSet>();
|
||||
if ( !ensembleCurveSet ) continue;
|
||||
|
||||
auto sourceCase = sourceSummaryCurve->summaryCaseY();
|
||||
if ( !sourceCase ) continue;
|
||||
|
||||
sourceCases.push_back( sourceCase );
|
||||
}
|
||||
|
||||
highlightCurvesForSameRealization( sourceCase );
|
||||
return sourceCases;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryEnsembleTools::highlightCurvesForSameRealization( RimSummaryCase* sourceCase )
|
||||
void RimSummaryEnsembleTools::selectSummaryCasesInProjectTree( const std::vector<RimSummaryCase*>& sourceCases )
|
||||
{
|
||||
if ( !sourceCase ) return;
|
||||
if ( sourceCases.empty() ) return;
|
||||
|
||||
if ( auto mainWindow = RiuPlotMainWindow::instance() )
|
||||
{
|
||||
if ( auto treeView = mainWindow->getTreeViewWithItem( sourceCases.front() ) )
|
||||
{
|
||||
std::vector<const caf::PdmUiItem*> sourceItems;
|
||||
for ( auto sourceCase : sourceCases )
|
||||
{
|
||||
sourceItems.push_back( sourceCase );
|
||||
}
|
||||
|
||||
treeView->selectItems( sourceItems );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryEnsembleTools::highlightCurvesForSummaryCases( const std::vector<RimSummaryCase*>& sourceCases )
|
||||
{
|
||||
auto summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection();
|
||||
|
||||
for ( auto multiPlot : summaryPlotColl->multiPlots() )
|
||||
@@ -390,25 +408,30 @@ void RimSummaryEnsembleTools::highlightCurvesForSameRealization( RimSummaryCase*
|
||||
|
||||
auto summaryCurves = plot->summaryAndEnsembleCurves();
|
||||
|
||||
std::vector<RimSummaryCurve*> curvesForSameRealization;
|
||||
std::vector<RimPlotCurve*> curvesForSameRealization;
|
||||
|
||||
for ( auto curve : summaryCurves )
|
||||
{
|
||||
if ( sourceCase == curve->summaryCaseY() )
|
||||
auto summaryCaseY = curve->summaryCaseY();
|
||||
if ( std::find( sourceCases.begin(), sourceCases.end(), summaryCaseY ) != sourceCases.end() )
|
||||
{
|
||||
curvesForSameRealization.push_back( curve );
|
||||
}
|
||||
}
|
||||
|
||||
bool updateCurveOrder = false;
|
||||
plotWidget->resetPlotItemHighlighting( updateCurveOrder );
|
||||
|
||||
if ( !curvesForSameRealization.empty() )
|
||||
{
|
||||
bool updateCurveOrder = false;
|
||||
plotWidget->resetPlotItemHighlighting( updateCurveOrder );
|
||||
std::sort( curvesForSameRealization.begin(), curvesForSameRealization.end() );
|
||||
curvesForSameRealization.erase( std::unique( curvesForSameRealization.begin(), curvesForSameRealization.end() ),
|
||||
curvesForSameRealization.end() );
|
||||
|
||||
std::set<RimPlotCurve*> realizationCurvesSet( curvesForSameRealization.begin(), curvesForSameRealization.end() );
|
||||
plotWidget->highlightCurvesUpdateOrder( realizationCurvesSet );
|
||||
plotWidget->replot();
|
||||
plotWidget->highlightCurvesUpdateOrder( curvesForSameRealization );
|
||||
}
|
||||
|
||||
plotWidget->replot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,10 @@ std::vector<RigEnsembleParameter> createVariationSortedEnsembleParameters( const
|
||||
|
||||
size_t calculateEnsembleParametersIntersectionHash( const std::vector<RimSummaryCase*>& summaryCases );
|
||||
|
||||
bool isEnsembleCurve( RimPlotCurve* sourceCurve );
|
||||
void highlightCurvesForSameRealizationFromCurve( RimPlotCurve* sourceCurve );
|
||||
void highlightCurvesForSameRealization( RimSummaryCase* sourceCase );
|
||||
void resetHighlightAllPlots();
|
||||
bool isEnsembleCurve( RimPlotCurve* sourceCurve );
|
||||
std::vector<RimSummaryCase*> summaryCasesFromCurves( const std::vector<RimPlotCurve*>& sourceCurves );
|
||||
void selectSummaryCasesInProjectTree( const std::vector<RimSummaryCase*>& sourceCases );
|
||||
void highlightCurvesForSummaryCases( const std::vector<RimSummaryCase*>& sourceCases );
|
||||
void resetHighlightAllPlots();
|
||||
|
||||
} // namespace RimSummaryEnsembleTools
|
||||
@@ -223,9 +223,6 @@ void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index )
|
||||
|
||||
RimMultiPlot::insertPlot( plot, index );
|
||||
}
|
||||
|
||||
if ( summaryPlots().size() == 1 ) m_disableWheelZoom = false;
|
||||
if ( summaryPlots().size() == 2 ) m_disableWheelZoom = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1551,6 +1548,16 @@ QWidget* RimSummaryMultiPlot::createViewWidget( QWidget* mainWindowParent )
|
||||
return m_viewer;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::onPlotAdditionOrRemoval()
|
||||
{
|
||||
m_disableWheelZoom = ( summaryPlots().size() > 1 );
|
||||
|
||||
RimMultiPlot::onPlotAdditionOrRemoval();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -125,6 +125,8 @@ protected:
|
||||
|
||||
QWidget* createViewWidget( QWidget* mainWindowParent ) override;
|
||||
|
||||
void onPlotAdditionOrRemoval() override;
|
||||
|
||||
private:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
|
||||
@@ -1121,6 +1121,19 @@ void RimSummaryPlot::enableCurvePointTracking( bool enable )
|
||||
m_summaryPlot->enableCurvePointTracking( enable );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::any RimSummaryPlot::valueForKey( std::string key ) const
|
||||
{
|
||||
if ( key == "TimeStampZoomOperation" )
|
||||
{
|
||||
return m_lastZoomTime;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -2618,6 +2631,8 @@ void RimSummaryPlot::onPlotZoomed()
|
||||
timeAxisSettingsChanged( nullptr );
|
||||
|
||||
axisChanged.send( this );
|
||||
|
||||
m_lastZoomTime = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -210,7 +210,8 @@ public:
|
||||
RimSummaryPlotSourceStepping* sourceStepper();
|
||||
void scheduleReplotIfVisible();
|
||||
|
||||
void enableCurvePointTracking( bool enable );
|
||||
void enableCurvePointTracking( bool enable );
|
||||
std::any valueForKey( std::string key ) const override;
|
||||
|
||||
public:
|
||||
// RimViewWindow overrides
|
||||
@@ -351,4 +352,6 @@ private:
|
||||
|
||||
bool m_isValid;
|
||||
RiuPlotWidget::Legend m_legendPosition;
|
||||
|
||||
std::chrono::steady_clock::time_point m_lastZoomTime;
|
||||
};
|
||||
Reference in new issue
Block a user