Consolidate the hand-written PropertyType / NNCPropertyType enums in
enums.py into the auto-generated StrEnum classes that already exist in
generated_classes.py. enums.py and all its imports are removed.
The auto-generated class for caf::AppEnum<RiaDefines::ResultCatType>
was named "ResultType" because the existing scriptable m_resultType
fields used keyword "ResultType". Switch those fields to
CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault, keeping the XML
keyword "ResultType" (so project files still load) but exposing the
script keyword as "PropertyType". The generator now emits a single
PropertyType StrEnum that:
- matches the proto PropertyType for setters (FLOAT/INTEGER aside, the
members callers actually use are identical),
- gains ALLAN_DIAGRAMS that the C++ side already knew about,
- loses the proto-only REMOVED/UNDEFINED sentinels (unused in any
Python caller).
rips.NNCPropertyType was exported but unreferenced anywhere — dropped.
Updated Python callers:
- rips.ResultType.X -> rips.PropertyType.X across examples and tests.
- result_type= kwarg / .result_type attribute -> property_type /
.property_type (the script keyword change renamed those everywhere
the affected PdmObject fields are accessed from Python).
- view.apply_cell_result's hand-written wrapper now takes property_type
instead of result_type and forwards via cell_result.property_type.
All 271 Python tests pass, ruff and clang-format clean.
Replace the hand-written PropertyDataType wrapper with first-class enum
return support in the code generator. Scriptable methods that derive
from the new caf::PdmEnumObjectMethod<T> template return a typed enum
value across the gRPC boundary; the Python generator emits a StrEnum
class with the texts pulled from the underlying caf::AppEnum<T> and
wraps the call site so callers receive `EnumClass(value)` directly.
caf::PdmDataContainerEnum is the small PdmObject the framework uses to
carry the enum text on the wire (single scriptable QString field).
RimcEclipseCase_propertyDataType becomes declarative: implement
executeEnum() returning the typed RiaDefines::ResultDataType and pick a
returnEnumScriptName() — the base handles serialization and reports
the four AppEnum members (UNKNOWN, FLOAT, DOUBLE, INTEGER) to the
generator.
Drop the hand-written PropertyDataType in enums.py — the generated one
in resinsight_classes is wire-equivalent and now the single source of
truth.
Auto-generate enum.StrEnum classes from cafPdmPythonGenerator for every
caf::AppEnum-backed scriptable field, deduplicated by C++ AppEnum type.
Generated PdmObject attributes and method arguments now reference the
typed enum (e.g. self.depth_type: DepthType = DepthType.MEASURED_DEPTH)
instead of bare str. Member names are sanitized against Python keywords
and identifier rules (None -> None_, R-G -> R_G).
Existing scripts that pass plain strings keep working because StrEnum
members are strings; the wire format is unchanged.
Bumps python_requires to >=3.11 (StrEnum). Adds an Enum branch in
PdmObjectBase.__convert_to_grpc_value so future IntEnum use is also
handled.
The Python class generator previously emitted cvf::Color3f defaults using
the raw QTextStream operator ("r g b" floats), which is not valid Python
and does not match the hex-string form that scriptable color fields
expect on writeToField.
Convert Color3f defaults to their QColor::name() hex representation and
quote any non-QString value mapped to "str" (e.g. Color3f, caf::FilePath)
so the generated Python is syntactically valid.
This makes it possible to configure the capabilities of a field one place and avoids duplication.
Extends scripting capabilities by introducing a `dataType` method to `PdmAbstractFieldScriptingCapability`.
This allows the Python generator to retrieve the data type of a field directly from its scriptability, providing a more flexible and extensible way to determine the data type for scripting purposes.
Ensures that empty strings are correctly handled as `None` values when they are used as default values in optional fields of PDM objects. Avoid changes in other generated Python code introduced in
871973d02a
* Remove debug output in the views function
* Add scripting support for Mat4d
* Add scripting support to camera
* Separate updates for background color and font size
* Refactor interface to PdmObjectHandle and PdmFieldHandle
Return objects instead of passing in structures as parameters
* Add nodiscard to several functions
* Remove redundant this->
* Rename to ptrReferencedObjectsByType
* #7885 Update opm-common with optimized coordinate import
* #7885 Allow null as default result from a script method
* #7885 Propagate default parameter values to generated Python code
* #7885 Add CommandRouter as hub for worker methods
* #7885 Add support for use of CommadRouter from Python
* #7797 Well Targets: Add scripting capability
* #7794 Python : Do not update childField or childFieldArray
* #7797: Python - Add scripting to well path collection
- Extend the pdmobject.py with method add_object()
- allow objects to be created from Python in well path collections
- add well targets to modelled well path
* #7795 Python : Make sure referenced generated classes are defined
* #7810 StimPlanModel: clean-up python generation
* Python : Always use empty string as default value for ptrFieldValue
It can happen that a ptrField is assigned to a pointer on object construction. (FaciesProperties) Make sure that constructor always assigns an empty string.
Co-authored-by: magnesj <magnesj@users.noreply.github.com>
Co-authored-by: Kristian Bendiksen <kristian.bendiksen@gmail.com>