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
11 changed files with 94 additions and 65 deletions

View File

@@ -2031,11 +2031,12 @@ QString RimEnsembleCurveSet::createAutoName() const
RimSummaryPlot* plot = nullptr; RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfTypeAsserted( plot ); firstAncestorOrThisOfTypeAsserted( plot );
QString curveSetName = QString curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(),
m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), plot->plotTitleHelper() ); plot->plotTitleHelper(),
plot->plotTitleHelper() );
if ( curveSetName.isEmpty() ) if ( curveSetName.isEmpty() )
{ {
curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), nullptr ); curveSetName = m_summaryAddressNameTools->curveNameY( m_yValuesSummaryAddress->address(), nullptr, nullptr );
} }
if ( curveSetName.isEmpty() ) 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 isSegmentInTitle() const override;
bool isCompletionInTitle() 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 titleVectorName() const override;
std::string titleWellName() const override; std::string titleWellName() const override;

View File

@@ -521,14 +521,15 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions( const caf:
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QString RimSummaryCurve::createCurveAutoName() QString RimSummaryCurve::createCurveAutoName()
{ {
std::vector<const RimSummaryNameHelper*> nameHelpers; const RimSummaryNameHelper* currentPlotNameHelper = nullptr;
std::vector<const RimSummaryNameHelper*> plotNameHelpers;
{ {
RimSummaryPlot* plot = nullptr; RimSummaryPlot* plot = nullptr;
firstAncestorOrThisOfType( plot ); firstAncestorOrThisOfType( plot );
if ( plot ) if ( plot )
{ {
auto nameHelper = plot->plotTitleHelper(); currentPlotNameHelper = plot->plotTitleHelper();
if ( nameHelper ) nameHelpers.push_back( nameHelper ); if ( currentPlotNameHelper ) plotNameHelpers.push_back( currentPlotNameHelper );
} }
} }
{ {
@@ -537,23 +538,25 @@ QString RimSummaryCurve::createCurveAutoName()
if ( summaryMultiPlot ) if ( summaryMultiPlot )
{ {
auto nameHelper = summaryMultiPlot->nameHelper(); auto nameHelper = summaryMultiPlot->nameHelper();
if ( nameHelper ) nameHelpers.push_back( nameHelper ); if ( nameHelper ) plotNameHelpers.push_back( nameHelper );
} }
} }
RimMultiSummaryPlotNameHelper multiNameHelper( nameHelpers ); RimMultiSummaryPlotNameHelper multiNameHelper( plotNameHelpers );
QString curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), &multiNameHelper ); QString curveName =
m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), currentPlotNameHelper, &multiNameHelper );
if ( curveName.isEmpty() ) if ( curveName.isEmpty() )
{ {
curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), nullptr ); curveName = m_curveNameConfig->curveNameY( m_yValuesSummaryAddress->address(), nullptr, nullptr );
} }
if ( isCrossPlotCurve() ) if ( isCrossPlotCurve() )
{ {
QString curveNameX = m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), &multiNameHelper ); QString curveNameX =
m_curveNameConfig->curveNameX( m_xValuesSummaryAddress->address(), currentPlotNameHelper, &multiNameHelper );
if ( curveNameX.isEmpty() ) 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() ) if ( !curveName.isEmpty() || !curveNameX.isEmpty() )
@@ -1095,10 +1098,6 @@ void RimSummaryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow(); RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
mainPlotWindow->updateMultiPlotToolBar(); 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 ) else if ( changedField == &m_plotAxisProperties )
{ {

View File

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

View File

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

View File

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

View File

@@ -175,6 +175,14 @@ bool RimSummaryPlotNameHelper::isCompletionInTitle() const
return !m_titleCompletion.empty(); 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 isSegmentInTitle() const override;
bool isCompletionInTitle() 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 titleVectorName() const override;
std::string titleWellName() const override; std::string titleWellName() const override;

View File

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

View File

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