mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05: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
@@ -611,7 +611,38 @@ bool RiuQwtPlotWidget::eventFilter( QObject* watched, QEvent* event )
|
||||
{
|
||||
endZoomOperations();
|
||||
|
||||
selectClosestPlotItem( mouseEvent->pos(), toggleItemInSelection );
|
||||
auto hasRecentlyBeenZoomed = [this]() -> bool
|
||||
{
|
||||
if ( !m_plotDefinition ) return false;
|
||||
auto lastZoom = m_plotDefinition->valueForKey( "TimeStampZoomOperation" );
|
||||
if ( lastZoom.has_value() )
|
||||
{
|
||||
try
|
||||
{
|
||||
auto retrieved_time = std::any_cast<std::chrono::steady_clock::time_point>( lastZoom );
|
||||
auto t0 = std::chrono::steady_clock::now();
|
||||
|
||||
auto timeDiff = std::chrono::duration_cast<std::chrono::milliseconds>( t0 - retrieved_time ).count();
|
||||
if ( timeDiff < 10 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if ( !hasRecentlyBeenZoomed() )
|
||||
{
|
||||
// Avoid selecting the curve if a zoom operation has been performed recently
|
||||
// It is confusing to select a curve when the user is trying to zoom
|
||||
|
||||
selectClosestPlotItem( mouseEvent->pos(), toggleItemInSelection );
|
||||
}
|
||||
|
||||
m_clickPosition = QPoint();
|
||||
return true;
|
||||
}
|
||||
@@ -931,22 +962,47 @@ void RiuQwtPlotWidget::selectClosestPlotItem( const QPoint& pos, bool toggleItem
|
||||
findClosestPlotItem( pos, &closestItem, &closestCurvePoint, &distanceFromClick );
|
||||
|
||||
RiuPlotMainWindowTools::showPlotMainWindow();
|
||||
if ( closestItem && distanceFromClick < 20 )
|
||||
if ( closestItem )
|
||||
{
|
||||
RimPlotCurve* clickedCurve = nullptr;
|
||||
if ( auto curve = dynamic_cast<RiuPlotCurve*>( closestItem ) )
|
||||
{
|
||||
clickedCurve = curve->ownerRimCurve();
|
||||
}
|
||||
|
||||
std::vector<RimPlotCurve*> curvesToSelect;
|
||||
|
||||
bool wasToggledOff = false;
|
||||
if ( toggleItemInSelection )
|
||||
{
|
||||
for ( auto highlightedCurve : m_hightlightedCurves )
|
||||
{
|
||||
if ( toggleItemInSelection && ( highlightedCurve == clickedCurve ) )
|
||||
{
|
||||
wasToggledOff = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
curvesToSelect.push_back( highlightedCurve );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !wasToggledOff && clickedCurve ) curvesToSelect.push_back( clickedCurve );
|
||||
|
||||
bool updateCurveOrder = false;
|
||||
resetPlotItemHighlighting( updateCurveOrder );
|
||||
|
||||
auto curve = dynamic_cast<RiuPlotCurve*>( closestItem );
|
||||
if ( curve && curve->ownerRimCurve() )
|
||||
if ( !curvesToSelect.empty() )
|
||||
{
|
||||
const auto rimCurve = curve->ownerRimCurve();
|
||||
if ( RimSummaryEnsembleTools::isEnsembleCurve( rimCurve ) )
|
||||
if ( RimSummaryEnsembleTools::isEnsembleCurve( curvesToSelect.front() ) )
|
||||
{
|
||||
RimSummaryEnsembleTools::highlightCurvesForSameRealizationFromCurve( rimCurve );
|
||||
auto summaryCases = RimSummaryEnsembleTools::summaryCasesFromCurves( curvesToSelect );
|
||||
RimSummaryEnsembleTools::selectSummaryCasesInProjectTree( summaryCases );
|
||||
RimSummaryEnsembleTools::highlightCurvesForSummaryCases( summaryCases );
|
||||
}
|
||||
else
|
||||
{
|
||||
highlightCurvesUpdateOrder( { rimCurve } );
|
||||
highlightCurvesUpdateOrder( curvesToSelect );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -989,7 +1045,7 @@ void RiuQwtPlotWidget::replot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::highlightCurvesUpdateOrder( const std::set<RimPlotCurve*>& curves )
|
||||
void RiuQwtPlotWidget::highlightCurvesUpdateOrder( const std::vector<RimPlotCurve*>& curves )
|
||||
{
|
||||
highlightPlotCurves( curves );
|
||||
|
||||
@@ -999,7 +1055,7 @@ void RiuQwtPlotWidget::highlightCurvesUpdateOrder( const std::set<RimPlotCurve*>
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::highlightPlotCurves( const std::set<RimPlotCurve*>& curves )
|
||||
void RiuQwtPlotWidget::highlightPlotCurves( const std::vector<RimPlotCurve*>& curves )
|
||||
{
|
||||
if ( !m_plotDefinition || !m_plotDefinition->isCurveHighlightSupported() )
|
||||
{
|
||||
@@ -1014,7 +1070,8 @@ void RiuQwtPlotWidget::highlightPlotCurves( const std::set<RimPlotCurve*>& curve
|
||||
|
||||
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 ( !currentRimPlotCurve ) continue;
|
||||
|
||||
auto* plotCurve = dynamic_cast<QwtPlotCurve*>( plotItem );
|
||||
@@ -1036,7 +1093,9 @@ void RiuQwtPlotWidget::highlightPlotCurves( const std::set<RimPlotCurve*>& curve
|
||||
}
|
||||
|
||||
double zValue = plotCurve->z();
|
||||
if ( curves.count( currentRimPlotCurve ) > 0 )
|
||||
|
||||
auto it = std::find( curves.begin(), curves.end(), currentRimPlotCurve );
|
||||
if ( it != curves.end() )
|
||||
{
|
||||
auto highlightColor = curveColor;
|
||||
|
||||
@@ -1204,7 +1263,7 @@ void RiuQwtPlotWidget::resetPlotAxisHighlighting()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::highlightPlotItemsForQwtAxis( QwtAxisId axisId )
|
||||
{
|
||||
std::set<RimPlotCurve*> curves;
|
||||
std::vector<RimPlotCurve*> curves;
|
||||
|
||||
auto plotItemList = m_plot->itemList();
|
||||
for ( QwtPlotItem* plotItem : plotItemList )
|
||||
@@ -1218,12 +1277,15 @@ void RiuQwtPlotWidget::highlightPlotItemsForQwtAxis( QwtAxisId axisId )
|
||||
{
|
||||
if ( auto curve = qwtPlotCurve->ownerRimCurve() )
|
||||
{
|
||||
curves.insert( curve );
|
||||
curves.push_back( curve );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort( curves.begin(), curves.end() );
|
||||
curves.erase( std::unique( curves.begin(), curves.end() ), curves.end() );
|
||||
|
||||
highlightCurvesUpdateOrder( curves );
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user