Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,8 @@ 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}/RicNewIjkIntersection3dviewFeature.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
@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicNewIjkIntersection3dviewFeature.h"

#include "RiaApplication.h"

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

#include "Riu3DMainWindowTools.h"

#include <QAction>

CAF_CMD_SOURCE_INIT( RicNewIjkIntersection3dviewFeature, "RicNewIjkIntersection3dviewFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicNewIjkIntersection3dviewFeature::isCommandEnabled() const
{
// I/J/K intersections rely on a structured Eclipse grid
return dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeMainOrComparisonGridView() ) != nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewIjkIntersection3dviewFeature::onActionTriggered( bool isChecked )
{
QVariant userData = this->userData();
if ( userData.isNull() || userData.type() != QVariant::List ) return;

// Axis and 0-based fixed index computed from the picked cell
QVariantList list = userData.toList();
CAF_ASSERT( list.size() == 2 );

auto axis = static_cast<RimIjkIntersection::GridAxis>( list[0].toInt() );
int fixedIndex = list[1].toInt();

auto* eclipseView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeMainOrComparisonGridView() );
if ( !eclipseView ) return;

RimIntersectionCollection* coll = eclipseView->intersectionCollection();
if ( !coll ) return;

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();
intersection->setAxis( axis );
intersection->setFixedIndex( fixedIndex );

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

eclipseView->scheduleCreateDisplayModelAndRedraw();
eclipseView->showGridCells( false );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewIjkIntersection3dviewFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/IntersectionBox16x16.png" ) );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RicNewIjkIntersection3dviewFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

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