Skip to content

Commit

Permalink
Fix all firstAncestorOrThisOfTypeAsserted calls to get RimCase.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Mar 20, 2024
1 parent 9dfbdd0 commit 2e20320
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ void RicNewCellIndexFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

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

RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
RimCellIndexFilter* lastCreatedOrUpdated = filtColl->addNewCellIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ void RicNewPolygonFilterFeature::onActionTriggered( bool isChecked )
}
}

auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted<RimCase>();

if ( auto lastCreatedOrUpdated = cellFilterCollection->addNewPolygonFilter( sourceCase, polygon ) )
auto sourceCase = cellFilterCollection->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( 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 @@ -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"
Expand All @@ -45,13 +47,16 @@ void RicNewRangeFilterSliceFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

// and the case to use
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<RimCase>();
RimCase* sourceCase = filtColl->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->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 );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -41,12 +43,15 @@ void RicNewUserDefinedFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

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

RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
RimUserDefinedFilter* lastCreatedOrUpdated = filtColl->addNewUserDefinedFilter( sourceCase );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "RicNewUserDefinedIndexFilterFeature.h"

#include "Rim3dView.h"
#include "RimCase.h"
#include "RimCellFilterCollection.h"
#include "RimUserDefinedIndexFilter.h"
Expand All @@ -42,12 +43,15 @@ void RicNewUserDefinedIndexFilterFeature::onActionTriggered( bool isChecked )
RimCellFilterCollection* filtColl = colls[0];

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

auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
if ( sourceCase )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
auto* lastCreatedOrUpdated = filtColl->addNewUserDefinedIndexFilter( sourceCase );
if ( lastCreatedOrUpdated )
{
Riu3DMainWindowTools::selectAsCurrentItem( lastCreatedOrUpdated );
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo()
intersection->setName( "Azimuth and Dip" );
intersection->configureForAzimuthLine();

RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted<RimCase>();
cvf::BoundingBox bBox = rimCase->allCellsBoundingBox();
RimCase* rimCase = m_intersectionCollection->firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();
if ( !rimCase ) return;

cvf::BoundingBox bBox = rimCase->allCellsBoundingBox();
if ( bBox.isValid() )
{
intersection->setLengthUp( cvf::Math::floor( bBox.extent()[2] / 2 ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ QString RimCellFilter::modeString() const
//--------------------------------------------------------------------------------------------------
const cvf::StructGridInterface* RimCellFilter::selectedGrid() const
{
auto rimCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
auto rimCase = firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();
if ( !rimCase ) return nullptr;

int clampedIndex = gridIndex();
if ( clampedIndex >= RigReservoirGridTools::gridCount( rimCase ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ QString RimGeoMechContourMapView::createAutoName() const

QStringList generatedAutoTags;

auto ownerCase = firstAncestorOrThisOfTypeAsserted<RimCase>();

if ( nameConfig()->addCaseName() )
if ( nameConfig()->addCaseName() && ownerCase() )
{
generatedAutoTags.push_back( ownerCase->caseUserDescription() );
generatedAutoTags.push_back( ownerCase()->caseUserDescription() );
}

if ( nameConfig()->addAggregationType() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,9 @@ QString RimGeoMechView::createAutoName() const

QStringList generatedAutoTags;

RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted<RimCase>();

if ( nameConfig()->addCaseName() )
if ( nameConfig()->addCaseName() && ownerCase() )
{
generatedAutoTags.push_back( ownerCase->caseUserDescription() );
generatedAutoTags.push_back( ownerCase()->caseUserDescription() );
}

if ( nameConfig()->addProperty() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void RimBoxIntersection::switchSingelPlaneState()
//--------------------------------------------------------------------------------------------------
cvf::BoundingBox RimBoxIntersection::currentCellBoundingBox()
{
auto rimCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
auto rimCase = firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();

return rimCase->activeCellsBoundingBox();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ RimCase* Rim2dIntersectionView::ownerCase() const

if ( !rimCase )
{
rimCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
rimCase = firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();
}

return rimCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ std::vector<Rim2dIntersectionView*> Rim2dIntersectionViewCollection::views()
//--------------------------------------------------------------------------------------------------
void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpdate )
{
auto parentCase = firstAncestorOrThisOfTypeAsserted<RimCase>();
auto parentCase = firstAncestorOrThisOfTypeAsserted<Rim3dView>()->ownerCase();

std::vector<RimExtrudedCurveIntersection*> allOrderedIntersectionsInCase =
parentCase->descendantsIncludingThisOfType<RimExtrudedCurveIntersection>();
Expand Down Expand Up @@ -109,8 +109,5 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda
}

if ( doUpdate ) updateConnectedEditors();

auto rimCase = firstAncestorOrThisOfType<RimCase>();

if ( rimCase ) rimCase->updateConnectedEditors();
if ( parentCase ) parentCase->updateConnectedEditors();
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ void RimAdvancedSnapshotExportDefinition::fieldChangedByUi( const caf::PdmFieldH
{
actCellInfo = RigReservoirGridTools::activeCellInfo( view() );

auto rimCase = view()->firstAncestorOrThisOfTypeAsserted<RimCase>();

mainGrid = RigReservoirGridTools::mainGrid( rimCase );
auto rimCase = view()->ownerCase();
if ( rimCase )
{
mainGrid = RigReservoirGridTools::mainGrid( rimCase );
}
}

if ( mainGrid && actCellInfo )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@ QString RimEclipseContourMapView::createAutoName() const

QStringList generatedAutoTags;

RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted<RimCase>();

if ( nameConfig()->addCaseName() )
if ( nameConfig()->addCaseName() && ownerCase() )
{
generatedAutoTags.push_back( ownerCase->caseUserDescription() );
generatedAutoTags.push_back( ownerCase()->caseUserDescription() );
}

if ( nameConfig()->addAggregationType() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,13 +806,16 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(

options.push_back( caf::PdmOptionItemInfo( "Disabled", RigEclipseResultAddress::noTimeLapseValue() ) );

std::vector<QDateTime> 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<QDateTime> 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<int>( stepIdx ) ) );
options.push_back( caf::PdmOptionItemInfo( displayString, static_cast<int>( stepIdx ) ) );
}
}
}
}
Expand Down

0 comments on commit 2e20320

Please sign in to comment.