Merge pull request #7960 from OPM/geomech_WIA4

GeoMech: Well Integrity Analysis
This commit is contained in:
jonjenssen
2021-09-09 17:34:27 +02:00
committed by GitHub
parent c603e6fe90
commit a5b80c649b
49 changed files with 2778 additions and 30 deletions

View File

@@ -3,7 +3,9 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimDoubleParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimIntegerParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimStringParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimListParameter.h
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroup.h
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroups.h
)
set(SOURCE_GROUP_SOURCE_FILES
@@ -11,7 +13,9 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimDoubleParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimIntegerParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimStringParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimListParameter.cpp
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroup.cpp
${CMAKE_CURRENT_LIST_DIR}/RimParameterGroups.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@@ -84,3 +84,18 @@ double RimDoubleParameter::value() const
{
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimDoubleParameter::duplicate() const
{
RimDoubleParameter* retval = new RimDoubleParameter();
retval->setName( name() );
retval->setValue( value() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@@ -44,6 +44,8 @@ public:
double value() const;
virtual RimGenericParameter* duplicate() const;
private:
caf::PdmField<double> m_value;
};

View File

@@ -143,3 +143,11 @@ QString RimGenericParameter::description() const
{
return m_description();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimGenericParameter::jsonValue() const
{
return stringValue();
}

View File

@@ -43,6 +43,7 @@ public:
virtual void setValue( QString value ) = 0;
virtual QVariant variantValue() const = 0;
virtual QString stringValue() const = 0;
virtual QString jsonValue() const;
QString name() const;
QString label() const;
@@ -50,6 +51,8 @@ public:
bool isAdvanced() const;
bool isValid() const;
virtual RimGenericParameter* duplicate() const = 0;
protected:
void setValid( bool valid );

View File

@@ -69,6 +69,14 @@ QVariant RimIntegerParameter::variantValue() const
return QVariant( m_value() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimIntegerParameter::value() const
{
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -76,3 +84,18 @@ QString RimIntegerParameter::stringValue() const
{
return QString::number( m_value() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimIntegerParameter::duplicate() const
{
RimIntegerParameter* retval = new RimIntegerParameter();
retval->setName( name() );
retval->setValue( value() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@@ -41,6 +41,9 @@ public:
void setValue( QString value ) override;
QVariant variantValue() const override;
QString stringValue() const override;
int value() const;
RimGenericParameter* duplicate() const override;
private:
caf::PdmField<int> m_value;

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - Equinor ASA
//
// ResInsight 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.
//
// ResInsight 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimListParameter.h"
#include <cmath>
CAF_PDM_SOURCE_INIT( RimListParameter, "ListParameter" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimListParameter::RimListParameter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimListParameter::~RimListParameter()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimListParameter::jsonValue() const
{
return stringValue();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimListParameter::duplicate() const
{
RimListParameter* retval = new RimListParameter();
retval->setName( name() );
retval->setValue( stringValue() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - Equinor ASA
//
// ResInsight 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.
//
// ResInsight 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
#include "RimStringParameter.h"
//==================================================================================================
///
///
//==================================================================================================
class RimListParameter : public RimStringParameter
{
CAF_PDM_HEADER_INIT;
public:
RimListParameter();
~RimListParameter() override;
QString jsonValue() const override;
RimGenericParameter* duplicate() const override;
};

View File

@@ -49,9 +49,24 @@ RimParameterGroup::RimParameterGroup()
m_name.uiCapability()->setUiHidden( true );
m_name.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_label, "Label", "Label", "", "", "" );
m_label.uiCapability()->setUiHidden( true );
m_label.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_comment, "Comment", "Comment", "", "", "" );
m_comment.uiCapability()->setUiHidden( true );
m_comment.uiCapability()->setUiReadOnly( true );
m_comment.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_showExpanded, "Expanded", "Expanded", "", "", "" );
m_name.uiCapability()->setUiHidden( true );
m_name.uiCapability()->setUiReadOnly( true );
m_showExpanded.uiCapability()->setUiHidden( true );
m_showExpanded.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_labelProxy, "LabelProxy", "Label Proxy", "", "", "" );
m_labelProxy.registerGetMethod( this, &RimParameterGroup::labelOrName );
m_labelProxy.uiCapability()->setUiReadOnly( true );
m_labelProxy.uiCapability()->setUiHidden( true );
m_labelProxy.xmlCapability()->disableIO();
}
//--------------------------------------------------------------------------------------------------
@@ -66,7 +81,16 @@ RimParameterGroup::~RimParameterGroup()
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimParameterGroup::userDescriptionField()
{
return &m_name;
return &m_labelProxy;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimParameterGroup::labelOrName() const
{
if ( m_label().isEmpty() ) return m_name;
return m_label;
}
//--------------------------------------------------------------------------------------------------
@@ -87,7 +111,7 @@ void RimParameterGroup::addParameter( QString name, int value )
p->setLabel( name );
p->setValue( value );
m_parameters.push_back( p );
addParameter( p );
}
//--------------------------------------------------------------------------------------------------
@@ -100,7 +124,7 @@ void RimParameterGroup::addParameter( QString name, QString value )
p->setLabel( name );
p->setValue( value );
m_parameters.push_back( p );
addParameter( p );
}
//--------------------------------------------------------------------------------------------------
@@ -113,7 +137,7 @@ void RimParameterGroup::addParameter( QString name, double value )
p->setLabel( name );
p->setValue( value );
m_parameters.push_back( p );
addParameter( p );
}
//--------------------------------------------------------------------------------------------------
@@ -151,7 +175,8 @@ void RimParameterGroup::defineEditorAttribute( const caf::PdmFieldHandle* field,
//--------------------------------------------------------------------------------------------------
void RimParameterGroup::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
auto group = uiOrdering.addNewGroup( name() );
auto group = uiOrdering.addNewGroup( label() );
if ( !m_comment().isEmpty() ) group->add( &m_comment );
group->add( &m_parameters );
uiOrdering.skipRemainingFields( true );
@@ -165,6 +190,22 @@ void RimParameterGroup::setName( QString name )
m_name = name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroup::setLabel( QString label )
{
m_label = label;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroup::setComment( QString comment )
{
m_comment = comment;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -189,6 +230,22 @@ QString RimParameterGroup::name() const
return m_name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimParameterGroup::comment() const
{
return m_comment;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimParameterGroup::label() const
{
return labelOrName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -237,3 +294,16 @@ RimGenericParameter* RimParameterGroup::parameter( QString name ) const
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QVariant RimParameterGroup::parameterValue( QString name ) const
{
RimGenericParameter* p = parameter( name );
if ( p )
{
return p->variantValue();
}
return QVariant();
}

View File

@@ -21,8 +21,10 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmProxyValueField.h"
#include <QString>
#include <QVariant>
#include <vector>
class RimGenericParameter;
@@ -47,6 +49,8 @@ public:
void appendParametersToList( std::list<RimGenericParameter*>& parameterList );
void setName( QString name );
void setLabel( QString label );
void setComment( QString comment );
void setExpanded( bool expand );
void setParameterValue( QString name, int value );
@@ -55,20 +59,28 @@ public:
bool isExpanded() const;
QString name() const;
QString comment() const;
QString label() const;
std::vector<RimGenericParameter*> parameters() const;
RimGenericParameter* parameter( QString name ) const;
QVariant parameterValue( QString name ) const;
private:
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
caf::PdmFieldHandle* userDescriptionField() override;
QString labelOrName() const;
private:
caf::PdmChildArrayField<RimGenericParameter*> m_parameters;
caf::PdmField<bool> m_showExpanded;
caf::PdmField<QString> m_name;
caf::PdmField<QString> m_label;
caf::PdmField<QString> m_comment;
caf::PdmProxyValueField<QString> m_labelProxy;
};

View File

@@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- Equinor ASA
//
// ResInsight 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.
//
// ResInsight 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimParameterGroups.h"
#include "RimGenericParameter.h"
#include "RimParameterGroup.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimParameterGroups::RimParameterGroups()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimParameterGroups::~RimParameterGroups()
{
clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroups::clear()
{
for ( const auto& [key, value] : m_groups )
{
delete value;
}
m_groups.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimParameterGroups::mergeGroup( RimParameterGroup* group, bool addCommentAsParameter /* = false */ )
{
const QString grpName = group->name();
if ( m_groups.count( grpName ) == 0 )
{
RimParameterGroup* newGroup = new RimParameterGroup();
newGroup->setName( grpName );
newGroup->setLabel( group->label() );
newGroup->setComment( group->comment() );
if ( addCommentAsParameter && !newGroup->comment().isEmpty() )
{
newGroup->addParameter( "comments", newGroup->comment() );
}
m_groups[grpName] = newGroup;
}
RimParameterGroup* dstGroup = m_groups[grpName];
for ( auto& parameter : group->parameters() )
{
dstGroup->addParameter( parameter->duplicate() );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<RimParameterGroup*> RimParameterGroups::groups() const
{
std::vector<RimParameterGroup*> retGroups;
for ( const auto& [key, value] : m_groups )
{
retGroups.push_back( value );
}
return retGroups;
}

View File

@@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 - Equinor ASA
//
// ResInsight 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.
//
// ResInsight 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <map>
#include <vector>
class RimParameterGroup;
//==================================================================================================
///
///
//==================================================================================================
class RimParameterGroups
{
public:
RimParameterGroups();
~RimParameterGroups();
void mergeGroup( RimParameterGroup* group, bool addCommentAsParameter = false );
const std::vector<RimParameterGroup*> groups() const;
void clear();
private:
std::map<QString, RimParameterGroup*> m_groups;
};

View File

@@ -66,3 +66,26 @@ QString RimStringParameter::stringValue() const
{
return m_value();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimStringParameter::jsonValue() const
{
return QString( "\"%1\"" ).arg( stringValue() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGenericParameter* RimStringParameter::duplicate() const
{
RimStringParameter* retval = new RimStringParameter();
retval->setName( name() );
retval->setValue( stringValue() );
retval->setDescription( description() );
retval->setLabel( label() );
retval->setAdvanced( isAdvanced() );
return retval;
}

View File

@@ -40,6 +40,9 @@ public:
void setValue( QString value ) override;
QVariant variantValue() const override;
QString stringValue() const override;
QString jsonValue() const override;
RimGenericParameter* duplicate() const override;
private:
caf::PdmField<QString> m_value;