2021-01-04 04:09:01 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2020- 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 "RicNewWellPathLateralAtDepthFeature.h"
|
|
|
|
|
|
|
|
#include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h"
|
|
|
|
|
|
|
|
#include "RigWellPath.h"
|
2021-02-26 07:27:59 -06:00
|
|
|
#include "RimFishbones.h"
|
2021-01-04 04:09:01 -06:00
|
|
|
#include "RimFishbonesCollection.h"
|
2021-02-26 07:27:59 -06:00
|
|
|
#include "RimModeledWellPath.h"
|
2021-01-04 04:09:01 -06:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
2021-02-26 07:27:59 -06:00
|
|
|
#include "RimWellPathGeometryDef.h"
|
2021-01-04 04:09:01 -06:00
|
|
|
#include "RimWellPathGroup.h"
|
2021-02-26 07:27:59 -06:00
|
|
|
#include "RimWellPathTarget.h"
|
2021-01-04 04:09:01 -06:00
|
|
|
|
|
|
|
#include "Riu3DMainWindowTools.h"
|
|
|
|
#include "Riu3dSelectionManager.h"
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
CAF_CMD_SOURCE_INIT( RicNewWellPathLateralAtDepthFeature, "RicNewWellPathLateralAtDepthFeature" );
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicNewWellPathLateralAtDepthFeature::isCommandEnabled()
|
|
|
|
{
|
|
|
|
if ( wellPathSelectionItem() )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewWellPathLateralAtDepthFeature::onActionTriggered( bool isChecked )
|
|
|
|
{
|
|
|
|
RiuWellPathSelectionItem* wellPathSelItem = wellPathSelectionItem();
|
|
|
|
CVF_ASSERT( wellPathSelItem );
|
|
|
|
|
|
|
|
RimWellPath* wellPath = wellPathSelItem->m_wellpath;
|
|
|
|
CVF_ASSERT( wellPath );
|
|
|
|
RimWellPathGroup* wellPathGroup = nullptr;
|
|
|
|
wellPath->firstAncestorOrThisOfType( wellPathGroup );
|
|
|
|
|
|
|
|
RimProject* project = RimProject::current();
|
|
|
|
if ( project && RimProject::current()->activeOilField() )
|
|
|
|
{
|
|
|
|
RimWellPathCollection* wellPathCollection = RimProject::current()->activeOilField()->wellPathCollection();
|
|
|
|
|
|
|
|
if ( wellPathCollection )
|
|
|
|
{
|
2021-02-26 07:27:59 -06:00
|
|
|
auto newModeledWellPath = new RimModeledWellPath();
|
2021-01-04 04:09:01 -06:00
|
|
|
|
|
|
|
auto [pointVector, measuredDepths] =
|
|
|
|
wellPath->wellPathGeometry()->clippedPointSubset( wellPath->wellPathGeometry()->measuredDepths().front(),
|
|
|
|
wellPathSelItem->m_measuredDepth );
|
|
|
|
if ( pointVector.size() < 2u ) return;
|
2021-02-26 07:27:59 -06:00
|
|
|
newModeledWellPath->geometryDefinition()->setMdAtFirstTarget( measuredDepths.back() );
|
|
|
|
newModeledWellPath->geometryDefinition()->setUseAutoGeneratedTargetAtSeaLevel( false );
|
|
|
|
newModeledWellPath->geometryDefinition()->setFixedWellPathPoints( pointVector );
|
|
|
|
newModeledWellPath->geometryDefinition()->setFixedMeasuredDepths( measuredDepths );
|
|
|
|
newModeledWellPath->setName( wellPath->name() + QString( " md=%1" ).arg( wellPathSelItem->m_measuredDepth ) );
|
2021-01-04 04:09:01 -06:00
|
|
|
newModeledWellPath->geometryDefinition()->enableTargetPointPicking( true );
|
|
|
|
newModeledWellPath->createWellPathGeometry();
|
|
|
|
if ( wellPathGroup )
|
|
|
|
{
|
|
|
|
wellPathGroup->addChildWellPath( newModeledWellPath );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wellPathCollection->addWellPath( newModeledWellPath, false );
|
|
|
|
wellPathCollection->groupWellPaths( { wellPath, newModeledWellPath } );
|
|
|
|
}
|
|
|
|
newModeledWellPath->firstAncestorOrThisOfTypeAsserted( wellPathGroup );
|
|
|
|
wellPathGroup->updateAllRequiredEditors();
|
|
|
|
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
|
|
|
|
|
|
|
Riu3DMainWindowTools::selectAsCurrentItem( newModeledWellPath->geometryDefinition() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicNewWellPathLateralAtDepthFeature::setupActionLook( QAction* actionToSetup )
|
|
|
|
{
|
|
|
|
actionToSetup->setText( "Create Well Path Lateral at this Depth" );
|
|
|
|
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RiuWellPathSelectionItem* RicNewWellPathLateralAtDepthFeature::wellPathSelectionItem()
|
|
|
|
{
|
|
|
|
Riu3dSelectionManager* riuSelManager = Riu3dSelectionManager::instance();
|
|
|
|
RiuSelectionItem* selItem = riuSelManager->selectedItem( Riu3dSelectionManager::RUI_TEMPORARY );
|
|
|
|
|
|
|
|
RiuWellPathSelectionItem* wellPathItem = dynamic_cast<RiuWellPathSelectionItem*>( selItem );
|
|
|
|
|
|
|
|
return wellPathItem;
|
|
|
|
}
|