2018-10-05 04:49:44 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-10-09 02:47:01 -05:00
|
|
|
#include "RicExportLgrUi.h"
|
2018-10-05 04:49:44 -05:00
|
|
|
|
|
|
|
#include "RicCellRangeUi.h"
|
|
|
|
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimTools.h"
|
|
|
|
|
|
|
|
#include "cafPdmUiFilePathEditor.h"
|
|
|
|
#include "cafVecIjk.h"
|
|
|
|
|
|
|
|
|
2018-10-09 02:47:01 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RicExportLgrUi, "RicExportLgrUi");
|
2018-10-05 04:49:44 -05:00
|
|
|
|
2018-10-09 01:01:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
2018-10-09 02:47:01 -05:00
|
|
|
void RicExportLgrUi::LgrSplitTypeEnum::setUp()
|
2018-10-09 01:01:56 -05:00
|
|
|
{
|
2018-10-09 02:47:01 -05:00
|
|
|
addItem(RicExportLgrUi::PER_CELL_LGR, "PER_CELL_LGR", "LGR Per Cell");
|
|
|
|
addItem(RicExportLgrUi::SINGLE_LGR, "SINGLE_LGR", "Single LGR");
|
2018-10-09 01:01:56 -05:00
|
|
|
|
2018-10-09 02:47:01 -05:00
|
|
|
setDefault(RicExportLgrUi::PER_CELL_LGR);
|
2018-10-09 01:01:56 -05:00
|
|
|
}
|
|
|
|
}
|
2018-10-05 04:49:44 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
RicExportLgrUi::RicExportLgrUi()
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Export CARFIN", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_exportFolder, "ExportFolder", "Export Folder", "", "", "");
|
|
|
|
m_exportFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_caseToApply, "CaseToApply", "Source Case", "", "", "");
|
2018-10-11 02:31:06 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_timeStep, "TimeStepIndex", "Time Step", "", "", "");
|
2018-10-05 04:49:44 -05:00
|
|
|
|
2018-10-19 06:07:47 -05:00
|
|
|
QString ijkLabel = "Cell Count I, J, K";
|
|
|
|
CAF_PDM_InitField(&m_cellCountI, "CellCountI", 2, ijkLabel, "", "", "");
|
2018-10-05 04:49:44 -05:00
|
|
|
CAF_PDM_InitField(&m_cellCountJ, "CellCountJ", 2, "Cell Count J", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_cellCountK, "CellCountK", 2, "Cell Count K", "", "", "");
|
2018-10-09 01:01:56 -05:00
|
|
|
|
2018-10-19 06:07:47 -05:00
|
|
|
m_cellCountJ.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
|
|
|
m_cellCountK.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
|
|
|
|
|
2018-10-09 01:01:56 -05:00
|
|
|
CAF_PDM_InitField(&m_splitType, "SplitType", LgrSplitTypeEnum(), "Split Type", "", "", "");
|
2018-10-05 04:49:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
void RicExportLgrUi::setCase(RimEclipseCase* rimCase)
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
bool isDifferent = (rimCase != m_caseToApply);
|
|
|
|
|
|
|
|
if (isDifferent)
|
|
|
|
{
|
|
|
|
m_caseToApply = rimCase;
|
|
|
|
setDefaultValuesFromCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-11 02:31:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicExportLgrUi::setTimeStep(int timeStep)
|
|
|
|
{
|
|
|
|
bool isDifferent = timeStep != m_timeStep;
|
|
|
|
|
|
|
|
if (isDifferent)
|
|
|
|
{
|
|
|
|
m_timeStep = timeStep;
|
|
|
|
setDefaultValuesFromCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-05 04:49:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
caf::VecIjk RicExportLgrUi::lgrCellCount() const
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
return caf::VecIjk (m_cellCountI, m_cellCountJ, m_cellCountK);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
QString RicExportLgrUi::exportFolder() const
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
return m_exportFolder();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
RimEclipseCase* RicExportLgrUi::caseToApply() const
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
return m_caseToApply();
|
|
|
|
}
|
|
|
|
|
2018-10-11 02:31:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RicExportLgrUi::timeStep() const
|
|
|
|
{
|
|
|
|
return m_timeStep;
|
|
|
|
}
|
|
|
|
|
2018-10-09 01:01:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
bool RicExportLgrUi::singleLgrSplit() const
|
2018-10-09 01:01:56 -05:00
|
|
|
{
|
|
|
|
return m_splitType == SINGLE_LGR;
|
|
|
|
}
|
|
|
|
|
2018-10-05 04:49:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
void RicExportLgrUi::setExportFolder(const QString& folder)
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
m_exportFolder = folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
void RicExportLgrUi::setDefaultValuesFromCase()
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
if (m_caseToApply)
|
|
|
|
{
|
|
|
|
QString caseFolder = m_caseToApply->locationOnDisc();
|
|
|
|
m_exportFolder = caseFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_cellCountI = 2;
|
|
|
|
m_cellCountJ = 2;
|
|
|
|
m_cellCountK = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
QList<caf::PdmOptionItemInfo> RicExportLgrUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
|
|
|
if (fieldNeedingOptions == &m_caseToApply)
|
|
|
|
{
|
|
|
|
RimTools::caseOptionItems(&options);
|
|
|
|
}
|
2018-10-11 02:31:06 -05:00
|
|
|
else if (fieldNeedingOptions == &m_timeStep)
|
|
|
|
{
|
|
|
|
QStringList timeStepNames;
|
|
|
|
|
|
|
|
if (m_caseToApply)
|
|
|
|
{
|
|
|
|
timeStepNames = m_caseToApply->timeStepStrings();
|
|
|
|
}
|
|
|
|
for (int i = 0; i < timeStepNames.size(); i++)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
|
|
|
|
}
|
|
|
|
}
|
2018-10-05 04:49:44 -05:00
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
void RicExportLgrUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
if (changedField == &m_caseToApply)
|
|
|
|
{
|
|
|
|
setDefaultValuesFromCase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
void RicExportLgrUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
uiOrdering.add(&m_caseToApply);
|
2018-10-11 02:31:06 -05:00
|
|
|
uiOrdering.add(&m_timeStep);
|
2018-10-05 04:49:44 -05:00
|
|
|
uiOrdering.add(&m_exportFolder);
|
|
|
|
|
|
|
|
caf::PdmUiGroup* gridRefinement = uiOrdering.addNewGroup("Grid Refinement");
|
2018-10-19 06:07:47 -05:00
|
|
|
gridRefinement->add(&m_cellCountI, {true, 2, 1});
|
|
|
|
gridRefinement->add(&m_cellCountJ, false);
|
|
|
|
gridRefinement->add(&m_cellCountK, false);
|
|
|
|
gridRefinement->add(&m_splitType, { true, 2});
|
2018-10-11 02:31:06 -05:00
|
|
|
|
|
|
|
uiOrdering.skipRemainingFields(true);
|
2018-10-05 04:49:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-10-09 02:47:01 -05:00
|
|
|
void RicExportLgrUi::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
2018-10-05 04:49:44 -05:00
|
|
|
{
|
|
|
|
if (field == &m_exportFolder)
|
|
|
|
{
|
|
|
|
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
|
|
|
|
if (myAttr)
|
|
|
|
{
|
2018-10-09 01:01:56 -05:00
|
|
|
myAttr->m_selectDirectory = true;
|
2018-10-05 04:49:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|