#756 Refactoring the filter data into a separate object as a PdmChild

This commit is contained in:
Jacob Støren 2016-06-15 17:31:50 +02:00
parent e1fa9aa9f3
commit ce2112fbc6
7 changed files with 479 additions and 146 deletions

View File

@ -81,6 +81,7 @@ ${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.h
${CEE_CURRENT_LIST_DIR}RimSummaryPlot.h
${CEE_CURRENT_LIST_DIR}RimSummaryCurve.h
${CEE_CURRENT_LIST_DIR}RimSummaryCurveFilter.h
${CEE_CURRENT_LIST_DIR}RimSummaryFilter.h
${CEE_CURRENT_LIST_DIR}RimSummaryCase.h
${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp
${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp
@ -166,6 +167,7 @@ ${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.cpp
${CEE_CURRENT_LIST_DIR}RimSummaryPlot.cpp
${CEE_CURRENT_LIST_DIR}RimSummaryCurve.cpp
${CEE_CURRENT_LIST_DIR}RimSummaryCurveFilter.cpp
${CEE_CURRENT_LIST_DIR}RimSummaryFilter.cpp
${CEE_CURRENT_LIST_DIR}RimSummaryCase.cpp
${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp
${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp

View File

@ -34,6 +34,7 @@
#include "qwt_date.h"
#include "RimSummaryCase.h"
#include "RigSummaryCaseData.h"
#include "RimSummaryFilter.h"
CAF_PDM_SOURCE_INIT(RimSummaryAddress, "SummaryAddress");
@ -126,33 +127,6 @@ void caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory>::setUp()
}
namespace caf
{
template<>
void caf::AppEnum<RimSummaryCurve::SummaryFilterType>::setUp()
{
addItem(RimSummaryCurve::SUM_FILTER_VAR_STRING, "SUM_FILTER_VAR_STRING", "Concatenated Variable Text");
addItem(RimSummaryCurve::SUM_FILTER_FIELD, "SUM_FILTER_FIELD", "Field");
addItem(RimSummaryCurve::SUM_FILTER_WELL, "SUM_FILTER_WELL", "Well");
addItem(RimSummaryCurve::SUM_FILTER_WELL_GROUP, "SUM_FILTER_WELL_GROUP", "Group");
addItem(RimSummaryCurve::SUM_FILTER_WELL_COMPLETION, "SUM_FILTER_WELL_COMPLETION", "Completion");
addItem(RimSummaryCurve::SUM_FILTER_WELL_SEGMENT, "SUM_FILTER_SEGMENT", "Segment");
addItem(RimSummaryCurve::SUM_FILTER_BLOCK, "SUM_FILTER_BLOCK", "Block");
addItem(RimSummaryCurve::SUM_FILTER_REGION, "SUM_FILTER_REGION", "Region");
addItem(RimSummaryCurve::SUM_FILTER_REGION_2_REGION, "SUM_FILTER_REGION_2_REGION", "Region-Region");
addItem(RimSummaryCurve::SUM_FILTER_WELL_LGR, "SUM_FILTER_WELL_LGR", "Lgr-Well");
addItem(RimSummaryCurve::SUM_FILTER_WELL_COMPLETION_LGR, "SUM_FILTER_WELL_COMPLETION_LGR", "Lgr-Completion");
addItem(RimSummaryCurve::SUM_FILTER_BLOCK_LGR, "SUM_FILTER_BLOCK_LGR", "Lgr-Block");
addItem(RimSummaryCurve::SUM_FILTER_MISC, "SUM_FILTER_MISC", "Misc");
addItem(RimSummaryCurve::SUM_FILTER_AQUIFER, "SUM_FILTER_AQUIFER", "Aquifer");
addItem(RimSummaryCurve::SUM_FILTER_NETWORK, "SUM_FILTER_NETWORK", "Network");
addItem(RimSummaryCurve::SUM_FILTER_ANY, "SUM_FILTER_ANY", "Any");
setDefault(RimSummaryCurve::SUM_FILTER_VAR_STRING);
}
}
CAF_PDM_SOURCE_INIT(RimSummaryCurve, "SummaryCurve");
//--------------------------------------------------------------------------------------------------
@ -170,6 +144,15 @@ RimSummaryCurve::RimSummaryCurve()
m_selectedVariableDisplayField.xmlCapability()->setIOReadable(false);
m_selectedVariableDisplayField.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitFieldNoDefault(&m_summaryFilter, "VarListFilter", "Filter", "", "", "");
m_summaryFilter.xmlCapability()->setIOWritable(false);
m_summaryFilter.xmlCapability()->setIOReadable(false);
m_summaryFilter.uiCapability()->setUiChildrenHidden(true);
m_summaryFilter.uiCapability()->setUiHidden(true);
m_summaryFilter = new RimSummaryFilter();
#if 0
CAF_PDM_InitFieldNoDefault(&m_filterType,"SummaryFilterType","Filter Type","","","");
m_filterType.xmlCapability()->setIOWritable(false);
m_filterType.xmlCapability()->setIOReadable(false);
@ -203,10 +186,10 @@ RimSummaryCurve::RimSummaryCurve()
CAF_PDM_InitFieldNoDefault(&m_cellIJKFilter ,"SummaryCellIJKFilter","I, J, K","","","");
m_cellIJKFilter.xmlCapability()->setIOWritable(false);
m_cellIJKFilter.xmlCapability()->setIOReadable(false);
#endif
CAF_PDM_InitFieldNoDefault(&m_uiFilterResultSelection, "FilterResultSelection", "Filter Result", "", "", "");
m_cellIJKFilter.xmlCapability()->setIOWritable(false);
m_cellIJKFilter.xmlCapability()->setIOReadable(false);
m_uiFilterResultSelection.xmlCapability()->setIOWritable(false);
m_uiFilterResultSelection.xmlCapability()->setIOReadable(false);
m_uiFilterResultSelection.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_uiFilterResultSelection.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_uiFilterResultSelection.uiCapability()->setAutoAddingOptionFromValue(false);
@ -227,6 +210,7 @@ RimSummaryCurve::RimSummaryCurve()
RimSummaryCurve::~RimSummaryCurve()
{
delete m_curveVariable();
delete m_summaryFilter();
}
//--------------------------------------------------------------------------------------------------
@ -286,7 +270,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::
std::map<RifEclipseSummaryAddress, int> addrToIdxMap;
for(int i = 0; i <addressCount; i++)
{
if (!isIncludedByFilter(allAddresses[i] )) continue;
if (!m_summaryFilter->isIncludedByFilter(allAddresses[i] )) continue;
addrToIdxMap[allAddresses[i]] = i;
}
@ -363,97 +347,8 @@ void RimSummaryCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
curveDataGroup->add(&m_selectedVariableDisplayField);
caf::PdmUiGroup* curveVarSelectionGroup = curveDataGroup->addNewGroup("Variable Selection");
curveVarSelectionGroup->add(&m_filterType);
m_summaryFilter->defineUiOrdering(uiConfigName, *curveVarSelectionGroup);
caf::PdmUiGroup* curveVarFilterGroup = nullptr;
if (m_filterType() == SUM_FILTER_VAR_STRING)
{
curveVarSelectionGroup->add(&m_completeVarStringFilter);
}
else
{
caf::PdmUiGroup* curveVarFilterGroup = curveVarSelectionGroup->addNewGroup("Filter Settings");
curveVarFilterGroup->add(&m_filterQuantityName);
switch (m_filterType())
{
case SUM_FILTER_ANY:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_wellGroupNameFilter);
curveVarFilterGroup->add(&m_regionNumberFilter);
curveVarFilterGroup->add(&m_regionNumber2Filter);
curveVarFilterGroup->add(&m_wellSegmentNumberFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_REGION:
{
curveVarFilterGroup->add(&m_regionNumberFilter);
}
break;
case SUM_FILTER_REGION_2_REGION:
{
curveVarFilterGroup->add(&m_regionNumberFilter);
curveVarFilterGroup->add(&m_regionNumber2Filter);
}
break;
case SUM_FILTER_WELL_GROUP:
{
curveVarFilterGroup->add(&m_wellGroupNameFilter);
}
break;
case SUM_FILTER_WELL:
{
curveVarFilterGroup->add(&m_wellNameFilter);
}
break;
case SUM_FILTER_WELL_COMPLETION:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_WELL_LGR:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
}
break;
case SUM_FILTER_WELL_COMPLETION_LGR:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_WELL_SEGMENT:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_wellSegmentNumberFilter);
}
break;
case SUM_FILTER_BLOCK:
{
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_BLOCK_LGR:
{
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
}
}
curveVarSelectionGroup->add(&m_uiFilterResultSelection);
caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup("Appearance");
@ -466,7 +361,7 @@ void RimSummaryCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
uiOrdering.setForgetRemainingFields(true); // For now.
}
#if 0
bool isNumberMatch(QString numericalFilterString, int number)
{
if(numericalFilterString.isEmpty()) return true;
@ -612,7 +507,7 @@ bool RimSummaryCurve::isSumVarTypeMatchingFilterType(SummaryFilterType sumFilter
return false;
}
#endif
//--------------------------------------------------------------------------------------------------
///

View File

@ -32,6 +32,7 @@
class RimSummaryCase;
class RifReaderEclipseSummary;
class RiuLineSegmentQwtPlotCurve;
class RimSummaryFilter;
class RimSummaryAddress: public caf::PdmObject
{
@ -46,7 +47,7 @@ public:
private:
caf::PdmField<caf::AppEnum<RifEclipseSummaryAddress::SummaryVarCategory> >
m_category;
m_category;
caf::PdmField<QString> m_quantityName;
caf::PdmField<int> m_regionNumber;
caf::PdmField<int> m_regionNumber2;
@ -73,7 +74,7 @@ public:
void setSummaryCase(RimSummaryCase* sumCase);
void setVariable(QString varName);
#if 0
enum SummaryFilterType
{
SUM_FILTER_VAR_STRING,
@ -93,7 +94,7 @@ public:
SUM_FILTER_BLOCK,
SUM_FILTER_BLOCK_LGR,
};
#endif
protected:
// RimPlotCurve overrides
@ -117,8 +118,10 @@ private:
caf::PdmField<QString> m_selectedVariableDisplayField;
// Filter fields
caf::PdmChildField<RimSummaryFilter*> m_summaryFilter;
#if 0
bool isIncludedByFilter(const RifEclipseSummaryAddress& addr);
bool isSumVarTypeMatchingFilterType(SummaryFilterType sumFilterType, RifEclipseSummaryAddress::SummaryVarCategory sumVarType);
static bool isSumVarTypeMatchingFilterType(SummaryFilterType sumFilterType, RifEclipseSummaryAddress::SummaryVarCategory sumVarType);
caf::PdmField<caf::AppEnum<SummaryFilterType> >
m_filterType;
@ -132,7 +135,7 @@ private:
caf::PdmField<QString> m_wellSegmentNumberFilter;
caf::PdmField<QString> m_lgrNameFilter;
caf::PdmField<QString> m_cellIJKFilter;
#endif
caf::PdmField<int> m_uiFilterResultSelection;
};

View File

@ -67,6 +67,15 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
m_selectedVariableDisplayField.xmlCapability()->setIOReadable(false);
m_selectedVariableDisplayField.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitFieldNoDefault(&m_summaryFilter, "VarListFilter", "Filter", "", "", "");
m_summaryFilter.xmlCapability()->setIOWritable(true);
m_summaryFilter.xmlCapability()->setIOReadable(true);
m_summaryFilter.uiCapability()->setUiChildrenHidden(true);
m_summaryFilter.uiCapability()->setUiHidden(true);
m_summaryFilter = new RimSummaryFilter();
#if 0
CAF_PDM_InitFieldNoDefault(&m_filterType,"SummaryFilterType","Filter Type","","","");
m_filterType.xmlCapability()->setIOWritable(false);
m_filterType.xmlCapability()->setIOReadable(false);
@ -100,10 +109,11 @@ RimSummaryCurveFilter::RimSummaryCurveFilter()
CAF_PDM_InitFieldNoDefault(&m_cellIJKFilter ,"SummaryCellIJKFilter","I, J, K","","","");
m_cellIJKFilter.xmlCapability()->setIOWritable(false);
m_cellIJKFilter.xmlCapability()->setIOReadable(false);
#endif
CAF_PDM_InitFieldNoDefault(&m_uiFilterResultMultiSelection, "FilterResultSelection", "Filter Result", "", "", "");
m_cellIJKFilter.xmlCapability()->setIOWritable(false);
m_cellIJKFilter.xmlCapability()->setIOReadable(false);
m_uiFilterResultMultiSelection.xmlCapability()->setIOWritable(false);
m_uiFilterResultMultiSelection.xmlCapability()->setIOReadable(false);
m_uiFilterResultMultiSelection.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
m_uiFilterResultMultiSelection.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN);
m_uiFilterResultMultiSelection.uiCapability()->setAutoAddingOptionFromValue(false);
@ -163,7 +173,7 @@ QList<caf::PdmOptionItemInfo> RimSummaryCurveFilter::calculateValueOptions(const
std::set<RifEclipseSummaryAddress> addrUnion;
for(int i = 0; i <addressCount; i++)
{
if (false) continue;
if (!m_summaryFilter->isIncludedByFilter(allAddresses[i])) continue;
addrUnion.insert(allAddresses[i]);
}
@ -195,11 +205,13 @@ void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
curveDataGroup->add(&m_selectedVariableDisplayField);
caf::PdmUiGroup* curveVarSelectionGroup = curveDataGroup->addNewGroup("Variable Selection");
m_summaryFilter->defineUiOrdering(uiConfigName, *curveVarSelectionGroup);
#if 0
curveVarSelectionGroup->add(&m_filterType);
caf::PdmUiGroup* curveVarFilterGroup = nullptr;
if (m_filterType() == RimSummaryCurve::SUM_FILTER_VAR_STRING)
if (m_filterType() == RimSummaryFilter::SUM_FILTER_VAR_STRING)
{
curveVarSelectionGroup->add(&m_completeVarStringFilter);
}
@ -211,7 +223,7 @@ void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
switch (m_filterType())
{
case RimSummaryCurve::SUM_FILTER_ANY:
case RimSummaryFilter::SUM_FILTER_ANY:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_wellGroupNameFilter);
@ -222,62 +234,62 @@ void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_REGION:
case RimSummaryFilter::SUM_FILTER_REGION:
{
curveVarFilterGroup->add(&m_regionNumberFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_REGION_2_REGION:
case RimSummaryFilter::SUM_FILTER_REGION_2_REGION:
{
curveVarFilterGroup->add(&m_regionNumberFilter);
curveVarFilterGroup->add(&m_regionNumber2Filter);
}
break;
case RimSummaryCurve::SUM_FILTER_WELL_GROUP:
case RimSummaryFilter::SUM_FILTER_WELL_GROUP:
{
curveVarFilterGroup->add(&m_wellGroupNameFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_WELL:
case RimSummaryFilter::SUM_FILTER_WELL:
{
curveVarFilterGroup->add(&m_wellNameFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_WELL_COMPLETION:
case RimSummaryFilter::SUM_FILTER_WELL_COMPLETION:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_WELL_LGR:
case RimSummaryFilter::SUM_FILTER_WELL_LGR:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_WELL_COMPLETION_LGR:
case RimSummaryFilter::SUM_FILTER_WELL_COMPLETION_LGR:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_WELL_SEGMENT:
case RimSummaryFilter::SUM_FILTER_WELL_SEGMENT:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_wellSegmentNumberFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_BLOCK:
case RimSummaryFilter::SUM_FILTER_BLOCK:
{
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case RimSummaryCurve::SUM_FILTER_BLOCK_LGR:
case RimSummaryFilter::SUM_FILTER_BLOCK_LGR:
{
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
@ -286,6 +298,7 @@ void RimSummaryCurveFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrd
}
}
#endif
curveVarSelectionGroup->add(&m_uiFilterResultMultiSelection);
uiOrdering.setForgetRemainingFields(true);

View File

@ -31,6 +31,7 @@
#include "cafAppEnum.h"
#include "RimSummaryCurve.h"
#include "RimSummaryFilter.h"
class RimSummaryCase;
class RifReaderEclipseSummary;
@ -69,8 +70,9 @@ private:
caf::PdmField<QString> m_selectedVariableDisplayField;
// Filter fields
caf::PdmField<caf::AppEnum<RimSummaryCurve::SummaryFilterType> >
caf::PdmChildField<RimSummaryFilter*> m_summaryFilter;
#if 0
caf::PdmField<caf::AppEnum<RimSummaryFilter::SummaryFilterType> >
m_filterType;
caf::PdmField<QString> m_completeVarStringFilter;
@ -82,7 +84,7 @@ private:
caf::PdmField<QString> m_wellSegmentNumberFilter;
caf::PdmField<QString> m_lgrNameFilter;
caf::PdmField<QString> m_cellIJKFilter;
#endif
caf::PdmField<std::vector<RifEclipseSummaryAddress> > m_uiFilterResultMultiSelection;
};

View File

@ -0,0 +1,340 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimSummaryFilter.h"
#include "RimSummaryCurve.h"
namespace caf
{
template<>
void caf::AppEnum<RimSummaryFilter::SummaryFilterType>::setUp()
{
addItem(RimSummaryFilter::SUM_FILTER_VAR_STRING, "SUM_FILTER_VAR_STRING", "Concatenated Variable Text");
addItem(RimSummaryFilter::SUM_FILTER_FIELD, "SUM_FILTER_FIELD", "Field");
addItem(RimSummaryFilter::SUM_FILTER_WELL, "SUM_FILTER_WELL", "Well");
addItem(RimSummaryFilter::SUM_FILTER_WELL_GROUP, "SUM_FILTER_WELL_GROUP", "Group");
addItem(RimSummaryFilter::SUM_FILTER_WELL_COMPLETION, "SUM_FILTER_WELL_COMPLETION", "Completion");
addItem(RimSummaryFilter::SUM_FILTER_WELL_SEGMENT, "SUM_FILTER_SEGMENT", "Segment");
addItem(RimSummaryFilter::SUM_FILTER_BLOCK, "SUM_FILTER_BLOCK", "Block");
addItem(RimSummaryFilter::SUM_FILTER_REGION, "SUM_FILTER_REGION", "Region");
addItem(RimSummaryFilter::SUM_FILTER_REGION_2_REGION, "SUM_FILTER_REGION_2_REGION", "Region-Region");
addItem(RimSummaryFilter::SUM_FILTER_WELL_LGR, "SUM_FILTER_WELL_LGR", "Lgr-Well");
addItem(RimSummaryFilter::SUM_FILTER_WELL_COMPLETION_LGR, "SUM_FILTER_WELL_COMPLETION_LGR", "Lgr-Completion");
addItem(RimSummaryFilter::SUM_FILTER_BLOCK_LGR, "SUM_FILTER_BLOCK_LGR", "Lgr-Block");
addItem(RimSummaryFilter::SUM_FILTER_MISC, "SUM_FILTER_MISC", "Misc");
addItem(RimSummaryFilter::SUM_FILTER_AQUIFER, "SUM_FILTER_AQUIFER", "Aquifer");
addItem(RimSummaryFilter::SUM_FILTER_NETWORK, "SUM_FILTER_NETWORK", "Network");
addItem(RimSummaryFilter::SUM_FILTER_ANY, "SUM_FILTER_ANY", "Any");
setDefault(RimSummaryFilter::SUM_FILTER_VAR_STRING);
}
}
CAF_PDM_SOURCE_INIT(RimSummaryFilter, "SummaryFilterSettings");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryFilter::RimSummaryFilter()
{
CAF_PDM_InitObject("Summary Filter", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_filterType, "SummaryFilterType", "Filter Type", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_completeVarStringFilter, "SummaryCompleteVarStringFilter", "Filter", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_filterQuantityName, "SummaryVarQuantityFilter", "Quantity", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_regionNumberFilter, "SummaryRegionNumberFilter", "Region", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_regionNumber2Filter, "SummaryRegionNumber2Filter", "Region 2", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellGroupNameFilter, "SummaryWellGroupNameFilter", "Well Group", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellNameFilter, "SummaryWellNameFilter", "Well", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_wellSegmentNumberFilter, "SummaryWellSegmentNumberFilter", "Segment", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_lgrNameFilter, "SummaryLgrNameFilter", "Lgr", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_cellIJKFilter, "SummaryCellIJKFilter", "I, J, K", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimSummaryFilter::~RimSummaryFilter()
{
}
bool isNumberMatch(QString numericalFilterString, int number)
{
if(numericalFilterString.isEmpty()) return true;
// Todo: Ranges, and lists
int filterNumber = numericalFilterString.toInt();
return number == filterNumber;
}
bool isStringMatch(QString filterString, std::string value)
{
if(filterString.isEmpty()) return true;
QRegExp searcher(filterString, Qt::CaseInsensitive, QRegExp::WildcardUnix);
QString qstrValue = QString::fromStdString(value);
return searcher.exactMatch(qstrValue);
}
bool isIJKMatch(QString filterString, int cellI, int cellJ, int cellK)
{
if(filterString.isEmpty()) return true;
// Todo: Ranges, and lists
int filterNumber = filterString.toInt();
return cellI == filterNumber;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryFilter::isIncludedByFilter(const RifEclipseSummaryAddress& addr)
{
if(!isSumVarTypeMatchingFilterType(m_filterType(), addr.category())) return false;
if(m_filterType() == SUM_FILTER_VAR_STRING)
{
return isStringMatch(m_completeVarStringFilter(), addr.uiText());
}
if(!isStringMatch(m_filterQuantityName(), addr.quantityName())) return false;
if(m_filterType() == SUM_FILTER_ANY)
{
return (isNumberMatch(m_regionNumberFilter(), addr.regionNumber())
&& isNumberMatch(m_regionNumber2Filter(), addr.regionNumber2())
&& isStringMatch(m_wellGroupNameFilter(), addr.wellGroupName())
&& isStringMatch(m_wellNameFilter(), addr.wellName())
&& isStringMatch(m_lgrNameFilter(), addr.lgrName())
&& isNumberMatch(m_wellSegmentNumberFilter(), addr.wellSegmentNumber())
&& isIJKMatch(m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK()));
}
switch(addr.category())
{
case RifEclipseSummaryAddress::SUMMARY_REGION:
{
return isNumberMatch(m_regionNumberFilter(), addr.regionNumber());
}
break;
case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION:
{
return isNumberMatch(m_regionNumberFilter(), addr.regionNumber())
&& isNumberMatch(m_regionNumber2Filter(), addr.regionNumber2());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP:
{
return isStringMatch(m_wellGroupNameFilter(), addr.wellGroupName());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL:
{
return isStringMatch(m_wellNameFilter(), addr.wellName());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION:
{
return isStringMatch(m_wellNameFilter(), addr.wellName())
&& isIJKMatch(m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_LGR:
{
return isStringMatch(m_wellNameFilter(), addr.wellName())
&& isStringMatch(m_lgrNameFilter(), addr.lgrName());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR:
{
return isStringMatch(m_wellNameFilter(), addr.wellName())
&& isStringMatch(m_lgrNameFilter(), addr.lgrName())
&& isIJKMatch(m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT:
{
return isStringMatch(m_wellNameFilter(), addr.wellName())
&& isNumberMatch(m_wellSegmentNumberFilter(), addr.wellSegmentNumber());
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK:
{
return isIJKMatch(m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK());
}
break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR:
{
return isStringMatch(m_lgrNameFilter(), addr.lgrName())
&& isIJKMatch(m_cellIJKFilter(), addr.cellI(), addr.cellJ(), addr.cellK());
}
break;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryFilter::isSumVarTypeMatchingFilterType(SummaryFilterType sumFilterType, RifEclipseSummaryAddress::SummaryVarCategory sumVarType)
{
if(sumVarType == RifEclipseSummaryAddress::SUMMARY_INVALID) return false;
if(sumFilterType == SUM_FILTER_ANY || sumFilterType == SUM_FILTER_VAR_STRING) return true;
switch(sumVarType)
{
case RifEclipseSummaryAddress::SUMMARY_FIELD: { return (sumFilterType == SUM_FILTER_FIELD); } break;
case RifEclipseSummaryAddress::SUMMARY_AQUIFER: { return (sumFilterType == SUM_FILTER_AQUIFER); } break;
case RifEclipseSummaryAddress::SUMMARY_NETWORK: { return (sumFilterType == SUM_FILTER_NETWORK); } break;
case RifEclipseSummaryAddress::SUMMARY_MISC: { return (sumFilterType == SUM_FILTER_MISC); } break;
case RifEclipseSummaryAddress::SUMMARY_REGION: { return (sumFilterType == SUM_FILTER_REGION); } break;
case RifEclipseSummaryAddress::SUMMARY_REGION_2_REGION: { return (sumFilterType == SUM_FILTER_REGION_2_REGION); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_GROUP: { return (sumFilterType == SUM_FILTER_WELL_GROUP); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL: { return (sumFilterType == SUM_FILTER_WELL); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: { return (sumFilterType == SUM_FILTER_WELL_COMPLETION); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_LGR: { return (sumFilterType == SUM_FILTER_WELL_LGR); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION_LGR: { return (sumFilterType == SUM_FILTER_FIELD); } break;
case RifEclipseSummaryAddress::SUMMARY_WELL_SEGMENT: { return (sumFilterType == SUM_FILTER_WELL_SEGMENT); } break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK: { return (sumFilterType == SUM_FILTER_BLOCK); } break;
case RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR: { return (sumFilterType == SUM_FILTER_BLOCK_LGR); } break;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
uiOrdering.add(&m_filterType);
caf::PdmUiGroup* curveVarFilterGroup = nullptr;
if(m_filterType() == SUM_FILTER_VAR_STRING)
{
uiOrdering.add(&m_completeVarStringFilter);
}
else
{
caf::PdmUiGroup* curveVarFilterGroup = uiOrdering.addNewGroup("Filter Settings");
curveVarFilterGroup->add(&m_filterQuantityName);
switch(m_filterType())
{
case SUM_FILTER_ANY:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_wellGroupNameFilter);
curveVarFilterGroup->add(&m_regionNumberFilter);
curveVarFilterGroup->add(&m_regionNumber2Filter);
curveVarFilterGroup->add(&m_wellSegmentNumberFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_REGION:
{
curveVarFilterGroup->add(&m_regionNumberFilter);
}
break;
case SUM_FILTER_REGION_2_REGION:
{
curveVarFilterGroup->add(&m_regionNumberFilter);
curveVarFilterGroup->add(&m_regionNumber2Filter);
}
break;
case SUM_FILTER_WELL_GROUP:
{
curveVarFilterGroup->add(&m_wellGroupNameFilter);
}
break;
case SUM_FILTER_WELL:
{
curveVarFilterGroup->add(&m_wellNameFilter);
}
break;
case SUM_FILTER_WELL_COMPLETION:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_WELL_LGR:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
}
break;
case SUM_FILTER_WELL_COMPLETION_LGR:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_WELL_SEGMENT:
{
curveVarFilterGroup->add(&m_wellNameFilter);
curveVarFilterGroup->add(&m_wellSegmentNumberFilter);
}
break;
case SUM_FILTER_BLOCK:
{
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
case SUM_FILTER_BLOCK_LGR:
{
curveVarFilterGroup->add(&m_lgrNameFilter);
curveVarFilterGroup->add(&m_cellIJKFilter);
}
break;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSummaryFilter::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
caf::PdmObject* parent = dynamic_cast<caf::PdmObject*>( this->parentField()->ownerObject());
if (parent)
{
parent->updateConnectedEditors();
}
}

View File

@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "RifEclipseSummaryAddress.h"
class RimSummaryFilter: public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
enum SummaryFilterType
{
SUM_FILTER_VAR_STRING,
SUM_FILTER_ANY,
SUM_FILTER_FIELD,
SUM_FILTER_AQUIFER,
SUM_FILTER_NETWORK,
SUM_FILTER_MISC,
SUM_FILTER_REGION,
SUM_FILTER_REGION_2_REGION,
SUM_FILTER_WELL_GROUP,
SUM_FILTER_WELL,
SUM_FILTER_WELL_COMPLETION,
SUM_FILTER_WELL_COMPLETION_LGR,
SUM_FILTER_WELL_LGR,
SUM_FILTER_WELL_SEGMENT,
SUM_FILTER_BLOCK,
SUM_FILTER_BLOCK_LGR,
};
RimSummaryFilter();
virtual ~RimSummaryFilter();
bool isIncludedByFilter(const RifEclipseSummaryAddress& addr);
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
private:
friend class RimSummaryCurve;
friend class RimSummaryCurveFilter;
static bool isSumVarTypeMatchingFilterType(SummaryFilterType sumFilterType, RifEclipseSummaryAddress::SummaryVarCategory sumVarType);
caf::PdmField<caf::AppEnum<SummaryFilterType> >
m_filterType;
caf::PdmField<QString> m_completeVarStringFilter;
caf::PdmField<QString> m_filterQuantityName;
caf::PdmField<QString> m_regionNumberFilter;
caf::PdmField<QString> m_regionNumber2Filter;
caf::PdmField<QString> m_wellGroupNameFilter;
caf::PdmField<QString> m_wellNameFilter;
caf::PdmField<QString> m_wellSegmentNumberFilter;
caf::PdmField<QString> m_lgrNameFilter;
caf::PdmField<QString> m_cellIJKFilter;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
};