ResInsight/ApplicationLibCode/ProjectDataModel/RimGridCollection.h
Magne Sjaastad f8c5cf389f
clang-format: Set column width to 140
* Set column width to 140
* Use c++20
* Remove redundant virtual
2023-02-26 10:48:40 +01:00

127 lines
4.4 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
class RigMainGrid;
//==================================================================================================
///
//==================================================================================================
class RimGridInfo : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimGridInfo();
~RimGridInfo() override {}
void setName( const QString& name );
void setEclipseGridIndex( int index );
void setActive( bool active );
bool isActive() const;
QString name() const;
int eclipseGridIndex() const;
caf::PdmFieldHandle* objectToggleField() override;
protected:
caf::PdmFieldHandle* userDescriptionField() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
private:
caf::PdmField<bool> m_isActive;
caf::PdmField<QString> m_gridName;
caf::PdmField<int> m_eclipseGridIndex;
};
//==================================================================================================
///
//==================================================================================================
class RimGridInfoCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimGridInfoCollection();
~RimGridInfoCollection() override {}
bool isActive() const;
void addGridInfo( RimGridInfo* gridInfo );
void clear();
bool containsGrid( const QString& gridName ) const;
void deleteGridInfo( const QString& gridName );
std::vector<RimGridInfo*> gridInfos() const;
caf::PdmFieldHandle* objectToggleField() override;
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
private:
caf::PdmField<bool> m_isActive;
caf::PdmChildArrayField<RimGridInfo*> m_gridInfos;
};
//==================================================================================================
///
///
//==================================================================================================
class RimGridCollection : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimGridCollection();
~RimGridCollection() override;
void setActive( bool active );
bool isActive() const;
std::vector<size_t> indicesToVisibleGrids() const;
caf::PdmFieldHandle* objectToggleField() override;
void syncFromMainEclipseGrid();
void setMainGridActive( bool active );
static const QString persistentGridUiName();
static const QString temporaryGridUiName();
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void initAfterRead() override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
private:
const RigMainGrid* mainEclipseGrid() const;
bool hasPersistentLgrs() const;
bool hasTemporaryLgrs() const;
caf::PdmField<bool> m_isActive;
caf::PdmChildField<RimGridInfo*> m_mainGrid;
caf::PdmChildField<RimGridInfoCollection*> m_persistentLgrs;
caf::PdmChildField<RimGridInfoCollection*> m_temporaryLgrs;
};