mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-14 01:55:53 -06:00
140 lines
5.3 KiB
C++
140 lines
5.3 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//
|
||
|
|
// Copyright (C) 2025- 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 "RimWellEventKeyword.h"
|
||
|
|
|
||
|
|
#include "RimWellEventKeywordItem.h"
|
||
|
|
|
||
|
|
#include "FileInterface/RifEventKeywordFormatter.h"
|
||
|
|
|
||
|
|
#include "cafPdmFieldScriptingCapability.h"
|
||
|
|
#include "cafPdmObjectScriptingCapability.h"
|
||
|
|
#include "cafPdmUiOrdering.h"
|
||
|
|
#include "cafPdmUiTreeOrdering.h"
|
||
|
|
|
||
|
|
CAF_PDM_SOURCE_INIT( RimWellEventKeyword, "WellEventKeyword" );
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
RimWellEventKeyword::RimWellEventKeyword()
|
||
|
|
{
|
||
|
|
CAF_PDM_InitScriptableObject( "Well Keyword Event", "", "", "WellEventKeyword" );
|
||
|
|
|
||
|
|
CAF_PDM_InitScriptableField( &m_keywordName, "KeywordName", QString(), "Keyword Name" );
|
||
|
|
CAF_PDM_InitFieldNoDefault( &m_items, "Items", "Items" );
|
||
|
|
|
||
|
|
setDeletable( true );
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
RimWellEventKeyword::~RimWellEventKeyword()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
QString RimWellEventKeyword::keywordName() const
|
||
|
|
{
|
||
|
|
return m_keywordName();
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
void RimWellEventKeyword::setKeywordName( const QString& keyword )
|
||
|
|
{
|
||
|
|
m_keywordName = keyword;
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
void RimWellEventKeyword::addStringItem( const QString& name, const QString& value )
|
||
|
|
{
|
||
|
|
auto* item = new RimWellEventKeywordItem();
|
||
|
|
item->setItemName( name );
|
||
|
|
item->setStringValue( value );
|
||
|
|
m_items.push_back( item );
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
void RimWellEventKeyword::addIntItem( const QString& name, int value )
|
||
|
|
{
|
||
|
|
auto* item = new RimWellEventKeywordItem();
|
||
|
|
item->setItemName( name );
|
||
|
|
item->setIntValue( value );
|
||
|
|
m_items.push_back( item );
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
void RimWellEventKeyword::addDoubleItem( const QString& name, double value )
|
||
|
|
{
|
||
|
|
auto* item = new RimWellEventKeywordItem();
|
||
|
|
item->setItemName( name );
|
||
|
|
item->setDoubleValue( value );
|
||
|
|
m_items.push_back( item );
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
std::vector<RimWellEventKeywordItem*> RimWellEventKeyword::items() const
|
||
|
|
{
|
||
|
|
std::vector<RimWellEventKeywordItem*> result;
|
||
|
|
for ( const auto& item : m_items )
|
||
|
|
{
|
||
|
|
if ( item.notNull() )
|
||
|
|
{
|
||
|
|
result.push_back( item.p() );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
QString RimWellEventKeyword::generateScheduleKeyword( const QString& wellName ) const
|
||
|
|
{
|
||
|
|
return RifEventKeywordFormatter::formatKeyword( m_keywordName(), items() );
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
void RimWellEventKeyword::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||
|
|
{
|
||
|
|
uiOrdering.add( &m_keywordName );
|
||
|
|
uiOrdering.add( &m_items );
|
||
|
|
}
|
||
|
|
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
///
|
||
|
|
//--------------------------------------------------------------------------------------------------
|
||
|
|
void RimWellEventKeyword::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
|
||
|
|
{
|
||
|
|
uiTreeOrdering.add( &m_items );
|
||
|
|
}
|