From 4414b61efdf2eee5b5cd9e9bd3e30f4582392654 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Thu, 17 Dec 2020 09:05:37 +0100 Subject: [PATCH] #7018 VFP plots: Remove brackets for empty unit labels. --- .../ProjectDataModel/RimVfpPlot.cpp | 38 ++++++++++++------- ApplicationCode/ProjectDataModel/RimVfpPlot.h | 2 + 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp index 8329b7aea3..a39416474f 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.cpp @@ -396,16 +396,16 @@ void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget, plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); - QString xAxisTitle = QString( "%1 [%2]" ) - .arg( caf::AppEnum::uiText( - RimVfpPlot::ProductionVariableType::LIQUID_FLOW_RATE ), - getDisplayUnit( RimVfpPlot::ProductionVariableType::LIQUID_FLOW_RATE ) ); + QString xAxisTitle = + QString( "%1 %2" ).arg( caf::AppEnum::uiText( + RimVfpPlot::ProductionVariableType::LIQUID_FLOW_RATE ), + getDisplayUnitWithBracket( RimVfpPlot::ProductionVariableType::LIQUID_FLOW_RATE ) ); plotWidget->setAxisTitleText( QwtPlot::xBottom, xAxisTitle ); - QString yAxisTitle = QString( "%1 [%2]" ) - .arg( caf::AppEnum::uiText( m_interpolatedVariable() ), - getDisplayUnit( RimVfpPlot::ProductionVariableType::THP ) ); + QString yAxisTitle = + QString( "%1 %2" ).arg( caf::AppEnum::uiText( m_interpolatedVariable() ), + getDisplayUnitWithBracket( RimVfpPlot::ProductionVariableType::THP ) ); plotWidget->setAxisTitleText( QwtPlot::yLeft, yAxisTitle ); std::vector thpValues = table.getTHPAxis(); @@ -458,13 +458,13 @@ void RimVfpPlot::populatePlotWidgetWithCurveData( RiuQwtPlotWidget* plotWidget->setAxisAutoScale( QwtPlot::xBottom, true ); plotWidget->setAxisAutoScale( QwtPlot::yLeft, true ); - QString xAxisTitle = QString( "%1 [%2]" ) - .arg( caf::AppEnum::uiText( primaryVariable ), - getDisplayUnit( primaryVariable ) ); + QString xAxisTitle = + QString( "%1 %2" ).arg( caf::AppEnum::uiText( primaryVariable ), + getDisplayUnitWithBracket( primaryVariable ) ); plotWidget->setAxisTitleText( QwtPlot::xBottom, xAxisTitle ); - QString yAxisTitle = QString( "%1 [%2]" ) - .arg( caf::AppEnum::uiText( m_interpolatedVariable() ), - getDisplayUnit( RimVfpPlot::ProductionVariableType::THP ) ); + QString yAxisTitle = + QString( "%1 %2" ).arg( caf::AppEnum::uiText( m_interpolatedVariable() ), + getDisplayUnitWithBracket( RimVfpPlot::ProductionVariableType::THP ) ); plotWidget->setAxisTitleText( QwtPlot::yLeft, yAxisTitle ); std::vector primaryAxisValues = getProductionTableData( table, primaryVariable ); @@ -574,6 +574,18 @@ void RimVfpPlot::convertToDisplayUnit( std::vector& values, RimVfpPlot:: values[i] = convertToDisplayUnit( values[i], variableType ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimVfpPlot::getDisplayUnitWithBracket( RimVfpPlot::ProductionVariableType variableType ) +{ + QString unit = getDisplayUnit( variableType ); + if ( !unit.isEmpty() ) + return QString( "[%1]" ).arg( unit ); + else + return unit; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimVfpPlot.h b/ApplicationCode/ProjectDataModel/RimVfpPlot.h index 2166539185..26cd13fccf 100644 --- a/ApplicationCode/ProjectDataModel/RimVfpPlot.h +++ b/ApplicationCode/ProjectDataModel/RimVfpPlot.h @@ -126,6 +126,8 @@ private: static QString getDisplayUnit( RimVfpPlot::ProductionVariableType variableType ); + static QString getDisplayUnitWithBracket( RimVfpPlot::ProductionVariableType variableType ); + private: caf::PdmField m_filePath; caf::PdmField m_tableNumber;