mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#11771 Highlight all curves for a realization when picking
When selecting a single curve in an ensemble, select and highlight all curves connected to this realization.
This commit is contained in:
@@ -23,7 +23,11 @@
|
|||||||
|
|
||||||
#include "RigEnsembleParameter.h"
|
#include "RigEnsembleParameter.h"
|
||||||
|
|
||||||
|
#include "RimEnsembleCurveSet.h"
|
||||||
#include "RimSummaryCase.h"
|
#include "RimSummaryCase.h"
|
||||||
|
#include "RimSummaryCurve.h"
|
||||||
|
#include "RimSummaryMultiPlot.h"
|
||||||
|
#include "RimSummaryMultiPlotCollection.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@@ -300,7 +304,7 @@ size_t RimSummaryEnsembleTools::calculateEnsembleParametersIntersectionHash( con
|
|||||||
|
|
||||||
size_t commonAddressCount = 0;
|
size_t commonAddressCount = 0;
|
||||||
|
|
||||||
// Find common addess count
|
// Find common address count
|
||||||
for ( const auto sumCase : summaryCases )
|
for ( const auto sumCase : summaryCases )
|
||||||
{
|
{
|
||||||
const auto reader = sumCase->summaryReader();
|
const auto reader = sumCase->summaryReader();
|
||||||
@@ -323,3 +327,68 @@ size_t RimSummaryEnsembleTools::calculateEnsembleParametersIntersectionHash( con
|
|||||||
|
|
||||||
return commonAddressCount;
|
return commonAddressCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryEnsembleTools::highlightCurvesForSameRealization( RimPlotCurve* sourceCurve )
|
||||||
|
{
|
||||||
|
auto sourceSummaryCurve = dynamic_cast<RimSummaryCurve*>( sourceCurve );
|
||||||
|
if ( !sourceSummaryCurve ) return;
|
||||||
|
|
||||||
|
auto ensembleCurveSet = sourceSummaryCurve->firstAncestorOfType<RimEnsembleCurveSet>();
|
||||||
|
if ( !ensembleCurveSet ) return;
|
||||||
|
|
||||||
|
auto summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection();
|
||||||
|
|
||||||
|
for ( auto multiPlot : summaryPlotColl->multiPlots() )
|
||||||
|
{
|
||||||
|
for ( auto plot : multiPlot->summaryPlots() )
|
||||||
|
{
|
||||||
|
auto plotWidget = dynamic_cast<RiuQwtPlotWidget*>( plot->plotWidget() );
|
||||||
|
if ( !plotWidget ) continue;
|
||||||
|
|
||||||
|
auto summaryCurves = plot->summaryAndEnsembleCurves();
|
||||||
|
|
||||||
|
std::vector<RimSummaryCurve*> curvesForSameRealization;
|
||||||
|
|
||||||
|
for ( auto curve : summaryCurves )
|
||||||
|
{
|
||||||
|
if ( sourceSummaryCurve->summaryCaseY() == curve->summaryCaseY() )
|
||||||
|
{
|
||||||
|
curvesForSameRealization.push_back( curve );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !curvesForSameRealization.empty() )
|
||||||
|
{
|
||||||
|
bool updateCurveOrder = false;
|
||||||
|
plotWidget->resetPlotItemHighlighting( updateCurveOrder );
|
||||||
|
|
||||||
|
std::set<RimPlotCurve*> realizationCurvesSet( curvesForSameRealization.begin(), curvesForSameRealization.end() );
|
||||||
|
plotWidget->highlightCurvesUpdateOrder( realizationCurvesSet );
|
||||||
|
plotWidget->replot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryEnsembleTools::resetHighlightAllPlots()
|
||||||
|
{
|
||||||
|
auto summaryPlotColl = RiaSummaryTools::summaryMultiPlotCollection();
|
||||||
|
|
||||||
|
for ( auto multiPlot : summaryPlotColl->multiPlots() )
|
||||||
|
{
|
||||||
|
for ( auto plot : multiPlot->summaryPlots() )
|
||||||
|
{
|
||||||
|
if ( auto plotWidget = dynamic_cast<RiuQwtPlotWidget*>( plot->plotWidget() ) )
|
||||||
|
{
|
||||||
|
plotWidget->resetPlotItemHighlighting();
|
||||||
|
plotWidget->replot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class RimSummaryCase;
|
class RimSummaryCase;
|
||||||
|
class RimPlotCurve;
|
||||||
class RigEnsembleParameter;
|
class RigEnsembleParameter;
|
||||||
|
|
||||||
namespace RimSummaryEnsembleTools
|
namespace RimSummaryEnsembleTools
|
||||||
@@ -37,4 +38,7 @@ std::vector<RigEnsembleParameter> createVariationSortedEnsembleParameters( const
|
|||||||
|
|
||||||
size_t calculateEnsembleParametersIntersectionHash( const std::vector<RimSummaryCase*>& summaryCases );
|
size_t calculateEnsembleParametersIntersectionHash( const std::vector<RimSummaryCase*>& summaryCases );
|
||||||
|
|
||||||
|
void highlightCurvesForSameRealization( RimPlotCurve* sourceCurve );
|
||||||
|
void resetHighlightAllPlots();
|
||||||
|
|
||||||
} // namespace RimSummaryEnsembleTools
|
} // namespace RimSummaryEnsembleTools
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "RimPlot.h"
|
#include "RimPlot.h"
|
||||||
#include "RimPlotCurve.h"
|
#include "RimPlotCurve.h"
|
||||||
|
#include "RimSummaryEnsembleTools.h"
|
||||||
|
|
||||||
#include "RiuDraggableOverlayFrame.h"
|
#include "RiuDraggableOverlayFrame.h"
|
||||||
#include "RiuGuiTheme.h"
|
#include "RiuGuiTheme.h"
|
||||||
@@ -934,14 +935,24 @@ void RiuQwtPlotWidget::selectClosestPlotItem( const QPoint& pos, bool toggleItem
|
|||||||
{
|
{
|
||||||
bool updateCurveOrder = false;
|
bool updateCurveOrder = false;
|
||||||
resetPlotItemHighlighting( updateCurveOrder );
|
resetPlotItemHighlighting( updateCurveOrder );
|
||||||
std::set<const QwtPlotItem*> plotItems = { closestItem };
|
if ( auto curve = dynamic_cast<RiuPlotCurve*>( closestItem ) )
|
||||||
highlightPlotItems( plotItems );
|
{
|
||||||
|
RimSummaryEnsembleTools::highlightCurvesForSameRealization( curve->ownerRimCurve() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Currently used from the matrix plot to highlight the selected cell in the matrix plot, see
|
||||||
|
// RimCorrelationMatrixPlot::createMatrix()
|
||||||
|
highlightPlotShapeItems( { closestItem } );
|
||||||
|
}
|
||||||
|
|
||||||
auto plotItem = std::make_shared<RiuQwtPlotItem>( closestItem );
|
auto plotItem = std::make_shared<RiuQwtPlotItem>( closestItem );
|
||||||
emit plotItemSelected( plotItem, toggleItemInSelection, distanceFromClick < 10 ? closestCurvePoint : -1 );
|
emit plotItemSelected( plotItem, toggleItemInSelection, distanceFromClick < 10 ? closestCurvePoint : -1 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resetPlotItemHighlighting();
|
RimSummaryEnsembleTools::resetHighlightAllPlots();
|
||||||
|
|
||||||
emit plotSelected( toggleItemInSelection );
|
emit plotSelected( toggleItemInSelection );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -968,10 +979,9 @@ void RiuQwtPlotWidget::replot()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotWidget::highlightPlotItems( const std::set<const QwtPlotItem*>& closestItems )
|
void RiuQwtPlotWidget::highlightCurvesUpdateOrder( const std::set<RimPlotCurve*>& curves )
|
||||||
{
|
{
|
||||||
highlightPlotCurves( closestItems );
|
highlightPlotCurves( curves );
|
||||||
highlightPlotShapeItems( closestItems );
|
|
||||||
|
|
||||||
updateCurveOrder();
|
updateCurveOrder();
|
||||||
}
|
}
|
||||||
@@ -979,7 +989,7 @@ void RiuQwtPlotWidget::highlightPlotItems( const std::set<const QwtPlotItem*>& c
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotWidget::highlightPlotCurves( const std::set<const QwtPlotItem*>& closestItems )
|
void RiuQwtPlotWidget::highlightPlotCurves( const std::set<RimPlotCurve*>& curves )
|
||||||
{
|
{
|
||||||
if ( !m_plotDefinition || !m_plotDefinition->isCurveHighlightSupported() )
|
if ( !m_plotDefinition || !m_plotDefinition->isCurveHighlightSupported() )
|
||||||
{
|
{
|
||||||
@@ -990,10 +1000,12 @@ void RiuQwtPlotWidget::highlightPlotCurves( const std::set<const QwtPlotItem*>&
|
|||||||
for ( QwtPlotItem* plotItem : plotItemList )
|
for ( QwtPlotItem* plotItem : plotItemList )
|
||||||
{
|
{
|
||||||
auto* riuPlotCurve = dynamic_cast<RiuPlotCurve*>( plotItem );
|
auto* riuPlotCurve = dynamic_cast<RiuPlotCurve*>( plotItem );
|
||||||
auto pdmObject = m_plotDefinition->findPdmObjectFromPlotCurve( riuPlotCurve );
|
if ( !riuPlotCurve ) continue;
|
||||||
|
|
||||||
|
auto currentRimPlotCurve = riuPlotCurve->ownerRimCurve();
|
||||||
|
|
||||||
// Do not modify curve objects with no associated Rim object, as the Rim object is used to restore color after highlight manipulation
|
// Do not modify curve objects with no associated Rim object, as the Rim object is used to restore color after highlight manipulation
|
||||||
if ( !pdmObject ) continue;
|
if ( !currentRimPlotCurve ) continue;
|
||||||
|
|
||||||
auto* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem );
|
auto* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem );
|
||||||
if ( plotCurve )
|
if ( plotCurve )
|
||||||
@@ -1014,7 +1026,7 @@ void RiuQwtPlotWidget::highlightPlotCurves( const std::set<const QwtPlotItem*>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
double zValue = plotCurve->z();
|
double zValue = plotCurve->z();
|
||||||
if ( closestItems.count( plotCurve ) > 0 )
|
if ( curves.count( currentRimPlotCurve ) > 0 )
|
||||||
{
|
{
|
||||||
auto highlightColor = curveColor;
|
auto highlightColor = curveColor;
|
||||||
|
|
||||||
@@ -1101,14 +1113,12 @@ void RiuQwtPlotWidget::resetPlotCurveHighlighting()
|
|||||||
const auto& plotItemList = m_plot->itemList();
|
const auto& plotItemList = m_plot->itemList();
|
||||||
for ( QwtPlotItem* plotItem : plotItemList )
|
for ( QwtPlotItem* plotItem : plotItemList )
|
||||||
{
|
{
|
||||||
if ( auto* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem ) )
|
if ( auto* riuPlotCurve = dynamic_cast<RiuQwtPlotCurve*>( plotItem ) )
|
||||||
{
|
{
|
||||||
auto* riuPlotCurve = dynamic_cast<RiuPlotCurve*>( plotItem );
|
if ( auto rimPlotCurve = riuPlotCurve->ownerRimCurve() )
|
||||||
|
|
||||||
if ( auto rimPlotCurve = dynamic_cast<RimPlotCurve*>( m_plotDefinition->findPdmObjectFromPlotCurve( riuPlotCurve ) ) )
|
|
||||||
{
|
{
|
||||||
rimPlotCurve->updateCurveAppearance();
|
rimPlotCurve->updateCurveAppearance();
|
||||||
double zValue = m_originalZValues[plotCurve];
|
double zValue = m_originalZValues[riuPlotCurve];
|
||||||
riuPlotCurve->setZ( zValue );
|
riuPlotCurve->setZ( zValue );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1172,23 +1182,27 @@ void RiuQwtPlotWidget::resetPlotAxisHighlighting()
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RiuQwtPlotWidget::highlightPlotItemsForQwtAxis( QwtAxisId axisId )
|
void RiuQwtPlotWidget::highlightPlotItemsForQwtAxis( QwtAxisId axisId )
|
||||||
{
|
{
|
||||||
std::set<const QwtPlotItem*> plotItems;
|
std::set<RimPlotCurve*> curves;
|
||||||
auto plotItemList = m_plot->itemList();
|
|
||||||
|
auto plotItemList = m_plot->itemList();
|
||||||
for ( QwtPlotItem* plotItem : plotItemList )
|
for ( QwtPlotItem* plotItem : plotItemList )
|
||||||
{
|
{
|
||||||
auto* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem );
|
auto* qwtPlotCurve = dynamic_cast<RiuQwtPlotCurve*>( plotItem );
|
||||||
if ( plotCurve )
|
if ( qwtPlotCurve )
|
||||||
{
|
{
|
||||||
QwtAxisId xAxis = plotCurve->xAxis();
|
QwtAxisId xAxis = qwtPlotCurve->xAxis();
|
||||||
QwtAxisId yAxis = plotCurve->yAxis();
|
QwtAxisId yAxis = qwtPlotCurve->yAxis();
|
||||||
if ( xAxis == axisId || yAxis == axisId )
|
if ( xAxis == axisId || yAxis == axisId )
|
||||||
{
|
{
|
||||||
plotItems.insert( plotItem );
|
if ( auto curve = qwtPlotCurve->ownerRimCurve() )
|
||||||
|
{
|
||||||
|
curves.insert( curve );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
highlightPlotItems( plotItems );
|
highlightCurvesUpdateOrder( curves );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -1550,9 +1564,14 @@ void RiuQwtPlotWidget::highlightPlotItem( const QwtPlotItem* plotItem )
|
|||||||
bool refreshCurveOrder = false;
|
bool refreshCurveOrder = false;
|
||||||
resetPlotItemHighlighting( refreshCurveOrder );
|
resetPlotItemHighlighting( refreshCurveOrder );
|
||||||
|
|
||||||
std::set<const QwtPlotItem*> items;
|
if ( auto curve = dynamic_cast<RiuQwtPlotCurve*>( const_cast<QwtPlotItem*>( plotItem ) ) )
|
||||||
items.insert( plotItem );
|
{
|
||||||
highlightPlotItems( items );
|
highlightCurvesUpdateOrder( { curve->ownerRimCurve() } );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
highlightPlotShapeItems( { plotItem } );
|
||||||
|
}
|
||||||
|
|
||||||
replot();
|
replot();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,6 +165,10 @@ public:
|
|||||||
QwtAxisId toQwtPlotAxis( RiuPlotAxis axis ) const;
|
QwtAxisId toQwtPlotAxis( RiuPlotAxis axis ) const;
|
||||||
|
|
||||||
void highlightPlotItem( const QwtPlotItem* plotItem );
|
void highlightPlotItem( const QwtPlotItem* plotItem );
|
||||||
|
void highlightCurvesUpdateOrder( const std::set<RimPlotCurve*>& curves );
|
||||||
|
void resetPlotItemHighlighting( bool doUpdateCurveOrder = true );
|
||||||
|
|
||||||
|
void replot() override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onLegendClicked( const QVariant& itemInfo, int index );
|
void onLegendClicked( const QVariant& itemInfo, int index );
|
||||||
@@ -202,14 +206,11 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection = false );
|
void selectClosestPlotItem( const QPoint& pos, bool toggleItemInSelection = false );
|
||||||
static int defaultMinimumWidth();
|
static int defaultMinimumWidth();
|
||||||
void replot() override;
|
|
||||||
|
|
||||||
void highlightPlotAxes( QwtAxisId axisIdX, QwtAxisId axisIdY );
|
void highlightPlotAxes( QwtAxisId axisIdX, QwtAxisId axisIdY );
|
||||||
void highlightPlotItemsForQwtAxis( QwtAxisId axisId );
|
void highlightPlotItemsForQwtAxis( QwtAxisId axisId );
|
||||||
void highlightPlotItems( const std::set<const QwtPlotItem*>& closestItems );
|
void highlightPlotCurves( const std::set<RimPlotCurve*>& curves );
|
||||||
void highlightPlotCurves( const std::set<const QwtPlotItem*>& closestItems );
|
|
||||||
void highlightPlotShapeItems( const std::set<const QwtPlotItem*>& closestItems );
|
void highlightPlotShapeItems( const std::set<const QwtPlotItem*>& closestItems );
|
||||||
void resetPlotItemHighlighting( bool doUpdateCurveOrder = true );
|
|
||||||
void resetPlotCurveHighlighting();
|
void resetPlotCurveHighlighting();
|
||||||
void resetPlotShapeItemHighlighting();
|
void resetPlotShapeItemHighlighting();
|
||||||
void resetPlotAxisHighlighting();
|
void resetPlotAxisHighlighting();
|
||||||
|
|||||||
Reference in New Issue
Block a user