2017-05-15 09:04:11 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2017-05-16 07:50:54 -05:00
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2018-01-31 01:41:23 -06:00
|
|
|
//
|
2017-05-15 09:04:11 -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-01-31 01:41:23 -06:00
|
|
|
//
|
2017-05-15 09:04:11 -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.
|
2018-01-31 01:41:23 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-05-15 09:04:11 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicWellPathExportCompletionDataFeature.h"
|
2018-01-31 00:55:24 -06:00
|
|
|
#include "RicWellPathExportCompletionDataFeatureImpl.h"
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2021-03-08 08:01:29 -06:00
|
|
|
#include "RiaLogging.h"
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2018-11-09 01:51:30 -06:00
|
|
|
#include "ExportCommands/RicExportLgrFeature.h"
|
2019-04-24 06:31:11 -05:00
|
|
|
#include "RicExportFeatureImpl.h"
|
2017-06-28 03:13:59 -05:00
|
|
|
|
2017-12-19 06:27:18 -06:00
|
|
|
#include "RimDialogData.h"
|
2021-02-26 07:27:59 -06:00
|
|
|
#include "RimFishbones.h"
|
2018-04-09 04:23:14 -05:00
|
|
|
#include "RimPerforationInterval.h"
|
2017-06-28 03:13:59 -05:00
|
|
|
#include "RimProject.h"
|
2018-04-09 04:23:14 -05:00
|
|
|
#include "RimSimWellFracture.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimSimWellInView.h"
|
2018-01-31 01:41:23 -06:00
|
|
|
#include "RimSimWellInViewCollection.h"
|
2017-06-28 03:13:59 -05:00
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
2019-04-08 04:04:21 -05:00
|
|
|
#include "RimWellPathCompletions.h"
|
2018-04-09 04:23:14 -05:00
|
|
|
#include "RimWellPathFracture.h"
|
2019-04-24 06:31:11 -05:00
|
|
|
#include "RimWellPathValve.h"
|
2017-06-07 09:04:34 -05:00
|
|
|
|
2018-02-27 09:37:06 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
2017-06-28 03:13:59 -05:00
|
|
|
#include "cafSelectionManager.h"
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
#include <QAction>
|
2021-03-08 08:01:29 -06:00
|
|
|
#include <QDir>
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicWellPathExportCompletionDataFeature, "RicWellPathExportCompletionDataFeature" );
|
2017-05-15 09:04:11 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-31 01:41:23 -06:00
|
|
|
///
|
2017-05-15 09:04:11 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions( const QString& dialogTitle,
|
|
|
|
const std::vector<RimWellPath*>& wellPaths,
|
|
|
|
const std::vector<RimSimWellInView*>& simWells )
|
2017-05-15 09:04:11 -05:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
RimProject* project = app->project();
|
|
|
|
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "COMPLETIONS" );
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2018-04-06 07:09:40 -05:00
|
|
|
RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData();
|
2017-06-12 05:03:42 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( wellPaths.empty() )
|
2017-06-12 05:03:42 -05:00
|
|
|
{
|
2017-12-19 06:27:18 -06:00
|
|
|
exportSettings->showForSimWells();
|
2017-06-12 05:03:42 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-19 06:27:18 -06:00
|
|
|
exportSettings->showForWellPath();
|
2017-06-12 05:03:42 -05:00
|
|
|
}
|
2017-12-22 06:50:49 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !exportSettings->caseToApply() )
|
2017-05-19 04:09:36 -05:00
|
|
|
{
|
2017-12-22 06:50:49 -06:00
|
|
|
std::vector<RimCase*> cases;
|
2019-09-06 03:40:57 -05:00
|
|
|
app->project()->allCases( cases );
|
|
|
|
for ( auto c : cases )
|
2017-05-19 04:09:36 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>( c );
|
|
|
|
if ( eclipseCase != nullptr )
|
2017-12-22 06:50:49 -06:00
|
|
|
{
|
|
|
|
exportSettings->caseToApply = eclipseCase;
|
|
|
|
break;
|
|
|
|
}
|
2017-05-19 04:09:36 -05:00
|
|
|
}
|
|
|
|
}
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( exportSettings->folder().isEmpty() ) exportSettings->folder = defaultDir;
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2021-02-26 07:27:59 -06:00
|
|
|
std::vector<RimSimWellFracture*> simWellFractures;
|
|
|
|
std::vector<RimWellPathFracture*> wellPathFractures;
|
|
|
|
std::vector<RimFishbones*> wellPathFishbones;
|
|
|
|
std::vector<RimPerforationInterval*> wellPathPerforations;
|
2018-04-09 04:23:14 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto s : simWells )
|
2018-04-09 04:23:14 -05:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
auto fratures = s->descendantsIncludingThisOfType<RimSimWellFracture>();
|
|
|
|
simWellFractures.insert( simWellFractures.end(), fratures.begin(), fratures.end() );
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
|
2021-04-13 00:22:56 -05:00
|
|
|
std::vector<RimWellPath*> topLevelWells;
|
|
|
|
{
|
|
|
|
std::set<RimWellPath*> myWells;
|
|
|
|
|
|
|
|
for ( auto w : wellPaths )
|
|
|
|
{
|
|
|
|
myWells.insert( w->topLevelWellPath() );
|
|
|
|
}
|
|
|
|
|
|
|
|
topLevelWells.assign( myWells.begin(), myWells.end() );
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<RimWellPath*> allLaterals;
|
|
|
|
{
|
2021-05-27 04:44:26 -05:00
|
|
|
std::set<RimWellPath*> lateralSet;
|
2021-04-13 00:22:56 -05:00
|
|
|
|
|
|
|
for ( auto t : topLevelWells )
|
|
|
|
{
|
2021-05-27 04:44:26 -05:00
|
|
|
auto laterals = t->allWellPathLaterals();
|
2021-04-13 00:22:56 -05:00
|
|
|
for ( auto l : laterals )
|
|
|
|
{
|
2021-05-27 04:44:26 -05:00
|
|
|
lateralSet.insert( l );
|
2021-04-13 00:22:56 -05:00
|
|
|
}
|
|
|
|
}
|
2021-05-27 04:44:26 -05:00
|
|
|
|
|
|
|
allLaterals.assign( lateralSet.begin(), lateralSet.end() );
|
2021-04-13 00:22:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for ( auto w : allLaterals )
|
2018-04-09 04:23:14 -05:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
auto fractures = w->descendantsIncludingThisOfType<RimWellPathFracture>();
|
|
|
|
wellPathFractures.insert( wellPathFractures.end(), fractures.begin(), fractures.end() );
|
|
|
|
|
|
|
|
auto fishbones = w->descendantsIncludingThisOfType<RimFishbones>();
|
|
|
|
wellPathFishbones.insert( wellPathFishbones.end(), fishbones.begin(), fishbones.end() );
|
|
|
|
|
|
|
|
auto perforations = w->descendantsIncludingThisOfType<RimPerforationInterval>();
|
|
|
|
wellPathPerforations.insert( wellPathPerforations.end(), perforations.begin(), perforations.end() );
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( ( !simWellFractures.empty() ) || ( !wellPathFractures.empty() ) )
|
2018-04-09 04:23:14 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings->showFractureInUi( true );
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings->showFractureInUi( false );
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !wellPathFishbones.empty() )
|
2018-04-09 04:23:14 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings->showFishbonesInUi( true );
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings->showFishbonesInUi( false );
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !wellPathPerforations.empty() )
|
2018-04-09 04:23:14 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings->showPerforationsInUi( true );
|
2019-04-24 06:31:11 -05:00
|
|
|
|
|
|
|
std::vector<const RimWellPathValve*> perforationValves;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const auto& perf : wellPathPerforations )
|
2019-04-24 06:31:11 -05:00
|
|
|
{
|
2023-05-12 14:41:34 -05:00
|
|
|
auto other = perf->descendantsIncludingThisOfType<const RimWellPathValve>();
|
|
|
|
perforationValves.insert( perforationValves.end(), other.begin(), other.end() );
|
2019-04-24 06:31:11 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !perforationValves.empty() )
|
2019-04-24 06:31:11 -05:00
|
|
|
{
|
|
|
|
exportSettings->enableIncludeMsw();
|
|
|
|
}
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings->showPerforationsInUi( false );
|
2018-04-09 04:23:14 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(), exportSettings, dialogTitle, "" );
|
|
|
|
RicExportFeatureImpl::configureForExport( propertyDialog.dialogButtonBox() );
|
2017-06-28 03:13:59 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( propertyDialog.exec() == QDialog::Accepted )
|
2017-05-15 09:04:11 -05:00
|
|
|
{
|
2021-03-08 08:01:29 -06:00
|
|
|
{
|
|
|
|
QDir folder( exportSettings->folder );
|
|
|
|
if ( !folder.exists() )
|
|
|
|
{
|
|
|
|
QString txt = QString( "The path '%1' does not exist. Aborting export." ).arg( exportSettings->folder );
|
|
|
|
RiaLogging::errorInMessageBox( Riu3DMainWindowTools::mainWindowWidget(), "Export", txt );
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RiaApplication::instance()->setLastUsedDialogDirectory( "COMPLETIONS", exportSettings->folder );
|
2017-05-15 09:04:11 -05:00
|
|
|
|
2021-04-13 00:22:56 -05:00
|
|
|
RicWellPathExportCompletionDataFeatureImpl::exportCompletions( topLevelWells, simWells, *exportSettings );
|
2017-05-15 09:04:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-09 03:08:10 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-06-26 07:28:46 -05:00
|
|
|
bool RicWellPathExportCompletionDataFeature::isCommandEnabled() const
|
2018-04-09 03:08:10 -05:00
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> wellPaths = selectedWellPaths();
|
|
|
|
|
2023-06-26 06:12:41 -05:00
|
|
|
return !wellPaths.empty();
|
2018-04-09 03:08:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicWellPathExportCompletionDataFeature::onActionTriggered( bool isChecked )
|
2018-04-09 03:08:10 -05:00
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> wellPaths = selectedWellPaths();
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( !wellPaths.empty() );
|
2018-04-09 03:08:10 -05:00
|
|
|
|
|
|
|
std::vector<RimSimWellInView*> simWells;
|
|
|
|
QString dialogTitle = "Export Completion Data for Selected Well Paths";
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions( dialogTitle, wellPaths, simWells );
|
2018-04-09 03:08:10 -05:00
|
|
|
}
|
|
|
|
|
2017-05-15 09:04:11 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-31 01:41:23 -06:00
|
|
|
///
|
2017-05-15 09:04:11 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicWellPathExportCompletionDataFeature::setupActionLook( QAction* actionToSetup )
|
2017-05-15 09:04:11 -05:00
|
|
|
{
|
2019-04-08 04:04:21 -05:00
|
|
|
std::vector<RimWellPath*> selected = selectedWellPaths();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( selected.size() == 1u )
|
2019-04-08 04:04:21 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Export Completion Data for Current Well Path" );
|
2019-04-08 04:04:21 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Export Completion Data for Selected Well Paths" );
|
2019-04-08 04:04:21 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/ExportCompletionsSymbol16x16.png" ) );
|
2017-05-15 09:04:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-01-31 01:41:23 -06:00
|
|
|
///
|
2017-05-15 09:04:11 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-05-29 08:52:35 -05:00
|
|
|
std::vector<RimWellPath*> RicWellPathExportCompletionDataFeature::selectedWellPaths()
|
|
|
|
{
|
|
|
|
std::vector<RimWellPath*> wellPaths;
|
2019-09-06 03:40:57 -05:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &wellPaths );
|
2017-05-29 08:52:35 -05:00
|
|
|
|
2018-04-09 02:29:41 -05:00
|
|
|
return wellPaths;
|
2017-06-12 05:03:42 -05:00
|
|
|
}
|