Skip to content

Commit

Permalink
Add view collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben committed Mar 15, 2024
1 parent efe36d6 commit 3cc7ffb
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 28 deletions.
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimResultSelectionUi.h
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimEmCase.h
${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand Down Expand Up @@ -268,6 +269,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimPlotRectAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEmCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolylinePickerInterface.cpp
${CMAKE_CURRENT_LIST_DIR}/RimEclipseViewCollection.cpp
)

if(RESINSIGHT_USE_QT_CHARTS)
Expand Down
28 changes: 8 additions & 20 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "RimEclipseResultAddressCollection.h"
#include "RimEclipseStatisticsCase.h"
#include "RimEclipseView.h"
#include "RimEclipseViewCollection.h"
#include "RimFaultInViewCollection.h"
#include "RimFormationNames.h"
#include "RimGridCollection.h"
Expand Down Expand Up @@ -293,29 +294,16 @@ void RimEclipseCase::initAfterRead()
//--------------------------------------------------------------------------------------------------
RimEclipseView* RimEclipseCase::createAndAddReservoirView()
{
RimEclipseView* rimEclipseView = new RimEclipseView();

rimEclipseView->setEclipseCase( this );

// Set default values
if ( rimEclipseView->currentGridCellResults() )
{
auto defaultResult = rimEclipseView->currentGridCellResults()->defaultResult();
rimEclipseView->cellResult()->setFromEclipseResultAddress( defaultResult );
}

auto prefs = RiaPreferences::current();
rimEclipseView->faultCollection()->setActive( prefs->enableFaultsByDefault() );
RimProject* project = RimProject::current();
if ( !project ) return nullptr;

rimEclipseView->cellEdgeResult()->setResultVariable( "MULT" );
rimEclipseView->cellEdgeResult()->setActive( false );
rimEclipseView->fractureColors()->setDefaultResultName();
RimOilField* oilField = project->activeOilField();
if ( !oilField ) return nullptr;

caf::PdmDocument::updateUiIconStateRecursively( rimEclipseView );
RimEclipseViewCollection* viewCollection = oilField->eclipseViewCollection();
if ( !viewCollection ) return nullptr;

reservoirViews().push_back( rimEclipseView );

return rimEclipseView;
return viewCollection->addView( this );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,9 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
{
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );

auto eclipseCase = firstAncestorOrThisOfTypeAsserted<RimEclipseCase>();
RimEclipseView* eclView = firstAncestorOrThisOfTypeAsserted<RimEclipseView>();

auto eclipseCase = eclView->eclipseCase();
if ( eclipseCase && eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->mainGrid() )
{
RimProject* proj = RimProject::current();
Expand All @@ -792,7 +794,9 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
}
else if ( fieldNeedingOptions == &m_timeLapseBaseTimestep )
{
RimEclipseCase* currentCase = firstAncestorOrThisOfTypeAsserted<RimEclipseCase>();
RimEclipseView* eclView = firstAncestorOrThisOfTypeAsserted<RimEclipseView>();

RimEclipseCase* currentCase = eclView->eclipseCase();

RimEclipseCase* baseCase = currentCase;
if ( m_differenceCase )
Expand Down
6 changes: 2 additions & 4 deletions ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,11 +1262,9 @@ QString RimEclipseView::createAutoName() const

QStringList generatedAutoTags;

RimCase* ownerCase = firstAncestorOrThisOfTypeAsserted<RimCase>();

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

if ( nameConfig()->addProperty() )
Expand Down
101 changes: 101 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#include "RimEclipseViewCollection.h"

#include "RiaLogging.h"
#include "RiaPreferences.h"

#include "RigCaseCellResultsData.h"

#include "Rim3dView.h"
#include "RimCellEdgeColors.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimFaultInViewCollection.h"
#include "RimGridView.h"
#include "RimProject.h"
#include "RimStimPlanColors.h"

CAF_PDM_SOURCE_INIT( RimEclipseViewCollection, "EclipseViewCollection", "EclipseViewCollection" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseViewCollection::RimEclipseViewCollection()
{
CAF_PDM_InitObject( "Views", ":/EclipseViews24x24.png" );

CAF_PDM_InitFieldNoDefault( &m_views, "Views", "Eclipse Views" );

setDeletable( false );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseViewCollection::~RimEclipseViewCollection()
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimEclipseView*> RimEclipseViewCollection::views() const
{
return m_views.childrenByType();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseViewCollection::isEmpty()
{
return !m_views.hasChildren();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseView* RimEclipseViewCollection::addView( RimEclipseCase* eclipseCase )
{
RimEclipseView* view = new RimEclipseView();

view->setEclipseCase( eclipseCase );

// Set default values
if ( view->currentGridCellResults() )
{
auto defaultResult = view->currentGridCellResults()->defaultResult();
view->cellResult()->setFromEclipseResultAddress( defaultResult );
}

auto prefs = RiaPreferences::current();
view->faultCollection()->setActive( prefs->enableFaultsByDefault() );

view->cellEdgeResult()->setResultVariable( "MULT" );
view->cellEdgeResult()->setActive( false );
view->fractureColors()->setDefaultResultName();

caf::PdmDocument::updateUiIconStateRecursively( view );

m_views.push_back( view );
updateConnectedEditors();

return view;
}
46 changes: 46 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimEclipseViewCollection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2024 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "cafPdmField.h"

#include "cafPdmChildArrayField.h"
#include "cafPdmObject.h"

#include <QString>

class RimEclipseView;
class RimEclipseCase;

class RimEclipseViewCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;

public:
RimEclipseViewCollection();
~RimEclipseViewCollection() override;

bool isEmpty();

RimEclipseView* addView( RimEclipseCase* eclipseCase );

std::vector<RimEclipseView*> views() const;

private:
caf::PdmChildArrayField<RimEclipseView*> m_views;
};
4 changes: 4 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimOilField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "RimAnnotationCollection.h"
#include "RimCompletionTemplateCollection.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseViewCollection.h"
#include "RimEnsembleWellLogsCollection.h"
#include "RimFormationNamesCollection.h"
#include "RimFractureTemplateCollection.h"
Expand Down Expand Up @@ -75,6 +76,9 @@ RimOilField::RimOilField()
CAF_PDM_InitFieldNoDefault( &seismicViewCollection, "SeismicViewCollection", "Seismic Views" );
seismicViewCollection = new RimSeismicViewCollection();

CAF_PDM_InitFieldNoDefault( &eclipseViewCollection, "EclipseViewCollection", "Eclipse Views" );
eclipseViewCollection = new RimEclipseViewCollection();

completionTemplateCollection = new RimCompletionTemplateCollection;
analysisModels = new RimEclipseCaseCollection();
wellPathCollection = new RimWellPathCollection();
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimOilField.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class RimSeismicViewCollection;
class RimSurfaceCollection;
class RimEnsembleWellLogsCollection;
class RimPolygonCollection;
class RimEclipseViewCollection;

//==================================================================================================
///
Expand Down Expand Up @@ -73,6 +74,7 @@ class RimOilField : public caf::PdmObject
caf::PdmChildField<RimSurfaceCollection*> surfaceCollection;
caf::PdmChildField<RimSeismicDataCollection*> seismicDataCollection;
caf::PdmChildField<RimSeismicViewCollection*> seismicViewCollection;
caf::PdmChildField<RimEclipseViewCollection*> eclipseViewCollection;
caf::PdmChildField<RimEnsembleWellLogsCollection*> ensembleWellLogsCollection;
caf::PdmChildField<RimPolygonCollection*> polygonCollection;

Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "RimDialogData.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseViewCollection.h"
#include "RimEnsembleWellLogsCollection.h"
#include "RimFileWellPath.h"
#include "RimFlowPlotCollection.h"
Expand Down Expand Up @@ -1522,6 +1523,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
if ( oilField )
{
if ( oilField->analysisModels() ) uiTreeOrdering.add( oilField->analysisModels() );
if ( oilField->eclipseViewCollection() ) uiTreeOrdering.add( oilField->eclipseViewCollection() );
if ( oilField->geoMechModels() ) uiTreeOrdering.add( oilField->geoMechModels() );
if ( oilField->wellPathCollection() ) uiTreeOrdering.add( oilField->wellPathCollection() );
if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,7 @@ void RimSimWellInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& u
//--------------------------------------------------------------------------------------------------
void RimSimWellInViewCollection::assignDefaultWellColors()
{
auto ownerCase = firstAncestorOrThisOfTypeAsserted<RimEclipseCase>();

auto ownerCase = m_reservoirView->eclipseCase();
for ( size_t wIdx = 0; wIdx < wells.size(); ++wIdx )
{
RimSimWellInView* well = wells[wIdx];
Expand Down

0 comments on commit 3cc7ffb

Please sign in to comment.