Add support for duplicating editable well paths from python

This commit is contained in:
jonjenssen authored and JJ committed 2025-08-04 15:25:05 +02:00
1 parent 84cdfe796c
commit 09f180ee53
6 files changed
+117 -18

No files matched your search

@@ -51,24 +51,7 @@ bool RicDuplicateWellPathFeature::isCommandEnabled() const
void RicDuplicateWellPathFeature::onActionTriggered( bool isChecked )
{
auto sourceWellPath = caf::firstAncestorOfTypeFromSelectedObject<RimModeledWellPath>();
if ( !sourceWellPath ) return;
RimProject* project = RimProject::current();
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( project && wellPathCollection )
{
auto newModeledWellPath = sourceWellPath->copyObject<RimModeledWellPath>();
size_t modelledWellpathCount = wellPathCollection->modelledWellPathCount();
newModeledWellPath->setName( "Well-" + QString::number( modelledWellpathCount + 1 ) );
newModeledWellPath->setWellPathColor( RiaColorTables::editableWellPathsPaletteColors().cycledColor3f( modelledWellpathCount ) );
wellPathCollection->addWellPaths( { newModeledWellPath } );
newModeledWellPath->createWellPathGeometry();
project->scheduleCreateDisplayModelAndRedrawAllViews();
Riu3DMainWindowTools::selectAsCurrentItem( newModeledWellPath->geometryDefinition() );
}
duplicateWellPath( sourceWellPath );
}
//--------------------------------------------------------------------------------------------------
@@ -79,3 +62,34 @@ void RicDuplicateWellPathFeature::setupActionLook( QAction* actionToSetup )
actionToSetup->setText( "Duplicate Well Path" );
actionToSetup->setIcon( QIcon( ":/caf/duplicate.svg" ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RicDuplicateWellPathFeature::duplicateWellPath( RimWellPath* wellPath )
{
if ( wellPath == nullptr ) return nullptr;
RimProject* project = RimProject::current();
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
if ( project && wellPathCollection )
{
auto newModeledWellPath = wellPath->copyObject<RimModeledWellPath>();
if ( newModeledWellPath == nullptr ) return nullptr;
size_t modelledWellpathCount = wellPathCollection->modelledWellPathCount();
newModeledWellPath->setName( "Well-" + QString::number( modelledWellpathCount + 1 ) );
newModeledWellPath->setWellPathColor( RiaColorTables::editableWellPathsPaletteColors().cycledColor3f( modelledWellpathCount ) );
wellPathCollection->addWellPaths( { newModeledWellPath } );
newModeledWellPath->createWellPathGeometry();
project->scheduleCreateDisplayModelAndRedrawAllViews();
Riu3DMainWindowTools::selectAsCurrentItem( newModeledWellPath->geometryDefinition() );
return newModeledWellPath;
}
return nullptr;
}
@@ -20,6 +20,8 @@
#include "cafCmdFeature.h"
class RimWellPath;
//==================================================================================================
///
//==================================================================================================
@@ -27,6 +29,9 @@ class RicDuplicateWellPathFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static RimWellPath* duplicateWellPath( RimWellPath* wellPath );
protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;