Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use polygon as data source for intersection #11221

Merged
merged 14 commits into from
Feb 25, 2024
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
9 changes: 5 additions & 4 deletions ApplicationExeCode/Resources/ResInsight.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,15 @@
<file>SeismicDelta16x16.png</file>
<file>SeismicView16x16.png</file>
<file>SeismicView24x24.png</file>
<file>SeismicViews24x24.png</file>
<file>SeismicData24x24.png</file>
<file>SeismicSection16x16.png</file>
<file>Fullscreen.png</file>
<file>SeismicViews24x24.png</file>
<file>SeismicData24x24.png</file>
<file>SeismicSection16x16.png</file>
<file>Fullscreen.png</file>
<file>plot-template-standard.svg</file>
<file>plot-template-ensemble.svg</file>
<file>decline-curve.svg</file>
<file>regression-curve.svg</file>
<file>padlock.svg</file>
</qresource>
<qresource prefix="/Shader">
<file>fs_CellFace.glsl</file>
Expand Down
11 changes: 11 additions & 0 deletions ApplicationExeCode/Resources/padlock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion ApplicationLibCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,10 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
}
}

setActiveReservoirView( riv );
if ( riv->showWindow() )
{
setActiveReservoirView( riv );
}

RimGridView* rigv = dynamic_cast<RimGridView*>( riv );
if ( rigv ) rigv->cellFilterCollection()->updateIconState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void RicNewPolygonFilter3dviewFeature::onActionTriggered( bool isChecked )
// and the case to use
RimCase* sourceCase = viewOrComparisonView->ownerCase();

RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase );
RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase, nullptr );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@

#include "RicNewPolygonFilterFeature.h"

#include "RiaApplication.h"

#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonInView.h"

#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimGridView.h"
#include "RimPolygonFilter.h"

#include "Riu3DMainWindowTools.h"
Expand All @@ -38,16 +42,31 @@ CAF_CMD_SOURCE_INIT( RicNewPolygonFilterFeature, "RicNewPolygonFilterFeature" );
//--------------------------------------------------------------------------------------------------
void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
{
// Find the selected Cell Filter Collection
std::vector<RimCellFilterCollection*> colls = caf::selectedObjectsByTypeStrict<RimCellFilterCollection*>();
if ( colls.empty() ) return;
RimCellFilterCollection* filtColl = colls[0];
auto cellFilterCollection = caf::SelectionManager::instance()->selectedItemOfType<RimCellFilterCollection>();

if ( !cellFilterCollection )
{
RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( activeView )
{
cellFilterCollection = activeView->cellFilterCollection();
}
}

if ( !cellFilterCollection ) return;

auto polygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !polygon )
{
if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>() )
{
polygon = polygonInView->polygon();
}
}

// and the case to use
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted<RimCase>();

RimPolygonFilter* lastCreatedOrUpdated = filtColl->addNewPolygonFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand All @@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewPolygonIntersectionFeature.cpp
)

list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 "RicNewPolygonIntersectionFeature.h"

#include "RiaApplication.h"

#include "RimExtrudedCurveIntersection.h"
#include "RimGridView.h"
#include "RimIntersectionCollection.h"

#include "Polygons/RimPolygon.h"
#include "Polygons/RimPolygonInView.h"

#include "cafSelectionManager.h"

#include <QAction>

CAF_CMD_SOURCE_INIT( RicNewPolygonIntersectionFeature, "RicNewPolygonIntersectionFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonIntersectionFeature::onActionTriggered( bool isChecked )
{
RimGridView* activeView = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( !activeView ) return;

auto collection = activeView->intersectionCollection();
if ( !collection ) return;

auto polygon = caf::SelectionManager::instance()->selectedItemOfType<RimPolygon>();
if ( !polygon )
{
if ( auto polygonInView = caf::SelectionManager::instance()->selectedItemOfType<RimPolygonInView>() )
{
polygon = polygonInView->polygon();
}
}

auto intersection = new RimExtrudedCurveIntersection();
intersection->configureForProjectPolyLine( polygon );
collection->appendIntersectionAndUpdate( intersection );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewPolygonIntersectionFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/CrossSection16x16.png" ) );
actionToSetup->setText( "Create Polygon Intersection" );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 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 RicNewPolygonIntersectionFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bool RicSeismicSectionFromIntersectionFeature::isCommandEnabled() const
if ( intersection != nullptr )
{
return ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) ||
( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) ||
( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_WELL_PATH ) );
}

