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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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