Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "RimEclipseCase.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimGridView.h"
#include "RimIjkIntersection.h"
#include "RimIntersectionCollection.h"

#include "cafCmdExecCommandManager.h"
Expand All @@ -43,14 +44,13 @@ enum SelectionComposition
{
SEL_INVALID,
SEL_COLLECTION,
SEL_INTERSECTIONS,
SEL_INTERSECTION_BOXES,
SEL_BOTH_INTERSECTION_TYPES
SEL_INTERSECTION_ITEMS
};

static RimIntersectionCollection* selectedIntersectionCollection();
static std::vector<RimExtrudedCurveIntersection*> selectedIntersections();
static std::vector<RimBoxIntersection*> selectedIntersectionBoxes();
static std::vector<RimIjkIntersection*> selectedIjkIntersections();
static SelectionComposition selectionComposition();
static RimCase* commonGridCase( std::vector<caf::PdmUiItem*> selectedItems );

Expand All @@ -77,18 +77,13 @@ void RicCopyIntersectionsToAllViewsInCaseFeature::onActionTriggered( bool isChec
RimIntersectionCollection* coll = selectedIntersectionCollection();
copyIntersectionsToOtherViews( *gridCase, coll->intersections() );
copyIntersectionBoxesToOtherViews( *gridCase, coll->intersectionBoxes() );
copyIjkIntersectionsToOtherViews( *gridCase, coll->ijkIntersections() );
}

std::vector<RimExtrudedCurveIntersection*> selIntersections = selectedIntersections();
std::vector<RimBoxIntersection*> selIntersectionBoxes = selectedIntersectionBoxes();

