mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 13:47:12 -05:00
Migrate all assert macros in ApplicationLibCode to CAF_ASSERT and remove every use of cvfAssert.h. CVF_ASSERT is replaced one to one. CVF_TIGHT_ASSERT is also replaced by CAF_ASSERT, which is semantically exact: CVF_ENABLE_TIGHT_ASSERTS is 1 only under _DEBUG, and that is what CAF_ASSERT now does. The two CVF_FAIL_MSG sites become CAF_ASSERT( false && "message" ), preserving the message with the idiom already used elsewhere in the code base. Counts before and after: CVF_ASSERT 1044 to 0, CVF_TIGHT_ASSERT 66 to 0, CVF_FAIL_MSG 2 to 0, cvfAssert.h references 154 to 0. Include handling: files that included cvfAssert.h directly now include cafAssert.h instead, includes left dead by the migration are removed, and files that were relying on cvfAssert.h transitively get an explicit cafAssert.h. Files that reach cafAssert.h through another caf header are left unchanged; a missing include here is a compile error, not a silently disabled assert. ResultStatisticsCache links only LibCore and therefore had no path to cafAssert.h. Add the cafPdmCore directory as a private include path rather than linking the library, since cafAssert.h is header only. Note that this stops these asserts from firing in Release and RelWithDebInfo, where CVF_ASSERT was previously active.
705 lines
26 KiB
C++
705 lines
26 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 "RimWellPathValve.h"
|
|
|
|
#include "RiaColorTables.h"
|
|
#include "RiaDefines.h"
|
|
#include "RiaEclipseUnitTools.h"
|
|
#include "RiaQDateTimeTools.h"
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
|
|
|
#include "Well/RigWellPath.h"
|
|
|
|
#include "RimMultipleValveLocations.h"
|
|
#include "RimPerforationInterval.h"
|
|
#include "RimProject.h"
|
|
#include "RimValveCollection.h"
|
|
#include "RimValveTemplate.h"
|
|
#include "RimWellPath.h"
|
|
|
|
#include "CompletionCommands/RicNewValveTemplateFeature.h"
|
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
|
#include "cafPdmObjectScriptingCapability.h"
|
|
#include "cafPdmUiDoubleSliderEditor.h"
|
|
#include "cafPdmUiToolButtonEditor.h"
|
|
|
|
CAF_PDM_SOURCE_INIT( RimWellPathValve, "WellPathValve" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellPathValve::RimWellPathValve()
|
|
{
|
|
CAF_PDM_InitScriptableObject( "WellPathValve", ":/ICDValve16x16.png" );
|
|
|
|
CAF_PDM_InitFieldNoDefault( &m_valveTemplate, "ValveTemplate", "Valve Template" );
|
|
CAF_PDM_InitScriptableField( &m_measuredDepth, "StartMeasuredDepth", 0.0, "Start MD" );
|
|
CAF_PDM_InitScriptableField( &m_isOpen, "IsOpen", true, "Valve is Open" );
|
|
CAF_PDM_InitFieldNoDefault( &m_multipleValveLocations, "ValveLocations", "Valve Locations" );
|
|
|
|
CAF_PDM_InitField( &m_useCustomStartDate, "UseCustomStartDate", false, "Custom Start Date" );
|
|
CAF_PDM_InitField( &m_startDate, "StartDate", QDateTime::currentDateTime(), "Start Date" );
|
|
|
|
m_measuredDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
|
m_multipleValveLocations = new RimMultipleValveLocations;
|
|
m_multipleValveLocations.uiCapability()->setUiTreeChildrenHidden( true );
|
|
|
|
nameField()->uiCapability()->setUiReadOnly( true );
|
|
|
|
setDeletable( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimWellPathValve::~RimWellPathValve()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::perforationIntervalUpdated()
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
const RimPerforationInterval* perfInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
|
|
double startMD = perfInterval->startMD();
|
|
double endMD = perfInterval->endMD();
|
|
m_measuredDepth = std::clamp( m_measuredDepth(), std::min( startMD, endMD ), std::max( startMD, endMD ) );
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::ICD || componentType() == RiaDefines::WellPathComponentType::AICD ||
|
|
componentType() == RiaDefines::WellPathComponentType::SICD )
|
|
{
|
|
m_multipleValveLocations->perforationIntervalUpdated();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::setMeasuredDepthAndCount( double startMD, double spacing, int valveCount )
|
|
{
|
|
m_measuredDepth = startMD;
|
|
double endMD = startMD + spacing * valveCount;
|
|
m_multipleValveLocations->initFields( RimMultipleValveLocations::VALVE_COUNT, startMD, endMD, spacing, valveCount, {} );
|
|
m_multipleValveLocations->computeRangesAndLocations();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::multipleValveGeometryUpdated()
|
|
{
|
|
if ( m_multipleValveLocations->valveLocations().empty() ) return;
|
|
|
|
m_measuredDepth = m_multipleValveLocations->valveLocations().front();
|
|
|
|
RimProject* proj = RimProject::current();
|
|
proj->reloadCompletionTypeResultsInAllViews();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<double> RimWellPathValve::valveLocations() const
|
|
{
|
|
std::vector<double> valveDepths;
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
valveDepths.push_back( m_measuredDepth );
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::ICD || componentType() == RiaDefines::WellPathComponentType::AICD ||
|
|
componentType() == RiaDefines::WellPathComponentType::SICD )
|
|
{
|
|
valveDepths = m_multipleValveLocations->valveLocations();
|
|
}
|
|
return valveDepths;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
double RimWellPathValve::orificeDiameter( RiaDefines::EclipseUnitSystem unitSystem ) const
|
|
{
|
|
if ( m_valveTemplate() )
|
|
{
|
|
double templateDiameter = m_valveTemplate()->orificeDiameter();
|
|
return convertOrificeDiameter( templateDiameter, m_valveTemplate()->templateUnits(), unitSystem );
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
double RimWellPathValve::area( RiaDefines::EclipseUnitSystem unitSystem ) const
|
|
{
|
|
const double orificeRadius = orificeDiameter( unitSystem ) / 2.0;
|
|
return orificeRadius * orificeRadius * cvf::PI_D;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
double RimWellPathValve::flowCoefficient() const
|
|
{
|
|
if ( m_valveTemplate() )
|
|
{
|
|
double templateCoefficient = m_valveTemplate()->flowCoefficient();
|
|
return templateCoefficient;
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimWellPathValve::isOpen() const
|
|
{
|
|
return m_isOpen();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::setOpen( bool openFlag )
|
|
{
|
|
m_isOpen = openFlag;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimValveTemplate* RimWellPathValve::valveTemplate() const
|
|
{
|
|
return m_valveTemplate;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::setValveTemplate( RimValveTemplate* valveTemplate )
|
|
{
|
|
m_valveTemplate = valveTemplate;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::applyValveLabelAndIcon()
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
setUiIconFromResourceString( ":/ICVValve16x16.png" );
|
|
QString fullName = QString( "%1: %2" ).arg( componentLabel() ).arg( m_measuredDepth() );
|
|
setName( fullName );
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::ICD )
|
|
{
|
|
setUiIconFromResourceString( ":/ICDValve16x16.png" );
|
|
QString fullName = QString( "%1 %2: %3 - %4" )
|
|
.arg( m_multipleValveLocations->valveLocations().size() )
|
|
.arg( componentLabel() )
|
|
.arg( m_multipleValveLocations->rangeStart() )
|
|
.arg( m_multipleValveLocations->rangeEnd() );
|
|
setName( fullName );
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::AICD )
|
|
{
|
|
setUiIconFromResourceString( ":/AICDValve16x16.png" );
|
|
QString fullName = QString( "%1 %2: %3 - %4" )
|
|
.arg( m_multipleValveLocations->valveLocations().size() )
|
|
.arg( componentLabel() )
|
|
.arg( m_multipleValveLocations->rangeStart() )
|
|
.arg( m_multipleValveLocations->rangeEnd() );
|
|
setName( fullName );
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::SICD )
|
|
{
|
|
setUiIconFromResourceString( ":/SICDValve16x16.png" );
|
|
QString fullName = QString( "%1 %2: %3 - %4" )
|
|
.arg( m_multipleValveLocations->valveLocations().size() )
|
|
.arg( componentLabel() )
|
|
.arg( m_multipleValveLocations->rangeStart() )
|
|
.arg( m_multipleValveLocations->rangeEnd() );
|
|
setName( fullName );
|
|
}
|
|
else
|
|
{
|
|
setName( "Unspecified Valve" );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const RimWellPathAicdParameters* RimWellPathValve::aicdParameters() const
|
|
{
|
|
if ( m_valveTemplate() )
|
|
{
|
|
return m_valveTemplate()->aicdParameters();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
const RimWellPathSicdParameters* RimWellPathValve::sicdParameters() const
|
|
{
|
|
if ( m_valveTemplate() )
|
|
{
|
|
return m_valveTemplate()->sicdParameters();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::enableCustomStartDate( bool enable )
|
|
{
|
|
m_useCustomStartDate = enable;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::setCustomStartDate( const QDate& date )
|
|
{
|
|
if ( date.isValid() )
|
|
{
|
|
m_startDate = RiaQDateTimeTools::createDateTime( date );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimWellPathValve::isActiveOnDate( const QDateTime& date ) const
|
|
{
|
|
return !( m_useCustomStartDate() && date < m_startDate() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
double RimWellPathValve::convertOrificeDiameter( double orificeDiameterWellPathUnits,
|
|
RiaDefines::EclipseUnitSystem wellPathUnits,
|
|
RiaDefines::EclipseUnitSystem unitSystem )
|
|
{
|
|
if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
|
|
{
|
|
if ( wellPathUnits == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
|
|
{
|
|
return RiaEclipseUnitTools::inchToMeter( orificeDiameterWellPathUnits );
|
|
}
|
|
else
|
|
{
|
|
return RiaEclipseUnitTools::mmToMeter( orificeDiameterWellPathUnits );
|
|
}
|
|
}
|
|
else if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
|
|
{
|
|
if ( wellPathUnits == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
|
|
{
|
|
return RiaEclipseUnitTools::meterToFeet( RiaEclipseUnitTools::mmToMeter( orificeDiameterWellPathUnits ) );
|
|
}
|
|
else
|
|
{
|
|
return RiaEclipseUnitTools::inchToFeet( orificeDiameterWellPathUnits );
|
|
}
|
|
}
|
|
CAF_ASSERT( false );
|
|
return 0.0;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
std::vector<std::pair<double, double>> RimWellPathValve::valveSegments() const
|
|
{
|
|
std::vector<std::pair<double, double>> segments;
|
|
|
|
if ( auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>() )
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
// Flow for ICV is defined as the complete perforation interval
|
|
|
|
segments.push_back( std::make_pair( perforationInterval->startMD(), perforationInterval->endMD() ) );
|
|
}
|
|
else
|
|
{
|
|
// ICD/AICD : Use the valve start/end, can be a subset of perforation interval
|
|
|
|
double startMD = this->startMD();
|
|
double endMD = this->endMD();
|
|
|
|
std::vector<double> valveMDs = valveLocations();
|
|
segments.reserve( valveMDs.size() );
|
|
|
|
for ( size_t i = 0; i < valveMDs.size(); ++i )
|
|
{
|
|
double segmentStart = startMD;
|
|
double segmentEnd = endMD;
|
|
if ( i > 0 )
|
|
{
|
|
segmentStart = 0.5 * ( valveMDs[i - 1] + valveMDs[i] );
|
|
}
|
|
if ( i < valveMDs.size() - 1u )
|
|
{
|
|
segmentEnd = 0.5 * ( valveMDs[i] + valveMDs[i + 1] );
|
|
}
|
|
segments.push_back( std::make_pair( segmentStart, segmentEnd ) );
|
|
}
|
|
}
|
|
}
|
|
else if ( firstAncestorOrThisOfType<RimValveCollection>() )
|
|
{
|
|
// stand-alone ICV valve
|
|
segments.emplace_back( startMD(), endMD() );
|
|
}
|
|
|
|
return segments;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::setComponentTypeFilter( const std::set<RiaDefines::WellPathComponentType>& filter )
|
|
{
|
|
m_componentTypeFilter = filter;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RimWellPathValve::isEnabled() const
|
|
{
|
|
if ( auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>() )
|
|
{
|
|
return perforationInterval->isEnabled() && isChecked();
|
|
}
|
|
if ( auto valveCollection = firstAncestorOrThisOfType<RimValveCollection>() )
|
|
{
|
|
return valveCollection->isChecked() && isChecked();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RiaDefines::WellPathComponentType RimWellPathValve::componentType() const
|
|
{
|
|
if ( m_valveTemplate() )
|
|
{
|
|
return m_valveTemplate()->type();
|
|
}
|
|
return RiaDefines::WellPathComponentType::UNDEFINED_COMPONENT;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RimWellPathValve::componentLabel() const
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICD )
|
|
{
|
|
if ( m_multipleValveLocations->valveLocations().size() > 1 )
|
|
{
|
|
return "ICDs";
|
|
}
|
|
else
|
|
{
|
|
return "ICD";
|
|
}
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::AICD )
|
|
{
|
|
if ( m_multipleValveLocations->valveLocations().size() > 1 )
|
|
{
|
|
return "AICDs";
|
|
}
|
|
else
|
|
{
|
|
return "AICD";
|
|
}
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::SICD )
|
|
{
|
|
if ( m_multipleValveLocations->valveLocations().size() > 1 )
|
|
{
|
|
return "SICDs";
|
|
}
|
|
else
|
|
{
|
|
return "SICD";
|
|
}
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
return "ICV";
|
|
}
|
|
return "Valve";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QString RimWellPathValve::componentTypeLabel() const
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICD )
|
|
{
|
|
return "ICD";
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::AICD )
|
|
{
|
|
return "AICD";
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::SICD )
|
|
{
|
|
return "SICD";
|
|
}
|
|
else if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
return "ICV";
|
|
}
|
|
return "Valve";
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
cvf::Color3f RimWellPathValve::defaultComponentColor() const
|
|
{
|
|
return RiaColorTables::wellPathComponentColors()[componentType()];
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
double RimWellPathValve::startMD() const
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
return m_measuredDepth;
|
|
}
|
|
else if ( m_multipleValveLocations()->valveLocations().size() < 2 )
|
|
{
|
|
return m_multipleValveLocations->rangeStart();
|
|
}
|
|
else
|
|
{
|
|
return m_multipleValveLocations()->valveLocations().front();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
double RimWellPathValve::endMD() const
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
return m_measuredDepth + 0.5;
|
|
}
|
|
else if ( m_multipleValveLocations()->valveLocations().size() < 2 )
|
|
{
|
|
return m_multipleValveLocations->rangeEnd();
|
|
}
|
|
else
|
|
{
|
|
return m_multipleValveLocations()->valveLocations().back();
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::applyOffset( double offsetMD )
|
|
{
|
|
m_measuredDepth = m_measuredDepth + offsetMD;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::templateUpdated()
|
|
{
|
|
applyValveLabelAndIcon();
|
|
|
|
// A valve can also be a stand-alone valve or a tie-in outlet valve, and then has no perforation interval
|
|
if ( auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>() )
|
|
{
|
|
perforationInterval->updateAllReferringTracks();
|
|
}
|
|
|
|
RimProject* proj = RimProject::current();
|
|
proj->reloadCompletionTypeResultsInAllViews();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
QList<caf::PdmOptionItemInfo> RimWellPathValve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
|
{
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
if ( fieldNeedingOptions == &m_valveTemplate )
|
|
{
|
|
RimProject* project = RimProject::current();
|
|
|
|
std::vector<RimValveTemplate*> allTemplates = project->allValveTemplates();
|
|
for ( RimValveTemplate* valveTemplate : allTemplates )
|
|
{
|
|
if ( !m_componentTypeFilter.empty() )
|
|
{
|
|
if ( m_componentTypeFilter.count( valveTemplate->type() ) == 0 ) continue;
|
|
}
|
|
|
|
options.push_back( caf::PdmOptionItemInfo( valveTemplate->name(), valveTemplate ) );
|
|
}
|
|
}
|
|
|
|
return options;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
|
{
|
|
if ( changedField == &m_valveTemplate )
|
|
{
|
|
applyValveLabelAndIcon();
|
|
updateConnectedEditors();
|
|
}
|
|
|
|
auto perfInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
|
|
if ( perfInterval )
|
|
{
|
|
perfInterval->updateAllReferringTracks();
|
|
}
|
|
|
|
RimProject* proj = RimProject::current();
|
|
proj->reloadCompletionTypeResultsInAllViews();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
|
{
|
|
uiOrdering.skipRemainingFields( true );
|
|
|
|
uiOrdering.add( &m_valveTemplate );
|
|
|
|
{
|
|
if ( m_valveTemplate() != nullptr )
|
|
{
|
|
uiOrdering.addNewButton( "Edit Template", [this]() { Riu3DMainWindowTools::selectAsCurrentItem( m_valveTemplate() ); } );
|
|
}
|
|
uiOrdering.addNewButton( "Create Template", [this]() { RicNewValveTemplateFeature::createNewValveTemplateForValveAndUpdate( this ); } );
|
|
}
|
|
|
|
if ( uiConfigName != "TemplateOnly" )
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV || componentType() == RiaDefines::WellPathComponentType::ICD )
|
|
{
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICV )
|
|
{
|
|
auto wellPath = firstAncestorOrThisOfType<RimWellPath>();
|
|
if ( wellPath )
|
|
{
|
|
if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
|
|
{
|
|
m_measuredDepth.uiCapability()->setUiName( "Measured Depth [m]" );
|
|
}
|
|
else if ( wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
|
|
{
|
|
m_measuredDepth.uiCapability()->setUiName( "Measured Depth [ft]" );
|
|
}
|
|
}
|
|
uiOrdering.add( &m_measuredDepth, { .totalColumnSpan = 3, .leftLabelColumnSpan = 1 } );
|
|
}
|
|
}
|
|
|
|
uiOrdering.add( &m_isOpen );
|
|
|
|
if ( componentType() == RiaDefines::WellPathComponentType::ICD || componentType() == RiaDefines::WellPathComponentType::AICD ||
|
|
componentType() == RiaDefines::WellPathComponentType::SICD )
|
|
{
|
|
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Multiple Valve Locations" );
|
|
m_multipleValveLocations->uiOrdering( uiConfigName, *group );
|
|
}
|
|
}
|
|
if ( m_valveTemplate() != nullptr )
|
|
{
|
|
caf::PdmUiGroup* group = uiOrdering.addNewGroup( "Parameters from Template" );
|
|
m_valveTemplate->uiOrdering( "InsideValve", *group );
|
|
}
|
|
|
|
uiOrdering.skipRemainingFields( true );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
|
{
|
|
if ( field == &m_measuredDepth )
|
|
{
|
|
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute );
|
|
|
|
if ( myAttr )
|
|
{
|
|
double minimumValue = 0.0, maximumValue = 0.0;
|
|
|
|
auto perforationInterval = firstAncestorOrThisOfType<RimPerforationInterval>();
|
|
if ( perforationInterval )
|
|
{
|
|
minimumValue = perforationInterval->startMD();
|
|
maximumValue = perforationInterval->endMD();
|
|
}
|
|
else
|
|
{
|
|
auto wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
|
|
|
|
minimumValue = wellPath->startMD();
|
|
maximumValue = wellPath->endMD();
|
|
}
|
|
myAttr->m_minimum = minimumValue;
|
|
myAttr->m_maximum = maximumValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RimWellPathValve::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
|
|
{
|
|
applyValveLabelAndIcon();
|
|
}
|