Skip to content

Commit

Permalink
WIP: move contour map collection from eclipse case child to standalon…
Browse files Browse the repository at this point in the history
…e collection.
  • Loading branch information
kriben committed Mar 22, 2024
1 parent 02806e0 commit 399d0fd
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 47 deletions.
16 changes: 13 additions & 3 deletions ApplicationLibCode/Commands/RicNewContourMapViewFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked )
{
RimEclipseView* reservoirView = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimEclipseCase>();
RimEclipseCase* eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
RimEclipseContourMapView* eclipseContourMap = nullptr;

RimGeoMechView* geoMechView = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechView>();
Expand All @@ -97,11 +97,19 @@ void RicNewContourMapViewFeature::onActionTriggered( bool isChecked )
// Find case to insert into
if ( existingEclipseContourMap )
{
eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap );
eclipseCase = existingEclipseContourMap->eclipseCase();
if ( eclipseCase )
{
eclipseContourMap = createEclipseContourMapFromExistingContourMap( eclipseCase, existingEclipseContourMap );
}
}
else if ( reservoirView )
{
eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView );
eclipseCase = reservoirView->eclipseCase();
if ( eclipseCase )
{
eclipseContourMap = createEclipseContourMapFrom3dView( eclipseCase, reservoirView );
}
}
else if ( eclipseCase )
{
Expand Down Expand Up @@ -268,6 +276,8 @@ RimEclipseContourMapView* RicNewContourMapViewFeature::createEclipseContourMapFr

contourMap->initAfterReadRecursively();

eclipseCase->contourMapCollection()->updateConnectedEditors();

return contourMap;
}

Expand Down
56 changes: 40 additions & 16 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ RimEclipseCase::RimEclipseCase()
// https://github.com/OPM/ResInsight/issues/7308
m_filesContainingFaults.xmlCapability()->disableIO();

CAF_PDM_InitFieldNoDefault( &m_contourMapCollection, "ContourMaps", "2d Contour Maps" );
m_contourMapCollection = new RimEclipseContourMapViewCollection;
CAF_PDM_InitFieldNoDefault( &m_contourMapCollection_OBSOLETE, "ContourMaps", "2d Contour Maps" );
m_contourMapCollection_OBSOLETE = new RimEclipseContourMapViewCollection;

CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "" );
m_inputPropertyCollection = new RimEclipseInputPropertyCollection;
Expand Down Expand Up @@ -290,11 +290,14 @@ void RimEclipseCase::initAfterRead()
}

m_reservoirViews_OBSOLETE.clearWithoutDelete();
}

for ( RimEclipseContourMapView* contourMap : m_contourMapCollection->views() )
{
contourMap->setEclipseCase( this );
// Move contour maps
for ( RimEclipseContourMapView* contourMap : m_contourMapCollection_OBSOLETE->views() )
{
contourMap->setEclipseCase( this );

// TODO: move to root collection
}
}
}

Expand Down Expand Up @@ -547,11 +550,6 @@ void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
{
uiTreeOrdering.add( &m_2dIntersectionViewCollection );
}

