2024-09-11 14:22:35 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2024 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.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2025-03-24 09:04:13 +01:00
|
|
|
#include "RicNewWellTargetMappingFeature.h"
|
2024-09-11 14:22:35 +02:00
|
|
|
|
2026-06-08 15:45:23 +02:00
|
|
|
#include "RimDataAnalyticsCollection.h"
|
2025-03-19 10:57:16 +01:00
|
|
|
#include "RimEclipseCase.h"
|
2024-09-11 14:22:35 +02:00
|
|
|
#include "RimEclipseCaseEnsemble.h"
|
2026-03-02 18:59:09 +01:00
|
|
|
#include "RimReservoirGridEnsemble.h"
|
2025-03-24 09:04:13 +01:00
|
|
|
#include "RimWellTargetMapping.h"
|
2024-09-11 14:22:35 +02:00
|
|
|
|
2024-12-20 11:06:28 +01:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
|
2024-09-11 14:22:35 +02:00
|
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
2025-03-24 09:04:13 +01:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewWellTargetMappingFeature, "RicNewWellTargetMappingFeature" );
|
2024-09-11 14:22:35 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2026-05-28 16:06:39 +02:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool RicNewWellTargetMappingFeature::isCommandEnabled() const
|
|
|
|
|
{
|
|
|
|
|
if ( auto gridEnsembles = caf::selectedObjectsByTypeStrict<RimReservoirGridEnsemble*>(); !gridEnsembles.empty() )
|
|
|
|
|
{
|
|
|
|
|
// Computation of well target mappings for individual grids is implemented in RimWellTargetMapping::generateEnsembleStatistics().
|
|
|
|
|
//
|
|
|
|
|
// If there is a future need to support well target mappings for ensembles with individual grids, the implementation in
|
|
|
|
|
// RimWellTargetMapping::generateEnsembleStatistics() will need to be updated, and this check can be removed.
|
|
|
|
|
//
|
|
|
|
|
// The main performance reason is the memory consumption of loading all grids in the ensemble into memory at the same time, which is
|
|
|
|
|
// currently needed in order to compute the well target mapping for ensembles with individual grids. For ensembles with shared grid,
|
|
|
|
|
// only the shared grid needs to be loaded, which is much more memory efficient.
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2024-09-11 14:22:35 +02:00
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-03-24 09:04:13 +01:00
|
|
|
void RicNewWellTargetMappingFeature::onActionTriggered( bool isChecked )
|
2024-09-11 14:22:35 +02:00
|
|
|
{
|
2025-03-19 10:57:16 +01:00
|
|
|
if ( auto ensembles = caf::selectedObjectsByTypeStrict<RimEclipseCaseEnsemble*>(); !ensembles.empty() )
|
|
|
|
|
{
|
2025-03-24 09:04:13 +01:00
|
|
|
auto ensemble = ensembles.front();
|
|
|
|
|
auto wellTargetMapping = new RimWellTargetMapping();
|
|
|
|
|
ensemble->addWellTargetMapping( wellTargetMapping );
|
2025-03-24 12:03:15 +01:00
|
|
|
wellTargetMapping->setDefaults();
|
2026-03-02 18:59:09 +01:00
|
|
|
|
|
|
|
|
ensemble->updateConnectedEditors();
|
|
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem( wellTargetMapping );
|
|
|
|
|
}
|
|
|
|
|
else if ( auto gridEnsembles = caf::selectedObjectsByTypeStrict<RimReservoirGridEnsemble*>(); !gridEnsembles.empty() )
|
|
|
|
|
{
|
|
|
|
|
auto ensemble = gridEnsembles.front();
|
|
|
|
|
auto wellTargetMapping = new RimWellTargetMapping();
|
|
|
|
|
ensemble->addWellTargetMapping( wellTargetMapping );
|
|
|
|
|
wellTargetMapping->setDefaults();
|
2024-09-11 14:22:35 +02:00
|
|
|
|
2025-03-19 10:57:16 +01:00
|
|
|
ensemble->updateConnectedEditors();
|
2025-03-24 09:04:13 +01:00
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem( wellTargetMapping );
|
2025-03-19 10:57:16 +01:00
|
|
|
}
|
|
|
|
|
else if ( auto eclipseCases = caf::selectedObjectsByTypeStrict<RimEclipseCase*>(); !eclipseCases.empty() )
|
|
|
|
|
{
|
2025-03-24 09:04:13 +01:00
|
|
|
auto eclipseCase = eclipseCases.front();
|
|
|
|
|
auto wellTargetMapping = new RimWellTargetMapping();
|
|
|
|
|
eclipseCase->addWellTargetMapping( wellTargetMapping );
|
2025-03-24 12:03:15 +01:00
|
|
|
wellTargetMapping->setDefaults();
|
2024-12-20 11:06:28 +01:00
|
|
|
|
2026-06-08 15:45:23 +02:00
|
|
|
eclipseCase->updateConnectedEditors();
|
|
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem( wellTargetMapping );
|
|
|
|
|
}
|
|
|
|
|
else if ( auto collections = caf::selectedObjectsByTypeStrict<RimDataAnalyticsCollection*>(); !collections.empty() )
|
|
|
|
|
{
|
|
|
|
|
auto eclipseCase = collections.front()->firstAncestorOrThisOfType<RimEclipseCase>();
|
|
|
|
|
if ( !eclipseCase ) return;
|
|
|
|
|
|
|
|
|
|
auto wellTargetMapping = new RimWellTargetMapping();
|
|
|
|
|
eclipseCase->addWellTargetMapping( wellTargetMapping );
|
|
|
|
|
wellTargetMapping->setDefaults();
|
|
|
|
|
|
2025-03-19 10:57:16 +01:00
|
|
|
eclipseCase->updateConnectedEditors();
|
2025-03-24 09:04:13 +01:00
|
|
|
RiuMainWindow::instance()->selectAsCurrentItem( wellTargetMapping );
|
2025-03-19 10:57:16 +01:00
|
|
|
}
|
2024-09-11 14:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-03-24 09:04:13 +01:00
|
|
|
void RicNewWellTargetMappingFeature::setupActionLook( QAction* actionToSetup )
|
2024-09-11 14:22:35 +02:00
|
|
|
{
|
2025-03-24 09:04:13 +01:00
|
|
|
actionToSetup->setText( "Create Well Target Mapping" );
|
2025-03-24 08:37:03 +01:00
|
|
|
actionToSetup->setIcon( QIcon( ":/WellTargets.png" ) );
|
2024-09-11 14:22:35 +02:00
|
|
|
}
|