Use helper function to get polygon collection

This commit is contained in:
Magne Sjaastad
2025-02-20 07:44:33 +01:00
parent 0b6578bcb2
commit 1273e98bce
8 changed files with 16 additions and 32 deletions

View File

@@ -24,8 +24,7 @@
#include "Polygons/RimPolygonCollection.h" #include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonTools.h" #include "Polygons/RimPolygonTools.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimOilField.h" #include "RimTools.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
@@ -38,8 +37,7 @@ CAF_CMD_SOURCE_INIT( RicCreatePolygonFeature, "RicCreatePolygonFeature" );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicCreatePolygonFeature::onActionTriggered( bool isChecked ) void RicCreatePolygonFeature::onActionTriggered( bool isChecked )
{ {
auto proj = RimProject::current(); auto polygonCollection = RimTools::polygonCollection();
auto polygonCollection = proj->activeOilField()->polygonCollection();
auto newPolygon = polygonCollection->appendUserDefinedPolygon(); auto newPolygon = polygonCollection->appendUserDefinedPolygon();
polygonCollection->uiCapability()->updateAllRequiredEditors(); polygonCollection->uiCapability()->updateAllRequiredEditors();

View File

@@ -19,8 +19,7 @@
#include "RicDeleteAllPolygonsFeature.h" #include "RicDeleteAllPolygonsFeature.h"
#include "Polygons/RimPolygonCollection.h" #include "Polygons/RimPolygonCollection.h"
#include "RimOilField.h" #include "RimTools.h"
#include "RimProject.h"
#include <QAction> #include <QAction>
@@ -31,8 +30,7 @@ CAF_CMD_SOURCE_INIT( RicDeleteAllPolygonsFeature, "RicDeleteAllPolygonsFeature"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicDeleteAllPolygonsFeature::onActionTriggered( bool isChecked ) void RicDeleteAllPolygonsFeature::onActionTriggered( bool isChecked )
{ {
auto proj = RimProject::current(); auto polygonCollection = RimTools::polygonCollection();
auto polygonCollection = proj->activeOilField()->polygonCollection();
polygonCollection->deleteAllPolygons(); polygonCollection->deleteAllPolygons();
polygonCollection->updateConnectedEditors(); polygonCollection->updateConnectedEditors();

View File

@@ -25,8 +25,7 @@
#include "Polygons/RimPolygonInView.h" #include "Polygons/RimPolygonInView.h"
#include "Polygons/RimPolygonTools.h" #include "Polygons/RimPolygonTools.h"
#include "Rim3dView.h" #include "Rim3dView.h"
#include "RimOilField.h" #include "RimTools.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
@@ -55,8 +54,7 @@ void RicDuplicatePolygonFeature::onActionTriggered( bool isChecked )
auto sourcePolygon = selPolygons[0]; auto sourcePolygon = selPolygons[0];
auto proj = RimProject::current(); auto polygonCollection = RimTools::polygonCollection();
auto polygonCollection = proj->activeOilField()->polygonCollection();
auto newPolygon = polygonCollection->createUserDefinedPolygon(); auto newPolygon = polygonCollection->createUserDefinedPolygon();
newPolygon->setPointsInDomainCoords( sourcePolygon->pointsInDomainCoords() ); newPolygon->setPointsInDomainCoords( sourcePolygon->pointsInDomainCoords() );

View File

@@ -24,8 +24,7 @@
#include "Polygons/RimPolygonCollection.h" #include "Polygons/RimPolygonCollection.h"
#include "Polygons/RimPolygonFile.h" #include "Polygons/RimPolygonFile.h"
#include "Polygons/RimPolygonTools.h" #include "Polygons/RimPolygonTools.h"
#include "RimOilField.h" #include "RimTools.h"
#include "RimProject.h"
#include "Riu3DMainWindowTools.h" #include "Riu3DMainWindowTools.h"
#include "RiuFileDialogTools.h" #include "RiuFileDialogTools.h"
@@ -56,8 +55,7 @@ void RicImportPolygonFileFeature::onActionTriggered( bool isChecked )
// Remember the path to next time // Remember the path to next time
app->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileNames.last() ).absolutePath() ); app->setLastUsedDialogDirectory( RimPolygonTools::polygonCacheName(), QFileInfo( fileNames.last() ).absolutePath() );
auto proj = RimProject::current(); auto polygonCollection = RimTools::polygonCollection();
auto polygonCollection = proj->activeOilField()->polygonCollection();
RimPolygon* objectToSelect = nullptr; RimPolygon* objectToSelect = nullptr;

View File

@@ -25,12 +25,11 @@
#include "RimAnnotationInViewCollection.h" #include "RimAnnotationInViewCollection.h"
#include "RimAnnotationLineAppearance.h" #include "RimAnnotationLineAppearance.h"
#include "RimGridView.h" #include "RimGridView.h"
#include "RimOilField.h"
#include "RimPolylineTarget.h" #include "RimPolylineTarget.h"
#include "RimPolylinesFromFileAnnotation.h" #include "RimPolylinesFromFileAnnotation.h"
#include "RimProject.h"
#include "RimReachCircleAnnotation.h" #include "RimReachCircleAnnotation.h"
#include "RimTextAnnotation.h" #include "RimTextAnnotation.h"
#include "RimTools.h"
#include "RimUserDefinedPolylinesAnnotation.h" #include "RimUserDefinedPolylinesAnnotation.h"
#include "Polygons/RimPolygon.h" #include "Polygons/RimPolygon.h"
@@ -79,7 +78,7 @@ RimAnnotationCollection::~RimAnnotationCollection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimAnnotationCollection::initAfterRead() void RimAnnotationCollection::initAfterRead()
{ {
auto polycoll = RimProject::current()->activeOilField()->polygonCollection(); auto polycoll = RimTools::polygonCollection();
for ( auto oldPolyObj : m_userDefinedPolylineAnnotations_OBSOLETE->annotations() ) for ( auto oldPolyObj : m_userDefinedPolylineAnnotations_OBSOLETE->annotations() )
{ {

View File

@@ -24,9 +24,9 @@
#include "RimCellFilter.h" #include "RimCellFilter.h"
#include "RimCellIndexFilter.h" #include "RimCellIndexFilter.h"
#include "RimCellRangeFilter.h" #include "RimCellRangeFilter.h"
#include "RimOilField.h"
#include "RimPolygonFilter.h" #include "RimPolygonFilter.h"
#include "RimProject.h" #include "RimProject.h"
#include "RimTools.h"
#include "RimUserDefinedFilter.h" #include "RimUserDefinedFilter.h"
#include "RimUserDefinedIndexFilter.h" #include "RimUserDefinedIndexFilter.h"
#include "RimViewController.h" #include "RimViewController.h"
@@ -144,8 +144,7 @@ void RimCellFilterCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuB
menuBuilder.subMenuStart( "Polygon Filter", QIcon( ":/CellFilter_Polygon.png" ) ); menuBuilder.subMenuStart( "Polygon Filter", QIcon( ":/CellFilter_Polygon.png" ) );
{ {
auto project = RimProject::current(); auto polygonCollection = RimTools::polygonCollection();
auto polygonCollection = project->activeOilField()->polygonCollection();
for ( auto p : polygonCollection->allPolygons() ) for ( auto p : polygonCollection->allPolygons() )
{ {
if ( !p ) continue; if ( !p ) continue;

View File

@@ -44,8 +44,6 @@
#include "RimEclipseCaseEnsemble.h" #include "RimEclipseCaseEnsemble.h"
#include "RimEclipseContourMapProjection.h" #include "RimEclipseContourMapProjection.h"
#include "RimEclipseResultDefinition.h" #include "RimEclipseResultDefinition.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInViewCollection.h" #include "RimSimWellInViewCollection.h"
#include "RimStatisticsContourMapProjection.h" #include "RimStatisticsContourMapProjection.h"
#include "RimStatisticsContourMapView.h" #include "RimStatisticsContourMapView.h"
@@ -213,8 +211,7 @@ void RimStatisticsContourMap::defineUiOrdering( QString uiConfigName, caf::PdmUi
if ( m_enableFormationFilter ) formationGrp->add( &m_selectedFormations ); if ( m_enableFormationFilter ) formationGrp->add( &m_selectedFormations );
} }
RimProject* proj = RimProject::current(); if ( auto polygonCollection = RimTools::polygonCollection() )
if ( auto polygonCollection = proj->activeOilField()->polygonCollection().p() )
{ {
if ( !polygonCollection->allPolygons().empty() ) if ( !polygonCollection->allPolygons().empty() )
{ {
@@ -389,8 +386,7 @@ QList<caf::PdmOptionItemInfo> RimStatisticsContourMap::calculateValueOptions( co
} }
else if ( &m_selectedPolygons == fieldNeedingOptions ) else if ( &m_selectedPolygons == fieldNeedingOptions )
{ {
RimProject* proj = RimProject::current(); if ( auto polygonCollection = RimTools::polygonCollection() )
if ( auto polygonCollection = proj->activeOilField()->polygonCollection().p() )
{ {
for ( auto p : polygonCollection->allPolygons() ) for ( auto p : polygonCollection->allPolygons() )
{ {

View File

@@ -558,8 +558,7 @@ RimWellPath* RimTools::firstWellPath()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimSurfaceCollection* RimTools::surfaceCollection() RimSurfaceCollection* RimTools::surfaceCollection()
{ {
RimProject* proj = RimProject::current(); return RimProject::current()->activeOilField()->surfaceCollection();
return proj->activeOilField()->surfaceCollection();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -567,8 +566,7 @@ RimSurfaceCollection* RimTools::surfaceCollection()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RimPolygonCollection* RimTools::polygonCollection() RimPolygonCollection* RimTools::polygonCollection()
{ {
RimProject* proj = RimProject::current(); return RimProject::current()->activeOilField()->polygonCollection();
return proj->activeOilField()->polygonCollection();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------