mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Regression test fixes (#9068)
* Make sure font size is updated correctly * Hide empty sub titles * Do not categorize as water cut if no curves are visible * Propagate settings from single summary plot to summary multi plot
This commit is contained in:
@@ -468,6 +468,44 @@ RimSummaryMultiPlot*
|
||||
return summaryMultiPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlotNoAutoSettings( RimSummaryPlot* plot )
|
||||
{
|
||||
RimProject* project = RimProject::current();
|
||||
auto* plotCollection = project->mainPlotCollection()->summaryMultiPlotCollection();
|
||||
|
||||
auto* summaryMultiPlot = new RimSummaryMultiPlot();
|
||||
summaryMultiPlot->setColumnCount( RiaDefines::ColumnCount::COLUMNS_1 );
|
||||
summaryMultiPlot->setRowCount( RiaDefines::RowCount::ROWS_1 );
|
||||
summaryMultiPlot->setAsPlotMdiWindow();
|
||||
|
||||
if ( !plot->autoPlotTitle() )
|
||||
{
|
||||
// Move settings from the single summary plot to the multi plot, and disable auto titles
|
||||
summaryMultiPlot->setAutoPlotTitle( false );
|
||||
summaryMultiPlot->setAutoSubPlotTitle( false );
|
||||
summaryMultiPlot->setMultiPlotTitleVisible( true );
|
||||
summaryMultiPlot->setMultiPlotTitle( plot->description() );
|
||||
|
||||
plot->setPlotTitleVisible( false );
|
||||
plot->setDescription( "" );
|
||||
}
|
||||
|
||||
plotCollection->addSummaryMultiPlot( summaryMultiPlot );
|
||||
|
||||
appendPlotsToSummaryMultiPlot( summaryMultiPlot, { plot } );
|
||||
|
||||
plotCollection->updateAllRequiredEditors();
|
||||
summaryMultiPlot->loadDataAndUpdate();
|
||||
summaryMultiPlot->updateAllRequiredEditors();
|
||||
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
|
||||
|
||||
return summaryMultiPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -79,6 +79,7 @@ public:
|
||||
createAndAppendDefaultSummaryMultiPlot( const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles );
|
||||
|
||||
static RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlotNoAutoSettings( RimSummaryPlot* plot );
|
||||
static RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlot( RimSummaryPlot* plot );
|
||||
static RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<RimSummaryPlot*>& plots );
|
||||
static RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<caf::PdmObjectHandle*>& objects );
|
||||
|
@@ -169,7 +169,7 @@ void RimMainPlotCollection::initAfterRead()
|
||||
{
|
||||
m_summaryPlotCollection_OBSOLETE()->removePlot( singlePlot );
|
||||
|
||||
RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlot( singlePlot );
|
||||
RicSummaryPlotBuilder::createAndAppendSingleSummaryMultiPlotNoAutoSettings( singlePlot );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -109,8 +109,8 @@ RimSummaryMultiPlot::RimSummaryMultiPlot()
|
||||
CAF_PDM_InitObject( "Multi Summary Plot", ":/SummaryPlotLight16x16.png" );
|
||||
this->setDeletable( true );
|
||||
|
||||
CAF_PDM_InitField( &m_autoPlotTitles, "AutoPlotTitles", true, "Auto Plot Titles" );
|
||||
CAF_PDM_InitField( &m_autoPlotTitlesOnSubPlots, "AutoPlotTitlesSubPlots", true, "Auto Plot Titles Sub Plots" );
|
||||
CAF_PDM_InitField( &m_autoPlotTitle, "AutoPlotTitle", true, "Auto Plot Title" );
|
||||
CAF_PDM_InitField( &m_autoSubPlotTitle, "AutoSubPlotTitle", true, "Auto Sub Plot Title" );
|
||||
|
||||
CAF_PDM_InitField( &m_createPlotDuplicate, "DuplicatePlot", false, "", "", "Duplicate Plot" );
|
||||
m_createPlotDuplicate.xmlCapability()->disableIO();
|
||||
@@ -396,14 +396,14 @@ void RimSummaryMultiPlot::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
|
||||
|
||||
auto titlesGroup = uiOrdering.addNewGroup( "Main Plot Settings" );
|
||||
titlesGroup->setCollapsedByDefault( true );
|
||||
titlesGroup->add( &m_autoPlotTitles );
|
||||
titlesGroup->add( &m_autoPlotTitle );
|
||||
titlesGroup->add( &m_showPlotWindowTitle );
|
||||
titlesGroup->add( &m_plotWindowTitle );
|
||||
titlesGroup->add( &m_titleFontSize );
|
||||
|
||||
auto subPlotSettingsGroup = uiOrdering.addNewGroup( "Sub Plot Settings" );
|
||||
subPlotSettingsGroup->setCollapsedByDefault( true );
|
||||
subPlotSettingsGroup->add( &m_autoPlotTitlesOnSubPlots );
|
||||
subPlotSettingsGroup->add( &m_autoSubPlotTitle );
|
||||
subPlotSettingsGroup->add( &m_showIndividualPlotTitles );
|
||||
subPlotSettingsGroup->add( &m_subTitleFontSize );
|
||||
|
||||
@@ -423,7 +423,7 @@ void RimSummaryMultiPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedFi
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_autoPlotTitles || changedField == &m_autoPlotTitlesOnSubPlots )
|
||||
if ( changedField == &m_autoPlotTitle || changedField == &m_autoSubPlotTitle )
|
||||
{
|
||||
onLoadDataAndUpdate();
|
||||
updateLayout();
|
||||
@@ -501,7 +501,7 @@ void RimSummaryMultiPlot::defineEditorAttribute( const caf::PdmFieldHandle* fiel
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::updatePlotWindowTitle()
|
||||
{
|
||||
if ( m_autoPlotTitles )
|
||||
if ( m_autoPlotTitle )
|
||||
{
|
||||
populateNameHelper( m_nameHelper.get() );
|
||||
|
||||
@@ -525,7 +525,7 @@ void RimSummaryMultiPlot::updatePlotWindowTitle()
|
||||
setMultiPlotTitle( title );
|
||||
}
|
||||
|
||||
if ( m_autoPlotTitlesOnSubPlots )
|
||||
if ( m_autoSubPlotTitle )
|
||||
{
|
||||
for ( auto plot : summaryPlots() )
|
||||
{
|
||||
@@ -556,17 +556,17 @@ const RimSummaryNameHelper* RimSummaryMultiPlot::nameHelper() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::setAutoTitlePlot( bool enable )
|
||||
void RimSummaryMultiPlot::setAutoPlotTitle( bool enable )
|
||||
{
|
||||
m_autoPlotTitles = enable;
|
||||
m_autoPlotTitle = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::setAutoTitleGraphs( bool enable )
|
||||
void RimSummaryMultiPlot::setAutoSubPlotTitle( bool enable )
|
||||
{
|
||||
m_autoPlotTitlesOnSubPlots = enable;
|
||||
m_autoSubPlotTitle = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -65,8 +65,8 @@ public:
|
||||
void setLayoutInfo( RimSummaryPlot* summaryPlot, int row, int col );
|
||||
void clearLayoutInfo();
|
||||
|
||||
void setAutoTitlePlot( bool enable );
|
||||
void setAutoTitleGraphs( bool enable );
|
||||
void setAutoPlotTitle( bool enable );
|
||||
void setAutoSubPlotTitle( bool enable );
|
||||
|
||||
std::vector<RimSummaryDataSourceStepping::Axis> availableAxes() const override;
|
||||
std::vector<RimSummaryCurve*> curvesForStepping( RimSummaryDataSourceStepping::Axis axis ) const override;
|
||||
@@ -145,8 +145,8 @@ private:
|
||||
void onSubPlotAxisChanged( const caf::SignalEmitter* emitter, RimSummaryPlot* summaryPlot );
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_autoPlotTitles;
|
||||
caf::PdmField<bool> m_autoPlotTitlesOnSubPlots;
|
||||
caf::PdmField<bool> m_autoPlotTitle;
|
||||
caf::PdmField<bool> m_autoSubPlotTitle;
|
||||
caf::PdmField<bool> m_disableWheelZoom;
|
||||
caf::PdmField<bool> m_createPlotDuplicate;
|
||||
caf::PdmField<bool> m_linkSubPlotAxes;
|
||||
|
@@ -938,8 +938,10 @@ void RimSummaryPlot::updateZoomForAxis( RiuPlotAxis plotAxis )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimSummaryPlot::isOnlyWaterCutCurvesVisible( RiuPlotAxis plotAxis )
|
||||
{
|
||||
auto curves = visibleSummaryCurvesForAxis( plotAxis );
|
||||
if ( curves.empty() ) return false;
|
||||
|
||||
size_t waterCutCurveCount = 0;
|
||||
auto curves = visibleSummaryCurvesForAxis( plotAxis );
|
||||
for ( auto c : curves )
|
||||
{
|
||||
auto quantityName = c->summaryAddressY().vectorName();
|
||||
|
@@ -37,6 +37,7 @@ RiuAbstractLegendFrame::RiuAbstractLegendFrame( QWidget* parent, const QString&
|
||||
, m_title( title )
|
||||
{
|
||||
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
|
||||
updateFontSize();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -69,7 +70,7 @@ QSize RiuAbstractLegendFrame::sizeHint() const
|
||||
preferredWidth = std::max( preferredWidth, titleWidth );
|
||||
preferredWidth = std::min( preferredWidth, 200 );
|
||||
|
||||
return QSize( preferredWidth, preferredHeight );
|
||||
return { preferredWidth, preferredHeight };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -81,11 +82,21 @@ QSize RiuAbstractLegendFrame::minimumSizeHint() const
|
||||
layoutInfo( &layout );
|
||||
|
||||
QFontMetrics fontMetrics( this->font() );
|
||||
QRect titleRect = fontMetrics.boundingRect( QRect( 0, 0, 200, 200 ), Qt::AlignLeft | Qt::TextWordWrap, m_title );
|
||||
|
||||
int preferredContentHeight = titleRect.height() + 2 * layout.lineSpacing + 1.0 * layout.lineSpacing;
|
||||
int preferredHeight = preferredContentHeight + layout.margins.top() + layout.margins.bottom();
|
||||
int titleWidth = titleRect.width() + layout.margins.left() + layout.margins.right();
|
||||
int preferredHeight = 0;
|
||||
int titleWidth = 0;
|
||||
|
||||
QStringList tokens = m_title.split( "\n" );
|
||||
for ( const auto& s : tokens )
|
||||
{
|
||||
QRect titleRect = fontMetrics.boundingRect( QRect( 0, 0, 200, 200 ), Qt::AlignLeft, s );
|
||||
int preferredContentHeight = titleRect.height() + 2 * layout.lineSpacing + 1.0 * layout.lineSpacing;
|
||||
int candidateHeight = preferredContentHeight + layout.margins.top() + layout.margins.bottom();
|
||||
int candidateTitleWidth = titleRect.width() + layout.margins.left() + layout.margins.right();
|
||||
|
||||
preferredHeight = std::max( preferredHeight, candidateHeight );
|
||||
titleWidth = std::max( titleWidth, candidateTitleWidth );
|
||||
}
|
||||
|
||||
int firstTextWidth = fontMetrics.boundingRect( label( 0 ) ).width();
|
||||
int lastTextWidth = fontMetrics.boundingRect( label( labelCount() - 1 ) ).width();
|
||||
@@ -97,7 +108,7 @@ QSize RiuAbstractLegendFrame::minimumSizeHint() const
|
||||
preferredWidth = std::max( preferredWidth, titleWidth );
|
||||
preferredWidth = std::min( preferredWidth, 400 );
|
||||
|
||||
return QSize( preferredWidth, preferredHeight );
|
||||
return { preferredWidth, preferredHeight };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -105,9 +116,7 @@ QSize RiuAbstractLegendFrame::minimumSizeHint() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
{
|
||||
QFont font = this->font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) );
|
||||
this->setFont( font );
|
||||
updateFontSize();
|
||||
|
||||
QColor textColor = RiuGuiTheme::getColorByVariableName( "textColor" );
|
||||
|
||||
@@ -135,7 +144,7 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
|
||||
}
|
||||
|
||||
std::vector<std::pair<QRect, QString>> visibleTickLabels = visibleLabels( layout );
|
||||
for ( auto tickLabel : visibleTickLabels )
|
||||
for ( const auto& tickLabel : visibleTickLabels )
|
||||
{
|
||||
painter->save();
|
||||
painter->translate( tickLabel.first.topLeft() );
|
||||
@@ -154,8 +163,6 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
|
||||
renderRect( painter, layout, i );
|
||||
}
|
||||
painter->drawRect( layout.colorBarRect );
|
||||
// painter->drawLine( QPointF( layout.tickMidX, layout.tickYPixelPos->get( i ) ),
|
||||
// QPointF( layout.tickMidX, layout.tickYPixelPos->get( i + 1 ) ) );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
@@ -187,7 +194,7 @@ std::vector<std::pair<QRect, QString>> RiuAbstractLegendFrame::visibleLabels( co
|
||||
|
||||
QString valueString = label( i );
|
||||
lastRect = rect;
|
||||
visibleTickLabels.push_back( { rect, valueString } );
|
||||
visibleTickLabels.emplace_back( rect, valueString );
|
||||
}
|
||||
return visibleTickLabels;
|
||||
}
|
||||
|
@@ -41,6 +41,16 @@ RiuAbstractOverlayContentFrame::~RiuAbstractOverlayContentFrame()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuAbstractOverlayContentFrame::updateFontSize()
|
||||
{
|
||||
QFont font = this->font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) );
|
||||
this->setFont( font );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -52,9 +62,7 @@ RiuTextOverlayContentFrame::RiuTextOverlayContentFrame( QWidget* parent /*= null
|
||||
m_textLabel = new QLabel;
|
||||
layout->addWidget( m_textLabel );
|
||||
|
||||
QFont font = m_textLabel->font();
|
||||
caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() );
|
||||
m_textLabel->setFont( font );
|
||||
updateLabelFont();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -70,6 +78,8 @@ void RiuTextOverlayContentFrame::setText( const QString& text )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuTextOverlayContentFrame::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
{
|
||||
updateLabelFont();
|
||||
|
||||
painter->save();
|
||||
painter->translate( targetRect.topLeft() + QPoint( this->contentsMargins().left(), this->contentsMargins().top() ) );
|
||||
painter->setFont( m_textLabel->font() );
|
||||
@@ -81,3 +91,13 @@ void RiuTextOverlayContentFrame::renderTo( QPainter* painter, const QRect& targe
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuTextOverlayContentFrame::updateLabelFont()
|
||||
{
|
||||
QFont font = m_textLabel->font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) );
|
||||
m_textLabel->setFont( font );
|
||||
}
|
||||
|
@@ -31,6 +31,9 @@ public:
|
||||
~RiuAbstractOverlayContentFrame() override;
|
||||
|
||||
virtual void renderTo( QPainter* painter, const QRect& targetRect ) = 0;
|
||||
|
||||
protected:
|
||||
void updateFontSize();
|
||||
};
|
||||
|
||||
class RiuTextOverlayContentFrame : public RiuAbstractOverlayContentFrame
|
||||
@@ -42,6 +45,9 @@ public:
|
||||
void setText( const QString& text );
|
||||
void renderTo( QPainter* painter, const QRect& targetRect ) override;
|
||||
|
||||
private:
|
||||
void updateLabelFont();
|
||||
|
||||
private:
|
||||
QPointer<QLabel> m_textLabel;
|
||||
};
|
||||
|
@@ -103,7 +103,8 @@ void RiuSummaryMultiPlotPage::reinsertPlotWidgets()
|
||||
auto summaryPlot = dynamic_cast<RimSummaryPlot*>( plotWidget->plotDefinition() );
|
||||
if ( summaryPlot ) m_summaryMultiPlot->setLayoutInfo( summaryPlot, row, col );
|
||||
|
||||
subTitles[visibleIndex]->setVisible( m_showSubTitles );
|
||||
bool isSubTitleVisible = m_showSubTitles && !subTitles[visibleIndex]->text().isEmpty();
|
||||
subTitles[visibleIndex]->setVisible( isSubTitleVisible );
|
||||
QFont subTitleFont = subTitles[visibleIndex]->font();
|
||||
subTitleFont.setPixelSize( m_subTitleFontPixelSize );
|
||||
subTitles[visibleIndex]->setFont( subTitleFont );
|
||||
|
@@ -31,8 +31,6 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
//#include <mathml/qwt_mathml_text_engine.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -94,9 +92,7 @@ QSize RiuTextContentFrame::minimumSizeHint() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuTextContentFrame::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
{
|
||||
QFont font = this->font();
|
||||
font.setPixelSize( caf::FontTools::pointSizeToPixelSize( RiaPreferences::current()->defaultPlotFontSize() ) );
|
||||
this->setFont( font );
|
||||
updateFontSize();
|
||||
|
||||
QColor textColor = RiuGuiTheme::getColorByVariableName( "textColor" );
|
||||
|
||||
@@ -128,18 +124,6 @@ void RiuTextContentFrame::renderTo( QPainter* painter, const QRect& targetRect )
|
||||
painter->translate( QPoint( layout.margins.left(), layout.margins.top() + layout.lineSpacing * 2 ) );
|
||||
painter->setPen( QPen( textColor ) );
|
||||
|
||||
/*
|
||||
QwtMathMLTextEngine textEngine = QwtMathMLTextEngine();
|
||||
textEngine.draw( painter,
|
||||
QRect( targetRect.left() + layout.margins.left(),
|
||||
targetRect.top() + layout.margins.top() + layout.lineSpacing * 2,
|
||||
targetRect.width() - layout.margins.left() - layout.margins.right(),
|
||||
targetRect.height() - layout.margins.top() - layout.margins.bottom() -
|
||||
layout.margins.top() + layout.lineSpacing * 2 ),
|
||||
Qt::AlignLeft,
|
||||
m_text );
|
||||
|
||||
*/
|
||||
QTextDocument td;
|
||||
td.setDocumentMargin( 0.0 );
|
||||
td.setDefaultFont( this->font() );
|
||||
|
Reference in New Issue
Block a user