#7811 Modeled Well Path : Add copy/paste of a modeled well path

This commit is contained in:
Magne Sjaastad 2021-06-24 13:17:43 +02:00
parent 5e5d5cb0a6
commit 95463c6521
6 changed files with 163 additions and 4 deletions

View File

@ -29,6 +29,7 @@
#include "RimGridCrossPlotCurve.h"
#include "RimGridCrossPlotDataSet.h"
#include "RimMimeData.h"
#include "RimModeledWellPath.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimWellAllocationPlot.h"
@ -177,6 +178,10 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( caf::PdmObjec
{
return true;
}
else if ( dynamic_cast<RimModeledWellPath*>( pdmObject ) )
{
return true;
}
return false;
}

View File

@ -19,6 +19,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicImportWellMeasurementsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralAtDepthFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicPasteModeledWellPathFeature.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.h
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.h
@ -48,6 +49,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicDeletePolylineTargetFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicImportWellMeasurementsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralAtDepthFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathLateralFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicPasteModeledWellPathFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/Ric3dObjectEditorHandle.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicPointTangentManipulator.cpp
${CMAKE_CURRENT_LIST_DIR}/PointTangentManipulator/RicWellTarget3dEditor.cpp

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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 "RicPasteModeledWellPathFeature.h"
CAF_CMD_SOURCE_INIT( RicPasteModeledWellPathFeature, "RicPasteModeledWellPathFeature" );
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
#include "RimModeledWellPath.h"
#include "RimOilField.h"
#include "RimWellPathCollection.h"
#include "cafPdmObjectGroup.h"
#include "cafSelectionManager.h"
#include <QAction>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicPasteModeledWellPathFeature::isCommandEnabled()
{
if ( !modeledWellPaths().empty() ) return true;
{
std::vector<RimWellPathCollection*> objects;
caf::SelectionManager::instance()->objectsByType( &objects );
if ( objects.size() > 0 )
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteModeledWellPathFeature::onActionTriggered( bool isChecked )
{
if ( modeledWellPaths().empty() ) return;
RimProject* proj = RimProject::current();
if ( proj && proj->activeOilField() )
{
RimWellPathCollection* wellPathCollection = proj->activeOilField()->wellPathCollection();
if ( wellPathCollection )
{
for ( auto souceWellPath : modeledWellPaths() )
{
RimModeledWellPath* newModeledWellPath = dynamic_cast<RimModeledWellPath*>(
souceWellPath->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
QString name = souceWellPath->name() + " (copy)";
newModeledWellPath->setName( name );
wellPathCollection->addWellPath( newModeledWellPath, false );
wellPathCollection->uiCapability()->updateConnectedEditors();
proj->scheduleCreateDisplayModelAndRedrawAllViews();
Riu3DMainWindowTools::selectAsCurrentItem( newModeledWellPath );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicPasteModeledWellPathFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Paste Well Path" );
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimModeledWellPath*> RicPasteModeledWellPathFeature::modeledWellPaths()
{
caf::PdmObjectGroup objectGroup;
RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup );
std::vector<caf::PdmPointer<RimModeledWellPath>> typedObjects;
objectGroup.objectsByType( &typedObjects );
std::vector<RimModeledWellPath*> wellPaths;
for ( auto obj : typedObjects )
{
wellPaths.push_back( obj );
}
return wellPaths;
}

View File

@ -0,0 +1,38 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021- 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RimModeledWellPath;
//==================================================================================================
///
//==================================================================================================
class RicPasteModeledWellPathFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<RimModeledWellPath*> modeledWellPaths();
};

View File

@ -339,6 +339,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
else if ( dynamic_cast<RimWellPathCollection*>( firstUiItem ) )
{
menuBuilder << "RicNewEditableWellPathFeature";
menuBuilder << "RicPasteModeledWellPathFeature";
menuBuilder.addSeparator();
menuBuilder.subMenuStart( "Import" );
menuBuilder << "RicWellPathsImportFileFeature";

View File

@ -899,12 +899,11 @@ std::map<QString, std::vector<RimWellPath*>>
QString rootWellName = wellPath->name().left( indexOfLateralStart );
rootWells[rootWellName].push_back( wellPath );
continue;
}
}
else
{
rootWells[RimWellPathCollection::unGroupedText()].push_back( wellPath );
}
rootWells[RimWellPathCollection::unGroupedText()].push_back( wellPath );
}
return rootWells;