Files
ResInsight/ApplicationLibCode/ProjectDataModel/RimProject.cpp
T

1566 lines
57 KiB
C++
Raw Normal View History

2012-05-18 09:45:23 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 15:04:57 +02:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
2012-05-18 09:45:23 +02:00
// 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.
//
2012-05-18 09:45:23 +02:00
// 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>
2012-05-18 09:45:23 +02:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimProject.h"
#include "RiaCompletionTypeCalculationScheduler.h"
#include "RiaFieldHandleTools.h"
#include "RiaFilePathTools.h"
#include "RiaGuiApplication.h"
#include "RiaPreferences.h"
#include "RiaPreferencesSystem.h"
#include "RiaProjectBackupTools.h"
2024-06-05 10:59:04 +02:00
#include "RiaProjectFileTools.h"
2013-03-22 16:12:00 +01:00
#include "RiaVersionInfo.h"
2017-01-10 09:51:39 +01:00
#include "RigEclipseCaseData.h"
2024-07-05 09:06:16 +02:00
#include "Cloud/RimCloudDataSourceCollection.h"
2025-02-03 14:27:45 +01:00
#include "ContourMap/RimEclipseContourMapViewCollection.h"
#include "EnsembleFileSet/RimEnsembleFileSetCollection.h"
#include "Formations/RimFormationNamesCollection.h"
#include "Formations/RimWellFormationsCollection.h"
2025-06-11 15:43:53 +02:00
#include "Jobs/RimJobCollection.h"
#include "PlotTemplates/RimPlotTemplateFolderItem.h"
2024-02-12 10:19:52 +01:00
#include "Polygons/RimPolygonCollection.h"
2024-10-18 14:25:04 +02:00
#include "QuickAccess/RimQuickAccessCollection.h"
#include "RimAdvancedSnapshotExportDefinition.h"
#include "RimAnalysisPlotCollection.h"
2018-11-23 13:33:59 +01:00
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
#include "RimCase.h"
2014-07-24 10:11:43 +02:00
#include "RimCaseCollection.h"
#include "RimColorLegendCollection.h"
#include "RimCompletionTemplateCollection.h"
#include "RimContextCommandBuilder.h"
2020-04-17 09:31:42 +02:00
#include "RimCorrelationPlotCollection.h"
2017-06-30 16:14:15 +02:00
#include "RimDialogData.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCaseEnsemble.h"
2025-01-16 16:53:05 +01:00
#include "RimEclipseView.h"
2021-05-26 12:10:45 +02:00
#include "RimEnsembleWellLogsCollection.h"
#include "RimFlowPlotCollection.h"
#include "RimFractureTemplate.h"
#include "RimFractureTemplateCollection.h"
#include "RimGeneric3dView.h"
#include "RimGenericViewCollection.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechModels.h"
#include "RimGridCalculationCollection.h"
#include "RimGridCrossPlotCollection.h"
#include "RimGridView.h"
2014-07-24 10:11:43 +02:00
#include "RimIdenticalGridCaseGroup.h"
#include "RimMainPlotCollection.h"
#include "RimMeasurement.h"
2019-11-13 12:22:50 +01:00
#include "RimMultiPlotCollection.h"
#include "RimObservedDataCollection.h"
#include "RimObservedSummaryData.h"
2014-07-24 10:11:43 +02:00
#include "RimOilField.h"
2019-11-14 20:48:11 +01:00
#include "RimPlotWindow.h"
2018-01-08 10:37:57 +01:00
#include "RimPltPlotCollection.h"
#include "RimPolylinesFromFileAnnotation.h"
2026-02-13 08:28:34 +01:00
#include "RimReservoirGridEnsemble.h"
2018-01-08 10:37:57 +01:00
#include "RimRftPlotCollection.h"
#include "RimSaturationPressurePlotCollection.h"
2014-07-24 10:11:43 +02:00
#include "RimScriptCollection.h"
2023-03-24 15:36:10 +01:00
#include "RimSeismicDataCollection.h"
2023-08-07 16:35:59 +02:00
#include "RimSeismicView.h"
#include "RimSeismicViewCollection.h"
#include "RimStimPlanModelPlotCollection.h"
#include "RimSummaryCalculationCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimSummaryEnsemble.h"
2022-03-04 10:52:17 +01:00
#include "RimSummaryMultiPlotCollection.h"
2023-03-23 14:10:30 +01:00
#include "RimSummaryTableCollection.h"
#include "RimSurfaceCollection.h"
#include "RimTools.h"
#include "RimValveTemplate.h"
#include "RimValveTemplateCollection.h"
#include "RimViewLinker.h"
#include "RimViewLinkerCollection.h"
#include "RimWellLogPlotCollection.h"
2018-01-08 10:37:57 +01:00
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellTargetMapping.h"
#include "Tools/RimAutomationSettings.h"
#include "VerticalFlowPerformance/RimVfpDataCollection.h"
#include "VerticalFlowPerformance/RimVfpPlotCollection.h"
2026-05-30 10:16:07 +02:00
#include "Workflow/RimWorkflowCollection.h"
#include "RiuPlotMainWindow.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiTreeOrdering.h"
2014-07-24 10:11:43 +02:00
#include <QDir>
#include <QFile>
2022-12-08 07:08:22 +01:00
#include <algorithm>
CAF_PDM_SOURCE_INIT( RimProject, "ResInsightProject" );
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2023-04-14 14:07:45 +02:00
RimProject::RimProject()
2012-05-18 09:45:23 +02:00
{
2020-03-03 10:43:07 +01:00
CAF_PDM_InitScriptableObjectWithNameAndComment( "Project", "", "", "", "Project", "The ResInsight Project" );
CAF_PDM_InitField( &m_projectFileVersionString, "ProjectFileVersionString", QString( STRPRODUCTVER ), "" );
m_projectFileVersionString.uiCapability()->setUiHidden( true );
2012-05-18 09:45:23 +02:00
CAF_PDM_InitFieldNoDefault( &m_globalPathList, "ReferencedExternalFiles", "" );
m_globalPathList.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &oilFields, "OilFields", "Oil Fields" );
CAF_PDM_InitFieldNoDefault( &colorLegendCollection, "ColorLegendCollection", "Color Legend Collection" );
colorLegendCollection = new RimColorLegendCollection();
2020-05-13 14:28:06 +02:00
colorLegendCollection->createStandardColorLegends();
CAF_PDM_InitFieldNoDefault( &scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png" );
scriptCollection.xmlCapability()->disableIO();
2026-05-30 10:16:07 +02:00
CAF_PDM_InitFieldNoDefault( &workflowCollection, "WorkflowCollection", "Workflows", ":/Folder.png" );
workflowCollection.xmlCapability()->disableIO();
2025-06-11 15:43:53 +02:00
CAF_PDM_InitFieldNoDefault( &m_jobCollection, "JobCollection", "Jobs", ":/gear.png" );
2022-08-19 05:30:25 -07:00
CAF_PDM_InitFieldNoDefault( &m_mainPlotCollection, "MainPlotCollection", "Plots" );
2024-10-18 14:25:04 +02:00
CAF_PDM_InitFieldNoDefault( &m_pinnedFieldCollection, "PinnedFieldCollection", "PinnedFieldCollection" );
CAF_PDM_InitFieldNoDefault( &viewLinkerCollection, "LinkedViews", "Linked Views", ":/LinkView.svg" );
viewLinkerCollection = new RimViewLinkerCollection;
CAF_PDM_InitFieldNoDefault( &calculationCollection, "CalculationCollection", "Calculation Collection" );
calculationCollection = new RimSummaryCalculationCollection;
CAF_PDM_InitFieldNoDefault( &gridCalculationCollection, "GridCalculationCollection", "Grid Calculation Collection" );
gridCalculationCollection = new RimGridCalculationCollection;
CAF_PDM_InitFieldNoDefault( &multiSnapshotDefinitions, "MultiSnapshotDefinitions", "Multi Snapshot Definitions" );
2022-01-28 13:19:52 +01:00
CAF_PDM_InitFieldNoDefault( &mainWindowTreeViewStates, "TreeViewStates", "" );
mainWindowTreeViewStates.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &mainWindowCurrentModelIndexPaths, "TreeViewCurrentModelIndexPaths", "" );
mainWindowCurrentModelIndexPaths.uiCapability()->setUiHidden( true );
2016-10-06 15:01:59 +02:00
2022-01-28 13:19:52 +01:00
CAF_PDM_InitFieldNoDefault( &plotWindowTreeViewStates, "PlotWindowTreeViewStates", "" );
plotWindowTreeViewStates.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &plotWindowCurrentModelIndexPaths, "PlotWindowTreeViewCurrentModelIndexPaths", "" );
plotWindowCurrentModelIndexPaths.uiCapability()->setUiHidden( true );
2013-04-19 13:20:46 +02:00
CAF_PDM_InitField( &m_show3DWindow, "show3DWindow", true, "Show 3D Window" );
m_show3DWindow.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_showPlotWindow, "showPlotWindow", false, "Show Plot Window" );
m_showPlotWindow.uiCapability()->setUiHidden( true );
2023-03-09 08:54:28 +01:00
CAF_PDM_InitField( &m_showPlotWindowOnTopOf3DWindow, "showPlotWindowOnTopOf3DWindow", false, "Show Plot On Top" );
m_showPlotWindowOnTopOf3DWindow.uiCapability()->setUiHidden( true );
2026-05-28 18:32:16 +02:00
CAF_PDM_InitField( &mainWindowDockState, "MainWindowDockState", QString(), "Dock State 3D Window" );
mainWindowDockState.uiCapability()->setUiHidden( true );
2019-04-02 19:18:00 +02:00
2026-05-28 18:32:16 +02:00
CAF_PDM_InitField( &plotWindowDockState, "PlotWindowDockState", QString(), "Dock State Plot Window" );
plotWindowDockState.uiCapability()->setUiHidden( true );
2019-04-02 19:18:00 +02:00
CAF_PDM_InitFieldNoDefault( &m_dialogData, "DialogData", "DialogData" );
2017-06-30 16:14:15 +02:00
m_dialogData = new RimDialogData();
m_dialogData.uiCapability()->setUiTreeChildrenHidden( true );
2017-06-30 16:14:15 +02:00
// Obsolete fields. The content is moved to OilFields and friends
CAF_PDM_InitFieldNoDefault( &casesObsolete, "Reservoirs", "" );
2022-06-02 15:57:00 +02:00
RiaFieldHandleTools::disableWriteAndSetFieldHidden( &casesObsolete );
CAF_PDM_InitFieldNoDefault( &caseGroupsObsolete, "CaseGroups", "" );
2022-06-02 15:57:00 +02:00
RiaFieldHandleTools::disableWriteAndSetFieldHidden( &caseGroupsObsolete );
// Initialization
2012-05-18 09:45:23 +02:00
scriptCollection = new RimScriptCollection();
scriptCollection->directory.uiCapability()->setUiHidden( true );
scriptCollection->uiCapability()->setUiName( "Scripts" );
scriptCollection->uiCapability()->setUiIconFromResourceString( ":/octave.png" );
2012-05-18 09:45:23 +02:00
2026-05-30 10:16:07 +02:00
workflowCollection = new RimWorkflowCollection();
workflowCollection->uiCapability()->setUiName( "Workflows" );
2024-10-18 14:25:04 +02:00
m_mainPlotCollection = new RimMainPlotCollection();
m_pinnedFieldCollection = new RimQuickAccessCollection();
2025-06-11 15:43:53 +02:00
m_jobCollection = new RimJobCollection();
CAF_PDM_InitFieldNoDefault( &m_plotTemplateTopFolder, "PlotTemplateCollection", "Plot Templates" );
m_plotTemplateTopFolder = new RimPlotTemplateFolderItem();
m_plotTemplateTopFolder.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault( &m_automationSettings, "AutomationSettings", "Automation Settings" );
m_automationSettings = new RimAutomationSettings();
CAF_PDM_InitFieldNoDefault( &m_ensembleFileSetCollection, "EnsembleFileSetCollection", "Ensemble File Sets" );
m_ensembleFileSetCollection = new RimEnsembleFileSetCollection();
// For now, create a default first oilfield that contains the rest of the project
oilFields.push_back( new RimOilField );
setUiHidden( true );
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2023-04-14 14:07:45 +02:00
RimProject::~RimProject()
{
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
2020-04-22 14:35:25 +02:00
///
//--------------------------------------------------------------------------------------------------
RimProject* RimProject::current()
{
return RiaApplication::instance()->project();
}
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
void RimProject::close()
{
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection() )
{
2022-08-19 05:30:25 -07:00
m_mainPlotCollection()->deleteAllContainedObjects();
}
2025-06-11 15:43:53 +02:00
m_jobCollection->deleteAllJobs();
m_ensembleFileSetCollection()->deleteAllFileSets();
oilFields.deleteChildren();
oilFields.push_back( new RimOilField );
casesObsolete.deleteChildren();
caseGroupsObsolete.deleteChildren();
2012-05-18 09:45:23 +02:00
multiSnapshotDefinitions.deleteChildren();
m_dialogData->clearProjectSpecificData();
calculationCollection->deleteAllContainedObjects();
gridCalculationCollection->deleteAllContainedObjects();
2020-05-13 14:28:06 +02:00
colorLegendCollection->deleteCustomColorLegends();
delete viewLinkerCollection->viewLinker();
2018-01-16 16:49:28 +01:00
viewLinkerCollection->viewLinker = nullptr;
2015-09-04 11:22:44 +02:00
setFileName( "" );
2022-12-08 07:08:22 +01:00
m_globalPathList = "";
2022-01-28 13:19:52 +01:00
mainWindowCurrentModelIndexPaths = "";
mainWindowTreeViewStates = "";
plotWindowCurrentModelIndexPaths = "";
plotWindowTreeViewStates = "";
2026-06-02 00:55:26 +02:00
mainWindowDockState = "";
plotWindowDockState = "";
2012-05-18 09:45:23 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::updatesAfterProjectFileIsRead()
{
RiaProjectFileTools::distributePathsFromGlobalPathList( this, m_globalPathList() );
// Create an empty oil field in case the project did not contain one
if ( oilFields.empty() )
{
oilFields.push_back( new RimOilField );
}
// Handle old project files with obsolete structure.
// Move caseGroupsObsolete and casesObsolete to oilFields()[idx]->analysisModels()
2023-02-26 10:48:40 +01:00
RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : nullptr;
bool movedOneRimIdenticalGridCaseGroup = false;
for ( size_t cgIdx = 0; cgIdx < caseGroupsObsolete.size(); ++cgIdx )
{
RimIdenticalGridCaseGroup* sourceCaseGroup = caseGroupsObsolete[cgIdx];
if ( analysisModels )
{
analysisModels->caseGroups.push_back( sourceCaseGroup );
movedOneRimIdenticalGridCaseGroup = true; // moved at least one so assume the others will be moved too...
}
}
if ( movedOneRimIdenticalGridCaseGroup )
{
caseGroupsObsolete.clearWithoutDelete();
}
bool movedOneRimCase = false;
for ( size_t cIdx = 0; cIdx < casesObsolete().size(); ++cIdx )
{
if ( analysisModels )
{
2015-09-01 17:04:08 +02:00
RimEclipseCase* sourceCase = casesObsolete[cIdx];
casesObsolete.set( cIdx, nullptr );
analysisModels->cases.push_back( sourceCase );
movedOneRimCase = true; // moved at least one so assume the others will be moved too...
}
}
if ( movedOneRimCase )
{
casesObsolete.clearWithoutDelete();
}
// Set project pointer to each well path
for ( size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++ )
{
RimOilField* oilField = oilFields[oilFieldIdx];
if ( oilField == nullptr || oilField->wellPathCollection == nullptr ) continue;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2024-10-18 14:25:04 +02:00
RimQuickAccessCollection* RimProject::pinnedFieldCollection() const
{
return m_pinnedFieldCollection();
}
2025-06-11 15:43:53 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimJobCollection* RimProject::jobCollection() const
{
return m_jobCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAutomationSettings* RimProject::automationSettings() const
{
return m_automationSettings();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEnsembleFileSetCollection* RimProject::ensembleFileSetCollection() const
{
return m_ensembleFileSetCollection();
}
2024-10-18 14:25:04 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::initAfterRead()
{
// Function moved to beforeInitAfterRead() to make sure that file path objects are replaced before other initAfterRead() is called
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
void RimProject::setupBeforeSave()
{
2021-10-21 15:46:50 +02:00
if ( RiaGuiApplication::isRunning() )
{
2021-10-21 15:46:50 +02:00
RiaGuiApplication* guiApp = RiaGuiApplication::instance();
if ( guiApp )
{
m_show3DWindow = guiApp->isMain3dWindowVisible();
m_showPlotWindow = guiApp->isMainPlotWindowVisible();
2023-03-09 08:54:28 +01:00
if ( m_showPlotWindow )
{
auto plotWindow = RiuPlotMainWindow::instance();
m_showPlotWindowOnTopOf3DWindow = plotWindow->isTopLevel();
}
2021-10-21 15:46:50 +02:00
}
}
2012-05-18 09:45:23 +02:00
m_projectFileVersionString = STRPRODUCTVER;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::PdmFieldHandle*> RimProject::fieldsForExport() const
{
std::vector<QString> orderedKeywords;
orderedKeywords.push_back( fileNameHandle()->keyword() );
orderedKeywords.push_back( m_projectFileVersionString.keyword() );
orderedKeywords.push_back( m_globalPathList.keyword() );
orderedKeywords.push_back( m_ensembleFileSetCollection.keyword() );
std::vector<caf::PdmFieldHandle*> ordered;
auto fieldHandles = fields();
for ( const auto& kw : orderedKeywords )
{
auto it = std::find_if( fieldHandles.begin(),
fieldHandles.end(),
[&]( const caf::PdmFieldHandle* field ) { return field->keyword() == kw; } );
if ( it != fieldHandles.end() )
{
ordered.push_back( *it );
}
}
// Append the rest of the fields
for ( auto fieldHandle : fields() )
{
if ( std::find( ordered.begin(), ordered.end(), fieldHandle ) == ordered.end() )
{
ordered.push_back( fieldHandle );
}
}
return ordered;
}
2022-08-19 05:30:25 -07:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMainPlotCollection* RimProject::mainPlotCollection() const
{
return m_mainPlotCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::writeProjectFile()
{
m_globalPathList = RiaProjectFileTools::transferPathsToGlobalPathList( this );
QFile xmlFile( fileName() );
if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
QString content = documentAsString();
xmlFile.write( content.toUtf8() );
if ( RiaPreferences::current()->storeBackupOfProjectFiles() )
{
QString backupFilename = fileName() + "db";
const int maximumRecordCount = 50;
RiaProjectBackupTools::appendTextToDatabase( backupFilename, maximumRecordCount, content );
}
RiaProjectFileTools::distributePathsFromGlobalPathList( this, m_globalPathList() );
return true;
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
/// Support list of multiple script paths divided by ';'
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
void RimProject::setScriptDirectories( const QString& scriptDirectories, int maxFolderDepth )
2012-05-18 09:45:23 +02:00
{
scriptCollection->calcScripts().deleteChildren();
scriptCollection->subDirectories().deleteChildren();
2012-05-18 09:45:23 +02:00
QStringList pathList = scriptDirectories.split( ';' );
2024-04-03 15:54:28 +02:00
for ( const QString& path : pathList )
2012-05-18 09:45:23 +02:00
{
QDir dir( path );
if ( !path.isEmpty() && dir.exists() && dir.isReadable() )
{
RimScriptCollection* sharedScriptLocation = new RimScriptCollection;
sharedScriptLocation->directory = path;
sharedScriptLocation->setUiName( dir.dirName() );
2012-05-18 09:45:23 +02:00
sharedScriptLocation->readContentFromDisc( maxFolderDepth );
2012-05-18 09:45:23 +02:00
scriptCollection->subDirectories.push_back( sharedScriptLocation );
}
2012-05-18 09:45:23 +02:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::setPlotTemplateFolders( const QStringList& plotTemplateFolders )
{
if ( !m_plotTemplateTopFolder() )
{
m_plotTemplateTopFolder = new RimPlotTemplateFolderItem();
}
m_plotTemplateTopFolder->createRootFolderItemsFromFolderPaths( plotTemplateFolders );
}
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
///
2012-05-18 09:45:23 +02:00
//--------------------------------------------------------------------------------------------------
QString RimProject::projectFileVersionString() const
{
return m_projectFileVersionString;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::isProjectFileVersionEqualOrOlderThan( const QString& otherProjectFileVersion ) const
{
QString candidateProjectFileVersion = projectFileVersionString();
2024-06-05 10:59:04 +02:00
return !RiaProjectFileTools::isCandidateVersionNewerThanOther( candidateProjectFileVersion, otherProjectFileVersion );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::setProjectFileNameAndUpdateDependencies( const QString& projectFileName )
{
// Extract the filename of the project file when it was saved
QString oldProjectFileName = fileName();
// Replace with the new actual filename
setFileName( projectFileName );
QFileInfo fileInfo( projectFileName );
QString newProjectPath = fileInfo.path();
QFileInfo fileInfoOld( oldProjectFileName );
QString oldProjectPath = fileInfoOld.path();
if ( newProjectPath == oldProjectPath ) return;
for ( caf::FilePath* filePath : allFilePaths() )
{
2023-02-15 07:56:17 +01:00
QString filePathCandidate = filePath->path();
2025-05-23 19:30:11 +02:00
QString newFilePath = RimTools::relocateFile( filePathCandidate, newProjectPath, oldProjectPath );
2023-02-15 07:56:17 +01:00
filePath->setPath( newFilePath );
2018-01-08 10:37:57 +01:00
}
2016-08-24 08:30:12 +02:00
if ( ensembleFileSetCollection() ) ensembleFileSetCollection()->updateFilePathsFromProjectPath( newProjectPath, oldProjectPath );
}
2020-04-08 14:30:38 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::assignCaseIdToSummaryCase( RimSummaryCase* summaryCase )
{
assignCaseIdsToSummaryCases( { summaryCase } );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::assignCaseIdsToSummaryCases( const std::vector<RimSummaryCase*>& summaryCases )
{
int nextValidId = 1;
for ( RimSummaryCase* s : allSummaryCases() )
2020-04-08 14:30:38 +02:00
{
nextValidId = std::max( nextValidId, s->caseId() + 1 );
}
2020-04-08 14:30:38 +02:00
for ( RimSummaryCase* summaryCase : summaryCases )
{
if ( summaryCase ) summaryCase->setCaseId( nextValidId++ );
2020-04-08 14:30:38 +02:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::assignIdToEnsemble( RimSummaryEnsemble* summaryCaseCollection )
{
if ( summaryCaseCollection )
{
int nextValidId = 1;
2025-04-25 11:06:02 +02:00
for ( RimSummaryEnsemble* ensemble : summaryEnsembles() )
{
nextValidId = std::max( nextValidId, ensemble->ensembleId() + 1 );
}
summaryCaseCollection->setEnsembleId( nextValidId );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimCase*> RimProject::allGridCases() const
{
std::vector<RimCase*> cases;
2024-04-03 15:54:28 +02:00
for ( RimOilField* oilField : oilFields() )
2023-09-11 15:12:18 +02:00
{
if ( !oilField ) continue;
RimEclipseCaseCollection* analysisModels = oilField->analysisModels();
if ( analysisModels )
{
2024-04-03 15:54:28 +02:00
for ( RimEclipseCase* eclipseCase : analysisModels->cases )
2023-09-11 15:12:18 +02:00
{
2024-04-03 15:54:28 +02:00
cases.push_back( eclipseCase );
2023-09-11 15:12:18 +02:00
}
2024-04-03 15:54:28 +02:00
for ( RimIdenticalGridCaseGroup* cg : analysisModels->caseGroups )
2023-09-11 15:12:18 +02:00
{
// Load the Main case of each IdenticalGridCaseGroup
if ( cg == nullptr ) continue;
if ( cg->statisticsCaseCollection() )
{
2024-04-03 15:54:28 +02:00
for ( RimEclipseCase* eclipseCase : cg->statisticsCaseCollection()->reservoirs )
2023-09-11 15:12:18 +02:00
{
2024-04-03 15:54:28 +02:00
cases.push_back( eclipseCase );
2023-09-11 15:12:18 +02:00
}
}
if ( cg->caseCollection() )
{
2024-04-03 15:54:28 +02:00
for ( RimEclipseCase* eclipseCase : cg->caseCollection()->reservoirs )
2023-09-11 15:12:18 +02:00
{
2024-04-03 15:54:28 +02:00
cases.push_back( eclipseCase );
2023-09-11 15:12:18 +02:00
}
}
}
for ( RimEclipseCaseEnsemble* ensemble : analysisModels->caseEnsembles() )
{
// The ensemble can be null if this function is called while the ensembles are being deleted,
// as PdmPointer entries in the child array field are nulled one by one during deletion.
if ( ensemble == nullptr ) continue;
for ( RimEclipseCase* acase : ensemble->cases() )
{
cases.push_back( acase );
}
for ( RimWellTargetMapping* wellTargetMapping : ensemble->wellTargetMappings() )
{
if ( auto ensembleStatisticsCase = wellTargetMapping->ensembleStatisticsCase() )
cases.push_back( ensembleStatisticsCase );
}
}
for ( RimReservoirGridEnsemble* ensemble : analysisModels->reservoirGridEnsembles.childrenByType() )
{
if ( ensemble == nullptr ) continue;
for ( RimEclipseCase* acase : ensemble->cases() )
{
cases.push_back( acase );
}
if ( ensemble->statisticsCaseCollection() )
{
for ( RimEclipseCase* eclipseCase : ensemble->statisticsCaseCollection()->reservoirs )
{
cases.push_back( eclipseCase );
}
}
}
RimGeoMechModels* geomModels = oilField->geoMechModels();
if ( geomModels )
2023-09-11 15:12:18 +02:00
{
for ( auto acase : geomModels->cases() )
{
cases.push_back( acase );
}
2023-09-11 15:12:18 +02:00
}
}
}
return cases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::assignCaseIdToCase( RimCase* reservoirCase )
{
if ( reservoirCase )
{
int nextValidId = 0;
for ( RimCase* rimCase : descendantsIncludingThisOfType<RimCase>() )
{
nextValidId = std::max( nextValidId, rimCase->caseId() + 1 );
}
reservoirCase->setCaseId( nextValidId );
}
}
2013-05-10 15:35:33 +02:00
//--------------------------------------------------------------------------------------------------
///
2013-05-10 15:35:33 +02:00
//--------------------------------------------------------------------------------------------------
void RimProject::assignIdToCaseGroup( RimIdenticalGridCaseGroup* caseGroup )
2013-05-10 15:35:33 +02:00
{
if ( caseGroup )
2013-05-10 15:35:33 +02:00
{
int nextValidId = 0;
for ( RimIdenticalGridCaseGroup* existingCaseGroup : descendantsIncludingThisOfType<RimIdenticalGridCaseGroup>() )
{
nextValidId = std::max( nextValidId, existingCaseGroup->groupId() + 1 );
}
caseGroup->groupId = nextValidId;
2013-05-10 15:35:33 +02:00
}
}
2026-02-13 08:28:34 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::assignIdToCaseGroup( RimReservoirGridEnsemble* gridEnsemble )
{
if ( gridEnsemble )
{
int nextValidId = 0;
2026-02-13 08:28:34 +01:00
for ( RimIdenticalGridCaseGroup* existingCaseGroup : descendantsIncludingThisOfType<RimIdenticalGridCaseGroup>() )
2026-02-13 08:28:34 +01:00
{
nextValidId = std::max( nextValidId, existingCaseGroup->groupId() + 1 );
2026-02-13 08:28:34 +01:00
}
for ( RimReservoirGridEnsemble* existingEnsemble : descendantsIncludingThisOfType<RimReservoirGridEnsemble>() )
2026-02-13 08:28:34 +01:00
{
nextValidId = std::max( nextValidId, existingEnsemble->groupId() + 1 );
2026-02-13 08:28:34 +01:00
}
gridEnsemble->setGroupId( nextValidId );
2026-02-13 08:28:34 +01:00
}
}
2019-07-15 11:43:22 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-11-14 20:48:11 +01:00
void RimProject::assignViewIdToView( Rim3dView* view )
2019-07-15 11:43:22 +02:00
{
if ( view )
2019-07-15 11:43:22 +02:00
{
int nextValidId = 0;
for ( Rim3dView* existingView : descendantsIncludingThisOfType<Rim3dView>() )
{
nextValidId = std::max( nextValidId, existingView->id() + 1 );
}
view->setId( nextValidId );
2019-07-15 11:43:22 +02:00
}
}
2019-11-14 20:48:11 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::assignPlotIdToPlotWindow( RimPlotWindow* plotWindow )
{
if ( plotWindow )
{
int nextValidId = 0;
for ( RimPlotWindow* existingPlotWindow : descendantsIncludingThisOfType<RimPlotWindow>() )
2019-11-14 20:48:11 +01:00
{
nextValidId = std::max( nextValidId, existingPlotWindow->id() + 1 );
2019-11-14 20:48:11 +01:00
}
plotWindow->setId( nextValidId );
2019-11-14 20:48:11 +01:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimSummaryCase*> RimProject::allSummaryCases() const
{
std::vector<RimSummaryCase*> sumCases;
for ( RimOilField* oilField : oilFields )
{
if ( !oilField ) continue;
RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection();
if ( sumCaseMainColl )
{
std::vector<RimSummaryCase*> allSummaryCases = sumCaseMainColl->allSummaryCases();
if ( !allSummaryCases.empty() )
{
sumCases.insert( sumCases.end(), allSummaryCases.begin(), allSummaryCases.end() );
}
}
auto& observedDataColl = oilField->observedDataCollection();
if ( observedDataColl != nullptr && !observedDataColl->allObservedSummaryData().empty() )
{
2019-08-20 15:09:13 +02:00
auto observedData = observedDataColl->allObservedSummaryData();
sumCases.insert( sumCases.end(), observedData.begin(), observedData.end() );
}
}
return sumCases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2025-04-25 11:06:02 +02:00
std::vector<RimSummaryEnsemble*> RimProject::summaryEnsembles() const
{
std::vector<RimSummaryEnsemble*> ensembles;
for ( RimOilField* oilField : oilFields )
{
if ( !oilField ) continue;
RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection();
if ( sumCaseMainColl )
{
std::vector<RimSummaryEnsemble*> ensemble = sumCaseMainColl->summaryEnsembles();
ensembles.insert( ensembles.end(), ensemble.begin(), ensemble.end() );
}
}
return ensembles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<Rim3dView*> RimProject::allNotLinkedViews() const
{
2022-11-24 10:46:54 +01:00
std::vector<Rim3dView*> alreadyLinkedViews;
if ( viewLinkerCollection->viewLinker() )
{
2022-11-04 15:48:25 +01:00
alreadyLinkedViews = viewLinkerCollection->viewLinker()->allViews();
}
std::vector<Rim3dView*> views;
for ( RimCase* rimCase : allGridCases() )
{
if ( !rimCase ) continue;
for ( Rim3dView* caseView : rimCase->views() )
{
2024-04-03 15:54:28 +02:00
RimGridView* gridView = dynamic_cast<RimGridView*>( caseView );
if ( !gridView ) continue;
bool isLinked = false;
for ( size_t lnIdx = 0; lnIdx < alreadyLinkedViews.size(); lnIdx++ )
{
if ( gridView == alreadyLinkedViews[lnIdx] )
{
isLinked = true;
}
}
if ( !isLinked )
{
views.push_back( gridView );
}
}
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<Rim3dView*> RimProject::allViews() const
{
std::vector<Rim3dView*> views;
for ( RimCase* rimCase : allGridCases() )
{
if ( !rimCase ) continue;
for ( Rim3dView* view : rimCase->views() )
{
2024-04-03 15:54:28 +02:00
if ( view )
{
2024-04-03 15:54:28 +02:00
views.push_back( view );
}
}
}
2023-08-07 16:35:59 +02:00
2024-04-03 15:54:28 +02:00
for ( RimOilField* oilField : oilFields() )
2023-08-07 16:35:59 +02:00
{
if ( !oilField ) continue;
2025-01-16 16:53:05 +01:00
if ( oilField->seismicViewCollection() )
2023-08-07 16:35:59 +02:00
{
2025-01-16 16:53:05 +01:00
for ( auto seisview : oilField->seismicViewCollection()->views() )
{
views.push_back( seisview );
}
}
if ( oilField->genericViewCollection() )
{
for ( auto dataView : oilField->genericViewCollection()->genericViews() )
{
views.push_back( dataView );
}
}
2025-01-16 16:53:05 +01:00
if ( oilField->analysisModels() )
{
for ( auto ensemble : oilField->analysisModels()->caseEnsembles.childrenByType() )
{
if ( !ensemble ) continue;
for ( auto view : ensemble->allViews() )
{
views.push_back( view );
}
}
for ( auto gridEnsemble : oilField->analysisModels()->reservoirGridEnsembles.childrenByType() )
{
if ( !gridEnsemble ) continue;
for ( auto view : gridEnsemble->allViews() )
{
views.push_back( view );
}
}
2023-08-07 16:35:59 +02:00
}
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<Rim3dView*> RimProject::allVisibleViews() const
{
std::vector<Rim3dView*> views;
2025-01-16 16:53:05 +01:00
for ( auto view : allViews() )
{
if ( view && view->viewer() )
{
2025-01-16 16:53:05 +01:00
views.push_back( view );
}
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimGridView*> RimProject::allVisibleGridViews() const
{
std::vector<RimGridView*> views;
for ( Rim3dView* view : allVisibleViews() )
{
RimGridView* gridView = dynamic_cast<RimGridView*>( view );
if ( gridView ) views.push_back( gridView );
}
return views;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::scheduleCreateDisplayModelAndRedrawAllViews()
{
2025-01-16 16:53:05 +01:00
for ( auto view : allViews() )
2023-08-07 16:35:59 +02:00
{
2025-01-16 16:53:05 +01:00
if ( view ) view->scheduleCreateDisplayModelAndRedraw();
2023-08-07 16:35:59 +02:00
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimOilField*> RimProject::allOilFields() const
{
return oilFields.childrenByType();
}
//--------------------------------------------------------------------------------------------------
/// Currently there will be only one oil field in Resinsight, so return hardcoded first oil field
/// from the RimOilField collection.
//--------------------------------------------------------------------------------------------------
RimOilField* RimProject::activeOilField()
{
CAF_ASSERT( oilFields.size() == 1 );
return oilFields[0];
}
//--------------------------------------------------------------------------------------------------
/// Currently there will be only one oil field in Resinsight, so return hardcoded first oil field
/// from the RimOilField collection.
//--------------------------------------------------------------------------------------------------
const RimOilField* RimProject::activeOilField() const
{
CAF_ASSERT( oilFields.size() == 1 );
return oilFields[0];
}
2015-08-06 11:00:21 +02:00
//--------------------------------------------------------------------------------------------------
///
2015-08-06 11:00:21 +02:00
//--------------------------------------------------------------------------------------------------
void RimProject::actionsBasedOnSelection( QMenu& contextMenu )
2015-08-06 11:00:21 +02:00
{
caf::CmdFeatureMenuBuilder menuBuilder = RimContextCommandBuilder::commandsFromSelection();
menuBuilder.appendToMenu( &contextMenu );
2015-08-06 11:00:21 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::show3DWindow() const
{
return m_show3DWindow;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::showPlotWindow() const
{
return m_showPlotWindow;
}
2023-03-09 08:54:28 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimProject::showPlotWindowOnTop() const
{
return m_showPlotWindowOnTopOf3DWindow();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-06-02 10:35:52 +02:00
void RimProject::reloadCompletionTypeResultsInAllViews()
{
RiaCompletionTypeCalculationScheduler::instance()->clearCompletionTypeResultsInAllCases();
scheduleCreateDisplayModelAndRedrawAllViews();
2022-08-19 05:30:25 -07:00
m_mainPlotCollection()->scheduleUpdatePlotsWithCompletions();
}
//--------------------------------------------------------------------------------------------------
///
2017-06-30 16:14:15 +02:00
//--------------------------------------------------------------------------------------------------
RimDialogData* RimProject::dialogData() const
{
return m_dialogData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimEclipseCase*> RimProject::eclipseCases() const
{
2023-09-11 15:12:18 +02:00
std::vector<RimEclipseCase*> allGridCases;
for ( const auto& oilField : oilFields )
{
const auto& cases = oilField->analysisModels->cases;
2023-09-11 15:12:18 +02:00
allGridCases.insert( allGridCases.end(), cases.begin(), cases.end() );
}
2023-09-11 15:12:18 +02:00
return allGridCases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimProject::eclipseCaseFromGridFileName( const QString& gridFileName ) const
{
for ( RimEclipseCase* eclCase : eclipseCases() )
{
2023-02-26 10:48:40 +01:00
if ( RiaFilePathTools::toInternalSeparator( eclCase->gridFileName() ) == RiaFilePathTools::toInternalSeparator( gridFileName ) )
{
return eclCase;
}
}
return nullptr;
}
2021-05-18 14:28:54 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimProject::eclipseCaseFromCaseId( const int caseId ) const
{
for ( RimEclipseCase* eclCase : eclipseCases() )
{
if ( eclCase->caseId() == caseId )
{
return eclCase;
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RimProject::simulationWellNames() const
{
std::set<QString> wellNames;
for ( RimOilField* oilField : oilFields )
{
auto analysisCaseColl = oilField->analysisModels();
for ( RimEclipseCase* eclCase : analysisCaseColl->cases() )
{
const auto& eclData = eclCase->eclipseCaseData();
if ( eclData == nullptr ) continue;
const auto names = eclData->simulationWellNames();
wellNames.insert( names.begin(), names.end() );
}
}
return std::vector<QString>( wellNames.begin(), wellNames.end() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimProject::wellPathFromSimWellName( const QString& simWellName, int branchIndex )
{
for ( RimWellPath* const path : allWellPaths() )
{
if ( QString::compare( path->associatedSimulationWellName(), simWellName ) == 0 &&
( branchIndex < 0 || path->associatedSimulationWellBranch() == branchIndex ) )
{
return path;
}
}
for ( RimWellPath* const path : allWellPaths() )
{
if ( QString::compare( path->name(), simWellName ) == 0 )
{
return path;
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimProject::wellPathByName( const QString& wellPathName ) const
{
for ( RimWellPath* const path : allWellPaths() )
{
if ( path->name() == wellPathName ) return path;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RimProject::allWellPaths() const
{
std::vector<RimWellPath*> wellPaths;
for ( const auto& oilField : oilFields() )
{
auto wellPathColl = oilField->wellPathCollection();
2020-10-07 16:18:24 +02:00
for ( auto wellPath : wellPathColl->allWellPaths() )
{
wellPaths.push_back( wellPath );
}
}
return wellPaths;
}
2018-11-23 13:33:59 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimTextAnnotation*> RimProject::textAnnotations() const
{
std::vector<RimTextAnnotation*> annotations;
// 'Global' text annotations
for ( const auto& oilField : oilFields() )
2018-11-23 13:33:59 +01:00
{
auto annotationColl = oilField->annotationCollection();
for ( const auto& annotation : annotationColl->textAnnotations() )
2018-11-23 13:33:59 +01:00
{
annotations.push_back( annotation );
2018-11-23 13:33:59 +01:00
}
}
// 'Local' text annotations
for ( const auto& view : allVisibleGridViews() )
{
std::vector<RimAnnotationInViewCollection*> annotationColls = view->descendantsIncludingThisOfType<RimAnnotationInViewCollection>();
if ( annotationColls.size() == 1 )
{
for ( const auto& annotation : annotationColls.front()->textAnnotations() )
{
annotations.push_back( annotation );
}
}
}
2018-11-23 13:33:59 +01:00
return annotations;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimReachCircleAnnotation*> RimProject::reachCircleAnnotations() const
{
std::vector<RimReachCircleAnnotation*> annotations;
for ( const auto& oilField : oilFields() )
2018-11-23 13:33:59 +01:00
{
auto annotationColl = oilField->annotationCollection();
for ( const auto& annotation : annotationColl->reachCircleAnnotations() )
2018-11-23 13:33:59 +01:00
{
annotations.push_back( annotation );
2018-11-23 13:33:59 +01:00
}
}
return annotations;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimGeoMechCase*> RimProject::geoMechCases() const
{
std::vector<RimGeoMechCase*> cases;
2024-04-03 15:54:28 +02:00
for ( RimOilField* oilField : oilFields() )
{
if ( !oilField ) continue;
RimGeoMechModels* geomModels = oilField->geoMechModels();
if ( geomModels )
{
for ( auto acase : geomModels->cases() )
{
cases.push_back( acase );
}
}
}
return cases;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimFractureTemplateCollection*> RimProject::allFractureTemplateCollections() const
{
std::vector<RimFractureTemplateCollection*> templColls;
2024-04-03 15:54:28 +02:00
for ( RimOilField* oilField : allOilFields() )
{
templColls.push_back( oilField->fractureDefinitionCollection() );
}
return templColls;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimFractureTemplate*> RimProject::allFractureTemplates() const
{
std::vector<RimFractureTemplate*> templates;
for ( RimFractureTemplateCollection* templColl : allFractureTemplateCollections() )
{
for ( RimFractureTemplate* templ : templColl->fractureTemplates() )
{
templates.push_back( templ );
}
}
return templates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimValveTemplateCollection*> RimProject::allValveTemplateCollections() const
{
std::vector<RimValveTemplateCollection*> templColls;
2024-04-03 15:54:28 +02:00
for ( RimOilField* oilField : allOilFields() )
{
templColls.push_back( oilField->valveTemplateCollection() );
}
return templColls;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimValveTemplate*> RimProject::allValveTemplates() const
{
std::vector<RimValveTemplate*> templates;
for ( RimValveTemplateCollection* templColl : allValveTemplateCollections() )
{
2025-12-22 14:06:09 +01:00
for ( RimValveTemplate* templ : templColl->items() )
{
templates.push_back( templ );
}
}
return templates;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::AppEnum<RiaDefines::EclipseUnitSystem> RimProject::commonUnitSystemForAllCases() const
{
RiaDefines::EclipseUnitSystem commonUnitSystem = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
for ( const auto& c : allGridCases() )
{
auto eclipseCase = dynamic_cast<RimEclipseCase*>( c );
if ( eclipseCase && eclipseCase->eclipseCaseData() )
{
if ( commonUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN )
{
commonUnitSystem = eclipseCase->eclipseCaseData()->unitsType();
}
else if ( commonUnitSystem != eclipseCase->eclipseCaseData()->unitsType() )
{
commonUnitSystem = RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
break;
}
}
}
return commonUnitSystem;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMeasurement* RimProject::measurement() const
{
return activeOilField()->measurement;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2022-05-25 11:01:45 +02:00
RimPlotTemplateFolderItem* RimProject::rootPlotTemplateItem() const
{
return m_plotTemplateTopFolder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<caf::FilePath*> RimProject::allFilePaths() const
{
2025-05-03 08:58:28 +02:00
std::vector<caf::FilePath*> filePaths = RiaProjectFileTools::writableFieldContent<caf::FilePath>( this );
return filePaths;
}
2017-06-02 10:35:52 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimProject::reloadCompletionTypeResultsForEclipseCase( RimEclipseCase* eclipseCase )
{
for ( Rim3dView* view : eclipseCase->views() )
{
2024-04-03 15:54:28 +02:00
view->scheduleCreateDisplayModelAndRedraw();
}
RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews( { eclipseCase } );
}
2015-08-06 15:55:17 +02:00
//--------------------------------------------------------------------------------------------------
///
2015-08-06 15:55:17 +02:00
//--------------------------------------------------------------------------------------------------
void RimProject::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
2015-08-06 15:55:17 +02:00
{
2022-01-28 13:19:52 +01:00
if ( uiConfigName == "PlotWindow.Plots" )
{
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection )
{
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->summaryMultiPlotCollection() )
2022-03-04 10:52:17 +01:00
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->summaryMultiPlotCollection() );
2022-03-04 10:52:17 +01:00
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->analysisPlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->analysisPlotCollection() );
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->correlationPlotCollection() )
2020-04-17 09:31:42 +02:00
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->correlationPlotCollection() );
2020-04-17 09:31:42 +02:00
}
2023-03-23 14:10:30 +01:00
if ( m_mainPlotCollection->summaryTableCollection() )
{
uiTreeOrdering.add( m_mainPlotCollection->summaryTableCollection() );
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->wellLogPlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->wellLogPlotCollection() );
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->rftPlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->rftPlotCollection() );
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->pltPlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->pltPlotCollection() );
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->flowPlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->flowPlotCollection() );
}
2019-02-21 12:52:23 +01:00
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->gridCrossPlotCollection() )
2019-02-21 12:52:23 +01:00
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->gridCrossPlotCollection() );
2019-02-21 12:52:23 +01:00
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->saturationPressurePlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->saturationPressurePlotCollection() );
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->multiPlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->multiPlotCollection() );
}
2020-05-14 06:39:55 +02:00
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->stimPlanModelPlotCollection() )
2020-05-14 06:39:55 +02:00
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->stimPlanModelPlotCollection() );
2020-05-14 06:39:55 +02:00
}
2022-08-19 05:30:25 -07:00
if ( m_mainPlotCollection->vfpPlotCollection() )
{
2022-08-19 05:30:25 -07:00
uiTreeOrdering.add( m_mainPlotCollection->vfpPlotCollection() );
}
2025-06-02 14:52:45 +02:00
if ( m_mainPlotCollection->histogramMultiPlotCollection() )
{
uiTreeOrdering.add( m_mainPlotCollection->histogramMultiPlotCollection() );
}
uiTreeOrdering.add( automationSettings() );
}
2022-01-28 13:19:52 +01:00
}
else if ( uiConfigName == "PlotWindow.DataSources" )
{
RimOilField* oilField = activeOilField();
if ( oilField )
{
if ( oilField->summaryCaseMainCollection() )
{
uiTreeOrdering.add( oilField->summaryCaseMainCollection() );
}
if ( oilField->observedDataCollection() )
{
uiTreeOrdering.add( oilField->observedDataCollection() );
}
if ( oilField->ensembleWellLogsCollection() )
{
uiTreeOrdering.add( oilField->ensembleWellLogsCollection() );
}
if ( oilField->vfpDataCollection() )
{
uiTreeOrdering.add( oilField->vfpDataCollection() );
}
if ( oilField->wellFormationsCollection() )
{
uiTreeOrdering.add( oilField->wellFormationsCollection() );
}
2022-01-28 13:19:52 +01:00
}
}
2022-05-11 19:17:46 +02:00
else if ( uiConfigName == "PlotWindow.Scripts" || uiConfigName == "MainWindow.Scripts" )
2022-01-28 13:19:52 +01:00
{
uiTreeOrdering.add( scriptCollection() );
2025-06-11 15:43:53 +02:00
uiTreeOrdering.add( jobCollection() );
if ( RiaPreferencesSystem::current()->isFeatureEnabled( "workflows" ) )
{
uiTreeOrdering.add( workflowCollection() );
}
}
else if ( uiConfigName == "PlotWindow.Templates" )
{
uiTreeOrdering.add( m_plotTemplateTopFolder );
}
2024-09-02 14:08:19 +02:00
else if ( uiConfigName == "PlotWindow.Cloud" )
{
uiTreeOrdering.add( &m_ensembleFileSetCollection );
2024-09-02 14:08:19 +02:00
if ( m_mainPlotCollection )
{
if ( activeOilField()->cloudDataCollection() )
{
uiTreeOrdering.add( activeOilField()->cloudDataCollection() );
}
}
}
2022-05-11 19:17:46 +02:00
else if ( uiConfigName == "MainWindow.DataSources" )
{
RimOilField* oilField = activeOilField();
if ( oilField )
{
if ( oilField->analysisModels() ) uiTreeOrdering.add( oilField->analysisModels() );
// Also shown in the plot window, see "PlotWindow.Cloud". A data source serves both windows: summary
// ensembles are created from it there, grid ensembles here, where the grid is going to be used.
if ( oilField->cloudDataCollection() ) uiTreeOrdering.add( oilField->cloudDataCollection() );
2022-05-11 19:17:46 +02:00
}
2026-02-13 08:28:34 +01:00
uiTreeOrdering.add( &m_ensembleFileSetCollection );
2022-05-11 19:17:46 +02:00
}
else
{
// Use object instead of field to avoid duplicate entries in the tree view
uiTreeOrdering.add( viewLinkerCollection() );
RimOilField* oilField = activeOilField();
if ( oilField )
{
if ( oilField->analysisModels() ) uiTreeOrdering.add( oilField->analysisModels() );
if ( oilField->genericViewCollection() ) uiTreeOrdering.add( oilField->genericViewCollection() );
if ( oilField->geoMechModels() ) uiTreeOrdering.add( oilField->geoMechModels() );
if ( oilField->wellPathCollection() ) uiTreeOrdering.add( oilField->wellPathCollection() );
if ( oilField->polygonCollection() ) uiTreeOrdering.add( oilField->polygonCollection() );
if ( oilField->surfaceCollection() ) uiTreeOrdering.add( oilField->surfaceCollection() );
2023-08-07 16:35:59 +02:00
if ( oilField->seismicDataCollection() )
{
auto child = uiTreeOrdering.add( "Seismic", ":/Seismic16x16.png" );
child->add( oilField->seismicDataCollection() );
child->add( oilField->seismicViewCollection() );
}
if ( oilField->formationNamesCollection() ) uiTreeOrdering.add( oilField->formationNamesCollection() );
2023-02-26 10:48:40 +01:00
if ( oilField->completionTemplateCollection() ) uiTreeOrdering.add( oilField->completionTemplateCollection() );
if ( oilField->annotationCollection() ) uiTreeOrdering.add( oilField->annotationCollection() );
if ( oilField->eclipseContourMapCollection() ) uiTreeOrdering.add( oilField->eclipseContourMapCollection() );
}
2015-08-06 15:55:17 +02:00
uiTreeOrdering.add( colorLegendCollection() );
}
2015-08-06 15:55:17 +02:00
uiTreeOrdering.skipRemainingChildren( true );
}