mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-05 21:53:27 -06:00
#3517 Temp LGR. Add nodes below Grids node. Command for deleting temp LGRs
This commit is contained in:
parent
08776a09b3
commit
608dae30a0
@ -73,6 +73,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.h
|
||||
)
|
||||
|
||||
|
||||
@ -143,6 +144,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.cpp
|
||||
)
|
||||
|
||||
|
||||
|
63
ApplicationCode/Commands/RicDeleteTemporaryLgrsFeature.cpp
Normal file
63
ApplicationCode/Commands/RicDeleteTemporaryLgrsFeature.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicDeleteTemporaryLgrsFeature.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimGridCollection.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafSelectionManagerTools.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicDeleteTemporaryLgrsFeature, "RicDeleteTemporaryLgrsFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteTemporaryLgrsFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>();
|
||||
return selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::TEMPORARY_LGR_UI_NAME;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteTemporaryLgrsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
std::vector<RimGridInfoCollection*> selGridInfos = caf::selectedObjectsByTypeStrict<RimGridInfoCollection*>();
|
||||
if (selGridInfos.size() == 1 && selGridInfos.front()->uiName() == RimGridCollection::TEMPORARY_LGR_UI_NAME)
|
||||
{
|
||||
RimEclipseCase* eclipseCase;
|
||||
selGridInfos.front()->firstAncestorOrThisOfType(eclipseCase);
|
||||
|
||||
if (eclipseCase) eclipseCase->reloadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteTemporaryLgrsFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Delete Temporary LGRs");
|
||||
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
||||
}
|
32
ApplicationCode/Commands/RicDeleteTemporaryLgrsFeature.h
Normal file
32
ApplicationCode/Commands/RicDeleteTemporaryLgrsFeature.h
Normal file
@ -0,0 +1,32 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- 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 "cafCmdFeature.h"
|
||||
|
||||
class RicDeleteTemporaryLgrsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered(bool isChecked) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
};
|
@ -64,7 +64,7 @@ RimCellRangeFilter* RicRangeFilterExecImpl::createRangeFilter()
|
||||
|
||||
size_t flterIndex = m_cellRangeFilterCollection->rangeFilters().size() + 1;
|
||||
|
||||
rangeFilter->gridIndex = m_gridIndex;
|
||||
rangeFilter->setGridIndex(m_gridIndex);
|
||||
|
||||
rangeFilter->name = QString("New Filter (%1)").arg(flterIndex);
|
||||
|
||||
@ -91,7 +91,7 @@ RimCellRangeFilter* RicRangeFilterExecImpl::createRangeFilter()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicRangeFilterExecImpl::applyCommandDataOnFilter(RimCellRangeFilter* rangeFilter)
|
||||
{
|
||||
rangeFilter->gridIndex = m_gridIndex;
|
||||
rangeFilter->setGridIndex(m_gridIndex);
|
||||
if (m_iSlice)
|
||||
{
|
||||
rangeFilter->cellCountI = 1;
|
||||
|
@ -43,7 +43,7 @@ RimCellRangeFilter::RimCellRangeFilter()
|
||||
{
|
||||
CAF_PDM_InitObject("Cell Range Filter", ":/CellFilter_Range.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&gridIndex, "GridIndex", 0, "Grid", "", "","");
|
||||
CAF_PDM_InitField(&m_gridIndex, "GridIndex", 0, "Grid", "", "","");
|
||||
CAF_PDM_InitField(&propagateToSubGrids, "PropagateToSubGrids", true, "Apply to Subgrids", "", "","");
|
||||
|
||||
CAF_PDM_InitField(&startIndexI, "StartIndexI", 1, "Start Index I", "", "","");
|
||||
@ -77,12 +77,28 @@ RimCellRangeFilter::~RimCellRangeFilter()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellRangeFilter::setGridIndex(int gridIndex)
|
||||
{
|
||||
m_gridIndex = gridIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimCellRangeFilter::gridIndex() const
|
||||
{
|
||||
return m_gridIndex;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellRangeFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &gridIndex)
|
||||
if (changedField == &m_gridIndex)
|
||||
{
|
||||
const cvf::StructGridInterface* grid = selectedGrid();
|
||||
|
||||
@ -306,7 +322,7 @@ void RimCellRangeFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi
|
||||
|
||||
uiOrdering.add(&name);
|
||||
uiOrdering.add(&filterMode);
|
||||
uiOrdering.add(&gridIndex);
|
||||
uiOrdering.add(&m_gridIndex);
|
||||
uiOrdering.add(&propagateToSubGrids);
|
||||
uiOrdering.add(&startIndexI);
|
||||
uiOrdering.add(&cellCountI);
|
||||
@ -346,7 +362,7 @@ QList<caf::PdmOptionItemInfo> RimCellRangeFilter::calculateValueOptions(const ca
|
||||
|
||||
if (useOptionsOnly) (*useOptionsOnly) = true;
|
||||
|
||||
if (&gridIndex == fieldNeedingOptions)
|
||||
if (&m_gridIndex == fieldNeedingOptions)
|
||||
{
|
||||
RimCase* rimCase = nullptr;
|
||||
this->firstAncestorOrThisOfTypeAsserted(rimCase);
|
||||
|
@ -46,7 +46,13 @@ public:
|
||||
RimCellRangeFilter();
|
||||
~RimCellRangeFilter() override;
|
||||
|
||||
caf::PdmField<int> gridIndex; // The index of the grid that this filter applies to
|
||||
void setGridIndex(int gridIndex);
|
||||
int gridIndex() const;
|
||||
|
||||
private:
|
||||
caf::PdmField<int> m_gridIndex; // The index of the grid that this filter applies to
|
||||
|
||||
public:
|
||||
caf::PdmField<bool> propagateToSubGrids; // Do propagate the effects to the sub-grids
|
||||
|
||||
caf::PdmField<int> startIndexI; // Eclipse indexing, first index is 1
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimGridCollection.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimIntersection.h"
|
||||
#include "RimIntersectionBox.h"
|
||||
@ -183,6 +184,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicCopyReferencesToClipboardFeature";
|
||||
menuBuilder << "Separator";
|
||||
}
|
||||
else if (dynamic_cast<RimGridInfoCollection*>(uiItem))
|
||||
{
|
||||
menuBuilder << "RicDeleteTemporaryLgrsFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimGeoMechCase*>(uiItem))
|
||||
{
|
||||
menuBuilder << "RicPasteGeoMechViewsFeature";
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
#include "RimFlowPlotCollection.h"
|
||||
#include "RimFormationNames.h"
|
||||
#include "RimGridCollection.h"
|
||||
#include "RimIntersectionCollection.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
@ -809,6 +810,17 @@ bool RimEclipseCase::openReserviorCase()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update grids node
|
||||
{
|
||||
std::vector<RimGridCollection*> gridColls;
|
||||
descendantsIncludingThisOfType(gridColls);
|
||||
if (!gridColls.empty())
|
||||
{
|
||||
gridColls.front()->syncFromMainGrid();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,217 @@
|
||||
|
||||
#include "RimGridCollection.h"
|
||||
#include "RimGridView.h"
|
||||
#include "RimEclipseCase.h"
|
||||
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
#include <cafPdmUiTreeOrdering.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void removeGridInfo(const QString& gridName, std::vector<RimGridInfo*>& collection)
|
||||
{
|
||||
for (size_t i = 0; i < collection.size(); i++)
|
||||
{
|
||||
if (collection[i]->name() == gridName)
|
||||
{
|
||||
collection.erase(collection.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGridInfo, "GridInfo");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridInfo::RimGridInfo()
|
||||
{
|
||||
CAF_PDM_InitObject("GridInfo", ":/draw_style_meshlines_24x24.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_isActive, "IsActive", true, "Show Grid Cells", "", "", "");
|
||||
CAF_PDM_InitField(&m_gridName, "GridName", QString(), "Grid Name", "", "", "");
|
||||
CAF_PDM_InitField(&m_gridIndex, "GridIndex", 0, "Grid Index", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimGridInfo::objectToggleField()
|
||||
{
|
||||
return nullptr; // &m_isActive;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfo::setActive(bool active)
|
||||
{
|
||||
m_isActive = active;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfo::setName(const QString& name)
|
||||
{
|
||||
m_gridName = name;
|
||||
setUiName(name);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfo::setIndex(int index)
|
||||
{
|
||||
m_gridIndex = index;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimGridInfo::name() const
|
||||
{
|
||||
return m_gridName();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGridInfo::index() const
|
||||
{
|
||||
return m_gridIndex();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimGridInfo::userDescriptionField()
|
||||
{
|
||||
return &m_gridName;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfo::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGridInfoCollection, "GridInfoCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGridInfoCollection::RimGridInfoCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("GridInfoCollection", ":/draw_style_meshlines_24x24.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_isActive, "IsActive", true, "Show Grid Cells", "", "", "");
|
||||
m_isActive.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_gridInfos, "GridInfos", "Grid Infos", "", "", "");
|
||||
|
||||
m_gridInfos.uiCapability()->setUiTreeHidden(true);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfoCollection::addGridInfo(const QString& name, size_t gridIndex)
|
||||
{
|
||||
auto gridInfo = new RimGridInfo();
|
||||
gridInfo->setActive(true);
|
||||
gridInfo->setName(name);
|
||||
gridInfo->setIndex((int)gridIndex);
|
||||
m_gridInfos.push_back(gridInfo);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfoCollection::clear()
|
||||
{
|
||||
m_gridInfos.deleteAllChildObjects();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridInfoCollection::containsGrid(const QString& gridName) const
|
||||
{
|
||||
for (auto gridInfo : m_gridInfos)
|
||||
{
|
||||
if (gridInfo->name() == gridName) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfoCollection::deleteGridInfo(const QString& gridName)
|
||||
{
|
||||
for (size_t i = 0; i < m_gridInfos.size(); i++)
|
||||
{
|
||||
auto gridInfo = m_gridInfos[i];
|
||||
if (gridInfo->name() == gridName)
|
||||
{
|
||||
m_gridInfos.erase(i);
|
||||
delete gridInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimGridInfo*> RimGridInfoCollection::gridInfos() const
|
||||
{
|
||||
std::vector<RimGridInfo*> list;
|
||||
for (size_t i = 0; i < m_gridInfos.size(); i++)
|
||||
{
|
||||
list.push_back(m_gridInfos[i]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimGridInfoCollection::objectToggleField()
|
||||
{
|
||||
return nullptr;// &m_isActive;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridInfoCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue)
|
||||
{
|
||||
}
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimGridCollection, "GridCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const QString RimGridCollection::PERSISTENT_LGR_UI_NAME = "Persistent LGRs";
|
||||
const QString RimGridCollection::TEMPORARY_LGR_UI_NAME = "Temporary LGRs";
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -30,8 +237,21 @@ RimGridCollection::RimGridCollection()
|
||||
{
|
||||
CAF_PDM_InitObject("Grids", ":/draw_style_meshlines_24x24.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&isActive, "IsActive", true, "Show Grid Cells", "", "", "");
|
||||
isActive.uiCapability()->setUiHidden(true);
|
||||
CAF_PDM_InitField(&m_isActive, "IsActive", true, "Show Grid Cells", "", "", "");
|
||||
m_isActive.uiCapability()->setUiHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_mainGrid, "MainGrid", "Main Grid", "", "", "");
|
||||
m_mainGrid = new RimGridInfo();
|
||||
m_mainGrid->setUiName("Main Grid");
|
||||
m_mainGrid->uiCapability()->setUiTreeHidden(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_persistentLgrs, "PersistentLgrs", "Persistent LGRs", "", "", "");
|
||||
m_persistentLgrs = new RimGridInfoCollection();
|
||||
m_persistentLgrs->setUiName(PERSISTENT_LGR_UI_NAME);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_temporaryLgrs, "TemporaryLgrs", "Temporary LGRs", "", "", "");
|
||||
m_temporaryLgrs = new RimGridInfoCollection();
|
||||
m_temporaryLgrs->setUiName(TEMPORARY_LGR_UI_NAME);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -42,12 +262,89 @@ RimGridCollection::~RimGridCollection()
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCollection::setActive(bool active)
|
||||
{
|
||||
m_isActive = active;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGridCollection::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmFieldHandle* RimGridCollection::objectToggleField()
|
||||
{
|
||||
return &isActive;
|
||||
return &m_isActive;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCollection::syncFromMainGrid()
|
||||
{
|
||||
auto mainGrid = this->mainGrid();
|
||||
if (mainGrid)
|
||||
{
|
||||
m_mainGrid->setName("Main Grid");
|
||||
m_mainGrid->setIndex(0);
|
||||
|
||||
auto allTemporaryGrids = m_temporaryLgrs->gridInfos();
|
||||
auto allPersistentGrids = m_persistentLgrs->gridInfos();
|
||||
|
||||
size_t gridCount = mainGrid->gridCount();
|
||||
for (size_t i = 1; i < gridCount; i++)
|
||||
{
|
||||
auto grid = mainGrid->gridByIndex(i);
|
||||
QString gridName = QString::fromStdString(grid->gridName());
|
||||
size_t gridIndex = grid->gridIndex();
|
||||
|
||||
if (grid->isTempGrid())
|
||||
{
|
||||
if (m_temporaryLgrs->containsGrid(gridName))
|
||||
{
|
||||
removeGridInfo(gridName, allTemporaryGrids);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_temporaryLgrs->addGridInfo(gridName, gridIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_persistentLgrs->containsGrid(gridName))
|
||||
{
|
||||
removeGridInfo(gridName, allPersistentGrids);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_persistentLgrs->addGridInfo(gridName, gridIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (!allPersistentGrids.empty())
|
||||
{
|
||||
auto gridName = allPersistentGrids.front()->name();
|
||||
m_persistentLgrs->deleteGridInfo(gridName);
|
||||
removeGridInfo(gridName, allPersistentGrids);
|
||||
}
|
||||
while (!allTemporaryGrids.empty())
|
||||
{
|
||||
auto gridName = allTemporaryGrids.front()->name();
|
||||
m_temporaryLgrs->deleteGridInfo(allTemporaryGrids.front()->name());
|
||||
removeGridInfo(gridName, allTemporaryGrids);
|
||||
}
|
||||
}
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -55,15 +352,15 @@ caf::PdmFieldHandle* RimGridCollection::objectToggleField()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &isActive)
|
||||
if (changedField == &m_isActive)
|
||||
{
|
||||
RimGridView* rimView = nullptr;
|
||||
this->firstAncestorOrThisOfType(rimView);
|
||||
CVF_ASSERT(rimView);
|
||||
|
||||
if (rimView) rimView->showGridCells(isActive);
|
||||
if (rimView) rimView->showGridCells(m_isActive);
|
||||
|
||||
updateUiIconFromState(isActive);
|
||||
updateUiIconFromState(m_isActive);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,5 +369,26 @@ void RimGridCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCollection::initAfterRead()
|
||||
{
|
||||
updateUiIconFromState(isActive);
|
||||
updateUiIconFromState(m_isActive);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
||||
{
|
||||
uiTreeOrdering.add(m_mainGrid());
|
||||
uiTreeOrdering.add(m_persistentLgrs());
|
||||
uiTreeOrdering.add(m_temporaryLgrs());
|
||||
uiTreeOrdering.skipRemainingChildren(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigMainGrid* RimGridCollection::mainGrid() const
|
||||
{
|
||||
RimEclipseCase* eclipseCase;
|
||||
firstAncestorOrThisOfType(eclipseCase);
|
||||
return eclipseCase ? eclipseCase->mainGrid() : nullptr;
|
||||
}
|
||||
|
@ -21,7 +21,68 @@
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RigMainGrid;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimGridInfo : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimGridInfo();
|
||||
~RimGridInfo() {}
|
||||
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
|
||||
void setActive(bool active);
|
||||
void setName(const QString& name);
|
||||
void setIndex(int index);
|
||||
|
||||
QString name() const;
|
||||
int index() const;
|
||||
|
||||
protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_isActive;
|
||||
caf::PdmField<QString> m_gridName;
|
||||
caf::PdmField<int> m_gridIndex;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimGridInfoCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimGridInfoCollection();
|
||||
~RimGridInfoCollection() {}
|
||||
|
||||
void addGridInfo(const QString& name, size_t gridIndex);
|
||||
void clear();
|
||||
bool containsGrid(const QString& gridName) const;
|
||||
void deleteGridInfo(const QString& gridName);
|
||||
std::vector<RimGridInfo*> gridInfos() const;
|
||||
|
||||
protected:
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<bool> m_isActive;
|
||||
caf::PdmChildArrayField<RimGridInfo*> m_gridInfos;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -31,15 +92,27 @@ class RimGridCollection : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
public:
|
||||
static const QString PERSISTENT_LGR_UI_NAME;
|
||||
static const QString TEMPORARY_LGR_UI_NAME;
|
||||
|
||||
RimGridCollection();
|
||||
~RimGridCollection() override;
|
||||
|
||||
void setActive(bool active);
|
||||
bool isActive() const;
|
||||
caf::PdmFieldHandle* objectToggleField() override;
|
||||
|
||||
caf::PdmField<bool> isActive;
|
||||
void syncFromMainGrid();
|
||||
|
||||
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* mainGrid() const;
|
||||
|
||||
caf::PdmField<bool> m_isActive;
|
||||
caf::PdmChildField<RimGridInfo*> m_mainGrid;
|
||||
caf::PdmChildField<RimGridInfoCollection*> m_persistentLgrs;
|
||||
caf::PdmChildField<RimGridInfoCollection*> m_temporaryLgrs;
|
||||
};
|
||||
|
@ -114,7 +114,7 @@ RimGridView::~RimGridView(void)
|
||||
void RimGridView::showGridCells(bool enableGridCells)
|
||||
{
|
||||
|
||||
m_gridCollection->isActive = enableGridCells;
|
||||
m_gridCollection->setActive(enableGridCells);
|
||||
|
||||
createDisplayModel();
|
||||
updateDisplayModelVisibility();
|
||||
@ -299,7 +299,7 @@ void RimGridView::initAfterRead()
|
||||
|
||||
bool isGridVisualizationModeBefore_2018_1_1 = ((surfaceMode() == RimGridView::SURFACE) || (meshMode() == RimGridView::FULL_MESH));
|
||||
|
||||
m_gridCollection->isActive = isGridVisualizationModeBefore_2018_1_1;
|
||||
m_gridCollection->setActive(isGridVisualizationModeBefore_2018_1_1);
|
||||
if (!isGridVisualizationModeBefore_2018_1_1)
|
||||
{
|
||||
// Was showing faults and intersections.
|
||||
|
Loading…
Reference in New Issue
Block a user