mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
Replace the transient Data Analytics tree label with a real RimDataAnalyticsCollection object that owns the case-level fault distance collection and the well target mappings. The folder shows its analytics objects flattened and exposes a right-click menu to create a new Fault Distance and a new Well Target Mapping. Migrate case-level well target mappings from older project files into the new collection via initAfterRead; fault distance is unreleased and needs no migration. The case accessors faultDistanceCollection() and addWellTargetMapping() now forward to the new object, and the creation features resolve a selected Data Analytics folder.
113 lines
4.9 KiB
C++
113 lines
4.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicNewWellTargetMappingFeature.h"
|
|
|
|
#include "RimDataAnalyticsCollection.h"
|
|
#include "RimEclipseCase.h"
|
|
#include "RimEclipseCaseEnsemble.h"
|
|
#include "RimReservoirGridEnsemble.h"
|
|
#include "RimWellTargetMapping.h"
|
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
#include "cafSelectionManagerTools.h"
|
|
|
|
#include <QAction>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicNewWellTargetMappingFeature, "RicNewWellTargetMappingFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
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;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicNewWellTargetMappingFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
if ( auto ensembles = caf::selectedObjectsByTypeStrict<RimEclipseCaseEnsemble*>(); !ensembles.empty() )
|
|
{
|
|
auto ensemble = ensembles.front();
|
|
auto wellTargetMapping = new RimWellTargetMapping();
|
|
ensemble->addWellTargetMapping( wellTargetMapping );
|
|
wellTargetMapping->setDefaults();
|
|
|
|
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();
|
|
|
|
ensemble->updateConnectedEditors();
|
|
RiuMainWindow::instance()->selectAsCurrentItem( wellTargetMapping );
|
|
}
|
|
else if ( auto eclipseCases = caf::selectedObjectsByTypeStrict<RimEclipseCase*>(); !eclipseCases.empty() )
|
|
{
|
|
auto eclipseCase = eclipseCases.front();
|
|
auto wellTargetMapping = new RimWellTargetMapping();
|
|
eclipseCase->addWellTargetMapping( wellTargetMapping );
|
|
wellTargetMapping->setDefaults();
|
|
|
|
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();
|
|
|
|
eclipseCase->updateConnectedEditors();
|
|
RiuMainWindow::instance()->selectAsCurrentItem( wellTargetMapping );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicNewWellTargetMappingFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Create Well Target Mapping" );
|
|
actionToSetup->setIcon( QIcon( ":/WellTargets.png" ) );
|
|
}
|