Refactor: improve api for views and oil fields.

This commit is contained in:
Kristian Bendiksen 2024-04-03 14:53:20 +02:00
parent ef637e3053
commit be3d06c549
21 changed files with 61 additions and 93 deletions

View File

@ -690,9 +690,7 @@ bool RiaApplication::loadProject( const QString& projectFileName, ProjectLoadAct
}
{
std::vector<Rim3dView*> views;
m_project->allViews( views );
std::vector<Rim3dView*> views = m_project->allViews();
for ( auto view : views )
{
if ( auto eclipseView = dynamic_cast<RimEclipseView*>( view ) )

View File

@ -50,9 +50,7 @@ void RicNewValveTemplateFeature::selectValveTemplateAndUpdate( RimValveTemplate*
RimProject* project = RimProject::current();
std::vector<Rim3dView*> views;
project->allVisibleViews( views );
std::vector<Rim3dView*> views = project->allVisibleViews();
for ( Rim3dView* view : views )
{
if ( dynamic_cast<RimEclipseView*>( view ) )

View File

@ -74,9 +74,7 @@ QList<caf::PdmOptionItemInfo> RicHoloLensExportToFolderUi::calculateValueOptions
if ( fieldNeedingOptions == &m_viewForExport )
{
std::vector<RimGridView*> visibleViews;
RimProject::current()->allVisibleGridViews( visibleViews );
std::vector<RimGridView*> visibleViews = RimProject::current()->allVisibleGridViews();
for ( RimGridView* v : visibleViews )
{
RiaOptionItemFactory::appendOptionItemFromViewNameAndCaseName( v, &options );

View File

@ -277,10 +277,8 @@ caf::PdmScriptResponse RicExportContourMapToTextFeature::execute()
RimProject* proj = app->project();
CAF_ASSERT( proj );
std::vector<Rim3dView*> allViews;
proj->allViews( allViews );
Rim3dView* myView = nullptr;
std::vector<Rim3dView*> allViews = proj->allViews();
Rim3dView* myView = nullptr;
for ( auto view : allViews )
{
if ( m_viewId == view->id() )

View File

@ -102,8 +102,7 @@ void RicWellMeasurementImportTools::importWellMeasurementsFromFiles( const QStri
auto proj = RimProject::current();
if ( proj )
{
std::vector<Rim3dView*> views;
proj->allViews( views );
std::vector<Rim3dView*> views = proj->allViews();
for ( auto& view : views )
{
RimGridView* gridView = dynamic_cast<RimGridView*>( view );

View File

@ -85,8 +85,7 @@ RimSeismicView* RicNewSeismicViewFeature::createInitialViewIfNeeded( RimSeismicD
{
auto proj = RimProject::current();
std::vector<Rim3dView*> views;
proj->allViews( views );
std::vector<Rim3dView*> views = proj->allViews();
if ( !views.empty() ) return nullptr;
return createSeismicView( seisData );

View File

@ -44,15 +44,13 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled() const
RimProject* proj = RimProject::current();
if ( !proj ) return false;
std::vector<Rim3dView*> visibleViews;
proj->allVisibleViews( visibleViews );
std::vector<Rim3dView*> linkedviews;
if ( proj->viewLinkerCollection() && proj->viewLinkerCollection()->viewLinker() )
{
linkedviews = proj->viewLinkerCollection()->viewLinker()->allViews();
}
std::vector<Rim3dView*> visibleViews = proj->allVisibleViews();
if ( visibleViews.size() >= 2 && ( linkedviews.size() < visibleViews.size() ) )
{
return !findLinkableVisibleViews().empty();
@ -88,9 +86,7 @@ std::vector<Rim3dView*> RicLinkVisibleViewsFeature::findLinkableVisibleViews()
std::vector<Rim3dView*> views;
std::vector<Rim3dView*> candidates;
proj->allVisibleViews( candidates );
std::vector<Rim3dView*> candidates = proj->allVisibleViews();
for ( auto gridView : candidates )
{
if ( gridView && !gridView->assosiatedViewLinker() ) views.push_back( gridView );

View File

@ -133,8 +133,7 @@ void RicNewPolylineTargetFeature::onActionTriggered( bool isChecked )
}
else
{
std::vector<RimGridView*> gridViews;
RimProject::current()->allVisibleGridViews( gridViews );
std::vector<RimGridView*> gridViews = RimProject::current()->allVisibleGridViews();
if ( !gridViews.empty() )
{
auto minPos = gridViews.front()->ownerCase()->allCellsBoundingBox().min();

View File

@ -132,9 +132,7 @@ std::vector<Rim3dView*> RimAnnotationCollectionBase::viewsContainingAnnotations(
RimProject* project = RimProject::current();
if ( !project ) return {};
std::vector<Rim3dView*> views;
project->allViews( views );
return views;
return project->allViews();
}
//--------------------------------------------------------------------------------------------------

View File

@ -316,8 +316,7 @@ void RimFractureTemplateCollection::onChildDeleted( caf::PdmChildArrayFieldHandl
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
std::vector<Rim3dView*> views;
proj->allVisibleViews( views );
std::vector<Rim3dView*> views = proj->allVisibleViews();
for ( Rim3dView* visibleView : views )
{
if ( dynamic_cast<RimEclipseView*>( visibleView ) )

View File

@ -189,8 +189,7 @@ void RimPolygonCollection::updateViewTreeItems()
RimProject* proj = RimProject::current();
// Make sure the tree items are synchronized
std::vector<Rim3dView*> views;
proj->allViews( views );
std::vector<Rim3dView*> views = proj->allViews();
for ( auto view : views )
{
view->updateViewTreeItems( RiaDefines::ItemIn3dView::POLYGON );

View File

@ -197,9 +197,7 @@ Rim3dView::~Rim3dView()
if ( auto proj = RimProject::current() )
{
std::vector<Rim3dView*> allViews;
proj->allViews( allViews );
std::vector<Rim3dView*> allViews = proj->allViews();
for ( auto v : allViews )
{
if ( v->activeComparisonView() == this )
@ -591,8 +589,7 @@ std::vector<Rim3dView*> Rim3dView::validComparisonViews() const
{
auto isIntersectionView = []( const Rim3dView* view ) { return dynamic_cast<const Rim2dIntersectionView*>( view ) != nullptr; };
std::vector<Rim3dView*> views;
RimProject::current()->allViews( views );
std::vector<Rim3dView*> views = RimProject::current()->allViews();
std::vector<Rim3dView*> validComparisonViews;
for ( auto view : views )

View File

@ -344,9 +344,6 @@ QList<caf::PdmOptionItemInfo> RimGridCalculation::calculateValueOptions( const c
{
options.push_back( caf::PdmOptionItemInfo( "Disabled", nullptr ) );
std::vector<Rim3dView*> views;
RimProject::current()->allViews( views );
RimEclipseCase* firstEclipseCase = nullptr;
if ( !inputCases().empty() )
{
@ -361,6 +358,7 @@ QList<caf::PdmOptionItemInfo> RimGridCalculation::calculateValueOptions( const c
if ( firstEclipseCase )
{
std::vector<Rim3dView*> views = RimProject::current()->allViews();
for ( auto* view : views )
{
auto eclipseView = dynamic_cast<RimEclipseView*>( view );

View File

@ -737,16 +737,17 @@ RimSummaryCaseMainCollection* RimProject::firstSummaryCaseMainCollection() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::allNotLinkedViews( std::vector<Rim3dView*>& views )
std::vector<Rim3dView*> RimProject::allNotLinkedViews() const
{
std::vector<RimCase*> cases = allGridCases();
std::vector<Rim3dView*> alreadyLinkedViews;
if ( viewLinkerCollection->viewLinker() )
{
alreadyLinkedViews = viewLinkerCollection->viewLinker()->allViews();
}
std::vector<Rim3dView*> views;
std::vector<RimCase*> cases = allGridCases();
for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ )
{
RimCase* rimCase = cases[caseIdx];
@ -773,15 +774,18 @@ void RimProject::allNotLinkedViews( std::vector<Rim3dView*>& views )
}
}
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::allViews( std::vector<Rim3dView*>& views ) const
std::vector<Rim3dView*> RimProject::allViews() const
{
std::vector<RimCase*> cases = allGridCases();
std::vector<Rim3dView*> views;
std::vector<RimCase*> cases = allGridCases();
for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ )
{
RimCase* rimCase = cases[caseIdx];
@ -808,15 +812,18 @@ void RimProject::allViews( std::vector<Rim3dView*>& views ) const
views.push_back( seisview );
}
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::allVisibleViews( std::vector<Rim3dView*>& views ) const
std::vector<Rim3dView*> RimProject::allVisibleViews() const
{
std::vector<RimCase*> cases = allGridCases();
std::vector<Rim3dView*> views;
std::vector<RimCase*> cases = allGridCases();
for ( size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++ )
{
RimCase* rimCase = cases[caseIdx];
@ -831,20 +838,24 @@ void RimProject::allVisibleViews( std::vector<Rim3dView*>& views ) const
}
}
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::allVisibleGridViews( std::vector<RimGridView*>& views ) const
std::vector<RimGridView*> RimProject::allVisibleGridViews() const
{
std::vector<Rim3dView*> visibleViews;
allVisibleViews( visibleViews );
std::vector<RimGridView*> views;
std::vector<Rim3dView*> visibleViews = allVisibleViews();
for ( Rim3dView* view : visibleViews )
{
RimGridView* gridView = dynamic_cast<RimGridView*>( view );
if ( gridView ) views.push_back( gridView );
}
return views;
}
//--------------------------------------------------------------------------------------------------
@ -878,13 +889,9 @@ void RimProject::scheduleCreateDisplayModelAndRedrawAllViews()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::allOilFields( std::vector<RimOilField*>& allOilFields ) const
std::vector<RimOilField*> RimProject::allOilFields() const
{
allOilFields.clear();
for ( const auto& oilField : oilFields )
{
allOilFields.push_back( oilField );
}
return oilFields.childrenByType();
}
//--------------------------------------------------------------------------------------------------
@ -1176,8 +1183,7 @@ std::vector<RimTextAnnotation*> RimProject::textAnnotations() const
}
// 'Local' text annotations
std::vector<RimGridView*> visibleViews;
allVisibleGridViews( visibleViews );
std::vector<RimGridView*> visibleViews = allVisibleGridViews();
for ( const auto& view : visibleViews )
{
std::vector<RimAnnotationInViewCollection*> annotationColls = view->descendantsIncludingThisOfType<RimAnnotationInViewCollection>();
@ -1263,9 +1269,7 @@ std::vector<RimGeoMechCase*> RimProject::geoMechCases() const
std::vector<RimFractureTemplateCollection*> RimProject::allFractureTemplateCollections() const
{
std::vector<RimFractureTemplateCollection*> templColls;
std::vector<RimOilField*> rimOilFields;
allOilFields( rimOilFields );
std::vector<RimOilField*> rimOilFields = allOilFields();
for ( RimOilField* oilField : rimOilFields )
{
templColls.push_back( oilField->fractureDefinitionCollection() );
@ -1295,9 +1299,7 @@ std::vector<RimFractureTemplate*> RimProject::allFractureTemplates() const
std::vector<RimValveTemplateCollection*> RimProject::allValveTemplateCollections() const
{
std::vector<RimValveTemplateCollection*> templColls;
std::vector<RimOilField*> rimOilFields;
allOilFields( rimOilFields );
std::vector<RimOilField*> rimOilFields = allOilFields();
for ( RimOilField* oilField : rimOilFields )
{
templColls.push_back( oilField->valveTemplateCollection() );

View File

@ -137,18 +137,18 @@ public:
std::vector<RimSummaryCaseCollection*> summaryGroups() const;
RimSummaryCaseMainCollection* firstSummaryCaseMainCollection() const;
void allViews( std::vector<Rim3dView*>& views ) const;
void allVisibleViews( std::vector<Rim3dView*>& views ) const;
void allVisibleGridViews( std::vector<RimGridView*>& views ) const;
void allNotLinkedViews( std::vector<Rim3dView*>& views );
[[nodiscard]] std::vector<Rim3dView*> allViews() const;
[[nodiscard]] std::vector<Rim3dView*> allVisibleViews() const;
[[nodiscard]] std::vector<RimGridView*> allVisibleGridViews() const;
[[nodiscard]] std::vector<Rim3dView*> allNotLinkedViews() const;
void scheduleCreateDisplayModelAndRedrawAllViews();
void computeUtmAreaOfInterest();
void allOilFields( std::vector<RimOilField*>& allOilFields ) const;
RimOilField* activeOilField();
const RimOilField* activeOilField() const;
[[nodiscard]] std::vector<RimOilField*> allOilFields() const;
RimOilField* activeOilField();
const RimOilField* activeOilField() const;
void actionsBasedOnSelection( QMenu& contextMenu );

View File

@ -108,9 +108,8 @@ QList<caf::PdmOptionItemInfo> RimViewController::calculateValueOptions( const ca
if ( fieldNeedingOptions == &m_managedView )
{
RimProject* proj = RimProject::current();
std::vector<Rim3dView*> views;
proj->allNotLinkedViews( views );
RimProject* proj = RimProject::current();
std::vector<Rim3dView*> views = proj->allNotLinkedViews();
// Add currently linked view to list
if ( managedView() )

View File

@ -109,10 +109,8 @@ void RimSeismicDataCollection::onChildDeleted( caf::PdmChildArrayFieldHandle* ch
//--------------------------------------------------------------------------------------------------
void RimSeismicDataCollection::updateViews()
{
RimProject* proj = RimProject::current();
std::vector<RimGridView*> views;
proj->allVisibleGridViews( views );
RimProject* proj = RimProject::current();
std::vector<RimGridView*> views = proj->allVisibleGridViews();
for ( auto view : views )
{
view->scheduleCreateDisplayModelAndRedraw();
@ -127,8 +125,7 @@ void RimSeismicDataCollection::updateTreeForAllViews()
RimProject* proj = RimProject::current();
if ( proj != nullptr )
{
std::vector<RimGridView*> views;
proj->allVisibleGridViews( views );
std::vector<RimGridView*> views = proj->allVisibleGridViews();
for ( auto view : views )
{
view->updateAllRequiredEditors();

View File

@ -132,8 +132,7 @@ void RimStimPlanModelTemplateCollection::onChildDeleted( caf::PdmChildArrayField
proj->scheduleCreateDisplayModelAndRedrawAllViews();
}
std::vector<Rim3dView*> views;
proj->allVisibleViews( views );
std::vector<Rim3dView*> views = proj->allVisibleViews();
for ( Rim3dView* visibleView : views )
{
if ( dynamic_cast<RimEclipseView*>( visibleView ) )

View File

@ -298,8 +298,7 @@ void RimSurfaceCollection::updateViews( const std::vector<RimSurface*>& surfsToR
RimProject* proj = RimProject::current();
// Make sure the tree items are synchronized
std::vector<Rim3dView*> views;
proj->allViews( views );
std::vector<Rim3dView*> views = proj->allViews();
for ( auto view : views )
{
view->updateViewTreeItems( RiaDefines::ItemIn3dView::SURFACE );
@ -347,9 +346,8 @@ void RimSurfaceCollection::updateViews( const std::vector<RimSurface*>& surfsToR
//--------------------------------------------------------------------------------------------------
void RimSurfaceCollection::updateViews()
{
RimProject* proj = RimProject::current();
std::vector<Rim3dView*> views;
proj->allViews( views );
RimProject* proj = RimProject::current();
std::vector<Rim3dView*> views = proj->allViews();
// Make sure the tree items are synchronized

View File

@ -325,8 +325,7 @@ void RiuSelectionChangedHandler::scheduleUpdateForAllVisibleViews() const
RimProject* proj = RimProject::current();
if ( proj )
{
std::vector<Rim3dView*> visibleViews;
proj->allVisibleViews( visibleViews );
std::vector<Rim3dView*> visibleViews = proj->allVisibleViews();
for ( size_t i = 0; i < visibleViews.size(); i++ )
{

View File

@ -552,10 +552,8 @@ QList<caf::PdmOptionItemInfo>
{
QList<caf::PdmOptionItemInfo> options;
RimProject* proj = RimProject::current();
std::vector<RimOilField*> oilFields;
proj->allOilFields( oilFields );
RimProject* proj = RimProject::current();
std::vector<RimOilField*> oilFields = proj->allOilFields();
for ( RimOilField* oilField : oilFields )
{
RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection();