2016-12-09 03:01:50 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2016- 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 "RimMultiSnapshotDefinition.h"
|
|
|
|
|
2016-12-09 07:40:26 -06:00
|
|
|
#include "RiaApplication.h"
|
2016-12-15 03:38:26 -06:00
|
|
|
|
|
|
|
#include "RigActiveCellInfo.h"
|
2016-12-22 01:45:30 -06:00
|
|
|
#include "RigCaseCellResultsData.h"
|
2017-06-28 06:46:19 -05:00
|
|
|
#include "RigReservoirGridTools.h"
|
2016-12-15 03:38:26 -06:00
|
|
|
|
2016-12-09 07:40:26 -06:00
|
|
|
#include "RimCase.h"
|
2016-12-22 01:45:30 -06:00
|
|
|
#include "RimEclipseView.h"
|
2016-12-09 07:40:26 -06:00
|
|
|
#include "RimProject.h"
|
2016-12-22 01:45:30 -06:00
|
|
|
#include "RimReservoirCellResultsStorage.h"
|
2017-01-05 00:53:14 -06:00
|
|
|
#include "RimTools.h"
|
2018-01-09 03:11:28 -06:00
|
|
|
#include "Rim3dView.h"
|
2016-12-09 07:40:26 -06:00
|
|
|
|
|
|
|
#include "cafPdmPointer.h"
|
|
|
|
|
2016-12-13 02:52:05 -06:00
|
|
|
namespace caf
|
|
|
|
{
|
|
|
|
template<>
|
|
|
|
void caf::AppEnum< RimMultiSnapshotDefinition::SnapShotDirectionEnum >::setUp()
|
|
|
|
{
|
2016-12-14 02:16:44 -06:00
|
|
|
addItem(RimMultiSnapshotDefinition::NO_RANGEFILTER, "None", "None");
|
2016-12-22 08:22:30 -06:00
|
|
|
addItem(RimMultiSnapshotDefinition::RANGEFILTER_I, "I", "I");
|
|
|
|
addItem(RimMultiSnapshotDefinition::RANGEFILTER_J, "J", "J");
|
|
|
|
addItem(RimMultiSnapshotDefinition::RANGEFILTER_K, "K", "K");
|
2016-12-13 02:52:05 -06:00
|
|
|
|
|
|
|
setDefault(RimMultiSnapshotDefinition::RANGEFILTER_K);
|
|
|
|
}
|
|
|
|
}
|
2016-12-09 03:01:50 -06:00
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimMultiSnapshotDefinition, "MultiSnapshotDefinition");
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimMultiSnapshotDefinition::RimMultiSnapshotDefinition()
|
|
|
|
{
|
|
|
|
//CAF_PDM_InitObject("MultiSnapshotDefinition", ":/Well.png", "", "");
|
|
|
|
CAF_PDM_InitObject("MultiSnapshotDefinition", "", "", "");
|
|
|
|
|
2017-01-17 05:59:13 -06:00
|
|
|
CAF_PDM_InitField(&isActive, "IsActive", true, "Active", "", "", "");
|
2017-01-16 15:55:22 -06:00
|
|
|
|
2017-01-17 05:59:13 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&view, "View", "View", "", "", "");
|
2016-12-22 01:45:30 -06:00
|
|
|
|
2016-12-22 08:22:30 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&eclipseResultType, "EclipseResultType", "Result Type", "", "", "");
|
2017-05-02 05:03:15 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&selectedEclipseResults, "SelectedEclipseResults", "Properties", "", "", "");
|
2016-12-22 01:45:30 -06:00
|
|
|
|
2017-05-02 05:03:15 -05:00
|
|
|
CAF_PDM_InitField(&timeStepStart, "TimeStepStart", 0, "Start Time", "", "", "");
|
|
|
|
CAF_PDM_InitField(&timeStepEnd, "TimeStepEnd", 0, "End Time", "", "", "");
|
2016-12-13 02:52:05 -06:00
|
|
|
|
2017-05-02 05:03:15 -05:00
|
|
|
CAF_PDM_InitField(&sliceDirection, "SnapShotDirection", caf::AppEnum<SnapShotDirectionEnum>(NO_RANGEFILTER), "Range Filter Slice", "", "", "");
|
|
|
|
CAF_PDM_InitField(&startSliceIndex, "RangeFilterStart", 1, "Range Start", "", "", "");
|
|
|
|
CAF_PDM_InitField(&endSliceIndex, "RangeFilterEnd", 1, "Range End", "", "", "");
|
2016-12-13 02:52:05 -06:00
|
|
|
|
2017-05-02 05:03:15 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&additionalCases, "AdditionalCases", "Cases", "", "", "");
|
2016-12-09 03:01:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimMultiSnapshotDefinition::~RimMultiSnapshotDefinition()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-12-09 07:40:26 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
2017-01-17 03:40:38 -06:00
|
|
|
if (fieldNeedingOptions == &view)
|
2016-12-09 07:40:26 -06:00
|
|
|
{
|
2017-01-17 04:05:21 -06:00
|
|
|
options.push_back(caf::PdmOptionItemInfo("None", nullptr));
|
|
|
|
|
2018-01-09 03:11:28 -06:00
|
|
|
std::vector<Rim3dView*> views;
|
2016-12-19 01:49:41 -06:00
|
|
|
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
2016-12-09 07:40:26 -06:00
|
|
|
std::vector<RimCase*> cases;
|
|
|
|
proj->allCases(cases);
|
|
|
|
|
2016-12-19 01:49:41 -06:00
|
|
|
for (RimCase* rimCase : cases)
|
2016-12-09 07:40:26 -06:00
|
|
|
{
|
2018-01-09 03:11:28 -06:00
|
|
|
for (Rim3dView* rimView : rimCase->views())
|
2016-12-09 07:40:26 -06:00
|
|
|
{
|
2016-12-19 01:49:41 -06:00
|
|
|
views.push_back(rimView);
|
2016-12-09 07:40:26 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-09 03:11:28 -06:00
|
|
|
for (Rim3dView* view : views)
|
2016-12-15 06:45:34 -06:00
|
|
|
{
|
2016-12-19 01:49:41 -06:00
|
|
|
QString caseAndView = view->ownerCase()->caseUserDescription() + " - " + view->name();
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(caseAndView, view));
|
2016-12-15 06:45:34 -06:00
|
|
|
}
|
2016-12-09 07:40:26 -06:00
|
|
|
}
|
2016-12-22 01:45:30 -06:00
|
|
|
else if (fieldNeedingOptions == &eclipseResultType)
|
|
|
|
{
|
2017-06-13 08:41:52 -05:00
|
|
|
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RiaDefines::ResultCatType>(RiaDefines::DYNAMIC_NATIVE).uiText(), RiaDefines::DYNAMIC_NATIVE));
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(caf::AppEnum<RiaDefines::ResultCatType>(RiaDefines::STATIC_NATIVE).uiText(), RiaDefines::STATIC_NATIVE));
|
2016-12-22 01:45:30 -06:00
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &selectedEclipseResults)
|
|
|
|
{
|
2017-06-30 06:35:58 -05:00
|
|
|
RimEclipseView* rimEclipseView = dynamic_cast<RimEclipseView*>(view());
|
2017-01-17 03:40:38 -06:00
|
|
|
if (rimEclipseView)
|
2016-12-22 01:45:30 -06:00
|
|
|
{
|
|
|
|
QStringList varList;
|
2017-09-13 03:39:20 -05:00
|
|
|
varList = rimEclipseView->currentGridCellResults()->resultNames(eclipseResultType());
|
2016-12-22 01:45:30 -06:00
|
|
|
|
|
|
|
options = toOptionList(varList);
|
|
|
|
}
|
|
|
|
}
|
2016-12-13 02:52:05 -06:00
|
|
|
else if (fieldNeedingOptions == &timeStepEnd)
|
|
|
|
{
|
2016-12-13 02:58:29 -06:00
|
|
|
getTimeStepStrings(options);
|
2016-12-13 02:52:05 -06:00
|
|
|
}
|
|
|
|
else if (fieldNeedingOptions == &timeStepStart)
|
|
|
|
{
|
2016-12-13 02:58:29 -06:00
|
|
|
getTimeStepStrings(options);
|
2016-12-13 02:52:05 -06:00
|
|
|
}
|
2016-12-19 08:06:20 -06:00
|
|
|
else if (fieldNeedingOptions == &additionalCases)
|
|
|
|
{
|
2017-01-05 00:53:14 -06:00
|
|
|
RimTools::caseOptionItems(&options);
|
2016-12-19 08:06:20 -06:00
|
|
|
}
|
2016-12-13 02:52:05 -06:00
|
|
|
|
2016-12-22 01:45:30 -06:00
|
|
|
if (useOptionsOnly) *useOptionsOnly = true;
|
|
|
|
|
2016-12-09 07:40:26 -06:00
|
|
|
return options;
|
|
|
|
}
|
2016-12-09 03:01:50 -06:00
|
|
|
|
2016-12-13 02:58:29 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimMultiSnapshotDefinition::getTimeStepStrings(QList<caf::PdmOptionItemInfo> &options)
|
|
|
|
{
|
2017-01-17 03:40:38 -06:00
|
|
|
if (!view()) return;
|
2017-01-16 16:21:28 -06:00
|
|
|
|
2016-12-15 06:45:34 -06:00
|
|
|
QStringList timeSteps;
|
|
|
|
|
2017-01-17 03:40:38 -06:00
|
|
|
timeSteps = view->ownerCase()->timeStepStrings();
|
2016-12-15 06:45:34 -06:00
|
|
|
|
2016-12-13 02:58:29 -06:00
|
|
|
for (int i = 0; i < timeSteps.size(); i++)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(timeSteps[i], i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-15 01:58:11 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimMultiSnapshotDefinition::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2016-12-22 01:45:30 -06:00
|
|
|
if (changedField == &eclipseResultType)
|
|
|
|
{
|
|
|
|
selectedEclipseResults.v().clear();
|
|
|
|
}
|
|
|
|
else if (changedField == &sliceDirection)
|
2016-12-15 01:58:11 -06:00
|
|
|
{
|
2016-12-15 03:38:26 -06:00
|
|
|
const cvf::StructGridInterface* mainGrid = nullptr;
|
2018-05-30 03:22:45 -05:00
|
|
|
const RigActiveCellInfo* actCellInfo = nullptr;
|
2016-12-19 01:49:41 -06:00
|
|
|
|
2017-01-17 03:40:38 -06:00
|
|
|
if (view())
|
2016-12-15 01:58:11 -06:00
|
|
|
{
|
2017-06-28 06:46:19 -05:00
|
|
|
actCellInfo = RigReservoirGridTools::activeCellInfo(view());
|
|
|
|
|
|
|
|
RimCase* rimCase = nullptr;
|
|
|
|
view()->firstAncestorOrThisOfTypeAsserted(rimCase);
|
|
|
|
|
|
|
|
mainGrid = RigReservoirGridTools::mainGrid(rimCase);
|
2016-12-15 03:38:26 -06:00
|
|
|
}
|
2016-12-15 01:58:11 -06:00
|
|
|
|
2016-12-15 03:38:26 -06:00
|
|
|
if (mainGrid && actCellInfo)
|
|
|
|
{
|
|
|
|
cvf::Vec3st min, max;
|
|
|
|
actCellInfo->IJKBoundingBox(min, max);
|
2016-12-15 01:58:11 -06:00
|
|
|
|
2016-12-15 03:38:26 -06:00
|
|
|
// Adjust to Eclipse indexing
|
|
|
|
min.x() = min.x() + 1;
|
|
|
|
min.y() = min.y() + 1;
|
|
|
|
min.z() = min.z() + 1;
|
2016-12-15 01:58:11 -06:00
|
|
|
|
2016-12-15 03:38:26 -06:00
|
|
|
max.x() = max.x() + 1;
|
|
|
|
max.y() = max.y() + 1;
|
|
|
|
max.z() = max.z() + 1;
|
2016-12-15 01:58:11 -06:00
|
|
|
|
2016-12-15 03:38:26 -06:00
|
|
|
int maxInt = 0;
|
|
|
|
int minInt = 0;
|
2016-12-15 01:58:11 -06:00
|
|
|
|
2016-12-15 03:38:26 -06:00
|
|
|
if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_I)
|
|
|
|
{
|
|
|
|
maxInt = static_cast<int>(max.x());
|
|
|
|
minInt = static_cast<int>(min.x());
|
|
|
|
}
|
|
|
|
else if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_J)
|
|
|
|
{
|
|
|
|
maxInt = static_cast<int>(max.y());
|
|
|
|
minInt = static_cast<int>(min.y());
|
|
|
|
}
|
|
|
|
else if (newValue == RimMultiSnapshotDefinition::RANGEFILTER_K)
|
|
|
|
{
|
|
|
|
maxInt = static_cast<int>(max.z());
|
|
|
|
minInt = static_cast<int>(min.z());
|
|
|
|
}
|
2016-12-15 01:58:11 -06:00
|
|
|
|
2016-12-15 03:38:26 -06:00
|
|
|
startSliceIndex = minInt;
|
|
|
|
endSliceIndex = maxInt;
|
2016-12-15 01:58:11 -06:00
|
|
|
|
2016-12-19 01:49:41 -06:00
|
|
|
}
|
2016-12-15 01:58:11 -06:00
|
|
|
|
|
|
|
startSliceIndex.uiCapability()->updateConnectedEditors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-22 01:45:30 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::toOptionList(const QStringList& varList)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> optionList;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < varList.size(); ++i)
|
|
|
|
{
|
|
|
|
optionList.push_back(caf::PdmOptionItemInfo(varList[i], varList[i]));
|
|
|
|
}
|
|
|
|
return optionList;
|
|
|
|
}
|
2017-01-17 05:59:13 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimMultiSnapshotDefinition::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
if (!isActive())
|
|
|
|
{
|
|
|
|
view.uiCapability()->setUiReadOnly(true);
|
|
|
|
eclipseResultType.uiCapability()->setUiReadOnly(true);
|
|
|
|
selectedEclipseResults.uiCapability()->setUiReadOnly(true);
|
|
|
|
timeStepStart.uiCapability()->setUiReadOnly(true);
|
|
|
|
timeStepEnd.uiCapability()->setUiReadOnly(true);
|
|
|
|
sliceDirection.uiCapability()->setUiReadOnly(true);
|
|
|
|
startSliceIndex.uiCapability()->setUiReadOnly(true);
|
|
|
|
endSliceIndex.uiCapability()->setUiReadOnly(true);
|
|
|
|
additionalCases.uiCapability()->setUiReadOnly(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
view.uiCapability()->setUiReadOnly(false);
|
|
|
|
|
|
|
|
if (!view())
|
|
|
|
{
|
|
|
|
eclipseResultType.uiCapability()->setUiReadOnly(true);
|
|
|
|
selectedEclipseResults.uiCapability()->setUiReadOnly(true);
|
|
|
|
timeStepStart.uiCapability()->setUiReadOnly(true);
|
|
|
|
timeStepEnd.uiCapability()->setUiReadOnly(true);
|
|
|
|
sliceDirection.uiCapability()->setUiReadOnly(true);
|
|
|
|
startSliceIndex.uiCapability()->setUiReadOnly(true);
|
|
|
|
endSliceIndex.uiCapability()->setUiReadOnly(true);
|
|
|
|
additionalCases.uiCapability()->setUiReadOnly(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eclipseResultType.uiCapability()->setUiReadOnly(false);
|
|
|
|
selectedEclipseResults.uiCapability()->setUiReadOnly(false);
|
|
|
|
timeStepStart.uiCapability()->setUiReadOnly(false);
|
|
|
|
timeStepEnd.uiCapability()->setUiReadOnly(false);
|
|
|
|
sliceDirection.uiCapability()->setUiReadOnly(false);
|
|
|
|
|
|
|
|
additionalCases.uiCapability()->setUiReadOnly(false);
|
|
|
|
|
|
|
|
bool rangeReadOnly = false;
|
|
|
|
if (sliceDirection() == NO_RANGEFILTER)
|
|
|
|
{
|
|
|
|
rangeReadOnly = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
startSliceIndex.uiCapability()->setUiReadOnly(rangeReadOnly);
|
|
|
|
endSliceIndex.uiCapability()->setUiReadOnly(rangeReadOnly);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|