2012-05-18 02:45:23 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-09-23 08:04:57 -05:00
|
|
|
// Copyright (C) 2011- Statoil ASA
|
|
|
|
// Copyright (C) 2013- Ceetron Solutions AS
|
|
|
|
// Copyright (C) 2011-2012 Ceetron AS
|
2012-05-18 02:45:23 -05:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-06-25 06:05:28 -05:00
|
|
|
#include "RimEclipsePropertyFilter.h"
|
2013-05-06 03:55:00 -05:00
|
|
|
|
2013-03-22 10:58:44 -05:00
|
|
|
#include "RigCaseCellResultsData.h"
|
2015-07-31 11:58:23 -05:00
|
|
|
|
2015-06-25 06:05:28 -05:00
|
|
|
#include "RimEclipsePropertyFilterCollection.h"
|
|
|
|
#include "RimEclipseResultDefinition.h"
|
2015-08-12 04:02:09 -05:00
|
|
|
#include "RimEclipseView.h"
|
|
|
|
#include "RimReservoirCellResultsStorage.h"
|
2014-07-24 03:11:43 -05:00
|
|
|
|
2015-07-31 11:58:23 -05:00
|
|
|
#include "RiuMainWindow.h"
|
|
|
|
|
2014-07-24 03:11:43 -05:00
|
|
|
#include "cafPdmUiDoubleSliderEditor.h"
|
2015-08-12 04:02:09 -05:00
|
|
|
|
2014-07-24 03:11:43 -05:00
|
|
|
#include "cvfAssert.h"
|
|
|
|
#include "cvfMath.h"
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
|
|
|
|
namespace caf
|
2015-06-24 08:03:55 -05:00
|
|
|
{ // Obsolete stuff
|
2012-05-18 02:45:23 -05:00
|
|
|
template<>
|
2015-06-25 04:45:31 -05:00
|
|
|
void caf::AppEnum< RimEclipsePropertyFilter::EvaluationRegionType>::setUp()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-06-25 04:45:31 -05:00
|
|
|
addItem(RimEclipsePropertyFilter::RANGE_FILTER_REGION, "RANGE_FILTER_REGION", "Range filter cells");
|
|
|
|
addItem(RimEclipsePropertyFilter::GLOBAL_REGION, "GLOBAL_REGION", "All cells");
|
|
|
|
setDefault(RimEclipsePropertyFilter::RANGE_FILTER_REGION);
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-25 04:45:31 -05:00
|
|
|
CAF_PDM_SOURCE_INIT(RimEclipsePropertyFilter, "CellPropertyFilter");
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
RimEclipsePropertyFilter::RimEclipsePropertyFilter()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Cell Property Filter", ":/CellFilter_Values.png", "", "");
|
|
|
|
|
2015-06-24 08:03:55 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&obsoleteField_evaluationRegion, "EvaluationRegion", "Evaluation region", "", "", "");
|
2015-08-05 06:27:36 -05:00
|
|
|
obsoleteField_evaluationRegion.uiCapability()->setUiHidden(true);
|
|
|
|
obsoleteField_evaluationRegion.xmlCapability()->setIOWritable(false);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&resultDefinition, "ResultDefinition", "Result definition", "", "", "");
|
2015-06-25 02:38:53 -05:00
|
|
|
resultDefinition = new RimEclipseResultDefinition();
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
// Set to hidden to avoid this item to been displayed as a child item
|
|
|
|
// Fields in this object are displayed using defineUiOrdering()
|
2015-08-05 06:27:36 -05:00
|
|
|
resultDefinition.uiCapability()->setUiHidden(true);
|
2015-08-10 01:00:16 -05:00
|
|
|
resultDefinition.uiCapability()->setUiChildrenHidden(true);
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
CAF_PDM_InitField(&lowerBound, "LowerBound", 0.0, "Min", "", "", "");
|
2015-08-05 06:27:36 -05:00
|
|
|
lowerBound.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
2012-10-09 09:19:49 -05:00
|
|
|
|
2012-05-18 02:45:23 -05:00
|
|
|
CAF_PDM_InitField(&upperBound, "UpperBound", 0.0, "Max", "", "", "");
|
2015-08-05 06:27:36 -05:00
|
|
|
upperBound.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName());
|
2012-05-18 02:45:23 -05:00
|
|
|
|
|
|
|
updateIconState();
|
2012-10-09 09:19:49 -05:00
|
|
|
|
|
|
|
m_minimumResultValue = cvf::UNDEFINED_DOUBLE;
|
|
|
|
m_maximumResultValue = cvf::UNDEFINED_DOUBLE;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
RimEclipsePropertyFilter::~RimEclipsePropertyFilter()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
void RimEclipsePropertyFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2013-04-30 06:41:53 -05:00
|
|
|
if (&name == changedField)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
|
|
|
}
|
2013-04-30 06:41:53 -05:00
|
|
|
|
|
|
|
if ( &lowerBound == changedField
|
|
|
|
|| &upperBound == changedField
|
2015-06-24 08:03:55 -05:00
|
|
|
|| &obsoleteField_evaluationRegion == changedField
|
2013-08-08 01:49:29 -05:00
|
|
|
|| &isActive == changedField
|
2013-04-30 06:41:53 -05:00
|
|
|
|| &filterMode == changedField)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-08-11 15:49:04 -05:00
|
|
|
parentContainer()->fieldChangedByUi(changedField, oldValue, newValue);
|
2015-07-02 05:49:28 -05:00
|
|
|
updateFilterName();
|
2012-05-18 02:45:23 -05:00
|
|
|
this->updateIconState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
QList<caf::PdmOptionItemInfo> RimEclipsePropertyFilter::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2014-04-04 04:30:01 -05:00
|
|
|
QList<caf::PdmOptionItemInfo> optionItems = resultDefinition->calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
|
|
|
|
|
2014-08-19 06:35:10 -05:00
|
|
|
std::vector<int> indicesToRemove;
|
2014-04-04 04:30:01 -05:00
|
|
|
for (int i = 0; i < optionItems.size(); i++)
|
|
|
|
{
|
|
|
|
QString text = optionItems[i].optionUiText;
|
|
|
|
|
2014-08-19 06:56:17 -05:00
|
|
|
if (RimDefines::isPerCellFaceResult(text))
|
2014-08-19 06:35:10 -05:00
|
|
|
{
|
|
|
|
indicesToRemove.push_back(i);
|
2014-04-04 04:30:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-19 06:35:10 -05:00
|
|
|
std::sort(indicesToRemove.begin(), indicesToRemove.end());
|
|
|
|
|
|
|
|
std::vector<int>::reverse_iterator rit;
|
|
|
|
for (rit = indicesToRemove.rbegin(); rit != indicesToRemove.rend(); ++rit)
|
2014-04-04 04:30:01 -05:00
|
|
|
{
|
2014-08-19 06:35:10 -05:00
|
|
|
optionItems.takeAt(*rit);
|
2014-04-04 04:30:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return optionItems;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:48:24 -05:00
|
|
|
RimEclipsePropertyFilterCollection* RimEclipsePropertyFilter::parentContainer()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-08-11 15:49:04 -05:00
|
|
|
return dynamic_cast<RimEclipsePropertyFilterCollection*>(this->parentField()->ownerObject());
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
void RimEclipsePropertyFilter::setToDefaultValues()
|
2012-05-18 02:45:23 -05:00
|
|
|
{
|
2015-08-11 15:49:04 -05:00
|
|
|
CVF_ASSERT(parentContainer());
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-08-07 02:00:09 -05:00
|
|
|
computeResultValueRange();
|
2012-05-18 02:45:23 -05:00
|
|
|
|
2013-08-07 02:00:09 -05:00
|
|
|
lowerBound = m_minimumResultValue;
|
|
|
|
upperBound = m_maximumResultValue;
|
2012-05-18 02:45:23 -05:00
|
|
|
}
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
void RimEclipsePropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
|
|
|
// Fields declared in RimCellFilter
|
|
|
|
uiOrdering.add(&name);
|
|
|
|
|
|
|
|
// Fields declared in RimResultDefinition
|
|
|
|
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result");
|
2013-04-30 06:41:53 -05:00
|
|
|
group1->add(&(resultDefinition->m_resultTypeUiField));
|
|
|
|
group1->add(&(resultDefinition->m_porosityModelUiField));
|
|
|
|
group1->add(&(resultDefinition->m_resultVariableUiField));
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
// Fields declared in RimCellFilter
|
2013-08-08 01:49:29 -05:00
|
|
|
uiOrdering.add(&isActive);
|
2012-06-26 09:10:41 -05:00
|
|
|
uiOrdering.add(&filterMode);
|
|
|
|
|
|
|
|
// Fields declared in this class (RimCellPropertyFilter)
|
|
|
|
uiOrdering.add(&lowerBound);
|
|
|
|
uiOrdering.add(&upperBound);
|
|
|
|
uiOrdering.add(&filterMode);
|
|
|
|
}
|
|
|
|
|
2012-10-09 09:19:49 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
void RimEclipsePropertyFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute)
|
2012-10-09 09:19:49 -05:00
|
|
|
{
|
|
|
|
if (m_minimumResultValue == cvf::UNDEFINED_DOUBLE || m_maximumResultValue == cvf::UNDEFINED_DOUBLE)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (field == &lowerBound || field == &upperBound)
|
|
|
|
{
|
|
|
|
caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>(attribute);
|
|
|
|
if (!myAttr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
myAttr->m_minimum = m_minimumResultValue;
|
|
|
|
myAttr->m_maximum = m_maximumResultValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 02:00:09 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-06-25 04:45:31 -05:00
|
|
|
void RimEclipsePropertyFilter::computeResultValueRange()
|
2013-08-07 02:00:09 -05:00
|
|
|
{
|
2015-08-11 15:49:04 -05:00
|
|
|
CVF_ASSERT(parentContainer());
|
2013-08-07 02:00:09 -05:00
|
|
|
|
|
|
|
double min = 0.0;
|
|
|
|
double max = 0.0;
|
|
|
|
|
2014-09-04 02:30:00 -05:00
|
|
|
size_t scalarIndex = resultDefinition->scalarResultIndex();
|
2013-08-07 02:00:09 -05:00
|
|
|
if (scalarIndex != cvf::UNDEFINED_SIZE_T)
|
|
|
|
{
|
|
|
|
RimReservoirCellResultsStorage* results = resultDefinition->currentGridCellResults();
|
|
|
|
if (results)
|
|
|
|
{
|
|
|
|
results->cellResults()->minMaxCellScalarValues(scalarIndex, min, max);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_maximumResultValue = max;
|
|
|
|
m_minimumResultValue = min;
|
|
|
|
|
2015-08-05 06:27:36 -05:00
|
|
|
lowerBound.uiCapability()->setUiName(QString("Min (%1)").arg(min));
|
|
|
|
upperBound.uiCapability()->setUiName(QString("Max (%1)").arg(max));
|
2013-08-07 02:00:09 -05:00
|
|
|
}
|
|
|
|
|
2015-07-02 05:49:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipsePropertyFilter::updateFilterName()
|
|
|
|
{
|
|
|
|
QString newFiltername;
|
|
|
|
newFiltername = resultDefinition->resultVariable() + " ("
|
|
|
|
+ QString::number(lowerBound()) + " .. " + QString::number(upperBound) + ")";
|
|
|
|
this->name = newFiltername;
|
|
|
|
RiuMainWindow::instance()->forceProjectTreeRepaint();
|
|
|
|
}
|
|
|
|
|
2015-08-12 04:02:09 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimEclipsePropertyFilter::initAfterRead()
|
|
|
|
{
|
|
|
|
resultDefinition->initAfterRead();
|
|
|
|
|
|
|
|
resultDefinition->setReservoirView(parentContainer()->reservoirView());
|
|
|
|
resultDefinition->loadResult();
|
|
|
|
updateIconState();
|
|
|
|
computeResultValueRange();
|
|
|
|
}
|
|
|
|
|