///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2011- Statoil ASA // Copyright (C) 2013- Ceetron Solutions AS // Copyright (C) 2011-2012 Ceetron AS // // 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "RiaDefines.h" #include "RiaPlotDefines.h" #include "cafPdmChildArrayField.h" #include "cafPdmChildField.h" #include "cafPdmDocument.h" #include "cvfCollection.h" #include class RigEclipseCaseData; class RigGridManager; class RigMainGrid; class RigWellPath; class RimTextAnnotation; class RimReachCircleAnnotation; class RimPolylinesAnnotation; class RimSummaryCalculationCollection; class RimSummaryCalculation; class RimCase; class RimCommandObject; class RimCommandObject; class RimDialogData; class RimEclipseCase; class RimGeoMechCase; class RimIdenticalGridCaseGroup; class RimMainPlotCollection; class RimMeasurement; class RimAdvancedSnapshotExportDefinition; class RimObservedSummaryData; class RimOilField; class RimColorLegendCollection; class RimScriptCollection; class RimSummaryCase; class RimSummaryCaseCollection; class RimSummaryCaseMainCollection; class Rim3dView; class RimGridView; class RimPlotWindow; class RimViewLinker; class RimViewLinkerCollection; class RimViewWindow; class RimWellPath; class RimWellPathImport; class RimFractureTemplateCollection; class RimFractureTemplate; class RimValveTemplateCollection; class RimValveTemplate; class RimCompletionTemplateCollection; class RimPlotTemplateFolderItem; class RimGridCalculationCollection; namespace caf { class PdmUiTreeOrdering; } class QAction; class QMenu; //================================================================================================== /// /// //================================================================================================== class RimProject : public caf::PdmDocument { CAF_PDM_HEADER_INIT; public: RimProject(); ~RimProject() override; static RimProject* current(); caf::PdmChildArrayField oilFields; caf::PdmChildField colorLegendCollection; caf::PdmChildField scriptCollection; caf::PdmChildField wellPathImport; caf::PdmChildField viewLinkerCollection; caf::PdmChildField calculationCollection; caf::PdmChildField gridCalculationCollection; caf::PdmChildArrayField commandObjects; RimMainPlotCollection* mainPlotCollection() const; caf::PdmChildArrayField multiSnapshotDefinitions; caf::PdmField mainWindowTreeViewStates; caf::PdmField mainWindowCurrentModelIndexPaths; caf::PdmField plotWindowTreeViewStates; caf::PdmField plotWindowCurrentModelIndexPaths; bool writeProjectFile(); void setScriptDirectories( const QString& scriptDirectories, int maxFolderDepth ); void setPlotTemplateFolders( const QStringList& plotTemplateFolders ); QString projectFileVersionString() const; bool isProjectFileVersionEqualOrOlderThan( const QString& otherProjectFileVersion ) const; void close(); void setProjectFileNameAndUpdateDependencies( const QString& projectFileName ); void assignCaseIdToCase( RimCase* reservoirCase ); void assignIdToCaseGroup( RimIdenticalGridCaseGroup* caseGroup ); void assignViewIdToView( Rim3dView* view ); void assignPlotIdToPlotWindow( RimPlotWindow* plotWindow ); void assignCaseIdToSummaryCase( RimSummaryCase* summaryCase ); void assignIdToEnsemble( RimSummaryCaseCollection* summaryCaseCollection ); std::vector allGridCases() const; void allCases( std::vector& cases ) const; // Deprecated, use allGridCases() std::vector allSummaryCases() const; std::vector summaryGroups() const; RimSummaryCaseMainCollection* firstSummaryCaseMainCollection() const; void allViews( std::vector& views ) const; void allVisibleViews( std::vector& views ) const; void allVisibleGridViews( std::vector& views ) const; void allNotLinkedViews( std::vector& views ); void scheduleCreateDisplayModelAndRedrawAllViews(); void computeUtmAreaOfInterest(); void allOilFields( std::vector& allOilFields ) const; RimOilField* activeOilField(); const RimOilField* activeOilField() const; void actionsBasedOnSelection( QMenu& contextMenu ); bool show3DWindow() const; bool showPlotWindow() const; bool showPlotWindowOnTop() const; RiaDefines::WindowTileMode subWindowsTileMode3DWindow() const; RiaDefines::WindowTileMode subWindowsTileModePlotWindow() const; void setSubWindowsTileMode3DWindow( RiaDefines::WindowTileMode tileMode ); void setSubWindowsTileModePlotWindow( RiaDefines::WindowTileMode tileMode ); void reloadCompletionTypeResultsInAllViews(); void reloadCompletionTypeResultsForEclipseCase( RimEclipseCase* eclipseCase ); RimDialogData* dialogData() const; std::vector eclipseCases() const; RimEclipseCase* eclipseCaseFromGridFileName( const QString& gridFileName ) const; RimEclipseCase* eclipseCaseFromCaseId( const int caseId ) const; std::vector simulationWellNames() const; RimWellPath* wellPathFromSimWellName( const QString& simWellName, int branchIndex = -1 ); RimWellPath* wellPathByName( const QString& wellPathName ) const; std::vector allWellPaths() const; std::vector textAnnotations() const; std::vector reachCircleAnnotations() const; std::vector polylineAnnotations() const; std::vector geoMechCases() const; std::vector allFractureTemplateCollections() const; std::vector allFractureTemplates() const; std::vector allValveTemplateCollections() const; std::vector allValveTemplates() const; caf::AppEnum commonUnitSystemForAllCases() const; RimMeasurement* measurement() const; RimPlotTemplateFolderItem* rootPlotTemplateItem() const; std::vector allFilePaths() const; protected: void beforeInitAfterRead() override; void initAfterRead() override; void setupBeforeSave() override; void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; private: template static void fieldContentsByType( const caf::PdmObjectHandle* object, std::vector& fieldContents ); void transferPathsToGlobalPathList(); void distributePathsFromGlobalPathList(); private: caf::PdmChildField m_mainPlotCollection; caf::PdmField m_globalPathList; caf::PdmField m_projectFileVersionString; caf::PdmChildField m_dialogData; caf::PdmChildField m_plotTemplateTopFolder; caf::PdmField m_show3DWindow; caf::PdmField m_showPlotWindow; caf::PdmField m_showPlotWindowOnTopOf3DWindow; caf::PdmField m_subWindowsTiled3DWindow_OBSOLETE; caf::PdmField m_subWindowsTiledPlotWindow_OBSOLETE; caf::PdmField> m_subWindowsTileMode3DWindow; caf::PdmField> m_subWindowsTileModePlotWindow; int m_nextValidCaseId; int m_nextValidCaseGroupId; int m_nextValidViewId; int m_nextValidPlotId; int m_nextValidSummaryCaseId; int m_nextValidEnsembleId; caf::PdmChildArrayField casesObsolete; // obsolete caf::PdmChildArrayField caseGroupsObsolete; // obsolete }; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- template void RimProject::fieldContentsByType( const caf::PdmObjectHandle* object, std::vector& fieldContents ) { if ( !object ) return; std::vector allFieldsInObject = object->fields(); std::vector children; for ( const auto& field : allFieldsInObject ) { auto xmlFieldCapability = field->xmlCapability(); if ( xmlFieldCapability && !xmlFieldCapability->isIOWritable() ) continue; caf::PdmField* typedField = dynamic_cast*>( field ); if ( typedField ) fieldContents.push_back( &typedField->v() ); caf::PdmField>* typedFieldInVector = dynamic_cast>*>( field ); if ( typedFieldInVector ) { for ( T& typedFieldFromVector : typedFieldInVector->v() ) { fieldContents.push_back( &typedFieldFromVector ); } } auto other = field->children(); children.insert( children.end(), other.begin(), other.end() ); } for ( const auto& child : children ) { fieldContentsByType( child, fieldContents ); } }