mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1670 Add cell range UI
This commit is contained in:
parent
15e805fba3
commit
407547d454
@ -5,6 +5,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicExportCarfin.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
|
||||
@ -14,19 +15,21 @@ ${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicExportCarfin.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicCellRangeUi.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
244
ApplicationCode/Commands/ExportCommands/RicCellRangeUi.cpp
Normal file
244
ApplicationCode/Commands/ExportCommands/RicCellRangeUi.cpp
Normal file
@ -0,0 +1,244 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicCellRangeUi.h"
|
||||
|
||||
#include "RifReaderInterface.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigReservoirGridTools.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
#include "RimEclipseCase.h"
|
||||
|
||||
#include "cafPdmUiSliderEditor.h"
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicCellRangeUi, "RicCellRangeUi");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicCellRangeUi::RicCellRangeUi()
|
||||
{
|
||||
CAF_PDM_InitObject("Cell Range", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_gridIndex, "GridIndex", 0, "Grid", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_startIndexI, "StartIndexI", 1, "Start index I", "", "", "");
|
||||
m_startIndexI.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_cellCountI, "CellCountI", 1, "Cell Count I", "", "", "");
|
||||
m_cellCountI.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_startIndexJ, "StartIndexJ", 1, "Start index J", "", "", "");
|
||||
m_startIndexJ.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 1, "Cell Count J", "", "", "");
|
||||
m_cellCountJ.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_startIndexK, "StartIndexK", 1, "Start index K", "", "", "");
|
||||
m_startIndexK.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
|
||||
CAF_PDM_InitField(&m_cellCountK, "CellCountK", 1, "Cell Count K", "", "", "");
|
||||
m_cellCountK.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCellRangeUi::setCase(RimCase* rimCase)
|
||||
{
|
||||
m_case = rimCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCellRangeUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
||||
{
|
||||
caf::PdmUiSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiSliderEditorAttribute*>(attribute);
|
||||
if (!myAttr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
|
||||
|
||||
if (field == &m_startIndexI || field == &m_cellCountI)
|
||||
{
|
||||
myAttr->m_minimum = 1;
|
||||
myAttr->m_maximum = static_cast<int>(grid->cellCountI());
|
||||
}
|
||||
else if (field == &m_startIndexJ || field == &m_cellCountJ)
|
||||
{
|
||||
myAttr->m_minimum = 1;
|
||||
myAttr->m_maximum = static_cast<int>(grid->cellCountJ());
|
||||
}
|
||||
else if (field == &m_startIndexK || field == &m_cellCountK)
|
||||
{
|
||||
myAttr->m_minimum = 1;
|
||||
myAttr->m_maximum = static_cast<int>(grid->cellCountK());
|
||||
}
|
||||
|
||||
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(m_case);
|
||||
RigActiveCellInfo* actCellInfo = activeCellInfo();
|
||||
|
||||
if (grid == mainGrid && actCellInfo)
|
||||
{
|
||||
cvf::Vec3st min, max;
|
||||
actCellInfo->IJKBoundingBox(min, max);
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
min.x() = min.x() + 1;
|
||||
min.y() = min.y() + 1;
|
||||
min.z() = min.z() + 1;
|
||||
|
||||
max.x() = max.x() + 1;
|
||||
max.y() = max.y() + 1;
|
||||
max.z() = max.z() + 1;
|
||||
|
||||
m_startIndexI.uiCapability()->setUiName(QString("I Start (%1)").arg(min.x()));
|
||||
m_startIndexJ.uiCapability()->setUiName(QString("J Start (%1)").arg(min.y()));
|
||||
m_startIndexK.uiCapability()->setUiName(QString("K Start (%1)").arg(min.z()));
|
||||
m_cellCountI.uiCapability()->setUiName( QString(" Width (%1)").arg(max.x() - min.x() + 1));
|
||||
m_cellCountJ.uiCapability()->setUiName( QString(" Width (%1)").arg(max.y() - min.y() + 1));
|
||||
m_cellCountK.uiCapability()->setUiName( QString(" Width (%1)").arg(max.z() - min.z() + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_startIndexI.uiCapability()->setUiName(QString("I Start"));
|
||||
m_startIndexJ.uiCapability()->setUiName(QString("J Start"));
|
||||
m_startIndexK.uiCapability()->setUiName(QString("K Start"));
|
||||
m_cellCountI.uiCapability()->setUiName( QString(" Width"));
|
||||
m_cellCountJ.uiCapability()->setUiName( QString(" Width"));
|
||||
m_cellCountK.uiCapability()->setUiName( QString(" Width"));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RicCellRangeUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if (useOptionsOnly) (*useOptionsOnly) = true;
|
||||
|
||||
if (&m_gridIndex == fieldNeedingOptions)
|
||||
{
|
||||
for (int gIdx = 0; gIdx < RigReservoirGridTools::gridCount(m_case); ++gIdx)
|
||||
{
|
||||
QString gridName;
|
||||
|
||||
gridName += RigReservoirGridTools::gridName(m_case, gIdx);
|
||||
if (gIdx == 0)
|
||||
{
|
||||
if (gridName.isEmpty())
|
||||
gridName += "Main Grid";
|
||||
else
|
||||
gridName += " (Main Grid)";
|
||||
}
|
||||
|
||||
caf::PdmOptionItemInfo item(gridName, (int)gIdx);
|
||||
options.push_back(item);
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCellRangeUi::clampValues()
|
||||
{
|
||||
if (!m_case) return;
|
||||
|
||||
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
|
||||
if (grid)
|
||||
{
|
||||
m_cellCountI = cvf::Math::clamp(m_cellCountI.v(), 1, static_cast<int>(grid->cellCountI()));
|
||||
m_startIndexI = cvf::Math::clamp(m_startIndexI.v(), 1, static_cast<int>(grid->cellCountI()));
|
||||
|
||||
m_cellCountJ = cvf::Math::clamp(m_cellCountJ.v(), 1, static_cast<int>(grid->cellCountJ()));
|
||||
m_startIndexJ = cvf::Math::clamp(m_startIndexJ.v(), 1, static_cast<int>(grid->cellCountJ()));
|
||||
|
||||
m_cellCountK = cvf::Math::clamp(m_cellCountK.v(), 1, static_cast<int>(grid->cellCountK()));
|
||||
m_startIndexK = cvf::Math::clamp(m_startIndexK.v(), 1, static_cast<int>(grid->cellCountK()));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCellRangeUi::setDefaultValues()
|
||||
{
|
||||
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
|
||||
|
||||
RigActiveCellInfo* actCellInfo = this->activeCellInfo();
|
||||
|
||||
const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(m_case);
|
||||
|
||||
if (grid == mainGrid && actCellInfo)
|
||||
{
|
||||
cvf::Vec3st min, max;
|
||||
actCellInfo->IJKBoundingBox(min, max);
|
||||
|
||||
// Adjust to Eclipse indexing
|
||||
min.x() = min.x() + 1;
|
||||
min.y() = min.y() + 1;
|
||||
min.z() = min.z() + 1;
|
||||
|
||||
max.x() = max.x() + 1;
|
||||
max.y() = max.y() + 1;
|
||||
max.z() = max.z() + 1;
|
||||
|
||||
m_startIndexI = static_cast<int>(min.x());
|
||||
m_startIndexJ = static_cast<int>(min.y());
|
||||
m_startIndexK = static_cast<int>(min.z());
|
||||
m_cellCountI = static_cast<int>(max.x() - min.x() + 1);
|
||||
m_cellCountJ = static_cast<int>(max.y() - min.y() + 1);
|
||||
m_cellCountK = static_cast<int>(max.z() - min.z() + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_startIndexI = 1;
|
||||
m_startIndexJ = 1;
|
||||
m_startIndexK = 1;
|
||||
m_cellCountI = static_cast<int>(grid->cellCountI());
|
||||
m_cellCountJ = static_cast<int>(grid->cellCountJ());
|
||||
m_cellCountK = static_cast<int>(grid->cellCountK());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigActiveCellInfo* RicCellRangeUi::activeCellInfo() const
|
||||
{
|
||||
RimEclipseCase* rimEclipeCase = dynamic_cast<RimEclipseCase*>(m_case.p());
|
||||
if (rimEclipeCase)
|
||||
{
|
||||
return rimEclipeCase->eclipseCaseData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
58
ApplicationCode/Commands/ExportCommands/RicCellRangeUi.h
Normal file
58
ApplicationCode/Commands/ExportCommands/RicCellRangeUi.h
Normal file
@ -0,0 +1,58 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
class RimCase;
|
||||
class RigActiveCellInfo;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCellRangeUi : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RicCellRangeUi();
|
||||
|
||||
void setCase(RimCase* rimCase);
|
||||
|
||||
private:
|
||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
|
||||
void clampValues();
|
||||
void setDefaultValues();
|
||||
RigActiveCellInfo* activeCellInfo() const;
|
||||
|
||||
private:
|
||||
caf::PdmPointer<RimCase> m_case;
|
||||
|
||||
caf::PdmField<int> m_gridIndex;
|
||||
|
||||
caf::PdmField<int> m_startIndexI; // Eclipse indexing, first index is 1
|
||||
caf::PdmField<int> m_startIndexJ; // Eclipse indexing, first index is 1
|
||||
caf::PdmField<int> m_startIndexK; // Eclipse indexing, first index is 1
|
||||
caf::PdmField<int> m_cellCountI;
|
||||
caf::PdmField<int> m_cellCountJ;
|
||||
caf::PdmField<int> m_cellCountK;
|
||||
};
|
73
ApplicationCode/Commands/ExportCommands/RicExportCarfin.cpp
Normal file
73
ApplicationCode/Commands/ExportCommands/RicExportCarfin.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicExportCarfin.h"
|
||||
|
||||
#include "RimCase.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicExportCarfin::isCommandEnabled()
|
||||
{
|
||||
if (RicExportCarfin::selectedCase() != nullptr)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportCarfin::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimCase* rimCase = RicExportCarfin::selectedCase();
|
||||
CVF_ASSERT(rimCase);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportCarfin::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Export CARFIN ...");
|
||||
actionToSetup->setIcon(QIcon(":/Save.png"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimCase* RicExportCarfin::selectedCase()
|
||||
{
|
||||
std::vector<RimCase*> selectedObjects;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedObjects);
|
||||
|
||||
if (selectedObjects.size() == 1)
|
||||
{
|
||||
return selectedObjects[0];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
42
ApplicationCode/Commands/ExportCommands/RicExportCarfin.h
Normal file
42
ApplicationCode/Commands/ExportCommands/RicExportCarfin.h
Normal file
@ -0,0 +1,42 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "cafCmdFeature.h"
|
||||
|
||||
class RimCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicExportCarfin : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
static RimCase* selectedCase();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user