Avoid plot title dictating the plot width.

This commit is contained in:
Gaute Lindkvist
2019-10-04 08:50:35 +02:00
parent 45d6acadaa
commit 09388b22c8
2 changed files with 21 additions and 8 deletions

View File

@@ -20,6 +20,7 @@
#include "RiuWellLogPlot.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "RimContextCommandBuilder.h"
#include "RimWellLogPlot.h"
@@ -31,6 +32,7 @@
#include "RiuWellLogTrack.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafQShortenedLabel.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
@@ -186,7 +188,6 @@ void RiuWellLogPlot::setDepthZoomAndReplot( double minDepth, double maxDepth )
void RiuWellLogPlot::setPlotTitle( const QString& plotTitle )
{
m_plotTitle->setText( plotTitle );
this->updateChildrenLayout();
}
//--------------------------------------------------------------------------------------------------
@@ -260,15 +261,23 @@ void RiuWellLogPlot::keyPressEvent( QKeyEvent* keyEvent )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QLabel* RiuWellLogPlot::createTitleLabel() const
caf::QShortenedLabel* RiuWellLogPlot::createTitleLabel() const
{
QLabel* plotTitle = new QLabel( "PLOT TITLE HERE", nullptr );
QFont font = plotTitle->font();
font.setPointSize( 14 );
caf::QShortenedLabel* plotTitle = new caf::QShortenedLabel( nullptr );
plotTitle->setText( "PLOT TITLE HERE" );
RiaApplication* app = RiaApplication::instance();
QFont font = plotTitle->font();
int defaultFontSize = RiaFontCache::pointSizeFromFontSizeEnum( app->preferences()->defaultPlotFontSize() );
font.setPointSize( defaultFontSize + 1 );
font.setBold( true );
plotTitle->setFont( font );
plotTitle->setVisible( m_plotDefinition->isPlotTitleVisible() );
plotTitle->setAlignment( Qt::AlignHCenter );
plotTitle->setWordWrap( true );
plotTitle->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
return plotTitle;
}

View File

@@ -36,10 +36,14 @@ class RimWellLogPlot;
class RiuWellLogTrack;
class QFocusEvent;
class QLabel;
class QScrollBar;
class QwtLegend;
namespace caf
{
class QShortenedLabel;
}
//==================================================================================================
//
// RiuWellLogPlot
@@ -74,7 +78,7 @@ protected:
void contextMenuEvent( QContextMenuEvent* ) override;
void keyPressEvent( QKeyEvent* keyEvent ) override;
QLabel* createTitleLabel() const;
caf::QShortenedLabel* createTitleLabel() const;
private:
void updateScrollBar( double minDepth, double maxDepth );
@@ -90,7 +94,7 @@ protected:
QPointer<QHBoxLayout> m_plotLayout;
QPointer<QFrame> m_trackFrame;
QPointer<QGridLayout> m_trackLayout;
QPointer<QLabel> m_plotTitle;
QPointer<caf::QShortenedLabel> m_plotTitle;
QPointer<QVBoxLayout> m_scrollBarLayout;
QScrollBar* m_scrollBar;
QList<QPointer<QwtLegend>> m_legends;