#12157 Always show vector name when underscore is present

This commit is contained in:
Magne Sjaastad
2025-02-12 13:51:11 +01:00
parent 04cd253fc6
commit 0604eea74b
13 changed files with 95 additions and 91 deletions

View File

@@ -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

View File

@@ -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