if ( !m_contourMapCollection->views().empty() )
{
uiTreeOrdering.add( &m_contourMapCollection );
}
}
else if ( uiConfigName == "MainWindow.DataSources" )
{
Expand Down Expand Up @@ -652,9 +650,15 @@ RimCaseCollection* RimEclipseCase::parentCaseCollection()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection()
RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection() const
{
return m_contourMapCollection;
RimProject* project = RimProject::current();
if ( !project ) return nullptr;

RimOilField* oilField = project->activeOilField();
if ( !oilField ) return nullptr;

return oilField->eclipseContourMapCollection();
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1069,7 +1073,7 @@ std::vector<Rim3dView*> RimEclipseCase::allSpecialViews() const
views.push_back( view );
}

for ( RimEclipseContourMapView* view : m_contourMapCollection->views() )
for ( RimEclipseContourMapView* view : contourMapViews() )
{
views.push_back( view );
}
Expand Down Expand Up @@ -1194,8 +1198,7 @@ RimEclipseViewCollection* RimEclipseCase::viewCollection() const
RimOilField* oilField = project->activeOilField();
if ( !oilField ) return nullptr;

RimEclipseViewCollection* viewCollection = oilField->eclipseViewCollection();
return viewCollection;
return oilField->eclipseViewCollection();
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -1218,3 +1221,24 @@ std::vector<RimEclipseView*> RimEclipseCase::reservoirViews() const

return views;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimEclipseContourMapView*> RimEclipseCase::contourMapViews() const
{
std::vector<RimEclipseContourMapView*> views;
RimEclipseContourMapViewCollection* viewColl = contourMapCollection();
if ( viewColl )
{
for ( auto view : viewColl->views() )
{
if ( view->eclipseCase() && view->eclipseCase() == this )
{
views.push_back( view );
}
}
}

return views;
}
26 changes: 14 additions & 12 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class RimEclipseCase : public RimCase
virtual QString locationOnDisc() const { return QString(); }

RimCaseCollection* parentCaseCollection();
RimEclipseContourMapViewCollection* contourMapCollection();
RimEclipseContourMapViewCollection* contourMapCollection() const;
RimEclipseInputPropertyCollection* inputPropertyCollection() const;

QStringList timeStepStrings() const override;
Expand Down Expand Up @@ -137,15 +137,18 @@ class RimEclipseCase : public RimCase

// Internal methods
protected:
void computeCachedData();
void setReservoirData( RigEclipseCaseData* eclipseCase );
std::vector<QString> additionalFiles() const;
RimEclipseViewCollection* viewCollection() const;
void computeCachedData();
void setReservoirData( RigEclipseCaseData* eclipseCase );
std::vector<QString> additionalFiles() const;
RimEclipseViewCollection* viewCollection() const;
RimEclipseContourMapViewCollection* contourMapViewCollection() const;

private:
void createTimeStepFormatString();
std::vector<Rim3dView*> allSpecialViews() const override;
void buildResultChildNodes();
void createTimeStepFormatString();
std::vector<Rim3dView*> allSpecialViews() const override;
std::vector<RimEclipseContourMapView*> contourMapViews() const;

void buildResultChildNodes();

protected:
caf::PdmField<bool> m_flipXAxis;
Expand All @@ -157,8 +160,6 @@ class RimEclipseCase : public RimCase
private:
caf::PdmField<bool> m_releaseResultMemory;

caf::PdmChildField<RimEclipseContourMapViewCollection*> m_contourMapCollection;

cvf::ref<RigEclipseCaseData> m_rigEclipseCase;
QString m_timeStepFormatString;
std::map<QString, cvf::Color3f> m_wellToColorMap;
Expand All @@ -170,6 +171,7 @@ class RimEclipseCase : public RimCase

caf::PdmField<std::vector<caf::FilePath>> m_filesContainingFaults;

// Fields:
caf::PdmChildArrayField<RimEclipseView*> m_reservoirViews_OBSOLETE;
// Obsolete fields:
caf::PdmChildArrayField<RimEclipseView*> m_reservoirViews_OBSOLETE;
caf::PdmChildField<RimEclipseContourMapViewCollection*> m_contourMapCollection_OBSOLETE;
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "RigHexIntersectionTools.h"
#include "RigMainGrid.h"

#include "Rim3dView.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseContourMapView.h"
Expand Down Expand Up @@ -385,7 +386,8 @@ std::vector<double> RimEclipseContourMapProjection::retrieveParameterWeights()
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimEclipseContourMapProjection::eclipseCase() const
{
return firstAncestorOrThisOfType<RimEclipseCase>();
if ( auto view = firstAncestorOrThisOfType<Rim3dView>() ) return dynamic_cast<RimEclipseCase*>( view->ownerCase() );
return nullptr;
}

//--------------------------------------------------------------------------------------------------
Expand Down
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 "RimEclipseContourMapViewCollection.h"
#include "RimEclipseViewCollection.h"
#include "RimEnsembleWellLogsCollection.h"
#include "RimFormationNamesCollection.h"
Expand Down Expand Up @@ -79,6 +80,9 @@ RimOilField::RimOilField()
CAF_PDM_InitFieldNoDefault( &eclipseViewCollection, "EclipseViewCollection", "Eclipse Views", ":/3DView16x16.png" );
eclipseViewCollection = new RimEclipseViewCollection();

CAF_PDM_InitFieldNoDefault( &eclipseContourMapCollection, "ContourMaps", "2d Contour Maps" );
eclipseContourMapCollection = new RimEclipseContourMapViewCollection;

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

//==================================================================================================
///
Expand All @@ -62,21 +63,22 @@ class RimOilField : public caf::PdmObject
RimValveTemplateCollection* valveTemplateCollection();
const RimValveTemplateCollection* valveTemplateCollection() const;

caf::PdmChildField<RimEclipseCaseCollection*> analysisModels;
caf::PdmChildField<RimGeoMechModels*> geoMechModels;
caf::PdmChildField<RimWellPathCollection*> wellPathCollection;
caf::PdmChildField<RimCompletionTemplateCollection*> completionTemplateCollection;
caf::PdmChildField<RimSummaryCaseMainCollection*> summaryCaseMainCollection;
caf::PdmChildField<RimObservedDataCollection*> observedDataCollection;
caf::PdmChildField<RimFormationNamesCollection*> formationNamesCollection;
caf::PdmChildField<RimAnnotationCollection*> annotationCollection;
caf::PdmChildField<RimMeasurement*> measurement;
caf::PdmChildField<RimSurfaceCollection*> surfaceCollection;
caf::PdmChildField<RimSeismicDataCollection*> seismicDataCollection;
caf::PdmChildField<RimSeismicViewCollection*> seismicViewCollection;
caf::PdmChildField<RimEclipseViewCollection*> eclipseViewCollection;
caf::PdmChildField<RimEnsembleWellLogsCollection*> ensembleWellLogsCollection;
caf::PdmChildField<RimPolygonCollection*> polygonCollection;
caf::PdmChildField<RimEclipseCaseCollection*> analysisModels;
caf::PdmChildField<RimGeoMechModels*> geoMechModels;
caf::PdmChildField<RimWellPathCollection*> wellPathCollection;
caf::PdmChildField<RimCompletionTemplateCollection*> completionTemplateCollection;
caf::PdmChildField<RimSummaryCaseMainCollection*> summaryCaseMainCollection;
caf::PdmChildField<RimObservedDataCollection*> observedDataCollection;
caf::PdmChildField<RimFormationNamesCollection*> formationNamesCollection;
caf::PdmChildField<RimAnnotationCollection*> annotationCollection;
caf::PdmChildField<RimMeasurement*> measurement;
caf::PdmChildField<RimSurfaceCollection*> surfaceCollection;
caf::PdmChildField<RimSeismicDataCollection*> seismicDataCollection;
caf::PdmChildField<RimSeismicViewCollection*> seismicViewCollection;
caf::PdmChildField<RimEclipseViewCollection*> eclipseViewCollection;
caf::PdmChildField<RimEnsembleWellLogsCollection*> ensembleWellLogsCollection;
caf::PdmChildField<RimPolygonCollection*> polygonCollection;
caf::PdmChildField<RimEclipseContourMapViewCollection*> eclipseContourMapCollection;

protected:
void initAfterRead() override;
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 "RimEclipseContourMapViewCollection.h"
#include "RimEclipseViewCollection.h"
#include "RimEnsembleWellLogsCollection.h"
#include "RimFileWellPath.h"
Expand Down Expand Up @@ -1537,6 +1538,7 @@ void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, Q
if ( oilField->formationNamesCollection() ) uiTreeOrdering.add( oilField->formationNamesCollection() );
if ( oilField->completionTemplateCollection() ) uiTreeOrdering.add( oilField->completionTemplateCollection() );
if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() );
if ( oilField->eclipseContourMapCollection() ) uiTreeOrdering.add( oilField->eclipseContourMapCollection() );
}

uiTreeOrdering.add( colorLegendCollection() );
Expand Down

0 comments on commit 399d0fd

Please sign in to comment.