Expand All @@ -70,7 +71,8 @@ void RicSeismicSectionFromIntersectionFeature::onActionTriggered( bool isChecked
RimSeismicSection* newSection = seisColl->addNewSection();
if ( !newSection ) return;

if ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE )
if ( ( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYLINE ) ||
( intersection->type() == RimExtrudedCurveIntersection::CrossSectionEnum::CS_POLYGON ) )
{
newSection->setSectionType( RiaDefines::SeismicSectionType::SS_POLYLINE );
newSection->setUserDescription( intersection->name() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void RicPolyline3dEditor::configureAndUpdateUi( const QString& uiConfigName )
}
m_targetEditors.clear();

if ( !pickerInterface ) return;
if ( !pickerInterface || !pickerInterface->pickEventHandler() ) return;

if ( pickerInterface->pickingEnabled() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,44 +44,41 @@ bool RicIntersectionPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& e
std::vector<RimExtrudedCurveIntersection*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );

if ( selection.size() == 1 )
if ( selection.size() != 1 ) return false;

RimExtrudedCurveIntersection* intersection = selection[0];

RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted<RimGridView>();

if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView )
{
return false;
}

cvf::ref<caf::DisplayCoordTransform> transForm = gridView->displayCoordTransform();

cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() );

if ( intersection->inputPolyLineFromViewerEnabled() )
{
{
RimExtrudedCurveIntersection* intersection = selection[0];

RimGridView* gridView = intersection->firstAncestorOrThisOfTypeAsserted<RimGridView>();

if ( RiaApplication::instance()->activeMainOrComparisonGridView() != gridView )
{
return false;
}

cvf::ref<caf::DisplayCoordTransform> transForm = gridView->displayCoordTransform();

cvf::Vec3d domainCoord = transForm->transformToDomainCoord( eventObject.m_pickItemInfos.front().globalPickedPoint() );

if ( intersection->inputPolyLineFromViewerEnabled() )
{
intersection->appendPointToPolyLine( domainCoord );

// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputExtrusionPointsFromViewerEnabled() )
{
intersection->appendPointToExtrusionDirection( domainCoord );

// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() )
{
intersection->appendPointToAzimuthLine( domainCoord );

// Further Ui processing is stopped when true is returned
return true;
}
}
intersection->appendPointToPolyLine( domainCoord );

// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputExtrusionPointsFromViewerEnabled() )
{
intersection->appendPointToExtrusionDirection( domainCoord );

// Further Ui processing is stopped when true is returned
return true;
}
else if ( intersection->inputTwoAzimuthPointsFromViewerEnabled() )
{
intersection->appendPointToAzimuthLine( domainCoord );

// Further Ui processing is stopped when true is returned
return true;
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/ModelVisualization/RivPolylinePartMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool RivPolylinePartMgr::isPolylinesInBoundingBox( std::vector<std::vector<cvf::
void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* displayXf, const cvf::BoundingBox& boundingBox )
{
auto polylineDef = m_polylineInterface->polyLinesData();
if ( polylineDef.isNull() || polylineDef->polyLines().empty() )
if ( polylineDef.isNull() || polylineDef->rawPolyLines().empty() )
{
clearAllGeometry();
return;
Expand Down Expand Up @@ -192,7 +192,7 @@ void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* d
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>> RivPolylinePartMgr::getPolylinesPointsInDomain( RigPolyLinesData* lineDef )
{
auto polylines = lineDef->polyLines();
auto polylines = lineDef->rawPolyLines();
if ( !lineDef->lockToZPlane() ) return polylines;

const double planeZ = lineDef->lockedZValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool RimPolylinesFromFileAnnotation::isEmpty()
{
if ( m_polyLinesData.isNull() ) return true;

for ( const std::vector<cvf::Vec3d>& line : m_polyLinesData->polyLines() )
for ( const std::vector<cvf::Vec3d>& line : m_polyLinesData->rawPolyLines() )
{
if ( !line.empty() ) return false;
}
Expand Down
Loading
Loading