diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp index e8c956a7a4..9025b559f7 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -1082,11 +1082,11 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspecsToFile(RimEclipse formatter .add(completions->wellNameForExport()) - .add(completions->wellGroupName()) + .add(completions->wellGroupNameForExport()) .addOneBasedCellIndex(ijIntersection.x()) .addOneBasedCellIndex(ijIntersection.y()) - .add(completions->referenceDepth()) - .add(completions->wellTypeName()) + .add(completions->referenceDepthForExport()) + .add(completions->wellTypeNameForExport()) .rowCompleted(); } @@ -1147,12 +1147,12 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile(RimEclipse formatter .add(completions->wellNameForExport()) - .add(completions->wellGroupName()) + .add(completions->wellGroupNameForExport()) .add(lgrName) .addOneBasedCellIndex(ijIntersection.x()) .addOneBasedCellIndex(ijIntersection.y()) - .add(completions->referenceDepth()) - .add(completions->wellTypeName()) + .add(completions->referenceDepthForExport()) + .add(completions->wellTypeNameForExport()) .rowCompleted(); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp index 247eb9968a..df0bdc656c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp @@ -18,6 +18,8 @@ #include "RimWellPathCompletions.h" +#include "RiaStdStringTools.h" + #include "RimFishbonesCollection.h" #include "RimFishboneWellPathCollection.h" #include "RimPerforationCollection.h" @@ -27,6 +29,13 @@ #include "cafPdmUiTreeOrdering.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// Internal constants +//-------------------------------------------------------------------------------------------------- +#define DOUBLE_INF std::numeric_limits::infinity() + namespace caf { @@ -98,7 +107,8 @@ RimPerforationCollection* RimWellPathCompletions::perforationCollection() const //-------------------------------------------------------------------------------------------------- void RimWellPathCompletions::setWellNameForExport(const QString& name) { - m_wellNameForExport = name; + auto n = name; + m_wellNameForExport = n.remove(' '); } //-------------------------------------------------------------------------------------------------- @@ -106,31 +116,43 @@ void RimWellPathCompletions::setWellNameForExport(const QString& name) //-------------------------------------------------------------------------------------------------- QString RimWellPathCompletions::wellNameForExport() const { - return m_wellNameForExport(); + return formatStringForExport(m_wellNameForExport()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPathCompletions::wellGroupName() const +QString RimWellPathCompletions::wellGroupNameForExport() const { - return m_wellGroupName; + return formatStringForExport(m_wellGroupName, "1*"); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPathCompletions::referenceDepth() const +QString RimWellPathCompletions::referenceDepthForExport() const { - return m_referenceDepth; + std::string refDepth = m_referenceDepth.v().toStdString(); + if (RiaStdStringTools::isNumber(refDepth, '.')) + { + return m_referenceDepth.v(); + } + return "1*"; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimWellPathCompletions::wellTypeName() const +QString RimWellPathCompletions::wellTypeNameForExport() const { - return WellTypeEnum(m_wellType).uiText(); + switch (m_wellType.v()) + { + case OIL: return "OIL"; + case GAS: return "GAS"; + case WATER: return "WATER"; + case LIQUID: return "LIQ"; + } + return ""; } //-------------------------------------------------------------------------------------------------- @@ -190,3 +212,37 @@ void RimWellPathCompletions::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTree uiTreeOrdering.add(&m_fractureCollection); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathCompletions::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_referenceDepth) + { + if (!RiaStdStringTools::isNumber(m_referenceDepth.v().toStdString(), '.')) + { + if (!RiaStdStringTools::isNumber(m_referenceDepth.v().toStdString(), ',')) + { + // Remove invalid input text + m_referenceDepth = ""; + } + else + { + // Wrong decimal sign entered, replace , by . + auto text = m_referenceDepth.v(); + m_referenceDepth = text.replace(',', '.'); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimWellPathCompletions::formatStringForExport(const QString& text, const QString& defaultValue) const +{ + if (text.isEmpty()) return defaultValue; + if (text.contains(' ')) return QString("'%1'").arg(text); + return text; +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h index 957038e15f..d58eb10f61 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h @@ -47,15 +47,19 @@ public: void setWellNameForExport(const QString& name); QString wellNameForExport() const; - QString wellGroupName() const; - QString referenceDepth() const; - QString wellTypeName() const; + QString wellGroupNameForExport() const; + QString referenceDepthForExport() const; + QString wellTypeNameForExport() const; bool hasCompletions() const; void setUnitSystemSpecificDefaults(); protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + +private: + QString formatStringForExport(const QString& text, const QString& defaultText = "") const; private: caf::PdmChildField m_fishbonesCollection;