mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 15:36:09 -06:00
#3953 Extend well completions spec
This commit is contained in:
parent
fde60d1e34
commit
7a50fa12f8
@ -705,14 +705,21 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspecsToFile(RimEclipse
|
||||
QTextStream stream(exportFile.get());
|
||||
|
||||
RifEclipseDataTableFormatter formatter(stream);
|
||||
formatter.setColumnSpacing(3);
|
||||
formatter.setColumnSpacing(2);
|
||||
|
||||
std::vector<RifEclipseOutputTableColumn> header = {RifEclipseOutputTableColumn("Well"),
|
||||
RifEclipseOutputTableColumn("Grp"),
|
||||
RifEclipseOutputTableColumn("I"),
|
||||
RifEclipseOutputTableColumn("J"),
|
||||
RifEclipseOutputTableColumn("RefDepth"),
|
||||
RifEclipseOutputTableColumn("WellType")};
|
||||
RifEclipseOutputTableColumn("Type"),
|
||||
RifEclipseOutputTableColumn("DrainRad"),
|
||||
RifEclipseOutputTableColumn("GasInEq"),
|
||||
RifEclipseOutputTableColumn("AutoShut"),
|
||||
RifEclipseOutputTableColumn("XFlow"),
|
||||
RifEclipseOutputTableColumn("FluidPVT"),
|
||||
RifEclipseOutputTableColumn("HydSDens"),
|
||||
RifEclipseOutputTableColumn("FluidInPlReg")};
|
||||
|
||||
formatter.keyword("WELSPECS");
|
||||
formatter.header(header);
|
||||
@ -732,15 +739,22 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspecsToFile(RimEclipse
|
||||
// Export
|
||||
for (const auto wellPath : wellPathSet)
|
||||
{
|
||||
auto rimCcompletions = wellPath->completions();
|
||||
auto rimCompletions = wellPath->completions();
|
||||
auto ijIntersection = wellPathUpperGridIntersectionIJ(gridCase, wellPath);
|
||||
|
||||
formatter.add(rimCcompletions->wellNameForExport())
|
||||
.add(rimCcompletions->wellGroupNameForExport())
|
||||
formatter.add(rimCompletions->wellNameForExport())
|
||||
.add(rimCompletions->wellGroupNameForExport())
|
||||
.addOneBasedCellIndex(ijIntersection.second.x())
|
||||
.addOneBasedCellIndex(ijIntersection.second.y())
|
||||
.add(rimCcompletions->referenceDepthForExport())
|
||||
.add(rimCcompletions->wellTypeNameForExport())
|
||||
.add(rimCompletions->referenceDepthForExport())
|
||||
.add(rimCompletions->wellTypeNameForExport())
|
||||
.add(rimCompletions->drainageRadiusForExport())
|
||||
.add(rimCompletions->gasInflowEquationForExport())
|
||||
.add(rimCompletions->automaticWellShutInForExport())
|
||||
.add(rimCompletions->allowWellCrossFlowForExport())
|
||||
.add(rimCompletions->wellBoreFluidPVTForExport())
|
||||
.add(rimCompletions->hydrostaticDensityForExport())
|
||||
.add(rimCompletions->fluidInPlaceRegionForExport())
|
||||
.rowCompleted();
|
||||
}
|
||||
|
||||
@ -758,7 +772,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile(
|
||||
QTextStream stream(exportFile.get());
|
||||
|
||||
RifEclipseDataTableFormatter formatter(stream);
|
||||
formatter.setColumnSpacing(3);
|
||||
formatter.setColumnSpacing(2);
|
||||
|
||||
std::vector<RifEclipseOutputTableColumn> header = {RifEclipseOutputTableColumn("Well"),
|
||||
RifEclipseOutputTableColumn("Grp"),
|
||||
@ -766,7 +780,14 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile(
|
||||
RifEclipseOutputTableColumn("I"),
|
||||
RifEclipseOutputTableColumn("J"),
|
||||
RifEclipseOutputTableColumn("RefDepth"),
|
||||
RifEclipseOutputTableColumn("WellType")};
|
||||
RifEclipseOutputTableColumn("Type"),
|
||||
RifEclipseOutputTableColumn("DrainRad"),
|
||||
RifEclipseOutputTableColumn("GasInEq"),
|
||||
RifEclipseOutputTableColumn("AutoShut"),
|
||||
RifEclipseOutputTableColumn("XFlow"),
|
||||
RifEclipseOutputTableColumn("FluidPVT"),
|
||||
RifEclipseOutputTableColumn("HydSDens"),
|
||||
RifEclipseOutputTableColumn("FluidInPlReg")};
|
||||
|
||||
formatter.keyword("WELSPECL");
|
||||
formatter.header(header);
|
||||
@ -817,6 +838,13 @@ void RicWellPathExportCompletionDataFeatureImpl::exportWelspeclToFile(
|
||||
.addOneBasedCellIndex(ijIntersection.y())
|
||||
.add(rimCompletions->referenceDepthForExport())
|
||||
.add(rimCompletions->wellTypeNameForExport())
|
||||
.add(rimCompletions->drainageRadiusForExport())
|
||||
.add(rimCompletions->gasInflowEquationForExport())
|
||||
.add(rimCompletions->automaticWellShutInForExport())
|
||||
.add(rimCompletions->allowWellCrossFlowForExport())
|
||||
.add(rimCompletions->wellBoreFluidPVTForExport())
|
||||
.add(rimCompletions->hydrostaticDensityForExport())
|
||||
.add(rimCompletions->fluidInPlaceRegionForExport())
|
||||
.rowCompleted();
|
||||
}
|
||||
}
|
||||
|
@ -24,37 +24,12 @@
|
||||
#include "cafPdmUiDoubleValueEditor.h"
|
||||
#include "cafPdmUiGroup.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
|
||||
#include <QDoubleValidator>
|
||||
#include "cafPdmDoubleStringValidator.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellPathAicdParameters, "WellPathAicdParameters");
|
||||
|
||||
class NumericStringValidator : public QDoubleValidator
|
||||
{
|
||||
public:
|
||||
NumericStringValidator(const QString& defaultValue)
|
||||
: m_defaultValue(defaultValue), QDoubleValidator(nullptr)
|
||||
{}
|
||||
|
||||
void fixup(QString& input) const override
|
||||
{
|
||||
input = m_defaultValue;
|
||||
}
|
||||
|
||||
State validate(QString& input, int& pos) const override
|
||||
{
|
||||
if (input == m_defaultValue)
|
||||
{
|
||||
return QValidator::Acceptable;
|
||||
}
|
||||
|
||||
return QDoubleValidator::validate(input, pos);
|
||||
}
|
||||
private:
|
||||
QString m_defaultValue;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -133,7 +108,7 @@ std::array<double, AICD_NUM_PARAMS> RimWellPathAicdParameters::doubleValues() co
|
||||
std::array<double, AICD_NUM_PARAMS> doubleValues;
|
||||
for (int i = 0; i < (int)AICD_NUM_PARAMS; ++i)
|
||||
{
|
||||
NumericStringValidator validator(nullptr);
|
||||
caf::PdmDoubleStringValidator validator(nullptr);
|
||||
QString stringValue = m_aicdParameterFields[(AICDParameters)i].value();
|
||||
bool ok = true;
|
||||
double doubleValue = stringValue.toDouble(&ok);
|
||||
@ -186,11 +161,11 @@ void RimWellPathAicdParameters::defineEditorAttribute(const caf::PdmFieldHandle*
|
||||
{
|
||||
if (stringFieldsWithNoValidDefault().count(stringField))
|
||||
{
|
||||
lineEditorAttr->validator = new NumericStringValidator("");
|
||||
lineEditorAttr->validator = new caf::PdmDoubleStringValidator("");
|
||||
}
|
||||
else
|
||||
{
|
||||
lineEditorAttr->validator = new NumericStringValidator("1*");
|
||||
lineEditorAttr->validator = new caf::PdmDoubleStringValidator("1*");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include "cafPdmDoubleStringValidator.h"
|
||||
#include "cafPdmUiDoubleValueEditor.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
|
||||
@ -56,7 +58,37 @@ namespace caf {
|
||||
|
||||
setDefault(RimWellPathCompletions::OIL);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void RimWellPathCompletions::GasInflowEnum::setUp()
|
||||
{
|
||||
addItem(RimWellPathCompletions::STANDARD_EQ, "STD", "Standard");
|
||||
addItem(RimWellPathCompletions::RUSSELL_GOODRICH, "R-G", "Russell-Goodrich");
|
||||
addItem(RimWellPathCompletions::DRY_GAS_PSEUDO_PRESSURE, "P-P", "Dry Gas Pseudo-Pressure");
|
||||
addItem(RimWellPathCompletions::GENERALIZED_PSEUDO_PRESSURE, "GPP", "Generalized Pseudo-Pressure");
|
||||
|
||||
setDefault(RimWellPathCompletions::STANDARD_EQ);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RimWellPathCompletions::AutomaticWellShutInEnum::setUp()
|
||||
{
|
||||
addItem(RimWellPathCompletions::ISOLATE_FROM_FORMATION, "SHUT", "Isolate from Formation");
|
||||
addItem(RimWellPathCompletions::STOP_ABOVE_FORMATION, "STOP", "Stop above Formation");
|
||||
|
||||
setDefault(RimWellPathCompletions::STOP_ABOVE_FORMATION);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RimWellPathCompletions::HydrostaticDensityEnum::setUp()
|
||||
{
|
||||
addItem(RimWellPathCompletions::SEGMENTED, "SEG", "Segmented");
|
||||
addItem(RimWellPathCompletions::AVERAGED, "AVG", "Averaged");
|
||||
|
||||
setDefault(RimWellPathCompletions::SEGMENTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellPathCompletions, "WellPathCompletions");
|
||||
@ -80,14 +112,19 @@ RimWellPathCompletions::RimWellPathCompletions()
|
||||
m_fractureCollection = new RimWellPathFractureCollection;
|
||||
m_fractureCollection.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitField(&m_wellNameForExport, "WellNameForExport", QString(), "Well Name for Completion Export", "", "", "");
|
||||
CAF_PDM_InitField(&m_wellNameForExport, "WellNameForExport", QString(), "Well Name", "", "", "");
|
||||
m_wellNameForExport.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_wellGroupName, "WellGroupNameForExport", QString(), "Well Group Name for Completion Export", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for Completion Export", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_wellType, "WellTypeForExport", WellTypeEnum(), "Well Type for Completion Export", "", "", "");
|
||||
CAF_PDM_InitField(&m_wellGroupName, "WellGroupNameForExport", QString(), "Well Group Name", "", "", "");
|
||||
CAF_PDM_InitField(&m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for BHP", "", "", "");
|
||||
CAF_PDM_InitField(&m_preferredFluidPhase, "WellTypeForExport", WellTypeEnum(), "Preferred Fluid Phase", "", "", "");
|
||||
CAF_PDM_InitField(&m_drainageRadiusForPI, "DrainageRadiusForPI", QString("0.0"), "Drainage Radius for PI", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_gasInflowEquation, "GasInflowEq", "Gas Inflow Equation", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_automaticWellShutIn, "AutoWellShutIn", "Automatic well shut-in", "", "", "");
|
||||
CAF_PDM_InitField(&m_allowWellCrossFlow, "AllowWellCrossFlow", true, "Allow Well Cross-Flow", "", "", "");
|
||||
CAF_PDM_InitField(&m_wellBoreFluidPVTTable, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density", "", "", "");
|
||||
CAF_PDM_InitField(&m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -153,7 +190,7 @@ QString RimWellPathCompletions::referenceDepthForExport() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::wellTypeNameForExport() const
|
||||
{
|
||||
switch (m_wellType.v())
|
||||
switch (m_preferredFluidPhase.v())
|
||||
{
|
||||
case OIL: return "OIL";
|
||||
case GAS: return "GAS";
|
||||
@ -227,6 +264,62 @@ bool RimWellPathCompletions::hasCompletions() const
|
||||
!perforationCollection()->perforations().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::drainageRadiusForExport() const
|
||||
{
|
||||
return m_drainageRadiusForPI();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::gasInflowEquationForExport() const
|
||||
{
|
||||
return m_gasInflowEquation().text();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::automaticWellShutInForExport() const
|
||||
{
|
||||
return m_automaticWellShutIn().text();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::allowWellCrossFlowForExport() const
|
||||
{
|
||||
return m_allowWellCrossFlow() ? "YES" : "NO";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::wellBoreFluidPVTForExport() const
|
||||
{
|
||||
return QString("%1").arg(m_wellBoreFluidPVTTable());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::hydrostaticDensityForExport() const
|
||||
{
|
||||
return m_hydrostaticDensity().text();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellPathCompletions::fluidInPlaceRegionForExport() const
|
||||
{
|
||||
return QString("%1").arg(m_fluidInPlaceRegion());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -246,6 +339,26 @@ QRegExp RimWellPathCompletions::wellNameForExportRegExp()
|
||||
return rx;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellPathCompletions::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
caf::PdmUiGroup* compExportGroup = uiOrdering.addNewGroup("Completion Export Parameters");
|
||||
compExportGroup->add(&m_wellNameForExport);
|
||||
compExportGroup->add(&m_wellGroupName);
|
||||
compExportGroup->add(&m_referenceDepth);
|
||||
compExportGroup->add(&m_preferredFluidPhase);
|
||||
compExportGroup->add(&m_drainageRadiusForPI);
|
||||
compExportGroup->add(&m_gasInflowEquation);
|
||||
compExportGroup->add(&m_automaticWellShutIn);
|
||||
compExportGroup->add(&m_allowWellCrossFlow);
|
||||
compExportGroup->add(&m_wellBoreFluidPVTTable);
|
||||
compExportGroup->add(&m_hydrostaticDensity);
|
||||
compExportGroup->add(&m_fluidInPlaceRegion);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -308,6 +421,24 @@ void RimWellPathCompletions::defineEditorAttribute(const caf::PdmFieldHandle* fi
|
||||
validator->setRegExp(wellNameForExportRegExp());
|
||||
lineEditorAttr->validator = validator;
|
||||
}
|
||||
else if (field == &m_drainageRadiusForPI && lineEditorAttr)
|
||||
{
|
||||
caf::PdmDoubleStringValidator* validator = new caf::PdmDoubleStringValidator("1*");
|
||||
lineEditorAttr->validator = validator;
|
||||
}
|
||||
else if (field == &m_wellBoreFluidPVTTable && lineEditorAttr)
|
||||
{
|
||||
// Positive integer
|
||||
QIntValidator* validator = new QIntValidator(0, std::numeric_limits<int>::max(), nullptr);
|
||||
lineEditorAttr->validator = validator;
|
||||
}
|
||||
else if (field == &m_fluidInPlaceRegion && lineEditorAttr)
|
||||
{
|
||||
// Any integer
|
||||
QIntValidator* validator = new QIntValidator(-std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), nullptr);
|
||||
lineEditorAttr->validator = validator;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -39,6 +39,15 @@ class RimWellPathCompletions : public caf::PdmObject
|
||||
enum WellType {OIL, GAS, WATER, LIQUID};
|
||||
typedef caf::AppEnum<WellType> WellTypeEnum;
|
||||
|
||||
enum GasInflowEquation {STANDARD_EQ, RUSSELL_GOODRICH, DRY_GAS_PSEUDO_PRESSURE, GENERALIZED_PSEUDO_PRESSURE };
|
||||
typedef caf::AppEnum<GasInflowEquation> GasInflowEnum;
|
||||
|
||||
enum AutomaticWellShutIn {ISOLATE_FROM_FORMATION, STOP_ABOVE_FORMATION };
|
||||
typedef caf::AppEnum<AutomaticWellShutIn> AutomaticWellShutInEnum;
|
||||
|
||||
enum HydrostaticDensity { SEGMENTED, AVERAGED };
|
||||
typedef caf::AppEnum<HydrostaticDensity> HydrostaticDensityEnum;
|
||||
|
||||
public:
|
||||
RimWellPathCompletions();
|
||||
|
||||
@ -56,9 +65,18 @@ public:
|
||||
QString wellTypeNameForExport() const;
|
||||
bool hasCompletions() const;
|
||||
|
||||
QString drainageRadiusForExport() const;
|
||||
QString gasInflowEquationForExport() const;
|
||||
QString automaticWellShutInForExport() const;
|
||||
QString allowWellCrossFlowForExport() const;
|
||||
QString wellBoreFluidPVTForExport() const;
|
||||
QString hydrostaticDensityForExport() const;
|
||||
QString fluidInPlaceRegionForExport() const;
|
||||
|
||||
void setUnitSystemSpecificDefaults();
|
||||
static QRegExp wellNameForExportRegExp();
|
||||
protected:
|
||||
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
@ -75,5 +93,12 @@ private:
|
||||
caf::PdmField<QString> m_wellGroupName;
|
||||
|
||||
caf::PdmField<QString> m_referenceDepth;
|
||||
caf::PdmField<WellTypeEnum> m_wellType;
|
||||
caf::PdmField<WellTypeEnum> m_preferredFluidPhase;
|
||||
caf::PdmField<QString> m_drainageRadiusForPI;
|
||||
caf::PdmField<GasInflowEnum> m_gasInflowEquation;
|
||||
caf::PdmField<AutomaticWellShutInEnum> m_automaticWellShutIn;
|
||||
caf::PdmField<bool> m_allowWellCrossFlow;
|
||||
caf::PdmField<int> m_wellBoreFluidPVTTable;
|
||||
caf::PdmField<HydrostaticDensityEnum> m_hydrostaticDensity;
|
||||
caf::PdmField<int> m_fluidInPlaceRegion;
|
||||
};
|
||||
|
@ -53,6 +53,7 @@ set (MOC_HEADER_FILES
|
||||
cafPdmUiFormLayoutObjectEditor.h
|
||||
cafPdmUiDoubleValueEditor.h
|
||||
cafPdmUniqueIdValidator.h
|
||||
cafPdmDoubleStringValidator.h
|
||||
)
|
||||
|
||||
if ( NOT CMAKE_AUTOMOC )
|
||||
@ -156,6 +157,7 @@ set( PROJECT_FILES
|
||||
cafMemoryInspector.h
|
||||
cafMemoryInspector.cpp
|
||||
cafPdmUniqueIdValidator.cpp
|
||||
cafPdmDoubleStringValidator.cpp
|
||||
)
|
||||
|
||||
add_library( ${PROJECT_NAME}
|
||||
|
57
Fwk/AppFwk/cafUserInterface/cafPdmDoubleStringValidator.cpp
Normal file
57
Fwk/AppFwk/cafUserInterface/cafPdmDoubleStringValidator.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||
// for more details.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
#include "cafPdmDoubleStringValidator.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QValidator::State caf::PdmDoubleStringValidator::validate(QString& inputString, int& position) const
|
||||
{
|
||||
if (m_defaultString == inputString)
|
||||
{
|
||||
return QValidator::Acceptable;
|
||||
}
|
||||
return QDoubleValidator::validate(inputString, position);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::PdmDoubleStringValidator::fixup(QString& inputString) const
|
||||
{
|
||||
inputString = m_defaultString;
|
||||
}
|
64
Fwk/AppFwk/cafUserInterface/cafPdmDoubleStringValidator.h
Normal file
64
Fwk/AppFwk/cafUserInterface/cafPdmDoubleStringValidator.h
Normal file
@ -0,0 +1,64 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||
// for more details.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
#pragma once
|
||||
|
||||
#include <QDoubleValidator>
|
||||
#include <QString>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Class that validates text strings containing double values but allows
|
||||
/// a default text string that isn't necessarily a double.
|
||||
/// Example use is the "1*" value in ECLIPSE output files or "N/A".
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class PdmDoubleStringValidator : public QDoubleValidator
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PdmDoubleStringValidator(const QString& defaultString)
|
||||
: QDoubleValidator(nullptr), m_defaultString(defaultString)
|
||||
{
|
||||
}
|
||||
|
||||
State validate(QString& inputString, int& position) const override;
|
||||
void fixup(QString& inputString) const override;
|
||||
|
||||
private:
|
||||
QString m_defaultString;
|
||||
};
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ namespace caf
|
||||
{
|
||||
class PdmUniqueIdValidator : public QValidator
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PdmUniqueIdValidator(const std::set<int>& usedIds, bool multipleSelectionOfSameFieldsSelected, const QString& errorMessage, QObject* parent);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user