From 78e4e1cd5ca073518176bb08fdd1f7c3e0e20e74 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 18 May 2021 15:31:40 +0200 Subject: [PATCH] Janitor : Use enum class --- .../RicExportCompletionDataSettingsUi.cpp | 32 +++++++++---------- .../RicExportCompletionDataSettingsUi.h | 6 ++-- ...ellPathExportCompletionDataFeatureImpl.cpp | 18 ++++++----- .../RicWellPathExportMswCompletionsImpl.cpp | 5 +-- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index d2b0f29065..3f774af6d6 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -32,26 +32,26 @@ namespace caf template<> void RicExportCompletionDataSettingsUi::ExportSplitType::setUp() { - addItem(RicExportCompletionDataSettingsUi::UNIFIED_FILE, "UNIFIED_FILE", "Unified File"); - addItem(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL, "SPLIT_ON_WELL", "Split on Well"); - addItem(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE, "SPLIT_ON_WELL_AND_COMPLETION_TYPE", "Split on Well and Completion Type"); - setDefault(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE); + addItem(RicExportCompletionDataSettingsUi::ExportSplit::UNIFIED_FILE, "UNIFIED_FILE", "Unified File"); + addItem(RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL, "SPLIT_ON_WELL", "Split on Well"); + addItem(RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL_AND_COMPLETION_TYPE, "SPLIT_ON_WELL_AND_COMPLETION_TYPE", "Split on Well and Completion Type"); + setDefault(RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL_AND_COMPLETION_TYPE); } template<> void RicExportCompletionDataSettingsUi::CompdatExportType::setUp() { - addItem(RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES, "TRANSMISSIBILITIES", "Calculated Transmissibilities"); - addItem(RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS, "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS", "Default Connection Factors and WPIMULT (Fractures Not Supported)"); - setDefault(RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES); + addItem(RicExportCompletionDataSettingsUi::CompdatExport::TRANSMISSIBILITIES, "TRANSMISSIBILITIES", "Calculated Transmissibilities"); + addItem(RicExportCompletionDataSettingsUi::CompdatExport::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS, "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS", "Default Connection Factors and WPIMULT (Fractures Not Supported)"); + setDefault(RicExportCompletionDataSettingsUi::CompdatExport::TRANSMISSIBILITIES); } template<> void RicExportCompletionDataSettingsUi::CombinationModeType::setUp() { - addItem(RicExportCompletionDataSettingsUi::INDIVIDUALLY, "INDIVIDUALLY", "Individually"); - addItem(RicExportCompletionDataSettingsUi::COMBINED, "COMBINED", "Combined"); - setDefault(RicExportCompletionDataSettingsUi::INDIVIDUALLY); + addItem(RicExportCompletionDataSettingsUi::CombinationMode::INDIVIDUALLY, "INDIVIDUALLY", "Individually"); + addItem(RicExportCompletionDataSettingsUi::CombinationMode::COMBINED, "COMBINED", "Combined"); + setDefault(RicExportCompletionDataSettingsUi::CombinationMode::INDIVIDUALLY); } template<> @@ -199,7 +199,7 @@ void RicExportCompletionDataSettingsUi::showFishbonesInUi( bool enable ) //-------------------------------------------------------------------------------------------------- bool RicExportCompletionDataSettingsUi::reportCompletionsTypesIndividually() const { - return m_reportCompletionTypesSeparately() == INDIVIDUALLY; + return m_reportCompletionTypesSeparately() == CombinationMode::INDIVIDUALLY; } //-------------------------------------------------------------------------------------------------- @@ -270,11 +270,11 @@ void RicExportCompletionDataSettingsUi::fieldChangedByUi( const caf::PdmFieldHan { if ( changedField == &compdatExport ) { - if ( compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS ) + if ( compdatExport == CompdatExport::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS ) { includeFractures = false; } - else if ( compdatExport == TRANSMISSIBILITIES || includeMsw ) + else if ( compdatExport == CompdatExport::TRANSMISSIBILITIES || includeMsw ) { includeFractures = true; } @@ -385,7 +385,7 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering( QString uiConfigName, group->add( &m_reportCompletionTypesSeparately ); group->add( &folder ); - if ( fileSplit() == UNIFIED_FILE ) + if ( fileSplit() == ExportSplit::UNIFIED_FILE ) { group->add( &m_useCustomFileName ); @@ -453,8 +453,8 @@ void RicExportCompletionDataSettingsUi::defineUiOrdering( QString uiConfigName, } // Set visibility - includeFractures.uiCapability()->setUiHidden( compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS && - !includeMsw ); + includeFractures.uiCapability()->setUiHidden( + compdatExport == CompdatExport::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS && !includeMsw ); } if ( !m_displayForSimWell ) diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 452e9bd597..0bfade5059 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -34,7 +34,7 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi public: // Exported in .proto file. Do not change without changing .proto - enum ExportSplit + enum class ExportSplit { UNIFIED_FILE, SPLIT_ON_WELL, @@ -43,7 +43,7 @@ public: typedef caf::AppEnum ExportSplitType; // Exported in .proto file. Do not change without changing .proto - enum CompdatExport + enum class CompdatExport { TRANSMISSIBILITIES, WPIMULT_AND_DEFAULT_CONNECTION_FACTORS, @@ -51,7 +51,7 @@ public: typedef caf::AppEnum CompdatExportType; // Exported in .proto file. Do not change without changing .proto - enum CombinationMode + enum class CombinationMode { INDIVIDUALLY, COMBINED, diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index 8120306645..59a8f17b87 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -269,7 +269,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription(); - if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE ) + if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::ExportSplit::UNIFIED_FILE ) { QString fileName = exportSettings.customFileName(); if ( fileName.isEmpty() ) fileName = QString( "UnifiedCompletions_%1" ).arg( eclipseCaseName ); @@ -283,7 +283,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v exportSettings.exportDataSourceAsComment(), exportSettings.exportWelspec() ); } - else if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ) + else if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL ) { for ( auto wellPath : topLevelWellPaths ) { @@ -318,7 +318,8 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v exportSettings.exportWelspec() ); } } - else if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ) + else if ( exportSettings.fileSplit == + RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL_AND_COMPLETION_TYPE ) { std::vector completionTypes; completionTypes.push_back( RigCompletionData::CompletionType::FISHBONES ); @@ -380,8 +381,8 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions( const std::v } // Export sim wells - if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL || - exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ) + if ( exportSettings.fileSplit == RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL || + exportSettings.fileSplit == RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL_AND_COMPLETION_TYPE ) { for ( auto simWell : simWells ) { @@ -568,7 +569,7 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell combinedDFactor = dFactorCalculator.weightedMean() / completions.size(); } - if ( settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES ) + if ( settings.compdatExport == RicExportCompletionDataSettingsUi::CompdatExport::TRANSMISSIBILITIES ) { resultCompletion.setCombinedValuesExplicitTrans( combinedTrans, combinedKh, @@ -578,7 +579,8 @@ RigCompletionData RicWellPathExportCompletionDataFeatureImpl::combineEclipseCell cellDirection, completionType ); } - else if ( settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS ) + else if ( settings.compdatExport == + RicExportCompletionDataSettingsUi::CompdatExport::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS ) { // calculate trans for main bore - but as Eclipse will do it! double transmissibilityEclipseCalculation = @@ -954,7 +956,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompdatAndWpimultTables( QString gridName = gridCompletions.first; exportCompdatTableUsingFormatter( formatter, gridName, completions ); - if ( exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS ) + if ( exportType == RicExportCompletionDataSettingsUi::CompdatExport::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS ) { exportWpimultTableUsingFormatter( formatter, gridName, completions ); } diff --git a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index b8b058cd6c..4560bdb7d6 100644 --- a/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -68,7 +68,7 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( { std::shared_ptr unifiedExportFile; std::shared_ptr unifiedLgrExportFile; - if ( exportSettings.fileSplit() == RicExportCompletionDataSettingsUi::UNIFIED_FILE ) + if ( exportSettings.fileSplit() == RicExportCompletionDataSettingsUi::ExportSplit::UNIFIED_FILE ) { { QString fileName; @@ -115,7 +115,8 @@ void RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( completion->componentType() == RiaDefines::WellPathComponentType::FISHBONES; } ); - if ( exportSettings.fileSplit() == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL && !unifiedWellPathFile ) + if ( exportSettings.fileSplit() == RicExportCompletionDataSettingsUi::ExportSplit::SPLIT_ON_WELL && + !unifiedWellPathFile ) { QString wellFileName = QString( "%1_UnifiedCompletions_MSW_%2" ) .arg( wellPath->name(), exportSettings.caseToApply->caseUserDescription() );