///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2020- 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 // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include "cafPdmNestedCollection.h" #include class RimSurface; class RimEnsembleSurface; class RimCase; class RimSurfaceCollection : public caf::PdmNestedCollection { CAF_PDM_HEADER_INIT; public: RimSurfaceCollection(); ~RimSurfaceCollection() override; // Construct the single top-level surface collection. Marks the instance as the topmost folder // and applies the branded surface icon. Sub-folders use the default folder icon from the // constructor. static RimSurfaceCollection* createTopmost(); void addSurface( RimSurface* surface ); void addEnsembleSurface( RimEnsembleSurface* ensembleSurface ); std::vector ensembleSurfaces() const; // Returns the last imported surface, or an error if no surface could be imported std::expected importSurfacesFromFiles( const QStringList& fileNames, bool showLegend = true ); RimSurface* addGridCaseSurface( RimCase* sourceCase, int oneBasedSliceIndex = 1 ); RimSurface* copySurfaces( std::vector surfaces ); RimSurface* addSurfacesAtIndex( int index, std::vector surfaces ); static RimSurface* createSurfaceFromFile( const QString& fileName ); bool containsFileSurface( QString filename ); bool containsSurface(); void reloadSurfaces( std::vector surfaces, bool showLegend = true ); void removeSurface( RimSurface* surface ); void removeMissingFileSurfaces(); virtual void loadData(); void updateViews(); void updateViews( const std::vector& surfsToReload, bool showLegend = true ); void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; std::vector surfaces() const; // Renames the surface if another surface in this folder already carries the same name. void ensureUniqueSurfaceName( RimSurface* surface ); protected: void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override; // Enforces name uniqueness among sibling folders when the folder is renamed. void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; private: void orderChanged( const caf::SignalEmitter* emitter ); };