#1670 Add command feature "Export CARFIN"

This commit is contained in:
Magne Sjaastad 2017-06-29 22:36:51 +02:00
parent ec990b5e2c
commit b2b4ab95ba
11 changed files with 488 additions and 86 deletions

View File

@ -30,6 +30,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h
${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h
# General delete of any object in a child array field
@ -67,6 +68,7 @@ ${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.cpp
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.cpp
# General delete of any object in a child array field

View File

@ -6,12 +6,12 @@ endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicExportCarfin.h
${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h
${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.h
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h
@ -20,12 +20,12 @@ ${CEE_CURRENT_LIST_DIR}RicCellRangeUi.h
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicExportCarfin.cpp
${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.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

View File

@ -18,6 +18,8 @@
#include "RicCellRangeUi.h"
#include "RicExportCarfinUi.h"
#include "RifReaderInterface.h"
#include "RigActiveCellInfo.h"
@ -44,22 +46,19 @@ RicCellRangeUi::RicCellRangeUi()
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_cellCountI, "CellCountI", 1, "Cell Count I", "", "", "");
CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 1, "Cell Count J", "", "", "");
CAF_PDM_InitField(&m_cellCountK, "CellCountK", 1, "Cell Count K", "", "", "");
m_cellCountK.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
m_startIndexI.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
m_startIndexJ.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
m_startIndexK.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName());
m_cellCountI.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName());
m_cellCountJ.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName());
m_cellCountK.uiCapability()->setUiEditorTypeName( caf::PdmUiSliderEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------
@ -68,6 +67,34 @@ RicCellRangeUi::RicCellRangeUi()
void RicCellRangeUi::setCase(RimCase* rimCase)
{
m_case = rimCase;
setDefaultValues();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::VecIjk RicCellRangeUi::start() const
{
return caf::VecIjk{m_startIndexI, m_startIndexJ, m_startIndexK};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::VecIjk RicCellRangeUi::count() const
{
return caf::VecIjk{ m_cellCountI, m_cellCountJ, m_cellCountK };
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicCellRangeUi::gridName() const
{
if (m_gridIndex() == 0) return "";
return RigReservoirGridTools::gridName(m_case, m_gridIndex());
}
//--------------------------------------------------------------------------------------------------
@ -82,55 +109,23 @@ void RicCellRangeUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt
}
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
if (field == &m_startIndexI || field == &m_cellCountI)
if (grid)
{
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"));
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());
}
}
}
@ -165,6 +160,27 @@ QList<caf::PdmOptionItemInfo> RicCellRangeUi::calculateValueOptions(const caf::P
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
clampValues();
if (changedField == &m_gridIndex)
{
updateLegendText();
}
// If this object is contained in another object, make sure the other object is updated
RicExportCarfinUi* exportCarfin = nullptr;
this->firstAncestorOrThisOfType(exportCarfin);
if (exportCarfin)
{
exportCarfin->uiCapability()->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -173,17 +189,16 @@ 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()));
if (!grid) return;
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_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_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()));
}
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()));
}
//--------------------------------------------------------------------------------------------------
@ -192,6 +207,7 @@ void RicCellRangeUi::clampValues()
void RicCellRangeUi::setDefaultValues()
{
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
if (!grid) return;
RigActiveCellInfo* actCellInfo = this->activeCellInfo();
@ -235,10 +251,70 @@ void RicCellRangeUi::setDefaultValues()
RigActiveCellInfo* RicCellRangeUi::activeCellInfo() const
{
RimEclipseCase* rimEclipeCase = dynamic_cast<RimEclipseCase*>(m_case.p());
if (rimEclipeCase)
if (rimEclipeCase && rimEclipeCase->eclipseCaseData())
{
return rimEclipeCase->eclipseCaseData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::updateLegendText()
{
const cvf::StructGridInterface* grid = RigReservoirGridTools::gridByIndex(m_case, m_gridIndex());
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"));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCellRangeUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_gridIndex);
uiOrdering.add(&m_startIndexI);
uiOrdering.add(&m_cellCountI);
uiOrdering.add(&m_startIndexJ);
uiOrdering.add(&m_cellCountJ);
uiOrdering.add(&m_startIndexK);
uiOrdering.add(&m_cellCountK);
updateLegendText();
}

View File

@ -20,10 +20,12 @@
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafVecIjk.h"
class RimCase;
class RigActiveCellInfo;
//==================================================================================================
///
//==================================================================================================
@ -36,13 +38,22 @@ public:
void setCase(RimCase* rimCase);
caf::VecIjk start() const;
caf::VecIjk count() const;
QString gridName() const;
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;
// PDM overrides
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;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void clampValues();
void setDefaultValues();
RigActiveCellInfo* activeCellInfo() const;
void updateLegendText();
private:
caf::PdmPointer<RimCase> m_case;

View File

@ -18,11 +18,23 @@
#include "RicExportCarfin.h"
#include "RimCase.h"
#include "RiaLogging.h"
#include "RicCellRangeUi.h"
#include "RicExportCarfinUi.h"
#include "RicExportFeatureImpl.h"
#include "RifEclipseDataTableFormatter.h"
#include "RimEclipseCase.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFile>
CAF_CMD_SOURCE_INIT(RicExportCarfin, "RicExportCarfin");
//--------------------------------------------------------------------------------------------------
///
@ -42,9 +54,68 @@ bool RicExportCarfin::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicExportCarfin::onActionTriggered(bool isChecked)
{
RimCase* rimCase = RicExportCarfin::selectedCase();
RimEclipseCase* rimCase = RicExportCarfin::selectedCase();
CVF_ASSERT(rimCase);
RicExportCarfinUi carfinUi;
carfinUi.setCase(rimCase);
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &carfinUi, "Export CARFIN to Eclipse Data", "");
RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted)
{
QString filePath = carfinUi.exportFileName();
QFile exportFile(filePath);
if (!exportFile.open(QIODevice::WriteOnly))
{
RiaLogging::error(QString("Export CARFIN: Could not open the file: %1").arg(filePath));
return;
}
QTextStream stream(&exportFile);
RifEclipseDataTableFormatter formatter(stream);
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("I1"),
RifEclipseOutputTableColumn("I2"),
RifEclipseOutputTableColumn("J1"),
RifEclipseOutputTableColumn("J2"),
RifEclipseOutputTableColumn("K1"),
RifEclipseOutputTableColumn("K2"),
RifEclipseOutputTableColumn("NX"),
RifEclipseOutputTableColumn("NY"),
RifEclipseOutputTableColumn("NZ"),
RifEclipseOutputTableColumn("NWMAX"),
RifEclipseOutputTableColumn("Parent LGR")
};
formatter.keyword("CARFIN");
formatter.header(header);
formatter.add(carfinUi.cellRange()->start().i());
formatter.add(carfinUi.cellRange()->start().i() + carfinUi.cellRange()->count().i());
formatter.add(carfinUi.cellRange()->start().j());
formatter.add(carfinUi.cellRange()->start().j() + carfinUi.cellRange()->count().j());
formatter.add(carfinUi.cellRange()->start().k());
formatter.add(carfinUi.cellRange()->start().k() + carfinUi.cellRange()->count().k());
formatter.add(carfinUi.lgrCellCount().i());
formatter.add(carfinUi.lgrCellCount().j());
formatter.add(carfinUi.lgrCellCount().k());
formatter.add(carfinUi.maxWellCount());
if (!carfinUi.gridName().isEmpty())
{
formatter.add(carfinUi.gridName());
}
formatter.rowCompleted();
formatter.tableCompleted();
}
}
//--------------------------------------------------------------------------------------------------
@ -59,9 +130,9 @@ void RicExportCarfin::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimCase* RicExportCarfin::selectedCase()
RimEclipseCase* RicExportCarfin::selectedCase()
{
std::vector<RimCase*> selectedObjects;
std::vector<RimEclipseCase*> selectedObjects;
caf::SelectionManager::instance()->objectsByType(&selectedObjects);
if (selectedObjects.size() == 1)

View File

@ -20,7 +20,7 @@
#include "cafCmdFeature.h"
class RimCase;
class RimEclipseCase;
//==================================================================================================
///
@ -31,12 +31,10 @@ class RicExportCarfin : public caf::CmdFeature
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static RimCase* selectedCase();
static RimEclipseCase* selectedCase();
};

