mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#12157 Always show vector name when underscore is present
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
#include "RimSummaryCurveAutoName.h"
|
||||
#include "RimSummaryEnsemble.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryMultiPlotCollection.h"
|
||||
@@ -93,6 +94,16 @@ RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSumma
|
||||
curve->setSummaryCaseY( summaryCase );
|
||||
curve->setSummaryAddressY( addr );
|
||||
|
||||
size_t pos = addr.vectorName().find( '_' );
|
||||
if ( pos != std::string::npos )
|
||||
{
|
||||
// https://github.com/OPM/ResInsight/issues/12157
|
||||
|
||||
RimSummaryCurveAutoName settings;
|
||||
settings.enableVectorName( true );
|
||||
curve->applyCurveAutoNameSettings( settings );
|
||||
}
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
@@ -540,10 +551,7 @@ RimEnsembleCurveSet* addNewEnsembleCurve( RimSummaryPlot* summaryPlot, const Ria
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* addNewSummaryCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryCase* summaryCase )
|
||||
{
|
||||
auto curve = new RimSummaryCurve();
|
||||
|
||||
curve->setSummaryCaseY( summaryCase );
|
||||
curve->setSummaryAddressY( curveAddress.summaryAddressY() );
|
||||
auto curve = createCurve( summaryCase, curveAddress.summaryAddressY() );
|
||||
|
||||
curve->setSummaryCaseX( summaryCase );
|
||||
curve->setSummaryAddressX( curveAddress.summaryAddressX() );
|
||||
|
@@ -255,11 +255,8 @@ RimSummaryCurve* RicPlotProductionRateFeature::addSummaryCurve( RimSummaryPlot*
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
||||
auto newCurve = RiaSummaryPlotTools::createCurve( summaryCase, addr );
|
||||
plot->addCurveAndUpdate( newCurve );
|
||||
|
||||
newCurve->setSummaryCaseY( summaryCase );
|
||||
newCurve->setSummaryAddressY( addr );
|
||||
newCurve->setColor( color );
|
||||
newCurve->setLeftOrRightAxisY( RiuPlotAxis( plotAxis ) );
|
||||
newCurve->loadDataAndUpdate( true );
|
||||
|
@@ -87,7 +87,7 @@ RimSummaryCurve* RicSummaryPlotFeatureImpl::createHistoryCurve( const RifEclipse
|
||||
historyAddr.setVectorName( historyAddr.vectorName() + "H" );
|
||||
if ( summaryCasesToUse->summaryReader()->allResultAddresses().count( historyAddr ) )
|
||||
{
|
||||
return createCurve( summaryCasesToUse, historyAddr );
|
||||
return RiaSummaryPlotTools::createCurve( summaryCasesToUse, historyAddr );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -621,7 +621,7 @@ std::vector<RimSummaryPlot*> RicSummaryPlotFeatureImpl::createMultipleSummaryPlo
|
||||
const std::set<RifEclipseSummaryAddress>& allAddrsInCase = sumCase->summaryReader()->allResultAddresses();
|
||||
if ( allAddrsInCase.count( addr ) )
|
||||
{
|
||||
auto* newCurve = createCurve( sumCase, addr );
|
||||
auto newCurve = RiaSummaryPlotTools::createCurve( sumCase, addr );
|
||||
createdCurves.push_back( newCurve );
|
||||
}
|
||||
}
|
||||
@@ -682,18 +682,6 @@ std::set<RifEclipseSummaryAddress>
|
||||
return filteredAdressesFromCases;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* RicSummaryPlotFeatureImpl::createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& address )
|
||||
{
|
||||
auto curve = new RimSummaryCurve();
|
||||
curve->setSummaryCaseY( summaryCase );
|
||||
curve->setSummaryAddressY( address );
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -746,8 +734,7 @@ std::vector<RimSummaryCurve*> RicSummaryPlotFeatureImpl::addCurvesFromAddressFil
|
||||
|
||||
for ( const auto& addr : curveAddressesToUse )
|
||||
{
|
||||
auto* newCurve = createCurve( summaryCase, addr );
|
||||
|
||||
auto newCurve = RiaSummaryPlotTools::createCurve( summaryCase, addr );
|
||||
createdCurves.push_back( newCurve );
|
||||
plot->addCurveNoUpdate( newCurve );
|
||||
}
|
||||
|
@@ -83,8 +83,6 @@ private:
|
||||
EnsembleColoringType ensembleColoringStyle,
|
||||
QString ensembleColoringParameter );
|
||||
|
||||
static RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& address );
|
||||
|
||||
static RimSummaryCurve* createHistoryCurve( const RifEclipseSummaryAddress& addr, RimSummaryCase* summaryCasesToUse );
|
||||
|
||||
static std::vector<RimSummaryCurve*> addCurvesFromAddressFiltersToPlot( const QStringList& curveFilters,
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include "RiaTimeTTools.h"
|
||||
#include "Summary/RiaSummaryAddressAnalyzer.h"
|
||||
#include "Summary/RiaSummaryCurveDefinition.h"
|
||||
#include "Summary/RiaSummaryPlotTools.h"
|
||||
|
||||
#include "RimSummaryCalculationCollection.h"
|
||||
#include "SummaryPlotCommands/RicSummaryPlotEditorUi.h"
|
||||
@@ -2052,9 +2053,7 @@ void RimEnsembleCurveSet::updateEnsembleCurves( const std::vector<RimSummaryCase
|
||||
|
||||
for ( auto& sumCase : sumCases )
|
||||
{
|
||||
RimSummaryCurve* curve = new RimSummaryCurve();
|
||||
curve->setSummaryCaseY( sumCase );
|
||||
curve->setSummaryAddressY( addr->address() );
|
||||
auto curve = RiaSummaryPlotTools::createCurve( sumCase, addr->address() );
|
||||
curve->setResampling( m_resampling() );
|
||||
|
||||
int lineThickness = 1;
|
||||
@@ -2228,7 +2227,7 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
|
||||
|
||||
for ( const auto& address : addresses )
|
||||
{
|
||||
auto curve = new RimSummaryCurve();
|
||||
auto curve = RiaSummaryPlotTools::createCurve( summaryCase, address.summaryAddressY() );
|
||||
curve->setParentPlotNoReplot( plot->plotWidget() );
|
||||
m_curves.push_back( curve );
|
||||
curve->setColor( m_statistics->color() );
|
||||
@@ -2256,8 +2255,6 @@ void RimEnsembleCurveSet::updateStatisticsCurves( const std::vector<RimSummaryCa
|
||||
curve->setSymbolSize( m_statisticsSymbolSize() );
|
||||
}
|
||||
|
||||
curve->setSummaryCaseY( summaryCase );
|
||||
curve->setSummaryAddressY( address.summaryAddressY() );
|
||||
curve->setLeftOrRightAxisY( axisY() );
|
||||
|
||||
if ( isXAxisSummaryVector() )
|
||||
|
@@ -186,6 +186,14 @@ void RimSummaryCurveAutoName::applySettings( const RimSummaryCurveAutoName& othe
|
||||
m_connection = other.m_connection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCurveAutoName::enableVectorName( bool enable )
|
||||
{
|
||||
m_vectorName = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -37,6 +37,7 @@ public:
|
||||
const RimSummaryNameHelper* plotNameHelper ) const;
|
||||
|
||||
void applySettings( const RimSummaryCurveAutoName& other );
|
||||
void enableVectorName( bool enable );
|
||||
|
||||
private:
|
||||
QString curveNameY( const RifEclipseSummaryAddress& summaryAddress,
|
||||
|
@@ -97,6 +97,13 @@ QString RimSummaryNameHelper::aggregatedPlotTitle( const RimSummaryNameHelper& o
|
||||
{
|
||||
if ( !title.isEmpty() ) title += ", ";
|
||||
title += QString::fromStdString( RiuSummaryQuantityNameInfoProvider::instance()->longNameFromVectorName( vectorName, true ) );
|
||||
|
||||
// https://github.com/OPM/ResInsight/issues/12157
|
||||
size_t pos = vectorName.find( '_' );
|
||||
if ( pos != std::string::npos )
|
||||
{
|
||||
title += "(" + vectorName + ")";
|
||||
}
|
||||
}
|
||||
|
||||
return title;
|
||||
|
@@ -55,6 +55,7 @@
|
||||
#include "RimSummaryPlotControls.h"
|
||||
#include "RimSummaryPlotNameHelper.h"
|
||||
#include "RimSummaryTimeAxisProperties.h"
|
||||
#include "Tools/RimPlotAxisTools.h"
|
||||
|
||||
#include "RiuPlotAxis.h"
|
||||
#include "RiuPlotMainWindow.h"
|
||||
@@ -2560,9 +2561,7 @@ RimSummaryCurve* RimSummaryPlot::addNewCurve( const RifEclipseSummaryAddress& ad
|
||||
const RifEclipseSummaryAddress& addressX,
|
||||
RimSummaryCase* summaryCaseX )
|
||||
{
|
||||
auto* newCurve = new RimSummaryCurve();
|
||||
newCurve->setSummaryCaseY( summaryCase );
|
||||
newCurve->setSummaryAddressY( address );
|
||||
auto newCurve = RiaSummaryPlotTools::createCurve( summaryCase, address );
|
||||
|
||||
// This address is RifEclipseSummaryAddress::time() if the curve is a time plot. Otherwise it is the address of the summary vector used
|
||||
// for the x-axis
|
||||
@@ -3108,7 +3107,9 @@ void RimSummaryPlot::assignYPlotAxis( RimSummaryCurve* curve )
|
||||
{
|
||||
if ( c == curve ) continue;
|
||||
|
||||
if ( c->summaryAddressY().vectorName() == curve->summaryAddressY().vectorName() )
|
||||
auto incomingAxisText = RimPlotAxisTools::axisTextForAddress( curve->summaryAddressY() );
|
||||
auto currentAxisText = RimPlotAxisTools::axisTextForAddress( c->summaryAddressY() );
|
||||
if ( incomingAxisText == currentAxisText )
|
||||
{
|
||||
curve->setLeftOrRightAxisY( c->axisY() );
|
||||
return;
|
||||
@@ -3180,11 +3181,8 @@ void RimSummaryPlot::assignYPlotAxis( RimSummaryCurve* curve )
|
||||
|
||||
if ( plotWidget() && plotWidget()->isMultiAxisSupported() )
|
||||
{
|
||||
QString axisObjectName = "New Axis";
|
||||
if ( !curve->summaryAddressY().uiText().empty() ) axisObjectName = QString::fromStdString( curve->summaryAddressY().uiText() );
|
||||
|
||||
auto newPlotAxis = plotWidget()->createNextPlotAxis( plotAxisType );
|
||||
addNewAxisProperties( newPlotAxis, axisObjectName );
|
||||
addNewAxisProperties( newPlotAxis, "New Axis" );
|
||||
|
||||
curve->setLeftOrRightAxisY( newPlotAxis );
|
||||
return;
|
||||
@@ -3239,7 +3237,9 @@ void RimSummaryPlot::assignXPlotAxis( RimSummaryCurve* curve )
|
||||
{
|
||||
if ( c == curve ) continue;
|
||||
|
||||
if ( c->summaryAddressX().vectorName() == curve->summaryAddressX().vectorName() )
|
||||
auto incomingAxisText = RimPlotAxisTools::axisTextForAddress( curve->summaryAddressY() );
|
||||
auto currentAxisText = RimPlotAxisTools::axisTextForAddress( c->summaryAddressY() );
|
||||
if ( incomingAxisText == currentAxisText )
|
||||
{
|
||||
curve->setTopOrBottomAxisX( c->axisX() );
|
||||
return;
|
||||
@@ -3311,11 +3311,8 @@ void RimSummaryPlot::assignXPlotAxis( RimSummaryCurve* curve )
|
||||
RiuPlotAxis newPlotAxis = RiuPlotAxis::defaultBottomForSummaryVectors();
|
||||
if ( plotWidget() && plotWidget()->isMultiAxisSupported() )
|
||||
{
|
||||
QString axisObjectName = "New Axis";
|
||||
if ( !curve->summaryAddressX().uiText().empty() ) axisObjectName = QString::fromStdString( curve->summaryAddressX().uiText() );
|
||||
|
||||
newPlotAxis = plotWidget()->createNextPlotAxis( plotAxisType );
|
||||
addNewAxisProperties( newPlotAxis, axisObjectName );
|
||||
addNewAxisProperties( newPlotAxis, "New Axis" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -144,7 +144,7 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const
|
||||
|
||||
if ( sumAddress.isCalculated() )
|
||||
{
|
||||
titleText = shortCalculationName( quantityName );
|
||||
titleText = RimPlotAxisTools::shortCalculationName( quantityName );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -279,36 +279,17 @@ QString RimSummaryPlotAxisFormatter::autoAxisTitle() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimSummaryPlotAxisFormatter::createAxisObjectName() const
|
||||
{
|
||||
std::set<std::string> vectorNames;
|
||||
|
||||
auto addVectorNames = [&]( const RifEclipseSummaryAddress& sumAddress )
|
||||
{
|
||||
size_t cutPos = sumAddress.vectorName().find( ':' );
|
||||
if ( cutPos == std::string::npos ) cutPos = -1;
|
||||
|
||||
std::string name;
|
||||
const std::string& quantityName = sumAddress.vectorName().substr( cutPos + 1 );
|
||||
|
||||
if ( sumAddress.isCalculated() )
|
||||
{
|
||||
name = shortCalculationName( quantityName );
|
||||
}
|
||||
else
|
||||
{
|
||||
name = quantityName;
|
||||
}
|
||||
vectorNames.insert( name );
|
||||
};
|
||||
std::set<QString> vectorNames;
|
||||
|
||||
for ( RimSummaryCurve* rimCurve : m_summaryCurves )
|
||||
{
|
||||
if ( rimCurve->axisY() == m_axisProperties->plotAxis() )
|
||||
{
|
||||
addVectorNames( rimCurve->summaryAddressY() );
|
||||
vectorNames.insert( RimPlotAxisTools::axisTextForAddress( rimCurve->summaryAddressY() ) );
|
||||
}
|
||||
else if ( rimCurve->axisX() == m_axisProperties->plotAxis() )
|
||||
{
|
||||
addVectorNames( rimCurve->summaryAddressX() );
|
||||
vectorNames.insert( RimPlotAxisTools::axisTextForAddress( rimCurve->summaryAddressX() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,11 +297,11 @@ QString RimSummaryPlotAxisFormatter::createAxisObjectName() const
|
||||
{
|
||||
if ( m_axisProperties->plotAxis().isVertical() )
|
||||
{
|
||||
addVectorNames( curveDef.summaryAddressY() );
|
||||
vectorNames.insert( RimPlotAxisTools::axisTextForAddress( curveDef.summaryAddressY() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
addVectorNames( curveDef.summaryAddressX() );
|
||||
vectorNames.insert( RimPlotAxisTools::axisTextForAddress( curveDef.summaryAddressX() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +309,7 @@ QString RimSummaryPlotAxisFormatter::createAxisObjectName() const
|
||||
|
||||
for ( const auto& vectorName : vectorNames )
|
||||
{
|
||||
assembledAxisObjectName += QString::fromStdString( vectorName ) + " ";
|
||||
assembledAxisObjectName += vectorName + " ";
|
||||
}
|
||||
|
||||
if ( !m_timeHistoryCurveQuantities.empty() )
|
||||
@@ -351,19 +332,3 @@ QString RimSummaryPlotAxisFormatter::createAxisObjectName() const
|
||||
|
||||
return assembledAxisObjectName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RimSummaryPlotAxisFormatter::shortCalculationName( const std::string& calculationName )
|
||||
{
|
||||
QString calculationShortName = QString::fromStdString( calculationName );
|
||||
|
||||
int indexOfFirstSpace = calculationShortName.indexOf( ' ' );
|
||||
if ( indexOfFirstSpace > -1 && indexOfFirstSpace < calculationShortName.size() )
|
||||
{
|
||||
calculationShortName = calculationShortName.left( indexOfFirstSpace );
|
||||
}
|
||||
|
||||
return calculationShortName.toStdString();
|
||||
}
|
||||
|
@@ -44,8 +44,6 @@ private:
|
||||
QString autoAxisTitle() const;
|
||||
QString createAxisObjectName() const;
|
||||
|
||||
static std::string shortCalculationName( const std::string& calculationName );
|
||||
|
||||
private:
|
||||
RimPlotAxisProperties* m_axisProperties;
|
||||
const std::vector<RimSummaryCurve*> m_summaryCurves;
|
||||
|
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "RimPlotAxisTools.h"
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include "RimPlotAxisLogRangeCalculator.h"
|
||||
#include "RimPlotAxisProperties.h"
|
||||
#include "RimPlotCurve.h"
|
||||
@@ -225,4 +227,40 @@ QString scaleFactorText( const RimPlotAxisProperties* const axisProperties )
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString axisTextForAddress( RifEclipseSummaryAddress address )
|
||||
{
|
||||
if ( address.isCalculated() )
|
||||
{
|
||||
auto shortName = shortCalculationName( address.uiText() );
|
||||
return QString::fromStdString( shortName );
|
||||
}
|
||||
|
||||
auto candidate = QString::fromStdString( address.uiText() );
|
||||
|
||||
// Strip text starting with _ to avoid duplicate axis names
|
||||
auto index = candidate.indexOf( "_" );
|
||||
if ( index != -1 ) candidate = candidate.left( index );
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string shortCalculationName( const std::string& calculationName )
|
||||
{
|
||||
QString calculationShortName = QString::fromStdString( calculationName );
|
||||
|
||||
int indexOfFirstSpace = calculationShortName.indexOf( ' ' );
|
||||
if ( indexOfFirstSpace > -1 && indexOfFirstSpace < calculationShortName.size() )
|
||||
{
|
||||
calculationShortName = calculationShortName.left( indexOfFirstSpace );
|
||||
}
|
||||
|
||||
return calculationShortName.toStdString();
|
||||
}
|
||||
|
||||
} // namespace RimPlotAxisTools
|
||||
|
@@ -22,6 +22,7 @@ class RimPlotAxisProperties;
|
||||
class RimPlotCurve;
|
||||
class RiuPlotAxis;
|
||||
class RiuPlotWidget;
|
||||
class RifEclipseSummaryAddress;
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
@@ -36,7 +37,9 @@ void updatePlotWidgetFromAxisProperties( RiuPlotWidget*
|
||||
const QString& axisTitle,
|
||||
const std::vector<const RimPlotCurve*>& plotCurves );
|
||||
|
||||
void applyAxisScaleDraw( RiuPlotWidget* plotWidget, RiuPlotAxis axis, const RimPlotAxisProperties* const axisProperties );
|
||||
QString scaleFactorText( const RimPlotAxisProperties* const axisProperties );
|
||||
void applyAxisScaleDraw( RiuPlotWidget* plotWidget, RiuPlotAxis axis, const RimPlotAxisProperties* const axisProperties );
|
||||
QString scaleFactorText( const RimPlotAxisProperties* const axisProperties );
|
||||
QString axisTextForAddress( RifEclipseSummaryAddress address );
|
||||
std::string shortCalculationName( const std::string& calculationName );
|
||||
|
||||
}; // namespace RimPlotAxisTools
|
||||
|
Reference in New Issue
Block a user