Files
ResInsight/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h
T

82 lines
3.1 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmNestedCollection.h"
#include <expected>
class RimSurface;
2021-08-17 13:38:12 +02:00
class RimEnsembleSurface;
2020-05-03 11:29:33 +02:00
class RimCase;
class RimSurfaceCollection : public caf::PdmNestedCollection<RimSurfaceCollection, RimSurface>
{
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<RimEnsembleSurface*> ensembleSurfaces() const;
2021-08-17 13:38:12 +02:00
// Returns the last imported surface, or an error if no surface could be imported
std::expected<RimSurface*, QString> importSurfacesFromFiles( const QStringList& fileNames, bool showLegend = true );
2021-08-17 13:38:12 +02:00
RimSurface* addGridCaseSurface( RimCase* sourceCase, int oneBasedSliceIndex = 1 );
RimSurface* copySurfaces( std::vector<RimSurface*> surfaces );
RimSurface* addSurfacesAtIndex( int index, std::vector<RimSurface*> surfaces );
static RimSurface* createSurfaceFromFile( const QString& fileName );
2021-05-18 14:28:54 +02:00
bool containsFileSurface( QString filename );
2020-09-18 14:43:15 +02:00
bool containsSurface();
void reloadSurfaces( std::vector<RimSurface*> surfaces, bool showLegend = true );
void removeSurface( RimSurface* surface );
2021-05-18 14:28:54 +02:00
void removeMissingFileSurfaces();
2021-09-13 10:16:09 +02:00
virtual void loadData();
void updateViews();
2021-05-18 14:28:54 +02:00
void updateViews( const std::vector<RimSurface*>& surfsToReload, bool showLegend = true );
2023-02-26 10:48:40 +01:00
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& referringObjects ) override;
2020-05-18 16:02:27 +02:00
std::vector<RimSurface*> 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;
2020-01-08 11:56:48 +01:00
private:
void orderChanged( const caf::SignalEmitter* emitter );
};