Files
ResInsight/ApplicationLibCode/ProjectDataModel/Completions/RimPerforationInterval.h
T
Kristian Bendiksen c9456bba62 Python: Add cell filter reference to perforation intervals
Lets a script attach a cell filter to a RimPerforationInterval as a
typed reference so subsequent work can gate completion-export
connections by the filter's cell mask. Pure metadata in this commit:
no consumer of RimPerforationInterval is modified, the field exists
purely as an API surface.

Add a non-scriptable caf::PdmPtrField<RimCellFilter*> m_cellFilter to
RimPerforationInterval with public cellFilter()/setCellFilter()
accessors and a "Cell Filter" group in the property panel between the
existing geometry/flow group and the Date Settings group. The field is
deliberately non-scriptable: a scriptable PdmPtrField round-trips in
Python as an opaque "ClassName:0xADDR" string rather than a resolved
object, defeating the point. Two CAF object methods on
RimcPerforationInterval expose the relationship:

- AddFilter (perf.add_filter(filter)) sets the pointer; replaces any
  existing filter (single filter per perforation).
- cell_filter (perf.cell_filter()) resolves to the referenced
  RimCellFilter object on read, mirroring the valve.template() pattern.

Composition stays in RimCombinedFilter: a script that wants AND/OR
across multiple filters attaches a combined filter as the single
filter on the perforation.

The Python example in PythonExamples builds a case-level AND combined
filter (PERMX 100..20000 AND K=5..10), creates a modeled well path
with two perforation intervals, and shares the same filter between
them. test_perforation_filter.py covers single-set, replace-on-second-
add, and shared-pointer round-trips.
2026-05-15 08:37:46 +02:00

113 lines
4.2 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
//
// 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 "Rim3dPropertiesInterface.h"
#include "RimCheckableNamedObject.h"
#include "RimWellPathComponentInterface.h"
#include "RiaDefines.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <QDate>
class RimCellFilter;
class RimWellPathValve;
//==================================================================================================
///
//==================================================================================================
class RimPerforationInterval : public RimCheckableNamedObject, public Rim3dPropertiesInterface, public RimWellPathComponentInterface
{
CAF_PDM_HEADER_INIT;
public:
RimPerforationInterval();
~RimPerforationInterval() override;
void setStartAndEndMD( double startMD, double endMD );
void enableCustomStartDate( bool enable );
void setCustomStartDate( const QDate& date );
void setCustomEndDate( const QDate& date );
void setDiameter( double diameter );
void setSkinFactor( double skinFactor );
void setCompletionNumber( int number );
double diameter( RiaDefines::EclipseUnitSystem unitSystem ) const;
double skinFactor() const;
int completionNumber() const;
bool isActiveOnDate( const QDateTime& date ) const;
cvf::BoundingBox boundingBoxInDomainCoords() const override;
void setUnitSystemSpecificDefaults();
void addValve( RimWellPathValve* valve );
std::vector<RimWellPathValve*> valves() const;
void updateAllReferringTracks();
RimCellFilter* cellFilter() const;
void setCellFilter( RimCellFilter* filter );
// RimWellPathCompletionInterface overrides
bool isEnabled() const override;
RiaDefines::WellPathComponentType componentType() const override;
QString componentLabel() const override;
QString componentTypeLabel() const override;
cvf::Color3f defaultComponentColor() const override;
double startMD() const override;
double endMD() const override;
void applyOffset( double offsetMD ) override;
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
void initAfterRead() override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
private:
caf::PdmField<double> m_startMD;
caf::PdmField<double> m_endMD;
caf::PdmField<double> m_diameter;
caf::PdmField<double> m_skinFactor;
caf::PdmField<int> m_completionNumber;
caf::PdmField<bool> m_useCustomStartDate;
caf::PdmField<QDateTime> m_startDate;
caf::PdmField<bool> m_useCustomEndDate;
caf::PdmField<QDateTime> m_endDate;
caf::PdmChildArrayField<RimWellPathValve*> m_valves;
caf::PdmPtrField<RimCellFilter*> m_cellFilter;
caf::PdmField<bool> m_startOfHistory_OBSOLETE;
};