From 4852f729ffdba4a36216bcc46924e74f9f409067 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 27 Sep 2019 10:22:07 +0200 Subject: [PATCH] #4781 Make sure horizontal well log plot legends expand vertically if needed. --- ApplicationCode/UserInterface/RiuWellLogPlot.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 1f5ea251f3..17c0dc947f 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -379,6 +379,8 @@ void RiuWellLogPlot::alignCanvasTops() } } + int legendHeight = 0; + for ( int tIdx = 0; tIdx < m_trackPlots.size(); ++tIdx ) { if ( m_trackPlots[tIdx]->isVisible() ) @@ -395,13 +397,18 @@ void RiuWellLogPlot::alignCanvasTops() QMargins margins = m_trackPlots[tIdx]->contentsMargins(); margins.setTop( margins.top() + canvasShift ); m_trackPlots[tIdx]->setContentsMargins( margins ); + + if ( m_legends[tIdx]->isVisible() ) + { + legendHeight = std::max( legendHeight, m_legends[tIdx]->heightForWidth( canvasRect.width() ) ); + } } } - if ( m_trackLayout->columnCount() > 0 && m_trackLayout->rowCount() > 0 ) + if ( m_plotDefinition->areTrackLegendsVisible() && m_trackLayout->columnCount() > 0 && m_trackLayout->rowCount() > 0 ) { - int legendHeight = m_trackLayout->cellRect( 0, 0 ).height(); m_scrollBarLayout->setContentsMargins( 0, legendHeight, 0, 0 ); + m_trackLayout->setRowMinimumHeight( 0, legendHeight ); } } @@ -417,7 +424,7 @@ void RiuWellLogPlot::reinsertTracks() { m_trackLayout->addWidget( m_legends[tIdx], 0, static_cast( visibleIndex ) ); m_trackLayout->addWidget( m_trackPlots[tIdx], 1, static_cast( visibleIndex ) ); - m_trackLayout->setRowStretch( 1, 1 ); + m_trackLayout->setRowStretch( 1, 10 ); if ( !m_plotDefinition->areTrackLegendsVisible() ) {