Skip to content

Commit

Permalink
Remove null-views from collection, and simplify code.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Apr 8, 2024
1 parent b18cd59 commit 944122c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 59 deletions.
8 changes: 3 additions & 5 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,10 +466,8 @@ void RimEclipseCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField,

computeCachedData();

for ( size_t i = 0; i < reservoirViews().size(); i++ )
for ( RimEclipseView* reservoirView : reservoirViews() )
{
RimEclipseView* reservoirView = reservoirViews()[i];

reservoirView->scheduleReservoirGridGeometryRegen();
reservoirView->scheduleSimWellGeometryRegen();
reservoirView->createDisplayModelAndRedraw();
Expand Down Expand Up @@ -1217,7 +1215,7 @@ std::vector<RimEclipseView*> RimEclipseCase::reservoirViews() const
{
for ( auto view : viewColl->views() )
{
if ( view->eclipseCase() && view->eclipseCase() == this )
if ( view && view->eclipseCase() && view->eclipseCase() == this )
{
views.push_back( view );
}
Expand All @@ -1237,7 +1235,7 @@ std::vector<RimEclipseContourMapView*> RimEclipseCase::contourMapViews() const
{
for ( auto view : viewColl->views() )
{
if ( view->eclipseCase() && view->eclipseCase() == this )
if ( view && view->eclipseCase() && view->eclipseCase() == this )
{
views.push_back( view );
}
Expand Down
26 changes: 10 additions & 16 deletions ApplicationLibCode/ProjectDataModel/RimEclipseStatisticsCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ void RimEclipseStatisticsCase::computeStatistics()
calculationName ) );
}

bool clearGridCalculationMemory = m_dataSourceForStatistics() == DataSourceType::GRID_CALCULATION;
bool clearGridCalculationMemory = m_dataSourceForStatistics() == DataSourceType::GRID_CALCULATION;
RimEclipseStatisticsCaseEvaluator stat( sourceCases, timeStepIndices, statisticsConfig, resultCase, gridCaseGroup, clearGridCalculationMemory );

if ( m_useZeroAsInactiveCellValue )
Expand All @@ -444,11 +444,9 @@ void RimEclipseStatisticsCase::computeStatistics()
//--------------------------------------------------------------------------------------------------
void RimEclipseStatisticsCase::scheduleACTIVEGeometryRegenOnReservoirViews()
{
for ( size_t i = 0; i < reservoirViews().size(); i++ )
for ( RimEclipseView* reservoirView : reservoirViews() )
{
RimEclipseView* reservoirView = reservoirViews()[i];
CVF_ASSERT( reservoirView );

reservoirView->scheduleGeometryRegen( ACTIVE );
}
}
Expand Down Expand Up @@ -755,9 +753,8 @@ void RimEclipseStatisticsCase::fieldChangedByUi( const caf::PdmFieldHandle* chan
caf::ProgressInfo progInfo( reservoirViews().size() + 1, "Updating Well Data for Views" );

// Update views
for ( size_t i = 0; i < reservoirViews().size(); i++ )
for ( RimEclipseView* reservoirView : reservoirViews() )
{
RimEclipseView* reservoirView = reservoirViews()[i];
CVF_ASSERT( reservoirView );

reservoirView->wellCollection()->wells.deleteChildren();
Expand Down Expand Up @@ -962,18 +959,15 @@ bool RimEclipseStatisticsCase::hasComputedStatistics() const
void RimEclipseStatisticsCase::updateConnectedEditorsAndReservoirViews()
{
auto views = reservoirViews();
for ( size_t i = 0; i < views.size(); ++i )
for ( RimEclipseView* view : reservoirViews() )
{
if ( views[i] )
{
// As new result might have been introduced, update all editors connected
views[i]->cellResult()->updateConnectedEditors();
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();

// It is usually not needed to create new display model, but if any derived geometry based on generated data
// (from Octave) a full display model rebuild is required
views[i]->scheduleCreateDisplayModelAndRedraw();
views[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
// It is usually not needed to create new display model, but if any derived geometry based on generated data
// (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}

updateConnectedEditors();
Expand Down
15 changes: 6 additions & 9 deletions ApplicationLibCode/SocketInterface/RiaNNCCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,13 @@ class RiaSetNNCProperty : public RiaSocketCommand

for ( RimEclipseView* view : m_currentReservoir->reservoirViews() )
{
if ( view )
{
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();

// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
}

Expand Down
30 changes: 12 additions & 18 deletions ApplicationLibCode/SocketInterface/RiaPropertyDataCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,16 +660,13 @@ class RiaSetActiveCellProperty : public RiaSocketCommand

for ( RimEclipseView* view : m_currentReservoir->reservoirViews() )
{
if ( view )
{
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();

// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
}

Expand Down Expand Up @@ -1035,16 +1032,13 @@ class RiaSetGridProperty : public RiaSocketCommand

for ( RimEclipseView* view : m_currentReservoir->reservoirViews() )
{
if ( view )
{
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();

// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
}

Expand Down
18 changes: 7 additions & 11 deletions GrpcInterface/RiaGrpcNNCPropertiesService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,15 @@ void RiaNNCInputValuesStateHandler::finish()
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED_NOT_SAVED;
}

auto views = m_eclipseCase->reservoirViews();
for ( size_t i = 0; i < views.size(); ++i )
for ( RimEclipseView* view : m_eclipseCase->reservoirViews() )
{
if ( views[i] )
{
// As new result might have been introduced, update all editors connected
views[i]->cellResult()->updateConnectedEditors();
// As new result might have been introduced, update all editors connected
view->cellResult()->updateConnectedEditors();

// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
views[i]->scheduleCreateDisplayModelAndRedraw();
views[i]->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
// It is usually not needed to create new display model, but if any derived geometry based on
// generated data (from Octave) a full display model rebuild is required
view->scheduleCreateDisplayModelAndRedraw();
view->intersectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews();
}
}
}
Expand Down

0 comments on commit 944122c

Please sign in to comment.