mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Refactored ensemble parameter legends
This commit is contained in:
@@ -429,6 +429,38 @@ void RiuQwtPlotWidget::setWidgetState( const QString& widgetState )
|
||||
m_plotStyleSheet.setWidgetState( this, widgetState );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Adds an overlay frame. The overlay frame becomes the responsibility of the plot widget
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::addOverlayFrame( QFrame* overlayFrame )
|
||||
{
|
||||
if ( std::find( m_overlayFrames.begin(), m_overlayFrames.end(), overlayFrame ) == m_overlayFrames.end() )
|
||||
{
|
||||
overlayFrame->setParent( this );
|
||||
m_overlayFrames.push_back( overlayFrame );
|
||||
updateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Remove the overlay widget. The frame becomes the responsibility of the caller
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::removeOverlayFrame( QFrame* overlayFrame )
|
||||
{
|
||||
overlayFrame->hide();
|
||||
overlayFrame->setParent( nullptr );
|
||||
m_overlayFrames.removeOne( overlayFrame );
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::updateLayout()
|
||||
{
|
||||
QwtPlot::updateLayout();
|
||||
updateOverlayFrameLayout();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -642,6 +674,36 @@ caf::UiStyleSheet RiuQwtPlotWidget::createCanvasStyleSheet() const
|
||||
return styleSheet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::updateOverlayFrameLayout()
|
||||
{
|
||||
const int spacing = 5;
|
||||
int startMarginX = this->canvas()->pos().x() + spacing;
|
||||
int startMarginY = this->canvas()->pos().y() + spacing;
|
||||
|
||||
int xpos = startMarginX;
|
||||
int ypos = startMarginY;
|
||||
int maxColumnWidth = 0;
|
||||
for ( QPointer<QFrame> frame : m_overlayFrames )
|
||||
{
|
||||
if ( !frame.isNull() )
|
||||
{
|
||||
if ( ypos + frame->height() + spacing > this->canvas()->height() )
|
||||
{
|
||||
xpos += spacing + maxColumnWidth;
|
||||
ypos = startMarginY;
|
||||
maxColumnWidth = 0;
|
||||
}
|
||||
frame->move( xpos, ypos );
|
||||
ypos += frame->height() + spacing;
|
||||
maxColumnWidth = std::max( maxColumnWidth, frame->width() );
|
||||
frame->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user