mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 15:10:22 -05:00
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:
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 );
|
||||
|
||||
Reference in new issue
Block a user