Files
ResInsight/ApplicationLibCode/Commands/CompletionExportCommands/RicExportCompletionsWellSegmentsFeature.cpp
T
Magne Sjaastad 313ed1e4fc #14241 MSW: Remove obsolete legacy MSW code and data structures
Remove the legacy tree-based MSW extraction path now that the geometry-based path is the only supported implementation. This deletes extractSingleWellMsw_Legacy and all unused tree-building helpers in RicWellPathExportMswTableData, trims RicMswTableDataTools to the shared helpers used by the geometry path, and removes the RicMswItem class family (RicMswBranch, RicMswSegment, RicMswCompletions, RicMswExportInfo, RicMswSegmentCellIntersection, RicMswValveAccumulators).

Also remove the useImprovedMswDataStructures preference and its keyword, and delete the obsolete legacy-vs-geometry comparison unit test.
2026-06-19 12:50:14 +02:00

149 lines
5.9 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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 "RicExportCompletionsWellSegmentsFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiuMessageDialog.h"
#include "RifTextDataTableFormatter.h"
#include "RicExportFeatureImpl.h"
#include "RicWellPathExportCompletionDataFeatureImpl.h"
#include "RicWellPathExportCompletionsFileTools.h"
#include "RicWellPathExportMswCompletionsImpl.h"
#include "RimEclipseCase.h"
#include "RimFishbones.h"
#include "RimFishbonesCollection.h"
#include "RimPerforationCollection.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathFractureCollection.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "Well/RigWellPath.h"
#include "Riu3DMainWindowTools.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include "cafUtils.h"
#include "cvfMath.h"
#include <QAction>
#include <QDir>
CAF_CMD_SOURCE_INIT( RicExportCompletionsWellSegmentsFeature, "RicExportCompletionsWellSegmentsFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCompletionsWellSegmentsFeature::onActionTriggered( bool isChecked )
{
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
CVF_ASSERT( wellPath );
RimFishbonesCollection* fishbonesCollection = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimFishbonesCollection>();
RimWellPathFractureCollection* fractureCollection =
caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFractureCollection>();
RimPerforationCollection* perforationCollection =
caf::SelectionManager::instance()->selectedItemAncestorOfType<RimPerforationCollection>();
CVF_ASSERT( fishbonesCollection || fractureCollection || perforationCollection );
RiaApplication* app = RiaApplication::instance();
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "COMPLETIONS" );
RicCaseAndFileExportSettingsUi exportSettings;
std::vector<RimCase*> cases = app->project()->allGridCases();
for ( auto c : cases )
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( c );
if ( eclipseCase != nullptr )
{
exportSettings.caseToApply = eclipseCase;
break;
}
}
exportSettings.folder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Well Segments", "" );
RicExportFeatureImpl::configureForExport( propertyDialog.dialogButtonBox() );
if ( propertyDialog.exec() == QDialog::Accepted )
{
{
QDir folder( exportSettings.folder );
if ( !folder.exists() )
{
QString txt = QString( "The path '%1' does not exist. Aborting export." ).arg( exportSettings.folder );
RiuMessageDialog::showError( Riu3DMainWindowTools::mainWindowWidget(), "Export", txt );
return;
}
}
RiaApplication::instance()->setLastUsedDialogDirectory( "COMPLETIONS", QFileInfo( exportSettings.folder ).absolutePath() );
RicExportCompletionDataSettingsUi completionExportSettings;
completionExportSettings.caseToApply.setValue( exportSettings.caseToApply );
completionExportSettings.folder.setValue( exportSettings.folder );
completionExportSettings.includeFishbones = fishbonesCollection != nullptr && !fishbonesCollection->activeFishbonesSubs().empty();
completionExportSettings.includeFractures = fractureCollection != nullptr && !fractureCollection->activeFractures().empty();
completionExportSettings.includePerforations = perforationCollection != nullptr &&
!perforationCollection->activePerforations().empty();
RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( completionExportSettings, { wellPath } );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCompletionsWellSegmentsFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Export Well Segments" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportCompletionsWellSegmentsFeature::isCommandEnabled() const
{
if ( caf::SelectionManager::instance()->selectedItemAncestorOfType<RimFishbonesCollection>() )
{
return true;
}
else if ( caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFractureCollection>() )
{
return true;
}
else if ( caf::SelectionManager::instance()->selectedItemAncestorOfType<RimPerforationCollection>() )
{
return true;
}
return false;
}