mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#9293 MultiPlot: avoid removing non-legend overlays.
The plots can have other kinds of overlays that should not be removed. Fixes #9293.
This commit is contained in:
parent
7b81490f90
commit
dfbdfaa726
@ -170,7 +170,11 @@ void RiuMultiPlotPage::insertPlot( RiuPlotWidget* plotWidget, size_t index )
|
||||
subTitle->setVisible( false );
|
||||
m_subTitles.insert( static_cast<int>( index ), subTitle );
|
||||
|
||||
plotWidget->clearOverlayFrames();
|
||||
// Remove legend overlays already attached to the plot widget
|
||||
auto matcher = []( RiuDraggableOverlayFrame* p ) {
|
||||
return dynamic_cast<RiuQwtLegendOverlayContentFrame*>( p->contentFrame() ) != nullptr;
|
||||
};
|
||||
plotWidget->clearOverlayFrames( matcher );
|
||||
|
||||
RiuQwtPlotWidget* qwtPlotWidget = dynamic_cast<RiuQwtPlotWidget*>( plotWidget );
|
||||
|
||||
|
@ -169,13 +169,18 @@ void RiuPlotWidget::removeOverlayFrame( RiuDraggableOverlayFrame* overlayFrame )
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Remove all overlay widgets.
|
||||
/// Remove overlay widgets matching a given criteria
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuPlotWidget::clearOverlayFrames()
|
||||
void RiuPlotWidget::clearOverlayFrames( std::function<bool( RiuDraggableOverlayFrame* )> matcher )
|
||||
{
|
||||
for ( auto p : m_overlayFrames )
|
||||
p->deleteLater();
|
||||
m_overlayFrames.clear();
|
||||
{
|
||||
if ( matcher( p ) )
|
||||
{
|
||||
removeOverlayFrame( p );
|
||||
p->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -163,9 +163,10 @@ public:
|
||||
void scheduleReplot();
|
||||
virtual void replot() = 0;
|
||||
|
||||
void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
|
||||
void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
|
||||
void clearOverlayFrames();
|
||||
void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
|
||||
void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
|
||||
void clearOverlayFrames( std::function<bool( RiuDraggableOverlayFrame* )> matcher );
|
||||
|
||||
virtual void updateLayout() = 0;
|
||||
|
||||
virtual void renderTo( QPainter* painter, const QRect& targetRect, double scaling ) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user