mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-30 17:10:19 -05:00
Move number formatting setting to CAF to enable use in UI editors
* Move RiaNumberFormat to cafPdmUiNumberFormat in caf framework * Add unit test
This commit is contained in:
1 parent
6cdcc4493a
commit
9aa5a3d222
26 files changed
+481
-197
No files matched your search
@@ -21,7 +21,6 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaNumberFormat.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaWeightedGeometricMeanCalculator.h"
|
||||
#include "RiaWeightedHarmonicMeanCalculator.h"
|
||||
@@ -45,6 +44,7 @@
|
||||
#include "FractureCommands/RicNewStimPlanFractureTemplateFeature.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmUiNumberFormat.h"
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
#include "cafPdmUiToolButtonEditor.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
@@ -1276,12 +1276,12 @@ QString RimEnsembleFractureStatistics::generateStatisticsTable(
|
||||
text += "</thead>";
|
||||
text += "<tbody>";
|
||||
|
||||
auto emptyTextOnInf = []( double value, RiaNumberFormat::NumberFormatType numberFormat, int precision )
|
||||
auto emptyTextOnInf = []( double value, caf::NumberFormatType numberFormat, int precision )
|
||||
{
|
||||
if ( std::isinf( value ) )
|
||||
return QString( "" );
|
||||
else
|
||||
return RiaNumberFormat::valueToText( value, numberFormat, precision );
|
||||
return caf::PdmUiNumberFormat::valueToText( value, numberFormat, precision );
|
||||
};
|
||||
|
||||
for ( auto propertyType : propertyTypes )
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "RiaEclipseUnitTools.h"
|
||||
#include "RiaFractureDefines.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaNumberFormat.h"
|
||||
#include "RiaWeightedGeometricMeanCalculator.h"
|
||||
#include "RiaWeightedMeanCalculator.h"
|
||||
|
||||
@@ -52,6 +51,7 @@
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
#include "cafPdmUiDoubleSliderEditor.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafPdmUiNumberFormat.h"
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
@@ -818,7 +818,7 @@ void RimStimPlanFractureTemplate::appendTextIfValidValue( QString&
|
||||
{
|
||||
QString name = caf::AppEnum<RigEnsembleFractureStatisticsCalculator::PropertyType>::uiText( propertyType );
|
||||
auto [numberFormat, precision] = RigEnsembleFractureStatisticsCalculator::numberFormatForProperty( propertyType );
|
||||
body += QString( "%1: %2<br>" ).arg( name ).arg( RiaNumberFormat::valueToText( value, numberFormat, precision ) );
|
||||
body += QString( "%1: %2<br>" ).arg( name ).arg( caf::PdmUiNumberFormat::valueToText( value, numberFormat, precision ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
#include "RiaNumberFormat.h"
|
||||
#include "RiaNumericalTools.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaResultNames.h"
|
||||
@@ -153,7 +152,7 @@ RimRegularLegendConfig::RimRegularLegendConfig()
|
||||
m_significantDigitsInData = m_precision;
|
||||
CAF_PDM_InitField( &m_tickNumberFormat,
|
||||
"TickNumberFormat",
|
||||
caf::AppEnum<RiaNumberFormat::NumberFormatType>( RiaNumberFormat::NumberFormatType::FIXED ),
|
||||
caf::AppEnum<caf::NumberFormatType>( caf::NumberFormatType::FIXED ),
|
||||
"Number format" );
|
||||
|
||||
CAF_PDM_InitField( &m_colorRangeMode_OBSOLETE, "ColorRangeMode", ColorRangeEnum( ColorRangesType::UNDEFINED ), "Colors" );
|
||||
@@ -533,12 +532,12 @@ void RimRegularLegendConfig::updateLegend()
|
||||
decadesInRange = cvf::Math::ceil( decadesInRange );
|
||||
|
||||
// Using Fixed format
|
||||
RiaNumberFormat::NumberFormatType nft = m_tickNumberFormat();
|
||||
caf::NumberFormatType nft = m_tickNumberFormat();
|
||||
m_scalarMapperLegend->setTickFormat( (caf::OverlayScalarMapperLegend::NumberFormat)nft );
|
||||
|
||||
// Set the fixed number of digits after the decimal point to the number needed to show all the significant digits.
|
||||
int numDecimalDigits = m_precision();
|
||||
if ( nft != RiaNumberFormat::NumberFormatType::SCIENTIFIC )
|
||||
if ( nft != caf::NumberFormatType::SCIENTIFIC )
|
||||
{
|
||||
numDecimalDigits -= static_cast<int>( decadesInRange );
|
||||
}
|
||||
@@ -572,7 +571,7 @@ void RimRegularLegendConfig::updateLegend()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::setTickNumberFormat( RiaNumberFormat::NumberFormatType numberFormat )
|
||||
void RimRegularLegendConfig::setTickNumberFormat( caf::NumberFormatType numberFormat )
|
||||
{
|
||||
m_tickNumberFormat = numberFormat;
|
||||
}
|
||||
@@ -1136,13 +1135,13 @@ void RimRegularLegendConfig::updateFonts()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimRegularLegendConfig::valueToText( double value ) const
|
||||
{
|
||||
return RiaNumberFormat::valueToText( value, m_tickNumberFormat(), m_significantDigitsInData );
|
||||
return caf::PdmUiNumberFormat::valueToText( value, m_tickNumberFormat(), m_significantDigitsInData );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaNumberFormat::NumberFormatType RimRegularLegendConfig::tickNumberFormat() const
|
||||
caf::NumberFormatType RimRegularLegendConfig::tickNumberFormat() const
|
||||
{
|
||||
return m_tickNumberFormat();
|
||||
}
|
||||
@@ -1164,7 +1163,7 @@ void RimRegularLegendConfig::setDefaultConfigForResultName( int caseId, const QS
|
||||
|
||||
RimRegularLegendConfig::MappingType mappingType = MappingType::LINEAR_CONTINUOUS;
|
||||
RimLegendConfig::RangeModeType rangeType = RimLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS;
|
||||
RiaNumberFormat::NumberFormatType numberFormat = RiaNumberFormat::NumberFormatType::FIXED;
|
||||
caf::NumberFormatType numberFormat = caf::NumberFormatType::FIXED;
|
||||
|
||||
if ( useLog )
|
||||
{
|
||||
@@ -1173,7 +1172,7 @@ void RimRegularLegendConfig::setDefaultConfigForResultName( int caseId, const QS
|
||||
else
|
||||
mappingType = RimRegularLegendConfig::MappingType::LOG10_CONTINUOUS;
|
||||
|
||||
numberFormat = RiaNumberFormat::NumberFormatType::AUTO;
|
||||
numberFormat = caf::NumberFormatType::AUTO;
|
||||
rangeType = RimLegendConfig::RangeModeType::USER_DEFINED;
|
||||
}
|
||||
|
||||
@@ -1203,7 +1202,7 @@ void RimRegularLegendConfig::setDefaultConfigForResultName( int caseId, const QS
|
||||
{
|
||||
mappingType = MappingType::LINEAR_DISCRETE;
|
||||
rangeType = RimLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS;
|
||||
numberFormat = RiaNumberFormat::NumberFormatType::FIXED;
|
||||
numberFormat = caf::NumberFormatType::FIXED;
|
||||
}
|
||||
|
||||
resetUserDefinedValues();
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaNumberFormat.h"
|
||||
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimLegendConfigChangeType.h"
|
||||
|
||||
@@ -29,6 +27,7 @@
|
||||
#include "cvfObject.h"
|
||||
|
||||
#include "cafPdmPtrField.h"
|
||||
#include "cafPdmUiNumberFormat.h"
|
||||
#include "cafSignal.h"
|
||||
|
||||
#include <tuple>
|
||||
@@ -128,9 +127,9 @@ public:
|
||||
void setMappingMode( MappingType mappingType );
|
||||
MappingType mappingMode() { return m_mappingMode(); }
|
||||
|
||||
void setTickNumberFormat( RiaNumberFormat::NumberFormatType numberFormat );
|
||||
void setTickNumberFormat( caf::NumberFormatType numberFormat );
|
||||
|
||||
RiaNumberFormat::NumberFormatType tickNumberFormat() const;
|
||||
caf::NumberFormatType tickNumberFormat() const;
|
||||
|
||||
int significantDigitsInData() const;
|
||||
|
||||
@@ -229,17 +228,17 @@ private:
|
||||
cvf::Color3ubArray m_categoryColors;
|
||||
|
||||
// Fields
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
caf::PdmField<int> m_numLevels;
|
||||
caf::PdmField<int> m_precision;
|
||||
caf::PdmField<caf::AppEnum<RiaNumberFormat::NumberFormatType>> m_tickNumberFormat;
|
||||
caf::PdmField<RangeModeEnum> m_rangeMode;
|
||||
caf::PdmField<double> m_userDefinedMaxValue;
|
||||
caf::PdmField<double> m_userDefinedMinValue;
|
||||
caf::PdmField<caf::AppEnum<ColorRangesType>> m_colorRangeMode_OBSOLETE;
|
||||
caf::PdmField<caf::AppEnum<MappingType>> m_mappingMode;
|
||||
caf::PdmField<caf::AppEnum<CategoryColorModeType>> m_categoryColorMode;
|
||||
caf::PdmField<bool> m_centerLegendAroundZero;
|
||||
caf::PdmField<bool> m_showLegend;
|
||||
caf::PdmField<int> m_numLevels;
|
||||
caf::PdmField<int> m_precision;
|
||||
caf::PdmField<caf::AppEnum<caf::NumberFormatType>> m_tickNumberFormat;
|
||||
caf::PdmField<RangeModeEnum> m_rangeMode;
|
||||
caf::PdmField<double> m_userDefinedMaxValue;
|
||||
caf::PdmField<double> m_userDefinedMinValue;
|
||||
caf::PdmField<caf::AppEnum<ColorRangesType>> m_colorRangeMode_OBSOLETE;
|
||||
caf::PdmField<caf::AppEnum<MappingType>> m_mappingMode;
|
||||
caf::PdmField<caf::AppEnum<CategoryColorModeType>> m_categoryColorMode;
|
||||
caf::PdmField<bool> m_centerLegendAroundZero;
|
||||
|
||||
caf::PdmPtrField<RimColorLegend*> m_colorLegend;
|
||||
caf::PdmField<bool> m_selectColorLegendButton;
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
#include "cafPdmUiLabelEditor.h"
|
||||
#include "cafPdmUiNumberFormat.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
@@ -1879,7 +1880,7 @@ void RimSummaryMultiPlot::updateReadOutLines( double qwtTimeValue, double yValue
|
||||
anno->setValue( yValue );
|
||||
|
||||
auto scaledValue = yValue / annotationAxis->scaleFactor();
|
||||
auto valueText = RiaNumberFormat::valueToText( scaledValue, RiaNumberFormat::NumberFormatType::FIXED, 2 );
|
||||
auto valueText = caf::PdmUiNumberFormat::valueToText( scaledValue, caf::NumberFormatType::FIXED, 2 );
|
||||
|
||||
anno->setName( valueText );
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "RimSummaryPlotAxisFormatter.h"
|
||||
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaNumberFormat.h"
|
||||
#include "Summary/RiaSummaryCurveDefinition.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
Reference in new issue
Block a user