2026-05-27 12:14:08 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2026- 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.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2026-06-05 14:35:21 +02:00
|
|
|
#include "RimFaultDistanceCollection.h"
|
2026-05-27 12:14:08 +02:00
|
|
|
|
2026-06-08 10:58:01 +02:00
|
|
|
#include "RimEclipseCase.h"
|
2026-06-05 14:35:21 +02:00
|
|
|
#include "RimFaultDistance.h"
|
2026-05-27 12:14:08 +02:00
|
|
|
|
2026-06-01 08:41:36 +02:00
|
|
|
#include "cafCmdFeatureMenuBuilder.h"
|
2026-05-27 12:59:19 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
|
|
|
|
#include "cafPdmObjectScriptingCapability.h"
|
2026-05-27 12:14:08 +02:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
|
|
|
|
|
|
|
|
|
#include <QRegularExpression>
|
|
|
|
|
|
2026-06-05 14:35:21 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RimFaultDistanceCollection, "RimFaultDistanceCollection" );
|
2026-05-27 12:14:08 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-06-05 14:35:21 +02:00
|
|
|
RimFaultDistanceCollection::RimFaultDistanceCollection()
|
2026-05-27 12:14:08 +02:00
|
|
|
{
|
2026-06-05 13:57:24 +02:00
|
|
|
CAF_PDM_InitScriptableObjectWithNameAndComment( "Fault Distance",
|
2026-05-27 12:59:19 +02:00
|
|
|
":/draw_style_faults_24x24.png",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
2026-06-05 14:35:21 +02:00
|
|
|
"FaultDistanceCollection",
|
2026-05-27 12:59:19 +02:00
|
|
|
"Collection of named, subset-based FAULTDIST results" );
|
|
|
|
|
|
2026-06-05 14:35:21 +02:00
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_items, "FaultDistances", "" );
|
2026-05-27 12:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-06-05 14:35:21 +02:00
|
|
|
RimFaultDistance* RimFaultDistanceCollection::addResult()
|
2026-05-27 12:14:08 +02:00
|
|
|
{
|
2026-06-05 14:35:21 +02:00
|
|
|
auto* newResult = new RimFaultDistance();
|
2026-05-27 12:14:08 +02:00
|
|
|
newResult->setResultName( nextDefaultName() );
|
|
|
|
|
addItem( newResult );
|
|
|
|
|
return newResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-06-05 14:35:21 +02:00
|
|
|
QString RimFaultDistanceCollection::nextDefaultName() const
|
2026-05-27 12:14:08 +02:00
|
|
|
{
|
|
|
|
|
QRegularExpression pattern( "^FAULTDIST(\\d+)$" );
|
|
|
|
|
int maxIndex = 0;
|
2026-06-05 14:35:21 +02:00
|
|
|
for ( RimFaultDistance* result : items() )
|
2026-05-27 12:14:08 +02:00
|
|
|
{
|
|
|
|
|
if ( !result ) continue;
|
|
|
|
|
const QRegularExpressionMatch match = pattern.match( result->resultName() );
|
|
|
|
|
if ( match.hasMatch() )
|
|
|
|
|
{
|
|
|
|
|
maxIndex = std::max( maxIndex, match.captured( 1 ).toInt() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QString( "FAULTDIST%1" ).arg( maxIndex + 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-06-05 14:35:21 +02:00
|
|
|
void RimFaultDistanceCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
|
2026-05-27 12:14:08 +02:00
|
|
|
{
|
2026-06-05 14:35:21 +02:00
|
|
|
for ( RimFaultDistance* result : items() )
|
2026-05-27 12:14:08 +02:00
|
|
|
{
|
|
|
|
|
uiTreeOrdering.add( result );
|
|
|
|
|
}
|
|
|
|
|
uiTreeOrdering.skipRemainingChildren( true );
|
|
|
|
|
}
|
2026-06-01 08:41:36 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-06-05 14:35:21 +02:00
|
|
|
void RimFaultDistanceCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
|
2026-06-01 08:41:36 +02:00
|
|
|
{
|
|
|
|
|
menuBuilder << "RicNewFaultDistanceResultFeature";
|
|
|
|
|
}
|
2026-06-08 10:58:01 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
/// The case-level "Data Analytics" folder is hidden from the tree while this collection is empty, so
|
|
|
|
|
/// refresh the owner case to re-run its defineUiTreeOrdering and add/remove the folder when the first
|
|
|
|
|
/// item appears or the last item is removed.
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimFaultDistanceCollection::onItemsChanged()
|
|
|
|
|
{
|
|
|
|
|
if ( auto* eclipseCase = firstAncestorOrThisOfType<RimEclipseCase>() ) eclipseCase->updateConnectedEditors();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimFaultDistanceCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects )
|
|
|
|
|
{
|
|
|
|
|
updateConnectedEditors();
|
|
|
|
|
|
|
|
|
|
if ( auto* eclipseCase = firstAncestorOrThisOfType<RimEclipseCase>() ) eclipseCase->updateConnectedEditors();
|
|
|
|
|
}
|