Summary improvements

* #9424 Show vector name in curve names when history vector is present
* #9426 Curve Legend disappears when curve is unchecked
* Remove duplicate call to visibilityChanged
* Remove unused code
This commit is contained in:
Magne Sjaastad 2022-11-01 08:00:51 +01:00 committed by GitHub
parent a577545212
commit e29b310566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 94 additions and 65 deletions

View File

@ -2031,11 +2031,12 @@ QString RimEnsembleCurveSet::createAutoName() const
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot );
QString curveSetName =
m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), plot->plotTitleHelper() );
QString curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(),
plot->plotTitleHelper(),
plot->plotTitleHelper() );
if ( curveSetName.isEmpty() )
{
curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), nullptr );
curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), nullptr, nullptr );
}
if ( curveSetName.isEmpty() )

View File

@ -132,6 +132,22 @@ bool RimMultiSummaryPlotNameHelper::isCompletionInTitle() const
} );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<std::string> RimMultiSummaryPlotNameHelper::vectorNames() const
{
std::set<std::string> allNames;
for ( auto nameHelper : m_nameHelpers )
{
auto nameHelperVectorNames = nameHelper->vectorNames();
allNames.insert( nameHelperVectorNames.begin(), nameHelperVectorNames.end() );
}
return allNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,8 @@ public:
bool isSegmentInTitle() const override;
bool isCompletionInTitle() const override;
QString caseName() const override;
std::set<std::string> vectorNames() const override;
QString caseName() const override;
std::string titleVectorName() const override;
std::string titleWellName() const override;

View File

@ -521,14 +521,15 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions( const caf:
//--------------------------------------------------------------------------------------------------
QString RimSummaryCurve::createCurveAutoName()
{
std::vector<const RimSummaryNameHelper*> nameHelpers;
const RimSummaryNameHelper* currentPlotNameHelper = nullptr;
std::vector<const RimSummaryNameHelper*> plotNameHelpers;
{
RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot );
if ( plot )
{
auto nameHelper = plot->plotTitleHelper();
if ( nameHelper ) nameHelpers.push_back( nameHelper );
currentPlotNameHelper = plot->plotTitleHelper();
if ( currentPlotNameHelper ) plotNameHelpers.push_back( currentPlotNameHelper );
}
}
{
@ -537,23 +538,25 @@ QString RimSummaryCurve::createCurveAutoName()
if ( summaryMultiPlot )
{
auto nameHelper = summaryMultiPlot->nameHelper();
if ( nameHelper ) nameHelpers.push_back( nameHelper );
if ( nameHelper ) plotNameHelpers.push_back( nameHelper );
}
}
RimMultiSummaryPlotNameHelper multiNameHelper( nameHelpers );
QString curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), &multiNameHelper );
RimMultiSummaryPlotNameHelper multiNameHelper( plotNameHelpers );
QString curveName =
m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), currentPlotNameHelper, &multiNameHelper );
if ( curveName.isEmpty() )
{
curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), nullptr );
curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), nullptr, nullptr );
}
if ( isCrossPlotCurve() )
{
QString curveNameX = m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), &multiNameHelper );
QString curveNameX =
m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), currentPlotNameHelper, &multiNameHelper );
if ( curveNameX.isEmpty() )
{
curveNameX = m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), nullptr );
curveNameX = m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), nullptr, nullptr );
}
if ( !curveName.isEmpty() || !curveNameX.isEmpty() )
@ -1095,10 +1098,6 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateMultiPlotToolBar();
// If no plot collection is found, we assume that we are inside a curve creator
// Update the summary curve collection to make sure the curve names are updated in curve creator UI
visibilityChanged.send( m_showCurve() );
}
else if ( changedField == &m_plotAxisProperties )
{

View File

@ -65,7 +65,8 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName()
///
//--------------------------------------------------------------------------------------------------
QString RimSummaryCurveAutoName::curveNameY( const RifEclipseSummaryAddress& summaryAddress,
const RimSummaryNameHelper* nameHelper ) const
const RimSummaryNameHelper* currentNameHelper,
const RimSummaryNameHelper* plotNameHelper ) const
{
RimSummaryCurve* summaryCurve = nullptr;
this->firstAncestorOrThisOfType( summaryCurve );
@ -91,7 +92,7 @@ QString RimSummaryCurveAutoName::curveNameY( const RifEclipseSummaryAddress& sum
}
}
QString curveName = buildCurveName( summaryAddress, nameHelper, unitNameY, caseNameY );
QString curveName = buildCurveName( summaryAddress, currentNameHelper, plotNameHelper, unitNameY, caseNameY );
return curveName;
}
@ -100,7 +101,8 @@ QString RimSummaryCurveAutoName::curveNameY( const RifEclipseSummaryAddress& sum
///
//--------------------------------------------------------------------------------------------------
QString RimSummaryCurveAutoName::curveNameX( const RifEclipseSummaryAddress& summaryAddress,
const RimSummaryNameHelper* nameHelper ) const
const RimSummaryNameHelper* currentNameHelper,
const RimSummaryNameHelper* plotNameHelper ) const
{
RimSummaryCurve* summaryCurve = nullptr;
this->firstAncestorOrThisOfType( summaryCurve );
@ -126,7 +128,7 @@ QString RimSummaryCurveAutoName::curveNameX( const RifEclipseSummaryAddress& sum
}
}
QString curveName = buildCurveName( summaryAddress, nameHelper, unitNameX, caseNameX );
QString curveName = buildCurveName( summaryAddress, currentNameHelper, plotNameHelper, unitNameX, caseNameX );
return curveName;
}
@ -182,7 +184,8 @@ void RimSummaryCurveAutoName::appendLgrName( std::string& text, const RifEclipse
///
//--------------------------------------------------------------------------------------------------
QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress& summaryAddress,
const RimSummaryNameHelper* nameHelper,
const RimSummaryNameHelper* currentNameHelper,
const RimSummaryNameHelper* plotNameHelper,
const std::string& unitText,
const std::string& caseName ) const
{
@ -190,7 +193,7 @@ QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress&
if ( m_vectorName )
{
bool skipSubString = nameHelper && nameHelper->isPlotDisplayingSingleVectorName();
bool skipSubString = currentNameHelper && currentNameHelper->vectorNames().size() == 1;
if ( !skipSubString )
{
if ( m_longVectorName() )
@ -230,11 +233,11 @@ QString RimSummaryCurveAutoName::buildCurveName( const RifEclipseSummaryAddress&
}
}
appendAddressDetails( text, summaryAddress, nameHelper );
appendAddressDetails( text, summaryAddress, plotNameHelper );
if ( !caseName.empty() )
{
bool skipSubString = nameHelper && nameHelper->isCaseInTitle();
bool skipSubString = plotNameHelper && plotNameHelper->isCaseInTitle();
if ( m_caseName && !skipSubString )
{

View File

@ -31,8 +31,12 @@ class RimSummaryCurveAutoName : public caf::PdmObject
public:
RimSummaryCurveAutoName();
QString curveNameY( const RifEclipseSummaryAddress& summaryAddress, const RimSummaryNameHelper* nameHelper ) const;
QString curveNameX( const RifEclipseSummaryAddress& summaryAddress, const RimSummaryNameHelper* nameHelper ) const;
QString curveNameY( const RifEclipseSummaryAddress& summaryAddress,
const RimSummaryNameHelper* currentNameHelper,
const RimSummaryNameHelper* plotNameHelper ) const;
QString curveNameX( const RifEclipseSummaryAddress& summaryAddress,
const RimSummaryNameHelper* currentNameHelper,
const RimSummaryNameHelper* plotNameHelper ) const;
void applySettings( const RimSummaryCurveAutoName& other );
@ -51,7 +55,8 @@ private:
void appendLgrName( std::string& text, const RifEclipseSummaryAddress& summaryAddress ) const;
QString buildCurveName( const RifEclipseSummaryAddress& summaryAddress,
const RimSummaryNameHelper* nameHelper,
const RimSummaryNameHelper* currentNameHelper,
const RimSummaryNameHelper* plotNameHelper,
const std::string& unitText,
const std::string& caseName ) const;

View File

@ -18,6 +18,7 @@
#pragma once
#include <set>
#include <string>
#include <vector>
@ -46,7 +47,8 @@ public:
virtual bool isSegmentInTitle() const = 0;
virtual bool isCompletionInTitle() const = 0;
virtual QString caseName() const = 0;
virtual std::set<std::string> vectorNames() const = 0;
virtual QString caseName() const = 0;
virtual std::string titleVectorName() const = 0;
virtual std::string titleWellName() const = 0;

View File

@ -175,6 +175,14 @@ bool RimSummaryPlotNameHelper::isCompletionInTitle() const
return !m_titleCompletion.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<std::string> RimSummaryPlotNameHelper::vectorNames() const
{
return m_analyzer->quantities();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -60,7 +60,8 @@ public:
bool isSegmentInTitle() const override;
bool isCompletionInTitle() const override;
QString caseName() const override;
std::set<std::string> vectorNames() const override;
QString caseName() const override;
std::string titleVectorName() const override;
std::string titleWellName() const override;

View File

@ -35,9 +35,9 @@
//--------------------------------------------------------------------------------------------------
RiuQwtPlotLegend::RiuQwtPlotLegend( QWidget* parent /*= nullptr */ )
: QwtLegend( parent )
, m_columnCount( 1 )
{
QwtDynGridLayout* legendLayout = qobject_cast<QwtDynGridLayout*>( contentsWidget()->layout() );
auto* legendLayout = qobject_cast<QwtDynGridLayout*>( contentsWidget()->layout() );
if ( legendLayout )
{
legendLayout->setExpandingDirections( Qt::Horizontal | Qt::Vertical );
@ -60,11 +60,6 @@ void RiuQwtPlotLegend::resizeEvent( QResizeEvent* event )
const QwtDynGridLayout* legendLayout = qobject_cast<QwtDynGridLayout*>( contentsWidget()->layout() );
if ( legendLayout )
{
QMargins margins = this->contentsMargins();
m_columnCount =
std::max( 1, (int)legendLayout->columnsForWidth( size.width() - margins.left() - margins.right() ) );
updateGeometry();
}
}
@ -75,40 +70,41 @@ void RiuQwtPlotLegend::resizeEvent( QResizeEvent* event )
QSize RiuQwtPlotLegend::sizeHint() const
{
QSize fullSizeHint = QwtLegend::sizeHint();
// Update width
const QwtDynGridLayout* legendLayout = qobject_cast<QwtDynGridLayout*>( contentsWidget()->layout() );
if ( legendLayout )
{
int numColumns = m_columnCount;
int numRows = legendLayout->itemCount() / numColumns;
QMargins margins = this->contentsMargins();
int numColumns =
std::max( 1, (int)legendLayout->columnsForWidth( fullSizeHint.width() - margins.left() - margins.right() ) );
int numRows = legendLayout->itemCount() / numColumns;
if ( numRows == 0 )
{
return QSize( 0, 0 );
return { 0, 0 };
}
else
if ( legendLayout->itemCount() % numColumns ) numRows++;
int width = numColumns * legendLayout->maxItemWidth();
int maxHeight = 0;
for ( unsigned int i = 0; i < legendLayout->itemCount(); ++i )
{
if ( legendLayout->itemCount() % numColumns ) numRows++;
int width = numColumns * legendLayout->maxItemWidth();
int maxHeight = 0;
for ( unsigned int i = 0; i < legendLayout->itemCount(); ++i )
{
auto itemSize = legendLayout->itemAt( i )->sizeHint();
maxHeight = std::max( maxHeight, itemSize.height() );
}
QMargins margins = legendLayout->contentsMargins();
int totalSpacing = ( numRows + 2 ) * legendLayout->spacing() + margins.top() + margins.bottom();
int height = maxHeight * numRows + totalSpacing;
QSize layoutSize( width, height );
QSize frameSize = layoutSize + QSize( 2 * frameWidth(), 2 * frameWidth() );
fullSizeHint.setWidth( std::max( fullSizeHint.width(), frameSize.width() ) );
fullSizeHint.setHeight( std::max( fullSizeHint.height(), frameSize.height() ) );
auto itemSize = legendLayout->itemAt( i )->sizeHint();
maxHeight = std::max( maxHeight, itemSize.height() );
}
int totalSpacing = ( numRows + 2 ) * legendLayout->spacing() + margins.top() + margins.bottom();
int height = maxHeight * numRows + totalSpacing;
QSize layoutSize( width, height );
QSize frameSize = layoutSize + QSize( 2 * frameWidth(), 2 * frameWidth() );
fullSizeHint.setWidth( std::max( fullSizeHint.width(), frameSize.width() ) );
fullSizeHint.setHeight( std::max( fullSizeHint.height(), frameSize.height() ) );
}
return fullSizeHint;
}

View File

@ -35,7 +35,4 @@ signals:
private:
void deleteAll();
private:
int m_columnCount;
};