View File

@ -0,0 +1,175 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicExportCarfinUi.h"
#include "RicCellRangeUi.h"
#include "RimEclipseCase.h"
#include "RimTools.h"
#include "cafPdmUiFilePathEditor.h"
#include "cafVecIjk.h"
CAF_PDM_SOURCE_INIT(RicExportCarfinUi, "RicExportCarfinUi");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicExportCarfinUi::RicExportCarfinUi()
{
CAF_PDM_InitObject("Export CARFIN", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellRange, "CellRange", "CellRange", "", "", "");
m_cellRange = new RicCellRangeUi;
CAF_PDM_InitFieldNoDefault(&m_exportFileName, "ExportFileName", "Export FileName", "", "", "");
m_exportFileName.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_caseToApply, "CaseToApply", "Source Case", "", "", "");
CAF_PDM_InitField(&m_cellCountI, "CellCountI", 2, "Cell Count I", "", "", "");
CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 2, "Cell Count J", "", "", "");
CAF_PDM_InitField(&m_cellCountK, "CellCountK", 2, "Cell Count K", "", "", "");
CAF_PDM_InitField(&m_maxWellCount, "MaxWellCount", 8, "Max Well Count", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::setCase(RimEclipseCase* rimCase)
{
m_caseToApply = rimCase;
m_cellRange->setCase(rimCase);
if (rimCase)
{
QString caseFolder = rimCase->locationOnDisc();
m_exportFileName = caseFolder + "/carfin.data";
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RicExportCarfinUi::maxWellCount() const
{
return m_maxWellCount();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::VecIjk RicExportCarfinUi::lgrCellCount() const
{
return caf::VecIjk{m_cellCountI, m_cellCountJ, m_cellCountK};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RicCellRangeUi* RicExportCarfinUi::cellRange() const
{
return m_cellRange();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportCarfinUi::exportFileName() const
{
return m_exportFileName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RicExportCarfinUi::caseToApply() const
{
return m_caseToApply();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicExportCarfinUi::gridName() const
{
return m_cellRange->gridName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RicExportCarfinUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_caseToApply)
{
RimTools::caseOptionItems(&options);
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (changedField == &m_caseToApply)
{
setCase(m_caseToApply);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_exportFileName);
uiOrdering.add(&m_caseToApply);
caf::PdmUiGroup* sourceGridBox = uiOrdering.addNewGroup("Source Grid Box");
m_cellRange->uiOrdering(uiConfigName, *sourceGridBox);
caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup("Grid Refinement");
gridRefinement->add(&m_cellCountI);
gridRefinement->add(&m_cellCountJ);
gridRefinement->add(&m_cellCountK);
gridRefinement->add(&m_maxWellCount);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportCarfinUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
{
if (field == &m_exportFileName)
{
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr)
{
myAttr->m_selectSaveFileName = true;
}
}
}

View File

@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafPdmChildField.h"
#include "cafPdmField.h"
#include "cafPdmPtrField.h"
class RimEclipseCase;
class RicCellRangeUi;
namespace caf {
class VecIjk;
}
//==================================================================================================
///
//==================================================================================================
class RicExportCarfinUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicExportCarfinUi();
void setCase(RimEclipseCase* rimCase);
int maxWellCount() const;
caf::VecIjk lgrCellCount() const;
const RicCellRangeUi* cellRange() const;
QString exportFileName() const;
RimEclipseCase* caseToApply() const;
QString gridName() const;
private:
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override;
private:
caf::PdmField<QString> m_exportFileName;
caf::PdmPtrField<RimEclipseCase*> m_caseToApply;
caf::PdmChildField<RicCellRangeUi*> m_cellRange;
caf::PdmField<int> m_cellCountI;
caf::PdmField<int> m_cellCountJ;
caf::PdmField<int> m_cellCountK;
caf::PdmField<int> m_maxWellCount;
};

View File

@ -399,6 +399,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicWellPathExportCompletionDataFeature";
commandIds << "RicWellPathImportCompletionsFileFeature";
commandIds << "RicFlyToObjectFeature";
commandIds << "RicExportCarfin";
// Work in progress -- End