Avoid duplicate plots when appending wells and keep legend order same as project tree

Skip appending plots for wells, groups and networks already present in the multi plot. Reattach curves in project tree order only when the attached order differs.
This commit is contained in:
Magne Sjaastad committed 2026-10-24 13:14:41 +02:00
1 parent 186c4795f9
commit cb60a8b9ae
4 files changed
+101

No files matched your search

@@ -1306,6 +1306,39 @@ std::vector<caf::PdmPointer<RimPlotCurve>> RiuQwtPlotWidget::highlightedCurves()
return m_highlightedCurves;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuQwtPlotWidget::isCurveOrderConsistentWith( const std::vector<RimPlotCurve*>& expectedOrder ) const
{
std::map<const RimPlotCurve*, size_t> expectedIndex;
for ( size_t i = 0; i < expectedOrder.size(); i++ )
{
expectedIndex[expectedOrder[i]] = i;
}
// Plot items are sorted by z-value, and items with equal z-value are kept in attach order
bool hasPrevious = false;
double previousZ = 0.0;
size_t previousIdx = 0;
for ( const QwtPlotItem* plotItem : m_plot->itemList() )
{
auto* riuPlotCurve = dynamic_cast<const RiuQwtPlotCurve*>( plotItem );
if ( !riuPlotCurve ) continue;
auto it = expectedIndex.find( riuPlotCurve->ownerRimCurve() );
if ( it == expectedIndex.end() ) continue;
if ( hasPrevious && plotItem->z() == previousZ && it->second < previousIdx ) return false;
hasPrevious = true;
previousZ = plotItem->z();
previousIdx = it->second;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -167,6 +167,9 @@ public:
void resetPlotItemHighlighting( bool doUpdateCurveOrder = true );
std::vector<caf::PdmPointer<RimPlotCurve>> highlightedCurves() const;
// True if curves with equal z-value are attached in the same relative order as in the given list
bool isCurveOrderConsistentWith( const std::vector<RimPlotCurve*>& expectedOrder ) const;
// Highlights the plot item closest to the given position, given in widget coordinates. Unlike a left-click, this
// only applies the visual highlight and does not change the project tree / selection manager selection.
void highlightClosestPlotItemAtPosition( const QPoint& widgetPos );