mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improve plot titles and layout adjustments
This commit is contained in:
parent
8e777bd987
commit
aaecd846fd
@ -22,6 +22,7 @@
|
||||
|
||||
#include <cctype>
|
||||
#include <charconv>
|
||||
#include <regex>
|
||||
|
||||
const std::string WHITESPACE = " \n\r\t\f\v";
|
||||
|
||||
@ -259,3 +260,14 @@ int RiaStdStringTools::computeEditDistance( const std::string& x, const std::str
|
||||
// The distance between the two full strings as the last value computed.
|
||||
return T[m][n];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RiaStdStringTools::removeHtmlTags( const std::string& s )
|
||||
{
|
||||
std::regex html_tags( "<.*?>" ); // Matches any HTML tag
|
||||
std::string result = std::regex_replace( s, html_tags, "" );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ public:
|
||||
|
||||
static int computeEditDistance( const std::string& x, const std::string& y );
|
||||
|
||||
static std::string removeHtmlTags( const std::string& s );
|
||||
|
||||
private:
|
||||
template <class Container>
|
||||
static void splitByDelimiter( const std::string& str, Container& cont, char delimiter = ' ' );
|
||||
|
@ -703,6 +703,15 @@ void RimFlowCharacteristicsPlot::onLoadDataAndUpdate()
|
||||
|
||||
m_timeStepToFlowResultMap = timeStepToFlowResultMap;
|
||||
|
||||
if ( m_case() )
|
||||
{
|
||||
m_flowCharPlotWidget->setCaseName( m_case()->caseUserDescription() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flowCharPlotWidget->setCaseName( "" );
|
||||
}
|
||||
|
||||
m_flowCharPlotWidget->setLorenzCurve( timeStepStrings, timeStepDates, lorenzVals );
|
||||
|
||||
for ( int timeStepIdx : m_currentlyPlottedTimeSteps )
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
|
||||
#include "RigAccWellFlowCalculator.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
@ -55,6 +56,8 @@
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
|
||||
#include "qwt_scale_draw.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimWellAllocationOverTimePlot, "RimWellAllocationOverTimePlot" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -281,6 +284,16 @@ RiuPlotWidget* RimWellAllocationOverTimePlot::doCreatePlotViewWidget( QWidget* m
|
||||
// Workaround: Enable axis title for bottom axis to activate correct font size for date axis
|
||||
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultBottom(), true );
|
||||
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true );
|
||||
|
||||
if ( auto qwtPlot = m_plotWidget->qwtPlot() )
|
||||
{
|
||||
auto scaleDraw = qwtPlot->axisScaleDraw( QwtAxis::XBottom );
|
||||
if ( scaleDraw )
|
||||
{
|
||||
scaleDraw->setLabelRotation( 30.0 );
|
||||
}
|
||||
}
|
||||
|
||||
m_plotWidget->insertLegend( RiuPlotWidget::Legend::RIGHT );
|
||||
|
||||
m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "[Date]" );
|
||||
@ -393,7 +406,10 @@ void RimWellAllocationOverTimePlot::updateFromWell()
|
||||
QString newDescription = descriptionText + ", " + valueTypeText;
|
||||
|
||||
setDescription( newDescription );
|
||||
m_plotWidget->setWindowTitle( newDescription );
|
||||
|
||||
const auto windowTitle = RiaStdStringTools::removeHtmlTags( newDescription.toStdString() );
|
||||
m_plotWidget->setWindowTitle( QString::fromStdString( windowTitle ) );
|
||||
|
||||
m_plotWidget->setPlotTitle( descriptionText + "<br>" + valueTypeText + "</br>" );
|
||||
m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), valueTypeText );
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
#include "RiaWellFlowDefines.h"
|
||||
|
||||
#include "RigAccWellFlowCalculator.h"
|
||||
@ -677,6 +678,9 @@ void RimWellConnectivityTable::onLoadDataAndUpdate()
|
||||
m_matrixPlotWidget->setAxisTitleFontSize( axisTitleFontSize() );
|
||||
m_matrixPlotWidget->setAxisLabelFontSize( axisLabelFontSize() );
|
||||
|
||||
const auto windowTitle = RiaStdStringTools::removeHtmlTags( createTableTitle().toStdString() );
|
||||
m_matrixPlotWidget->setWindowTitle( QString::fromStdString( windowTitle ) );
|
||||
|
||||
m_matrixPlotWidget->createPlot();
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,6 @@ void RimWellDistributionPlot::onLoadDataAndUpdate()
|
||||
const QString timeStepName = m_case ? m_case->timeStepName( m_timeStepIndex ) : "N/A";
|
||||
|
||||
const QString plotTitleStr = QString( "%1 Distribution: %2, %3" ).arg( phaseString ).arg( m_wellName ).arg( timeStepName );
|
||||
m_plotWidget->setPlotTitleRenderingFlags( Qt::AlignHCenter | Qt::TextWordWrap );
|
||||
m_plotWidget->setPlotTitle( plotTitleStr );
|
||||
|
||||
m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultBottom(), "TOF [years]" );
|
||||
|
@ -18,6 +18,9 @@
|
||||
|
||||
#include "RimWellDistributionPlotCollection.h"
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RimEclipseCaseTools.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
@ -28,8 +31,6 @@
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigTofWellDistributionCalculator.h"
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
|
||||
#include "RiuMultiPlotPage.h"
|
||||
#include "RiuPlotWidget.h"
|
||||
#include "RiuQwtPlotTools.h"
|
||||
@ -200,6 +201,12 @@ QWidget* RimWellDistributionPlotCollection::createViewWidget( QWidget* mainWindo
|
||||
{
|
||||
m_viewer = new RiuMultiPlotPage( this, mainWindowParent );
|
||||
m_viewer->setPlotTitle( m_plotWindowTitle );
|
||||
|
||||
auto pointSize =
|
||||
caf::FontTools::absolutePointSize( RiaPreferences::current()->defaultPlotFontSize(), caf::FontTools::RelativeSize::XLarge );
|
||||
|
||||
m_viewer->setTitleFontSizes( pointSize, pointSize );
|
||||
|
||||
recreatePlotWidgets();
|
||||
|
||||
return m_viewer;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
#include "RiaTimeHistoryCurveResampler.h"
|
||||
|
||||
@ -86,6 +87,7 @@ RimSummaryTable::RimSummaryTable()
|
||||
|
||||
// Table settings
|
||||
CAF_PDM_InitField( &m_showValueLabels, "ShowValueLabels", false, "Show Value Labels" );
|
||||
CAF_PDM_InitField( &m_maxTimeLabelCount, "MaxTimeLabelCount", 20, "Maximum Time Label Count" );
|
||||
|
||||
// Font control
|
||||
CAF_PDM_InitFieldNoDefault( &m_axisTitleFontSize, "AxisTitleFontSize", "Axis Title Font Size" );
|
||||
@ -283,6 +285,10 @@ void RimSummaryTable::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
}
|
||||
onLoadDataAndUpdate();
|
||||
}
|
||||
else if ( changedField == &m_maxTimeLabelCount )
|
||||
{
|
||||
onLoadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -323,6 +329,7 @@ void RimSummaryTable::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering
|
||||
fontGroup->add( &m_axisTitleFontSize );
|
||||
fontGroup->add( &m_axisLabelFontSize );
|
||||
fontGroup->add( &m_valueLabelFontSize );
|
||||
fontGroup->add( &m_maxTimeLabelCount );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
@ -464,6 +471,10 @@ void RimSummaryTable::onLoadDataAndUpdate()
|
||||
m_matrixPlotWidget->setLegendFontSize( legendFontSize() );
|
||||
m_matrixPlotWidget->setAxisTitleFontSize( axisTitleFontSize() );
|
||||
m_matrixPlotWidget->setAxisLabelFontSize( axisLabelFontSize() );
|
||||
m_matrixPlotWidget->setMaxColumnLabelCount( m_maxTimeLabelCount() );
|
||||
|
||||
const auto windowTitle = RiaStdStringTools::removeHtmlTags( title.toStdString() );
|
||||
m_matrixPlotWidget->setWindowTitle( QString::fromStdString( windowTitle ) );
|
||||
|
||||
m_matrixPlotWidget->createPlot();
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ private:
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_axisLabelFontSize;
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_valueLabelFontSize;
|
||||
caf::PdmField<bool> m_showValueLabels;
|
||||
caf::PdmField<int> m_maxTimeLabelCount;
|
||||
|
||||
caf::PdmField<RimRegularLegendConfig::MappingEnum> m_mappingType;
|
||||
caf::PdmField<caf::AppEnum<RangeType>> m_rangeType;
|
||||
|
@ -154,6 +154,21 @@ RiuFlowCharacteristicsPlot::~RiuFlowCharacteristicsPlot()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuFlowCharacteristicsPlot::setCaseName( const QString& caseName )
|
||||
{
|
||||
QString title = "Lorenz Coefficient";
|
||||
if ( !caseName.isEmpty() )
|
||||
{
|
||||
title += " - " + caseName;
|
||||
}
|
||||
m_lorenzPlot->setTitle( title );
|
||||
|
||||
setWindowTitle( title );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -308,14 +323,6 @@ void RiuFlowCharacteristicsPlot::showLegend( bool show )
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowCharacteristicsPlot* RiuFlowCharacteristicsPlot::ownerPlotDefinition()
|
||||
{
|
||||
return m_plotDefinition;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
RiuFlowCharacteristicsPlot( RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = nullptr );
|
||||
~RiuFlowCharacteristicsPlot() override;
|
||||
|
||||
void setCaseName( const QString& caseName );
|
||||
void setLorenzCurve( const QStringList& dateTimeStrings,
|
||||
const std::vector<QDateTime>& dateTimes,
|
||||
const std::vector<double>& timeHistoryValues );
|
||||
@ -62,8 +63,7 @@ public:
|
||||
|
||||
void showLegend( bool show );
|
||||
|
||||
RimFlowCharacteristicsPlot* ownerPlotDefinition();
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
RimViewWindow* ownerViewWindow() const override;
|
||||
|
||||
static void addWindowZoom( QwtPlot* plot );
|
||||
static RiuQwtPlotCurve* createEmptyCurve( QwtPlot* plot, const QString& curveName, const QColor& curveColor );
|
||||
|
@ -334,6 +334,14 @@ void RiuMatrixPlotWidget::setValueFontSize( int fontSize )
|
||||
m_plotWidget->scheduleReplot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMatrixPlotWidget::setMaxColumnLabelCount( int maxLabelCount )
|
||||
{
|
||||
m_maxColumnLabelCount = maxLabelCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -342,7 +350,8 @@ void RiuMatrixPlotWidget::updateAxes()
|
||||
if ( !m_plotWidget ) return;
|
||||
|
||||
// Labels on y-axis
|
||||
m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::YLeft, new TextScaleDraw( createIndexLabelMap( m_rowHeaders ) ) );
|
||||
const int maxLabelCount = 1000;
|
||||
m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::YLeft, new TextScaleDraw( createIndexLabelMap( m_rowHeaders, maxLabelCount ) ) );
|
||||
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::YLeft, new RiuQwtLinearScaleEngine );
|
||||
m_plotWidget->setAxisTitleText( RiuPlotAxis::defaultLeft(), m_rowTitle );
|
||||
m_plotWidget->setAxisTitleEnabled( RiuPlotAxis::defaultLeft(), true );
|
||||
@ -358,7 +367,7 @@ void RiuMatrixPlotWidget::updateAxes()
|
||||
static_cast<double>( m_rowHeaders.size() ) );
|
||||
|
||||
// Labels on column axis
|
||||
auto scaleDraw = new TextScaleDraw( createIndexLabelMap( m_columnHeaders ) );
|
||||
auto scaleDraw = new TextScaleDraw( createIndexLabelMap( m_columnHeaders, m_maxColumnLabelCount ) );
|
||||
scaleDraw->setLabelRotation( 30.0 );
|
||||
m_plotWidget->qwtPlot()->setAxisScaleDraw( QwtAxis::XBottom, scaleDraw );
|
||||
m_plotWidget->qwtPlot()->setAxisScaleEngine( QwtAxis::XBottom, new RiuQwtLinearScaleEngine );
|
||||
@ -437,13 +446,26 @@ void RiuMatrixPlotWidget::createMatrixCells()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<size_t, QString> RiuMatrixPlotWidget::createIndexLabelMap( const std::vector<QString>& labels )
|
||||
std::map<size_t, QString> RiuMatrixPlotWidget::createIndexLabelMap( const std::vector<QString>& labels, int maxLabelCount )
|
||||
{
|
||||
std::map<size_t, QString> indexLabelMap;
|
||||
for ( size_t i = 0; i < labels.size(); ++i )
|
||||
if ( labels.empty() ) return {};
|
||||
|
||||
int increment = 1;
|
||||
if ( (int)labels.size() > maxLabelCount )
|
||||
{
|
||||
indexLabelMap.emplace( i, labels[i] );
|
||||
increment = (int)labels.size() / ( maxLabelCount - 1 );
|
||||
increment = std::max( 1, increment );
|
||||
}
|
||||
|
||||
std::map<size_t, QString> indexLabelMap;
|
||||
for ( size_t i = 0; i < std::min( labels.size(), size_t( maxLabelCount - 1 ) ); ++i )
|
||||
{
|
||||
auto index = i * increment;
|
||||
indexLabelMap.emplace( index, labels[index] );
|
||||
}
|
||||
|
||||
indexLabelMap.emplace( labels.size() - 1, labels.back() );
|
||||
|
||||
return indexLabelMap;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
void setAxisTitleFontSize( int fontSize );
|
||||
void setAxisLabelFontSize( int fontSize );
|
||||
void setValueFontSize( int fontSize );
|
||||
void setMaxColumnLabelCount( int maxLabelCount );
|
||||
|
||||
void scheduleReplot();
|
||||
|
||||
@ -86,7 +87,7 @@ private slots:
|
||||
private:
|
||||
void updateAxes();
|
||||
void createMatrixCells();
|
||||
std::map<size_t, QString> createIndexLabelMap( const std::vector<QString>& labels );
|
||||
std::map<size_t, QString> createIndexLabelMap( const std::vector<QString>& labels, int maxLabelCount );
|
||||
|
||||
private:
|
||||
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
||||
@ -107,7 +108,8 @@ private:
|
||||
|
||||
QString m_rowTitle;
|
||||
QString m_columnTitle;
|
||||
int m_axisTitleFontSize = 8;
|
||||
int m_axisLabelFontSize = 8;
|
||||
int m_valueFontSize = 8;
|
||||
int m_axisTitleFontSize = 8;
|
||||
int m_axisLabelFontSize = 8;
|
||||
int m_valueFontSize = 8;
|
||||
int m_maxColumnLabelCount = 100;
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ RiuPlotWidget::RiuPlotWidget( RimPlot* plotDefinition, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_plotDefinition( plotDefinition )
|
||||
, m_overlayMargins( 5 )
|
||||
, m_plotTitle( "" )
|
||||
, m_plotTitleText( "" )
|
||||
, m_plotTitleEnabled( true )
|
||||
{
|
||||
}
|
||||
@ -107,7 +107,7 @@ int RiuPlotWidget::rowSpan() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString& RiuPlotWidget::plotTitle() const
|
||||
{
|
||||
return m_plotTitle;
|
||||
return m_plotTitleText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -202,7 +202,7 @@ protected:
|
||||
std::map<RiuPlotAxis, QString> m_axisTitles;
|
||||
std::map<RiuPlotAxis, bool> m_axisTitlesEnabled;
|
||||
const int m_overlayMargins;
|
||||
QString m_plotTitle;
|
||||
QString m_plotTitleText;
|
||||
bool m_plotTitleEnabled;
|
||||
|
||||
QList<QPointer<RiuDraggableOverlayFrame>> m_overlayFrames;
|
||||
|
@ -235,7 +235,7 @@ void RiuQtChartsPlotWidget::setAxisFormat( RiuPlotAxis axis, const QString& form
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQtChartsPlotWidget::setPlotTitle( const QString& plotTitle )
|
||||
{
|
||||
m_plotTitle = plotTitle;
|
||||
m_plotTitleText = plotTitle;
|
||||
applyPlotTitleToPlot();
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ void RiuQtChartsPlotWidget::setPlotTitle( const QString& plotTitle )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString& RiuQtChartsPlotWidget::plotTitle() const
|
||||
{
|
||||
return m_plotTitle;
|
||||
return m_plotTitleText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -547,7 +547,7 @@ void RiuQtChartsPlotWidget::keyPressEvent( QKeyEvent* event )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQtChartsPlotWidget::applyPlotTitleToPlot()
|
||||
{
|
||||
QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitle : QString( "" );
|
||||
QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitleText : QString( "" );
|
||||
m_viewer->chart()->setTitle( plotTitleToApply );
|
||||
m_viewer->chart()->update();
|
||||
}
|
||||
|
@ -78,7 +78,8 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuQwtPlotWidget::RiuQwtPlotWidget( RimPlot* plotDefinition, QWidget* parent )
|
||||
: RiuPlotWidget( plotDefinition, parent )
|
||||
, m_titleRenderingFlags( Qt::AlignHCenter | Qt::TextSingleLine )
|
||||
, m_titleRenderingFlags( Qt::AlignHCenter | Qt::TextWordWrap )
|
||||
, m_titleFontSize( -1 )
|
||||
{
|
||||
auto* layout = new QVBoxLayout;
|
||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||
@ -211,7 +212,7 @@ void RiuQwtPlotWidget::setAxisTitleEnabled( RiuPlotAxis axis, bool enable )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setPlotTitle( const QString& plotTitle )
|
||||
{
|
||||
m_plotTitle = plotTitle;
|
||||
m_plotTitleText = plotTitle;
|
||||
applyPlotTitleToQwt();
|
||||
}
|
||||
|
||||
@ -220,7 +221,7 @@ void RiuQwtPlotWidget::setPlotTitle( const QString& plotTitle )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString& RiuQwtPlotWidget::plotTitle() const
|
||||
{
|
||||
return m_plotTitle;
|
||||
return m_plotTitleText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -245,20 +246,9 @@ bool RiuQwtPlotWidget::plotTitleEnabled() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setPlotTitleFontSize( int titleFontSize )
|
||||
{
|
||||
auto title = m_plot->title();
|
||||
QFont font = title.font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( titleFontSize ) );
|
||||
title.setFont( font );
|
||||
title.setRenderFlags( title.renderFlags() | Qt::TextWordWrap );
|
||||
m_plot->setTitle( title );
|
||||
}
|
||||
m_titleFontSize = titleFontSize;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::setPlotTitleRenderingFlags( int flags )
|
||||
{
|
||||
m_titleRenderingFlags = flags;
|
||||
applyPlotTitleToQwt();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -676,14 +666,19 @@ void RiuQwtPlotWidget::keyPressEvent( QKeyEvent* event )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQwtPlotWidget::applyPlotTitleToQwt()
|
||||
{
|
||||
QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitle : QString( "" );
|
||||
QwtText plotTitle = m_plot->title();
|
||||
plotTitle.setRenderFlags( m_titleRenderingFlags );
|
||||
if ( plotTitleToApply != plotTitle.text() )
|
||||
QString plotTitleToApply = m_plotTitleEnabled ? m_plotTitleText : QString( "" );
|
||||
QwtText qwtText = m_plot->title();
|
||||
qwtText.setRenderFlags( m_titleRenderingFlags );
|
||||
if ( m_titleFontSize > 0 )
|
||||
{
|
||||
plotTitle.setText( plotTitleToApply );
|
||||
m_plot->setTitle( plotTitle );
|
||||
QFont font = qwtText.font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( m_titleFontSize ) );
|
||||
qwtText.setFont( font );
|
||||
}
|
||||
qwtText.setText( plotTitleToApply );
|
||||
|
||||
// Always set the title, as Qwt does not do anything if the text is the same
|
||||
m_plot->setTitle( qwtText );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -101,7 +101,6 @@ public:
|
||||
void setPlotTitleEnabled( bool enabled ) override;
|
||||
bool plotTitleEnabled() const override;
|
||||
void setPlotTitleFontSize( int titleFontSize ) override;
|
||||
void setPlotTitleRenderingFlags( int flags );
|
||||
|
||||
void setLegendFontSize( int fontSize ) override;
|
||||
void setInternalLegendVisible( bool visible ) override;
|
||||
@ -237,4 +236,5 @@ private:
|
||||
QPointer<QwtPlot> m_plot;
|
||||
|
||||
int m_titleRenderingFlags;
|
||||
int m_titleFontSize;
|
||||
};
|
||||
|
@ -50,6 +50,9 @@ RiuWellAllocationPlot::RiuWellAllocationPlot( RimWellAllocationPlot* plotDefinit
|
||||
this->layout()->setSpacing( 2 );
|
||||
|
||||
m_titleLabel = new QLabel( this );
|
||||
m_titleLabel->setWordWrap( true );
|
||||
m_titleLabel->setAlignment( Qt::AlignCenter );
|
||||
|
||||
new RiuPlotObjectPicker( m_titleLabel, m_plotDefinition->accumulatedWellFlowPlot() );
|
||||
|
||||
QFont font = m_titleLabel->font();
|
||||
@ -63,7 +66,7 @@ RiuWellAllocationPlot::RiuWellAllocationPlot( RimWellAllocationPlot* plotDefinit
|
||||
this->setAutoFillBackground( true );
|
||||
this->setPalette( pal );
|
||||
|
||||
mainLayout->addWidget( m_titleLabel, 0, Qt::AlignCenter );
|
||||
mainLayout->addWidget( m_titleLabel );
|
||||
|
||||
auto plotWidgetsLayout = new QHBoxLayout();
|
||||
auto leftColumnLayout = new QVBoxLayout();
|
||||
|
Loading…
Reference in New Issue
Block a user