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