mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 13:47:12 -05:00
Expose the case-level RimDataFilterCollection (introduced for
case-shared cell filters) to Python so scripts can build combined
filters with property-filter and IJK-range children without going
through a view.
Scriptable surface:
- RimEclipseCase.m_dataFilterCollection -> case.data_filter_collection()
- RimDataFilterCollection (object + Filters child array) -> filters()
- RimEclipsePropertyFilter (object + m_lowerBound + m_upperBound) ->
pf.lower_bound, pf.upper_bound
- RimCellRangeFilter (object + start_index_{i,j,k}, cell_count_{i,j,k})
New CAF object methods under ProjectDataModelCommands/:
- RimcDataFilterCollection: add_combined_filter(name, combine_mode)
- RimcCombinedFilter: add_property_filter(result_variable, result_type)
and add_range_filter(name, start_{i,j,k}, cell_count_{i,j,k}).
Bounds are not part of add_property_filter because the Python class
generator emits a bare nan literal as the default for double fields
initialised to quiet_NaN, which fails to import. Bounds are set via
the now-scriptable lower_bound/upper_bound fields after creation,
matching the update() pattern used elsewhere in the API.
RicEclipsePropertyFilterFeatureImpl::addPropertyFilterToCombinedFilter
now returns the new RimEclipsePropertyFilter* so the CAF method can
hand it back to Python. setDefaults is relaxed to be view-tolerant:
case-level filters have no Rim3dView ancestor and the eclipse case is
already wired by RimEclipsePropertyFilter::setCase via the owning
collection's onItemsChanged hook.
End-to-end coverage in tests/test_combined_filter.py: round-trip
create, mode toggle, property-filter add/mutate, range-filter
add/mutate. Example script in PythonExamples builds an AND combined
filter that gates PERMX between 100 and 20000 against a K=5..10
slice.
67 lines
2.4 KiB
C++
67 lines
2.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2026 Equinor 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 "cafPdmObjectHandle.h"
|
|
#include "cafPdmObjectMethod.h"
|
|
|
|
#include <QString>
|
|
|
|
//==================================================================================================
|
|
/// Adds a new property filter as a child of a RimCombinedFilter.
|
|
//==================================================================================================
|
|
class RimcCombinedFilter_addPropertyFilter : public caf::PdmObjectCreationMethod
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
RimcCombinedFilter_addPropertyFilter( caf::PdmObjectHandle* self );
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> execute() override;
|
|
QString classKeywordReturnedType() const override;
|
|
|
|
private:
|
|
caf::PdmField<QString> m_resultVariable;
|
|
caf::PdmField<QString> m_resultType;
|
|
};
|
|
|
|
//==================================================================================================
|
|
/// Adds a new IJK range filter as a child of a RimCombinedFilter.
|
|
//==================================================================================================
|
|
class RimcCombinedFilter_addRangeFilter : public caf::PdmObjectCreationMethod
|
|
{
|
|
CAF_PDM_HEADER_INIT;
|
|
|
|
public:
|
|
RimcCombinedFilter_addRangeFilter( caf::PdmObjectHandle* self );
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> execute() override;
|
|
QString classKeywordReturnedType() const override;
|
|
|
|
private:
|
|
caf::PdmField<QString> m_name;
|
|
caf::PdmField<int> m_startI;
|
|
caf::PdmField<int> m_startJ;
|
|
caf::PdmField<int> m_startK;
|
|
caf::PdmField<int> m_cellCountI;
|
|
caf::PdmField<int> m_cellCountJ;
|
|
caf::PdmField<int> m_cellCountK;
|
|
};
|