2016-12-20 09:53:19 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2019-01-16 14:57:43 +01:00
|
|
|
// Copyright (C) 2016-2018 Statoil ASA
|
|
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-12-20 09:53:19 +01: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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-12-20 09:53:19 +01: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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-12-20 09:53:19 +01:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2017-01-02 14:01:31 +01:00
|
|
|
#include "RicNewWellPathFractureFeature.h"
|
2016-12-20 09:53:19 +01:00
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
|
2018-02-06 13:15:36 +01:00
|
|
|
#include "RicFractureNameGenerator.h"
|
|
|
|
|
|
2017-02-27 07:13:06 +01:00
|
|
|
#include "RigWellPath.h"
|
|
|
|
|
|
2016-12-20 09:53:19 +01:00
|
|
|
#include "RimCase.h"
|
2018-02-06 13:15:36 +01:00
|
|
|
#include "RimEclipseView.h"
|
2017-02-07 11:08:56 +01:00
|
|
|
#include "RimFractureTemplateCollection.h"
|
2017-01-04 14:02:32 +01:00
|
|
|
#include "RimOilField.h"
|
2016-12-20 09:53:19 +01:00
|
|
|
#include "RimProject.h"
|
2018-02-06 13:15:36 +01:00
|
|
|
#include "RimStimPlanColors.h"
|
2017-01-31 15:58:13 +01:00
|
|
|
#include "RimWellPath.h"
|
2016-12-20 13:10:03 +01:00
|
|
|
#include "RimWellPathCollection.h"
|
2019-04-08 11:04:21 +02:00
|
|
|
#include "RimWellPathCompletions.h"
|
2017-01-02 11:59:30 +01:00
|
|
|
#include "RimWellPathFracture.h"
|
|
|
|
|
#include "RimWellPathFractureCollection.h"
|
2018-02-06 13:15:36 +01:00
|
|
|
|
2018-02-27 15:53:33 +01:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2017-06-09 13:05:32 +02:00
|
|
|
|
|
|
|
|
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
|
|
|
|
|
|
2016-12-20 09:53:19 +01:00
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
2017-01-02 10:10:45 +01:00
|
|
|
#include <QAction>
|
2016-12-20 09:53:19 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewWellPathFractureFeature, "RicNewWellPathFractureFeature" );
|
2016-12-20 09:53:19 +01:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-12-20 09:53:19 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicNewWellPathFractureFeature::addFracture( RimWellPath* wellPath, double measuredDepth )
|
2016-12-20 09:53:19 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
CVF_ASSERT( wellPath );
|
2017-06-09 12:19:14 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return;
|
2016-12-20 09:53:19 +01:00
|
|
|
|
2017-06-09 13:05:32 +02:00
|
|
|
RimWellPathFractureCollection* fractureCollection = wellPath->fractureCollection();
|
2019-09-06 10:40:57 +02:00
|
|
|
CVF_ASSERT( fractureCollection );
|
2017-06-09 13:05:32 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( fractureCollection->allFractures().empty() )
|
2018-02-06 13:15:36 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeReservoirView() );
|
|
|
|
|
if ( activeView )
|
2018-02-06 13:15:36 +01:00
|
|
|
{
|
2018-03-01 07:51:30 +01:00
|
|
|
activeView->fractureColors()->setDefaultResultName();
|
2018-02-06 13:15:36 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-02 11:59:30 +01:00
|
|
|
RimWellPathFracture* fracture = new RimWellPathFracture();
|
2019-09-06 10:40:57 +02:00
|
|
|
fractureCollection->addFracture( fracture );
|
2017-06-09 13:05:32 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
fracture->setMeasuredDepth( measuredDepth );
|
|
|
|
|
fracture->setFractureUnit( wellPath->unitSystem() );
|
2017-06-09 13:05:32 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
RigWellPath* wellPathGeometry = wellPath->wellPathGeometry();
|
|
|
|
|
cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath( measuredDepth );
|
|
|
|
|
fracture->setAnchorPosition( positionAtWellpath );
|
2017-01-06 13:13:25 +01:00
|
|
|
|
2017-01-04 14:02:32 +01:00
|
|
|
RimOilField* oilfield = nullptr;
|
2019-09-06 10:40:57 +02:00
|
|
|
fractureCollection->firstAncestorOrThisOfType( oilfield );
|
|
|
|
|
if ( !oilfield ) return;
|
2017-01-04 14:02:32 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
fracture->setName( RicFractureNameGenerator::nameForNewFracture() );
|
2017-01-31 15:54:04 +01:00
|
|
|
|
2018-02-21 09:10:40 +01:00
|
|
|
auto unitSet = wellPath->unitSystem();
|
2019-09-06 10:40:57 +02:00
|
|
|
fracture->setFractureUnit( unitSet );
|
2018-02-21 09:10:40 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection()->firstFractureOfUnit( unitSet );
|
|
|
|
|
if ( fracDef )
|
2019-01-16 14:57:43 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
fracture->setFractureTemplate( fracDef );
|
2019-01-16 14:57:43 +01:00
|
|
|
}
|
2016-12-20 09:53:19 +01:00
|
|
|
|
2017-06-21 11:06:38 +02:00
|
|
|
RimProject* project = nullptr;
|
2019-09-06 10:40:57 +02:00
|
|
|
fractureCollection->firstAncestorOrThisOfType( project );
|
|
|
|
|
if ( project )
|
2017-02-22 14:40:13 +01:00
|
|
|
{
|
2017-06-21 11:06:38 +02:00
|
|
|
project->reloadCompletionTypeResultsInAllViews();
|
2019-06-21 07:07:37 +02:00
|
|
|
project->updateAllRequiredEditors();
|
2017-02-22 14:40:13 +01:00
|
|
|
}
|
2019-06-21 07:07:37 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( fracture );
|
2016-12-20 09:53:19 +01:00
|
|
|
}
|
|
|
|
|
|
2017-06-09 13:05:32 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-06-09 13:05:32 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicNewWellPathFractureFeature::onActionTriggered( bool isChecked )
|
2017-06-09 13:05:32 +02:00
|
|
|
{
|
|
|
|
|
RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !fractureColl ) return;
|
2017-06-09 13:05:32 +02:00
|
|
|
|
|
|
|
|
RimWellPath* wellPath = nullptr;
|
2019-09-06 10:40:57 +02:00
|
|
|
fractureColl->firstAncestorOrThisOfTypeAsserted( wellPath );
|
2017-06-09 13:05:32 +02:00
|
|
|
|
|
|
|
|
double defaultMeasuredDepth = 0.0f;
|
2019-09-06 10:40:57 +02:00
|
|
|
RicNewWellPathFractureFeature::addFracture( wellPath, defaultMeasuredDepth );
|
2017-06-09 13:05:32 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-20 09:53:19 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-12-20 09:53:19 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicNewWellPathFractureFeature::setupActionLook( QAction* actionToSetup )
|
2016-12-20 09:53:19 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setIcon( QIcon( ":/FractureSymbol16x16.png" ) );
|
|
|
|
|
actionToSetup->setText( "Create Fracture" );
|
2016-12-20 09:53:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2016-12-20 09:53:19 +01:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-02 14:01:31 +01:00
|
|
|
bool RicNewWellPathFractureFeature::isCommandEnabled()
|
2016-12-20 09:53:19 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( selectedWellPathFractureCollection() )
|
2017-06-09 12:19:14 +02:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-12-20 09:53:19 +01:00
|
|
|
|
2017-06-09 12:19:14 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2016-12-20 09:53:19 +01:00
|
|
|
|
2017-06-09 12:19:14 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-06-09 12:19:14 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimWellPathFractureCollection* RicNewWellPathFractureFeature::selectedWellPathFractureCollection()
|
|
|
|
|
{
|
2019-04-12 09:08:38 +02:00
|
|
|
std::vector<caf::PdmUiItem*> allSelectedItems;
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::SelectionManager::instance()->selectedItems( allSelectedItems );
|
|
|
|
|
if ( allSelectedItems.size() != 1u ) return nullptr;
|
|
|
|
|
|
2017-06-09 12:19:14 +02:00
|
|
|
RimWellPathFractureCollection* objToFind = nullptr;
|
2016-12-20 09:53:19 +01:00
|
|
|
|
2019-04-12 09:08:38 +02:00
|
|
|
caf::PdmUiItem* pdmUiItem = allSelectedItems.front();
|
2017-06-09 12:19:14 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>( pdmUiItem );
|
|
|
|
|
if ( objHandle )
|
2016-12-20 09:53:19 +01:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
objHandle->firstAncestorOrThisOfType( objToFind );
|
2016-12-20 09:53:19 +01:00
|
|
|
}
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( objToFind == nullptr )
|
2017-06-20 13:38:27 +02:00
|
|
|
{
|
|
|
|
|
std::vector<RimWellPath*> wellPaths;
|
2019-09-06 10:40:57 +02:00
|
|
|
caf::SelectionManager::instance()->objectsByType( &wellPaths );
|
|
|
|
|
if ( !wellPaths.empty() )
|
2017-06-20 13:38:27 +02:00
|
|
|
{
|
|
|
|
|
return wellPaths[0]->fractureCollection();
|
|
|
|
|
}
|
2019-11-04 15:08:09 +01:00
|
|
|
RimWellPathCompletions* completions =
|
|
|
|
|
caf::SelectionManager::instance()->selectedItemOfType<RimWellPathCompletions>();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( completions )
|
2019-04-08 11:04:21 +02:00
|
|
|
{
|
|
|
|
|
return completions->fractureCollection();
|
|
|
|
|
}
|
2017-06-20 13:38:27 +02:00
|
|
|
}
|
|
|
|
|
|
2017-06-09 12:19:14 +02:00
|
|
|
return objToFind;
|
2016-12-20 09:53:19 +01:00
|
|
|
}
|