if ( compostion == SEL_INTERSECTIONS || compostion == SEL_BOTH_INTERSECTION_TYPES )
{
copyIntersectionsToOtherViews( *gridCase, selIntersections );
}
if ( compostion == SEL_INTERSECTION_BOXES || compostion == SEL_BOTH_INTERSECTION_TYPES )
else if ( compostion == SEL_INTERSECTION_ITEMS )
{
copyIntersectionBoxesToOtherViews( *gridCase, selIntersectionBoxes );
copyIntersectionsToOtherViews( *gridCase, selectedIntersections() );
copyIntersectionBoxesToOtherViews( *gridCase, selectedIntersectionBoxes() );
copyIjkIntersectionsToOtherViews( *gridCase, selectedIjkIntersections() );
}
}
}
Expand Down Expand Up @@ -158,6 +153,32 @@ void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionBoxesToOtherVi
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCopyIntersectionsToAllViewsInCaseFeature::copyIjkIntersectionsToOtherViews( RimCase& gridCase,
std::vector<RimIjkIntersection*> ijkIntersections )
{
for ( RimIjkIntersection* ijkIntersection : ijkIntersections )
{
for ( Rim3dView* const view : gridCase.views() )
{
RimGridView* currGridView = dynamic_cast<RimGridView*>( view );
RimGridView* parentView = ijkIntersection->firstAncestorOrThisOfType<RimGridView>();

if ( currGridView && parentView != nullptr && parentView != currGridView )
{
RimIntersectionCollection* destCollection = currGridView->intersectionCollection();

auto copy = ijkIntersection->copyObject<RimIjkIntersection>();
CVF_ASSERT( copy );

destCollection->appendIjkIntersectionAndUpdate( copy );
}
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -183,6 +204,14 @@ std::vector<RimBoxIntersection*> selectedIntersectionBoxes()
return caf::selectedObjectsByType<RimBoxIntersection*>();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimIjkIntersection*> selectedIjkIntersections()
{
return caf::selectedObjectsByType<RimIjkIntersection*>();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -193,22 +222,16 @@ SelectionComposition selectionComposition()
RimCase* gridCase = commonGridCase( selectedItems );
if ( gridCase && gridCase->gridViews().size() > 1 )
{
RimIntersectionCollection* selColl = selectedIntersectionCollection();
std::vector<RimExtrudedCurveIntersection*> selIntersections = selectedIntersections();
std::vector<RimBoxIntersection*> selIntersectionBoxes = selectedIntersectionBoxes();
RimIntersectionCollection* selColl = selectedIntersectionCollection();

if ( selColl )
{
if ( selectedItems.size() == 1 ) return SEL_COLLECTION;
}
else
{
if ( !selIntersections.empty() && !selIntersectionBoxes.empty() )
return SEL_BOTH_INTERSECTION_TYPES;
else if ( !selIntersections.empty() )
return SEL_INTERSECTIONS;
else if ( !selIntersectionBoxes.empty() )
return SEL_INTERSECTION_BOXES;
if ( !selectedIntersections().empty() || !selectedIntersectionBoxes().empty() || !selectedIjkIntersections().empty() )
return SEL_INTERSECTION_ITEMS;
}
}
return SEL_INVALID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
class RimCase;
class RimExtrudedCurveIntersection;
class RimBoxIntersection;
class RimIjkIntersection;
class RimIntersectionCollection;

//==================================================================================================
Expand All @@ -42,4 +43,5 @@ class RicCopyIntersectionsToAllViewsInCaseFeature : public caf::CmdFeature

void copyIntersectionsToOtherViews( RimCase& gridCase, std::vector<RimExtrudedCurveIntersection*> intersections );
void copyIntersectionBoxesToOtherViews( RimCase& gridCase, std::vector<RimBoxIntersection*> intersectionBoxes );
void copyIjkIntersectionsToOtherViews( RimCase& gridCase, std::vector<RimIjkIntersection*> ijkIntersections );
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicIntersectionFeatureImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionBoxFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAppendIjkIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxXSliceFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxYSliceFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxZSliceFeature.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026- 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 "RicAppendIjkIntersectionFeature.h"

#include "RimEclipseView.h"
#include "RimGridView.h"
#include "RimIjkIntersection.h"
#include "RimIntersectionCollection.h"

#include "Riu3DMainWindowTools.h"

#include "cafSelectionManager.h"

#include <QAction>

CAF_CMD_SOURCE_INIT( RicAppendIjkIntersectionFeature, "RicAppendIjkIntersectionFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAppendIjkIntersectionFeature::isCommandEnabled() const
{
RimIntersectionCollection* coll = RicAppendIjkIntersectionFeature::intersectionCollection();

// I/J/K intersections rely on a structured Eclipse grid
return coll != nullptr && coll->firstAncestorOrThisOfType<RimEclipseView>() != nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendIjkIntersectionFeature::onActionTriggered( bool isChecked )
{
RimIntersectionCollection* coll = RicAppendIjkIntersectionFeature::intersectionCollection();

if ( coll )
{
RimIjkIntersection* intersection = new RimIjkIntersection();
intersection->setName( "Intersection I/J/K" );

// The default values are computed from the grid, which is resolved through the parent
// view, so the intersection must be added to the collection first
coll->appendIjkIntersectionNoUpdate( intersection );
intersection->setToDefaultValues();

coll->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( intersection );

RimGridView* rimView = coll->firstAncestorOrThisOfTypeAsserted<RimGridView>();
rimView->scheduleCreateDisplayModelAndRedraw();
rimView->showGridCells( false );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendIjkIntersectionFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/IntersectionBox16x16.png" ) );
actionToSetup->setText( "New Intersection I/J/K" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimIntersectionCollection* RicAppendIjkIntersectionFeature::intersectionCollection()
{
if ( auto selectedObject = caf::SelectionManager::instance()->selectedItemOfType<caf::PdmObjectHandle>() )
{
return selectedObject->firstAncestorOrThisOfType<RimIntersectionCollection>();
}

return nullptr;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2026- 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 RimIntersectionCollection;

//==================================================================================================
///
//==================================================================================================
class RicAppendIjkIntersectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;

private:
static RimIntersectionCollection* intersectionCollection();
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "RimGeoMechView.h"
#include "RimGridCrossPlotCurve.h"
#include "RimGridCrossPlotDataSet.h"
#include "RimIjkIntersection.h"
#include "RimMimeData.h"
#include "RimModeledWellPath.h"
#include "RimSummaryMultiPlot.h"
Expand Down Expand Up @@ -125,6 +126,7 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( caf::PdmObjec
if ( dynamic_cast<RimEclipseCase*>( pdmObject ) ) return true;
if ( dynamic_cast<RimExtrudedCurveIntersection*>( pdmObject ) ) return true;
if ( dynamic_cast<RimBoxIntersection*>( pdmObject ) ) return true;
if ( dynamic_cast<RimIjkIntersection*>( pdmObject ) ) return true;
if ( dynamic_cast<RimSummaryPlot*>( pdmObject ) ) return true;
if ( dynamic_cast<RimFractureTemplate*>( pdmObject ) ) return true;
if ( dynamic_cast<RimEnsembleCurveSet*>( pdmObject ) ) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "RimBoxIntersection.h"
#include "RimExtrudedCurveIntersection.h"
#include "RimIjkIntersection.h"
#include "RimIntersectionCollection.h"

#include "RiuMainWindow.h"
Expand All @@ -47,7 +48,10 @@ bool RicPasteIntersectionsFeature::isCommandEnabled() const
std::vector<caf::PdmPointer<RimBoxIntersection>> intersectionBoxObjects;
objectGroup.objectsByType( &intersectionBoxObjects );

if ( intersectionObjects.empty() && intersectionBoxObjects.empty() )
std::vector<caf::PdmPointer<RimIjkIntersection>> ijkIntersectionObjects;
objectGroup.objectsByType( &ijkIntersectionObjects );

if ( intersectionObjects.empty() && intersectionBoxObjects.empty() && ijkIntersectionObjects.empty() )
{
return false;
}
Expand Down Expand Up @@ -110,6 +114,25 @@ void RicPasteIntersectionsFeature::onActionTriggered( bool isChecked )
intersectionCollection->appendIntersectionBoxNoUpdate( intersectionBox );
}
}

std::vector<caf::PdmPointer<RimIjkIntersection>> ijkIntersectionObjects;
objectGroup.objectsByType( &ijkIntersectionObjects );

for ( size_t i = 0; i < ijkIntersectionObjects.size(); i++ )
{
RimIjkIntersection* ijkIntersection = ijkIntersectionObjects[i]->copyObject<RimIjkIntersection>();
QString nameOfCopy = QString( "Copy of " ) + ijkIntersection->name();
ijkIntersection->setName( nameOfCopy );

if ( i == ijkIntersectionObjects.size() - 1 )
{
intersectionCollection->appendIjkIntersectionAndUpdate( ijkIntersection );
}
else
{
intersectionCollection->appendIjkIntersectionNoUpdate( ijkIntersection );
}
}
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -145,5 +168,11 @@ RimIntersectionCollection* RicPasteIntersectionsFeature::findIntersectionCollect
return intersectionBox->firstAncestorOrThisOfType<RimIntersectionCollection>();
}

RimIjkIntersection* ijkIntersection = dynamic_cast<RimIjkIntersection*>( objectHandle );
if ( ijkIntersection )
{
return ijkIntersection->firstAncestorOrThisOfType<RimIntersectionCollection>();
}

return nullptr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivBoxIntersectionSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIjkIntersectionGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIjkIntersectionPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivIjkIntersectionSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattener.cpp
${CMAKE_CURRENT_LIST_DIR}/RivEclipseIntersectionGrid.cpp
${CMAKE_CURRENT_LIST_DIR}/RivFemIntersectionGrid.cpp
Expand Down
Loading