diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp index 95121dd465a..88584f78308 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewCellIndexFilterFeature.cpp @@ -59,12 +59,15 @@ void RicNewCellIndexFilterFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp index dab91b85108..07b8a4050b5 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewPolygonFilterFeature.cpp @@ -64,11 +64,13 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked ) } } - auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted(); - - if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) ) + auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted()->ownerCase(); + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp index 124d299f638..a0d6b7772f9 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewRangeFilterSliceFeature.cpp @@ -18,9 +18,11 @@ #include "RicNewRangeFilterSliceFeature.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimCellRangeFilter.h" + #include "Riu3DMainWindowTools.h" #include "cafCmdExecCommandManager.h" @@ -45,13 +47,16 @@ void RicNewRangeFilterSliceFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - int gridIndex = 0; - RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + int gridIndex = 0; + RimCellFilter* lastCreatedOrUpdated = filtColl->addNewCellRangeFilter( sourceCase, gridIndex, m_sliceDirection ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp index db2ab3d874e..414d96d9d09 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedFilterFeature.cpp @@ -18,9 +18,11 @@ #include "RicNewUserDefinedFilterFeature.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimUserDefinedFilter.h" + #include "Riu3DMainWindowTools.h" #include "cafSelectionManagerTools.h" @@ -41,12 +43,15 @@ void RicNewUserDefinedFilterFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp index ec90f7893d1..3e41191ae90 100644 --- a/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp +++ b/ApplicationLibCode/Commands/CellFilterCommands/RicNewUserDefinedIndexFilterFeature.cpp @@ -18,6 +18,7 @@ #include "RicNewUserDefinedIndexFilterFeature.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellFilterCollection.h" #include "RimUserDefinedIndexFilter.h" @@ -42,12 +43,15 @@ void RicNewUserDefinedIndexFilterFeature::onActionTriggered( bool isChecked ) RimCellFilterCollection* filtColl = colls[0]; // and the case to use - RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted(); + RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted()->ownerCase(); - auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase ); - if ( lastCreatedOrUpdated ) + if ( sourceCase ) { - Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase ); + if ( lastCreatedOrUpdated ) + { + Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated ); + } } } diff --git a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index 65a2d59a56d..e24c88e6e1d 100644 --- a/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationLibCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -103,8 +103,10 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo() intersection->setName( "Azimuth and Dip" ); intersection->configureForAzimuthLine(); - RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted(); - cvf::BoundingBox bBox = rimCase->allCellsBoundingBox(); + RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted()->ownerCase(); + if ( !rimCase ) return; + + cvf::BoundingBox bBox = rimCase->allCellsBoundingBox(); if ( bBox.isValid() ) { intersection->setLengthUp( cvf::Math::floor( bBox.extent()[2] / 2 ) ); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp index c78d1a630f7..691d23a2eda 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilter.cpp @@ -298,7 +298,8 @@ QString RimCellFilter::modeString() const //-------------------------------------------------------------------------------------------------- const cvf::StructGridInterface* RimCellFilter::selectedGrid() const { - auto rimCase = firstAncestorOrThisOfTypeAsserted(); + auto rimCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); + if ( !rimCase ) return nullptr; int clampedIndex = gridIndex(); if ( clampedIndex >= RigReservoirGridTools::gridCount( rimCase ) ) diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp index c047e8c1018..d7eaf4b47fe 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechContourMapView.cpp @@ -104,11 +104,9 @@ QString RimGeoMechContourMapView::createAutoName() const QStringList generatedAutoTags; - auto ownerCase = firstAncestorOrThisOfTypeAsserted(); - - if ( nameConfig()->addCaseName() ) + if ( nameConfig()->addCaseName() && ownerCase() ) { - generatedAutoTags.push_back( ownerCase->caseUserDescription() ); + generatedAutoTags.push_back( ownerCase()->caseUserDescription() ); } if ( nameConfig()->addAggregationType() ) diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp index 293eea1334b..7b9777b9b63 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechView.cpp @@ -226,11 +226,9 @@ QString RimGeoMechView::createAutoName() const QStringList generatedAutoTags; - RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted(); - - if ( nameConfig()->addCaseName() ) + if ( nameConfig()->addCaseName() && ownerCase() ) { - generatedAutoTags.push_back( ownerCase->caseUserDescription() ); + generatedAutoTags.push_back( ownerCase()->caseUserDescription() ); } if ( nameConfig()->addProperty() ) diff --git a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp index 3633f6a7f18..6ec5f151c7e 100644 --- a/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Intersections/RimBoxIntersection.cpp @@ -656,7 +656,7 @@ void RimBoxIntersection::switchSingelPlaneState() //-------------------------------------------------------------------------------------------------- cvf::BoundingBox RimBoxIntersection::currentCellBoundingBox() { - auto rimCase = firstAncestorOrThisOfTypeAsserted(); + auto rimCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); return rimCase->activeCellsBoundingBox(); } diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp index 4fc6d0bd04b..43b10d393e7 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -176,7 +176,7 @@ RimCase* Rim2dIntersectionView::ownerCase() const if ( !rimCase ) { - rimCase = firstAncestorOrThisOfTypeAsserted(); + rimCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); } return rimCase; diff --git a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp index 7502d72fb7e..8614d2a6950 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -54,7 +54,7 @@ std::vector Rim2dIntersectionViewCollection::views() //-------------------------------------------------------------------------------------------------- void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpdate ) { - auto parentCase = firstAncestorOrThisOfTypeAsserted(); + auto parentCase = firstAncestorOrThisOfTypeAsserted()->ownerCase(); std::vector allOrderedIntersectionsInCase = parentCase->descendantsIncludingThisOfType(); @@ -109,8 +109,5 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda } if ( doUpdate ) updateConnectedEditors(); - - auto rimCase = firstAncestorOrThisOfType(); - - if ( rimCase ) rimCase->updateConnectedEditors(); + if ( parentCase ) parentCase->updateConnectedEditors(); } diff --git a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp index 046c5e7b7d4..e02f198250a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimAdvancedSnapshotExportDefinition.cpp @@ -190,9 +190,11 @@ void RimAdvancedSnapshotExportDefinition::fieldChangedByUi( const caf::PdmFieldH { actCellInfo = RigReservoirGridTools::activeCellInfo( view() ); - auto rimCase = view()->firstAncestorOrThisOfTypeAsserted(); - - mainGrid = RigReservoirGridTools::mainGrid( rimCase ); + auto rimCase = view()->ownerCase(); + if ( rimCase ) + { + mainGrid = RigReservoirGridTools::mainGrid( rimCase ); + } } if ( mainGrid && actCellInfo ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp index 67e3b0f9600..ab7d42a6621 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseContourMapView.cpp @@ -108,11 +108,9 @@ QString RimEclipseContourMapView::createAutoName() const QStringList generatedAutoTags; - RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted(); - - if ( nameConfig()->addCaseName() ) + if ( nameConfig()->addCaseName() && ownerCase() ) { - generatedAutoTags.push_back( ownerCase->caseUserDescription() ); + generatedAutoTags.push_back( ownerCase()->caseUserDescription() ); } if ( nameConfig()->addAggregationType() ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp index dfdc7e7a9ed..c5dea97ccf5 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -806,13 +806,16 @@ QList RimEclipseResultDefinition::calculateValueOptions( options.push_back( caf::PdmOptionItemInfo( "Disabled", RigEclipseResultAddress::noTimeLapseValue() ) ); - std::vector stepDates = baseCase->timeStepDates(); - for ( size_t stepIdx = 0; stepIdx < stepDates.size(); ++stepIdx ) + if ( baseCase ) { - QString displayString = stepDates[stepIdx].toString( RiaQDateTimeTools::dateFormatString() ); - displayString += QString( " (#%1)" ).arg( stepIdx ); + std::vector stepDates = baseCase->timeStepDates(); + for ( size_t stepIdx = 0; stepIdx < stepDates.size(); ++stepIdx ) + { + QString displayString = stepDates[stepIdx].toString( RiaQDateTimeTools::dateFormatString() ); + displayString += QString( " (#%1)" ).arg( stepIdx ); - options.push_back( caf::PdmOptionItemInfo( displayString, static_cast( stepIdx ) ) ); + options.push_back( caf::PdmOptionItemInfo( displayString, static_cast( stepIdx ) ) ); + } } } }