diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 958b7bb867..03bc7c1593 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -32,7 +32,6 @@ #include "RiuWellLogTrack.h" #include "cafCmdFeatureMenuBuilder.h" -#include "cafQShortenedLabel.h" #include "cafSelectionManager.h" #include "cvfAssert.h" @@ -95,7 +94,7 @@ RiuWellLogPlot::RiuWellLogPlot( RimWellLogPlot* plotDefinition, QWidget* parent new RiuPlotObjectPicker( m_plotTitle, m_plotDefinition ); - this->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); + this->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding ); setFocusPolicy( Qt::StrongFocus ); connect( m_scrollBar, SIGNAL( valueChanged( int ) ), this, SLOT( slotSetMinDepth( int ) ) ); @@ -135,7 +134,6 @@ void RiuWellLogPlot::insertTrackPlot( RiuWellLogTrack* trackPlot, size_t index ) legendColumns = 0; // unlimited } legend->setMaxColumns( legendColumns ); - legend->horizontalScrollBar()->setVisible( false ); legend->verticalScrollBar()->setVisible( false ); @@ -261,10 +259,9 @@ void RiuWellLogPlot::keyPressEvent( QKeyEvent* keyEvent ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::QShortenedLabel* RiuWellLogPlot::createTitleLabel() const +QLabel* RiuWellLogPlot::createTitleLabel() const { - caf::QShortenedLabel* plotTitle = new caf::QShortenedLabel( nullptr ); - plotTitle->setText( "PLOT TITLE HERE" ); + QLabel* plotTitle = new QLabel( "PLOT TITLE HERE", nullptr ); RiaApplication* app = RiaApplication::instance(); @@ -277,10 +274,19 @@ caf::QShortenedLabel* RiuWellLogPlot::createTitleLabel() const plotTitle->setVisible( m_plotDefinition->isPlotTitleVisible() ); plotTitle->setAlignment( Qt::AlignHCenter ); plotTitle->setWordWrap( true ); - plotTitle->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred ); + plotTitle->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); return plotTitle; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuWellLogPlot::resizeEvent( QResizeEvent* event ) +{ + QWidget::resizeEvent( event ); + updateChildrenLayout(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -341,15 +347,21 @@ void RiuWellLogPlot::reinsertTracks() { if ( m_trackPlots[tIdx]->isRimTrackVisible() ) { + m_trackLayout->addWidget( m_legends[tIdx], 0, static_cast( visibleIndex ) ); + m_trackLayout->addWidget( m_trackPlots[tIdx], 1, static_cast( visibleIndex ) ); + if ( m_plotDefinition->areTrackLegendsVisible() ) { - m_trackPlots[tIdx]->updateLegend(); int legendColumns = 1; if ( m_plotDefinition->areTrackLegendsHorizontal() ) { legendColumns = 0; // unlimited } m_legends[tIdx]->setMaxColumns( legendColumns ); + m_trackPlots[tIdx]->updateLegend(); + int minimumHeight = m_legends[tIdx]->heightForWidth( m_trackPlots[tIdx]->width() ); + m_legends[tIdx]->setMinimumHeight( minimumHeight ); + m_legends[tIdx]->show(); } else @@ -361,10 +373,12 @@ void RiuWellLogPlot::reinsertTracks() m_trackPlots[tIdx]->enableDepthAxisLabelsAndTicks( visibleIndex == 0 ); m_trackPlots[tIdx]->show(); - m_trackLayout->addWidget( m_legends[tIdx], 0, static_cast( visibleIndex ) ); - m_trackLayout->addWidget( m_trackPlots[tIdx], 1, static_cast( visibleIndex ) ); - - m_trackLayout->setColumnStretch( visibleIndex++, m_trackPlots[tIdx]->widthScaleFactor() ); + int widthScaleFactor = m_trackPlots[tIdx]->widthScaleFactor(); + if ( visibleIndex == 0 ) + { + widthScaleFactor += 1; // Give it a bit extra room due to depth axis + } + m_trackLayout->setColumnStretch( visibleIndex, widthScaleFactor ); m_trackLayout->setRowStretch( 1, 1 ); visibleIndex++; } @@ -387,10 +401,6 @@ void RiuWellLogPlot::clearTrackLayout() while ( ( item = m_trackLayout->takeAt( 0 ) ) != 0 ) { } - QWidget().setLayout( m_trackLayout ); - QPointer newGridLayout = new QGridLayout( m_trackFrame ); - m_trackLayout.swap( newGridLayout ); - newGridLayout->deleteLater(); } } diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.h b/ApplicationCode/UserInterface/RiuWellLogPlot.h index 676db21b54..61cdfc93a4 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.h +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.h @@ -36,14 +36,10 @@ class RimWellLogPlot; class RiuWellLogTrack; class QFocusEvent; +class QLabel; class QScrollBar; class QwtLegend; -namespace caf -{ -class QShortenedLabel; -} - //================================================================================================== // // RiuWellLogPlot @@ -78,7 +74,9 @@ protected: void contextMenuEvent( QContextMenuEvent* ) override; void keyPressEvent( QKeyEvent* keyEvent ) override; - caf::QShortenedLabel* createTitleLabel() const; + QLabel* createTitleLabel() const; + + void resizeEvent( QResizeEvent* event ) override; private: void updateScrollBar( double minDepth, double maxDepth ); @@ -94,7 +92,7 @@ protected: QPointer m_plotLayout; QPointer m_trackFrame; QPointer m_trackLayout; - QPointer m_plotTitle; + QPointer m_plotTitle; QPointer m_scrollBarLayout; QScrollBar* m_scrollBar; QList> m_legends;