ResInsight/ApplicationLibCode/ProjectDataModel/Summary/RimDerivedSummaryCase.cpp

590 lines
21 KiB
C++
Raw Normal View History

2018-06-25 08:14:47 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016- Statoil ASA
//
2018-06-25 08:14:47 -05:00
// 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.
//
2018-06-25 08:14:47 -05:00
// 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>
2018-06-25 08:14:47 -05:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimDerivedSummaryCase.h"
2018-06-25 08:14:47 -05:00
#include "RiaCurveMerger.h"
#include "RiaLogging.h"
2018-06-25 08:14:47 -05:00
#include "RifDerivedEnsembleReader.h"
#include "RimProject.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryPlot.h"
2018-06-25 08:14:47 -05:00
#include "cafPdmUiTreeSelectionEditor.h"
#include <QDateTime>
#include <algorithm>
namespace caf
{
template <>
void caf::AppEnum<DerivedSummaryOperator>::setUp()
{
addItem( DerivedSummaryOperator::DERIVED_OPERATOR_SUB, "Sub", "-" );
addItem( DerivedSummaryOperator::DERIVED_OPERATOR_ADD, "Add", "+" );
setDefault( DerivedSummaryOperator::DERIVED_OPERATOR_SUB );
}
template <>
void caf::AppEnum<RimDerivedSummaryCase::FixedTimeStepMode>::setUp()
{
addItem( RimDerivedSummaryCase::FixedTimeStepMode::FIXED_TIME_STEP_NONE, "FIXED_TIME_STEP_NONE", "None" );
addItem( RimDerivedSummaryCase::FixedTimeStepMode::FIXED_TIME_STEP_CASE_1, "FIXED_TIME_STEP_CASE_1", "Summary Case 1" );
addItem( RimDerivedSummaryCase::FixedTimeStepMode::FIXED_TIME_STEP_CASE_2, "FIXED_TIME_STEP_CASE_2", "Summary Case 2" );
setDefault( RimDerivedSummaryCase::FixedTimeStepMode::FIXED_TIME_STEP_NONE );
}
} // namespace caf
2018-06-25 08:14:47 -05:00
CAF_PDM_SOURCE_INIT( RimDerivedSummaryCase, "RimDerivedEnsembleCase" );
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
RimDerivedSummaryCase::RimDerivedSummaryCase()
: m_summaryCase1( nullptr )
, m_summaryCase2( nullptr )
2018-06-25 08:14:47 -05:00
{
2020-10-01 10:25:19 -05:00
CAF_PDM_InitObject( "Summary Case", ":/SummaryCase.svg", "", "" );
CAF_PDM_InitFieldNoDefault( &m_summaryCase1, "SummaryCase1", "Summary Case 1", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_operator, "Operator", "Operator", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_summaryCase2, "SummaryCase2", "Summary Case 2", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_useFixedTimeStep, "UseFixedTimeStep", "Use Fixed Time Step", "", "", "" );
CAF_PDM_InitField( &m_fixedTimeStepIndex, "FixedTimeStepIndex", 0, "Time Step", "", "", "" );
CAF_PDM_InitField( &m_inUse, "InUse", false, "In Use", "", "", "" );
m_fixedTimeStepIndex.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
m_fixedTimeStepIndex.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
2018-06-25 08:14:47 -05:00
}
2018-06-25 08:58:28 -05:00
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:58:28 -05:00
//--------------------------------------------------------------------------------------------------
RimDerivedSummaryCase::~RimDerivedSummaryCase()
{
}
2018-06-25 08:58:28 -05:00
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::setInUse( bool inUse )
2018-06-25 08:14:47 -05:00
{
m_inUse = inUse;
if ( !m_inUse )
2018-06-25 08:14:47 -05:00
{
m_summaryCase1 = nullptr;
m_summaryCase2 = nullptr;
m_dataCache.clear();
2018-06-25 08:14:47 -05:00
}
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
bool RimDerivedSummaryCase::isInUse() const
2018-06-25 08:14:47 -05:00
{
return m_inUse;
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::setSummaryCases( RimSummaryCase* sumCase1, RimSummaryCase* sumCase2 )
2018-06-25 08:14:47 -05:00
{
m_summaryCase1 = sumCase1;
m_summaryCase2 = sumCase2;
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
bool RimDerivedSummaryCase::needsCalculation( const RifEclipseSummaryAddress& address ) const
2018-06-25 08:14:47 -05:00
{
return m_dataCache.count( address ) == 0;
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
const std::vector<time_t>& RimDerivedSummaryCase::timeSteps( const RifEclipseSummaryAddress& address ) const
2018-06-25 08:14:47 -05:00
{
if ( m_dataCache.count( address ) == 0 )
{
static std::vector<time_t> empty;
return empty;
}
return m_dataCache.at( address ).first;
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RimDerivedSummaryCase::values( const RifEclipseSummaryAddress& address ) const
2018-06-25 08:14:47 -05:00
{
if ( m_dataCache.count( address ) == 0 )
{
static std::vector<double> empty;
return empty;
}
return m_dataCache.at( address ).second;
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::calculate( const RifEclipseSummaryAddress& address )
2018-06-25 08:14:47 -05:00
{
clearData( address );
2018-06-25 08:14:47 -05:00
RifSummaryReaderInterface* reader1 = m_summaryCase1 ? m_summaryCase1->summaryReader() : nullptr;
RifSummaryReaderInterface* reader2 = m_summaryCase2 ? m_summaryCase2->summaryReader() : nullptr;
int fixedTimeStepCase1 = -1;
int fixedTimeStepCase2 = -1;
if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_1 )
{
fixedTimeStepCase1 = m_fixedTimeStepIndex;
}
else if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_2 )
{
fixedTimeStepCase2 = m_fixedTimeStepIndex;
}
auto itAndIsInsertedPair = m_dataCache.insert(
std::make_pair( address,
calculateDerivedValues( reader1, fixedTimeStepCase1, reader2, fixedTimeStepCase2, m_operator(), address ) ) );
// Check if we got any data. If not, erase the map entry to comply with previous behavior
if ( !itAndIsInsertedPair.first->second.first.size() )
{
m_dataCache.erase( itAndIsInsertedPair.first );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<std::vector<time_t>, std::vector<double>>
RimDerivedSummaryCase::calculateDerivedValues( RifSummaryReaderInterface* reader1,
int fixedTimeStepCase1,
RifSummaryReaderInterface* reader2,
int fixedTimeStepCase2,
DerivedSummaryOperator m_operator,
const RifEclipseSummaryAddress& address )
{
using ResultPair = std::pair<std::vector<time_t>, std::vector<double>>;
if ( !reader1 || !reader2 ) return ResultPair();
2018-06-25 08:14:47 -05:00
if ( !reader1->hasAddress( address ) && !reader2->hasAddress( address ) )
{
return ResultPair();
}
if ( reader1->hasAddress( address ) && !reader2->hasAddress( address ) )
{
std::vector<double> summaryValues;
reader1->values( address, &summaryValues );
return ResultPair( reader1->timeSteps( address ), summaryValues );
}
else if ( !reader1->hasAddress( address ) && reader2->hasAddress( address ) )
{
std::vector<double> summaryValues;
reader2->values( address, &summaryValues );
if ( m_operator == DerivedSummaryOperator::DERIVED_OPERATOR_SUB )
{
for ( auto& v : summaryValues )
{
v = -v;
}
}
return ResultPair( reader2->timeSteps( address ), summaryValues );
}
RiaTimeHistoryCurveMerger merger;
std::vector<double> values1;
std::vector<double> values2;
2018-06-25 08:14:47 -05:00
reader1->values( address, &values1 );
reader2->values( address, &values2 );
2018-06-25 08:14:47 -05:00
if ( values1.empty() && values2.empty() )
{
return ResultPair();
}
merger.addCurveData( reader1->timeSteps( address ), values1 );
merger.addCurveData( reader2->timeSteps( address ), values2 );
2018-06-25 08:14:47 -05:00
merger.computeInterpolatedValues();
const std::vector<double>& allValues1 = merger.interpolatedYValuesForAllXValues( 0 );
const std::vector<double>& allValues2 = merger.interpolatedYValuesForAllXValues( 1 );
size_t sampleCount = merger.allXValues().size();
2018-06-25 08:14:47 -05:00
std::vector<double> calculatedValues;
calculatedValues.reserve( sampleCount );
int clampedIndexCase1 = std::min( fixedTimeStepCase1, static_cast<int>( values1.size() ) );
int clampedIndexCase2 = std::min( fixedTimeStepCase2, static_cast<int>( values2.size() ) );
for ( size_t i = 0; i < sampleCount; i++ )
2018-06-25 08:14:47 -05:00
{
double valueCase1 = clampedIndexCase1 >= 0 ? values1[clampedIndexCase1] : allValues1[i];
double valueCase2 = clampedIndexCase2 >= 0 ? values2[clampedIndexCase2] : allValues2[i];
if ( m_operator == DerivedSummaryOperator::DERIVED_OPERATOR_SUB )
2018-06-25 08:14:47 -05:00
{
calculatedValues.push_back( valueCase1 - valueCase2 );
2018-06-25 08:14:47 -05:00
}
else if ( m_operator == DerivedSummaryOperator::DERIVED_OPERATOR_ADD )
2018-06-25 08:14:47 -05:00
{
calculatedValues.push_back( valueCase1 + valueCase2 );
2018-06-25 08:14:47 -05:00
}
}
return ResultPair( merger.allXValues(), calculatedValues );
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
QString RimDerivedSummaryCase::caseName() const
2018-06-25 08:14:47 -05:00
{
return m_displayName;
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::createSummaryReaderInterface()
2018-06-25 08:14:47 -05:00
{
RifSummaryReaderInterface* summaryCase1Reader1 = nullptr;
RifSummaryReaderInterface* summaryCase1Reader2 = nullptr;
if ( m_summaryCase1 )
{
if ( !m_summaryCase1->summaryReader() )
{
m_summaryCase1->createSummaryReaderInterface();
}
summaryCase1Reader1 = m_summaryCase1->summaryReader();
}
if ( m_summaryCase2 )
{
if ( !m_summaryCase2->summaryReader() )
{
m_summaryCase2->createSummaryReaderInterface();
}
summaryCase1Reader2 = m_summaryCase2->summaryReader();
}
m_reader.reset( new RifDerivedEnsembleReader( this, summaryCase1Reader1, summaryCase1Reader2 ) );
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
RifSummaryReaderInterface* RimDerivedSummaryCase::summaryReader()
2018-06-25 08:14:47 -05:00
{
if ( !m_reader )
{
createSummaryReaderInterface();
}
2018-06-25 08:14:47 -05:00
return m_reader.get();
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::updateFilePathsFromProjectPath( const QString& newProjectPath, const QString& oldProjectPath )
2018-06-25 08:14:47 -05:00
{
// NOP
}
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::setOperator( DerivedSummaryOperator oper )
2018-06-25 08:14:47 -05:00
{
m_operator = oper;
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::setFixedTimeSteps( int fixedTimeStepCase1, int fixedTimeStepCase2 )
{
m_useFixedTimeStep = FixedTimeStepMode::FIXED_TIME_STEP_NONE;
if ( fixedTimeStepCase1 >= 0 )
{
m_useFixedTimeStep = FixedTimeStepMode::FIXED_TIME_STEP_CASE_1;
m_fixedTimeStepIndex = fixedTimeStepCase1;
}
else if ( fixedTimeStepCase2 >= 0 )
{
m_useFixedTimeStep = FixedTimeStepMode::FIXED_TIME_STEP_CASE_2;
m_fixedTimeStepIndex = fixedTimeStepCase2;
}
}
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
///
2018-06-25 08:14:47 -05:00
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::clearData( const RifEclipseSummaryAddress& address )
2018-06-25 08:14:47 -05:00
{
m_dataCache.erase( address );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::updateDisplayNameFromCases()
{
QString timeStepString;
{
RimSummaryCase* sourceEnsemble = nullptr;
if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_1 )
{
sourceEnsemble = m_summaryCase1;
}
else if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_2 )
{
sourceEnsemble = m_summaryCase2;
}
if ( sourceEnsemble )
{
auto summaryReader = sourceEnsemble->summaryReader();
if ( summaryReader )
{
const std::vector<time_t>& timeSteps = summaryReader->timeSteps( RifEclipseSummaryAddress() );
2020-04-24 12:55:54 -05:00
if ( m_fixedTimeStepIndex >= 0 && m_fixedTimeStepIndex < static_cast<int>( timeSteps.size() ) )
{
time_t selectedTime = timeSteps[m_fixedTimeStepIndex];
QDateTime dt = RiaQDateTimeTools::fromTime_t( selectedTime );
2020-11-06 03:46:38 -06:00
QString formatString = RiaQDateTimeTools::createTimeFormatStringFromDates( { dt } );
timeStepString = RiaQDateTimeTools::toStringUsingApplicationLocale( dt, formatString );
}
}
}
}
QString case1Name = "None";
QString case2Name = "None";
if ( m_summaryCase1 )
{
case1Name = m_summaryCase1->displayCaseName();
if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_1 ) case1Name += "@" + timeStepString;
}
if ( m_summaryCase2 )
{
case2Name = m_summaryCase2->displayCaseName();
if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_2 ) case2Name += "@" + timeStepString;
}
QString operatorText;
if ( m_operator() == DerivedSummaryOperator::DERIVED_OPERATOR_SUB )
operatorText = "Delta";
else if ( m_operator() == DerivedSummaryOperator::DERIVED_OPERATOR_ADD )
operatorText = "Sum";
QString name;
Updates after 2020.10.1 release (#7104) * Set version to 2020.10.1-RC03 * #6780 Flow Vector Result: Check if data exists before using * #7031 Delta Summary Case: Fix crash when updating case name * #7036 Well Picks : Skip import of empty lines * #7003 Python: Guard nullpointer access for summary methods * #7014 Python: Resize the result container before assigning data * #7042 File Import Dialog : Sort by numbers instead of text * Set version to 2020.10.1-RC04 * #7008 Python: Avoid terminating process as part of open/closeProject When running scripts, a project file can be opened. If other operations are issued after, the process monitor window was disconnected from the script process, and no text output from the script was visible in the process monitor text window. New behavior : Never terminate a process automatically. Never terminate process as part of open/close project. If a process is left unresponsive, the user is now responsible for manual termination of this process. * #7045 Contour map : Disable clipping of smoothed contour lines * #7046 Cross Plot : Avoid reset of curve visibility when color legend visibility changes * #7048 Grid Cross Plot: Fix inverted Y-axis for user-defined min/max range * #7055 Contour Map: Label format it should match the legend format * #7059 Well Targets : Fix index of of bound crash when building well path * Set version to 2020.10.1-RC05 * #6814 Correlation Report: Missing update of plots when changing ensemble * Set version to 2020.10.1-RC06 * #7055 Contour Map: Label format it should match the legend format * #7068 Fix missing import surface File -> Import Surface * Set version to 2020.10.1-RC07 * Prepare for release of 2020.10.1 * #5641 Avoid unnecessary regeneration of contour map * Move clearGeometry to a scheduleGeometryRegen override * Trigger update of contour maps following legend changes * Make legend config changed signal more fine grained for Contour Maps * Set version to 2020.10.1-RC08 * Prepare for release of 2020.10.1 * Set dev version after patch release Co-authored-by: Gaute Lindkvist <lindkvis@gmail.com>
2020-12-10 03:44:23 -06:00
if ( case1Name == case2Name && m_summaryCase1 && m_summaryCase2 && m_summaryCase1->ensemble() &&
m_summaryCase2->ensemble() )
{
QString ensembleName1 = m_summaryCase1->ensemble()->name();
QString ensembleName2 = m_summaryCase2->ensemble()->name();
name = QString( "%1: %2 - %3" ).arg( case1Name ).arg( ensembleName1 ).arg( ensembleName2 );
}
else
{
name = operatorText + QString( "(%1 , %2)" ).arg( case1Name ).arg( case2Name );
}
m_displayName = name;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RimDerivedSummaryCase::summaryCase1() const
{
return m_summaryCase1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RimDerivedSummaryCase::summaryCase2() const
{
return m_summaryCase2;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
// Base class
uiOrdering.add( &m_displayName );
uiOrdering.add( &m_summaryCase1 );
uiOrdering.add( &m_operator );
uiOrdering.add( &m_summaryCase2 );
uiOrdering.add( &m_useFixedTimeStep );
if ( m_useFixedTimeStep() != FixedTimeStepMode::FIXED_TIME_STEP_NONE )
{
uiOrdering.add( &m_fixedTimeStepIndex );
}
uiOrdering.skipRemainingFields();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimDerivedSummaryCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
RimProject* proj = RimProject::current();
auto summaryCases = proj->allSummaryCases();
if ( fieldNeedingOptions == &m_fixedTimeStepIndex )
{
RimSummaryCase* sourceCase = nullptr;
if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_1 )
{
sourceCase = m_summaryCase1;
}
else if ( m_useFixedTimeStep() == FixedTimeStepMode::FIXED_TIME_STEP_CASE_2 )
{
sourceCase = m_summaryCase2;
}
if ( sourceCase && sourceCase->summaryReader() )
{
const std::vector<time_t>& timeSteps = sourceCase->summaryReader()->timeSteps( RifEclipseSummaryAddress() );
options = RiaQDateTimeTools::createOptionItems( timeSteps );
}
}
if ( fieldNeedingOptions == &m_summaryCase1 || fieldNeedingOptions == &m_summaryCase2 )
{
for ( auto c : summaryCases )
{
if ( c != this ) options.push_back( caf::PdmOptionItemInfo( c->displayCaseName(), c ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue )
{
bool reloadData = false;
if ( changedField == &m_summaryCase2 || changedField == &m_summaryCase1 )
{
createSummaryReaderInterface();
reloadData = true;
}
else if ( changedField == &m_useFixedTimeStep || changedField == &m_fixedTimeStepIndex )
{
reloadData = true;
}
else if ( changedField == &m_operator )
{
reloadData = true;
}
else
{
RimSummaryCase::fieldChangedByUi( changedField, oldValue, newValue );
}
if ( reloadData )
{
updateDisplayNameFromCases();
m_dataCache.clear();
std::vector<caf::PdmObjectHandle*> referringObjects;
this->objectsWithReferringPtrFields( referringObjects );
std::set<RimSummaryPlot*> plotsToUpdate;
for ( auto o : referringObjects )
{
RimSummaryPlot* sumPlot = nullptr;
o->firstAncestorOrThisOfType( sumPlot );
if ( sumPlot )
{
plotsToUpdate.insert( sumPlot );
}
}
for ( auto p : plotsToUpdate )
{
p->loadDataAndUpdate();
}
}
2018-06-25 08:14:47 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimDerivedSummaryCase::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( &m_fixedTimeStepIndex == field )
{
auto a = dynamic_cast<caf::PdmUiTreeSelectionEditorAttribute*>( attribute );
if ( a )
{
a->singleSelectionMode = true;
a->showTextFilter = true;
}
}
}