Files
ResInsight/ApplicationLibCode/ProjectDataModel/Completions/RimValveTemplateCollection.cpp
T
JJ 24be78f105 Tie-in valve improvements (#13661)
Support (bool, something) pairs as tuples on python side.
Support custom outlet valve md
Add python test for custom outlet valve md
Use tie-in depth as default for custom valve md
Standalone valve creation and display updates
Update MSW valve export
Add valve open/shut flag.
Add python examples
2026-03-06 12:01:14 +01:00

117 lines
4.4 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- 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 "RimValveTemplateCollection.h"
#include "RimProject.h"
#include "RimValveTemplate.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
CAF_PDM_SOURCE_INIT( RimValveTemplateCollection, "ValveTemplateCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimValveTemplateCollection::RimValveTemplateCollection()
{
CAF_PDM_InitScriptableObject( "Valve Templates", ":/ICDValve16x16.png" );
CAF_PDM_InitScriptableFieldNoDefault( &m_items, "ValveDefinitions", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_defaultUnitsForValveTemplates, "ValveUnits", "Default unit system for valve templates" );
m_defaultUnitsForValveTemplates = RiaDefines::EclipseUnitSystem::UNITS_METRIC;
addDefaultValveTemplates();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimValveTemplateCollection::~RimValveTemplateCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::AppEnum<RiaDefines::EclipseUnitSystem> RimValveTemplateCollection::defaultUnitSystemType() const
{
return m_defaultUnitsForValveTemplates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimValveTemplateCollection::setDefaultUnitSystemBasedOnLoadedCases()
{
RimProject* proj = RimProject::current();
auto commonUnitSystem = proj->commonUnitSystemForAllCases();
if ( commonUnitSystem != RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN )
{
m_defaultUnitsForValveTemplates = commonUnitSystem;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimValveTemplateCollection::addDefaultValveTemplates()
{
RimValveTemplate* aicd = new RimValveTemplate;
aicd->setType( RiaDefines::WellPathComponentType::AICD );
aicd->setUserLabel( "Valve Template #1" );
RimValveTemplate* icd = new RimValveTemplate;
icd->setType( RiaDefines::WellPathComponentType::ICD );
icd->setUserLabel( "Valve Template #2" );
RimValveTemplate* icv = new RimValveTemplate;
icv->setType( RiaDefines::WellPathComponentType::ICV );
icv->setUserLabel( "Valve Template #3" );
RimValveTemplate* sicd = new RimValveTemplate;
sicd->setType( RiaDefines::WellPathComponentType::SICD );
sicd->setUserLabel( "Valve Template #4" );
addItem( aicd );
addItem( icd );
addItem( icv );
addItem( sicd );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimValveTemplate* RimValveTemplateCollection::getOrCreateIcvTemplate()
{
for ( RimValveTemplate* templateItem : items() )
{
if ( templateItem->type() == RiaDefines::WellPathComponentType::ICV )
{
return templateItem;
}
}
RimValveTemplate* icv = new RimValveTemplate;
icv->setType( RiaDefines::WellPathComponentType::ICV );
icv->setUserLabel( "ICV default template" );
addItem( icv );
return icv;
}