Commit Graph
46 Commits
Author SHA1 Message Date
Kristian Bendiksen 43b63ac4bf #14912 Reject enum names that conflict with module symbols 2026-10-23 15:21:23 +02:00
Kristian Bendiksen 5b229cdf32 #14912 Reject duplicate generated Python enum names 2026-10-23 15:21:23 +02:00
Magne Sjaastad 1272ec7bd0 #14689: Expose EnsembleCurveSet and fix returned class names in Python generator 2026-10-16 09:57:12 +02:00
Kristian Bendiksen fb0b05958f Python: Reject ambiguous generated enum names 2026-08-21 11:42:34 +02:00
Kristian Bendiksen 01ceb57323 #14001 Python: Drop hand-written PropertyType, use auto-generated PropertyType
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.
2026-05-26 08:23:28 +02:00
Kristian Bendiksen 8971ebfc9c #14001 Python: Auto-generate StrEnum return types for scriptable methods
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.
2026-05-26 08:23:28 +02:00
Kristian Bendiksen 21f1330232 #13982 Python: Generate StrEnum classes for AppEnum-typed fields
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.
2026-05-13 13:47:40 +02:00
Magne Sjaastad 29fc0aeaf5 #13806 PdmScripting: Emit hex strings for cvf::Color3f default values
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.
2026-04-20 18:55:36 +02:00
Magne Sjaastad 2573c17aed #13545 Add Python support for std::pair
- add test for Python generator
- add Python support for std::pair<bool, float/double>
2026-02-04 20:30:45 +01:00
Magne Sjaastad be283f39b4 #12972 Python: Detect duplicated method names 2025-10-02 14:01:37 +02:00
Magne Sjaastad dc2816a91c Adds new virtual method configureCapabilities to PdmFieldHandle
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.
2025-08-25 12:43:36 +02:00
jonjenssen b44a51c542 Use float as double variable type on Python side 2025-08-15 11:43:44 +02:00
Magne Sjaastad 9f5b346c17 Makes sure that empty strings in optional PDM fields are handled correctly
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
2025-08-08 12:30:57 +02:00
Magne Sjaastad 871973d02a Adds support for std::optional PdmFields 2025-08-07 15:45:09 +02:00
Magne Sjaastad 309c4af07e #12593 Simplify object methods exposed to Python 2025-06-16 11:05:00 +02:00
Magne Sjaastad cf2ae4ffb8 Python: Add support for manipulation of camera position
* 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
2025-02-17 18:27:16 +01:00
Kristian Bendiksen 58656f900b Qt6: string-related deprecations. 2024-10-04 15:27:43 +02:00
Magne Sjaastad 319dc2ab9b Adjust build settings to c++20
Adjust build settings to c++20
Add ifdef for code related to CeeViz, so it is possible to compile AppFwk without CeeViz
2023-11-09 14:17:43 +01:00
Kristian Bendiksen 7aabe8c4a8 Python: add type hinting to python code.
Types are checked using mypy.

Fixes #10394.
2023-08-23 09:47:44 +02:00
Magne Sjaastad 0c90f67dcc Change API for PdmObjectHandle and PdmFieldHandle
* 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
2023-05-12 21:41:34 +02:00
Magne Sjaastad 952e766c2f Update clang-format.yml (#10068)
* Update to clang-format-15
Removed two custom .clang-format files in subfolders of AppFwk

* Fixes by clang-format
2023-04-13 07:05:53 +02:00
Kristian Bendiksen 35d91130d3 #8571 Python: generate proper method docs for boolean parameters.
Fixes #8571.
2022-05-11 20:53:01 +02:00
Magne Sjaastadandmagnesj 64bed86f8f Intersection : Add Python support for triangle and result values (#8505)
#8508 Python : Make sure an empty list will be received as empty list in Python

Co-authored-by: magnesj <magnesj@users.noreply.github.com>
2022-02-07 17:38:19 +00:00
Magne Sjaastad fbc8300210 #8180 Python : Generate enum texts for documentation 2021-10-25 12:22:36 +02:00
Magne Sjaastad 3a94078867 Support optimized surface export from grid model layers
* #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
2021-08-23 11:58:32 +02:00
eb3c52aeb1 Python adjustments (#7809)
* #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>
2021-06-25 14:44:52 +02:00
Magne Sjaastad 65afd84db5 Documentation : Add line breaks to make sure Sphinx produce correct doc 2021-05-04 15:24:01 +02:00
magnesj d11e109c7e Fixes by clang-format 2020-11-06 06:18:34 -05:00
github-actions[bot] c4d2488d31 Fixes by clang-format (#6362)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2020-08-25 08:44:08 +02:00
Gaute Lindkvist f82b2f73ec #6320 Refactor of PdmScripting
* Make base class abstract
* Implement support for IOHandling for PdmChild and PdmChildArray fields
2020-08-25 08:33:47 +02:00
Gaute Lindkvist 454e7f17a0 #6322 Fix Python 3.8 problems
* Change base PdmObject class name to PdmObjectBase to avoid name conflicts
* Make all import paths relative
2020-08-24 09:40:36 +02:00
Magne Sjaastad bdc536dfc4 #6106 Apply clang-format on AppFwk 2020-06-19 08:00:01 +02:00
Gaute Lindkvist 27600fa57a Working click matrix to change correlation plots 2020-05-07 08:30:39 +02:00
Magne Sjaastad f076749dab Adjustments after review 2020-04-17 13:54:13 +02:00
Magne Sjaastad bd5ce912fb #5538 Python : Add methods at correct inheritance level 2020-04-17 13:54:10 +02:00
Magne Sjaastad 30eafceef4 Fix generation of Attributes header 2020-03-14 10:13:34 +01:00
Gaute Lindkvist 2853308a4a Python: Create summary plot from string 2020-03-13 14:18:41 +01:00
Gaute Lindkvist c51aa91c42 #5632 Python method commands (#5649)
* General PdmObjectMethods for scripting.
2020-03-10 14:11:22 +01:00
Gaute Lindkvist 6e2d87b05f Python: Fix child field retrieval 2020-03-05 13:05:04 +01:00
Gaute Lindkvist b77c057e7d Python fixup after code review 2020-03-05 11:09:07 +01:00
Gaute Lindkvist bd8e079e24 #5632 Generate PdmChildField and PdmChildArrayField methods 2020-03-05 08:40:46 +01:00
Gaute Lindkvist 2424d79c5d Move some more scriptability to caf 2020-03-05 08:40:46 +01:00
Gaute Lindkvist 508d8806e6 Rename PdmXmlFieldHandle::childClassKeyword to dataTypeName to reflect that it will contain names for built in types 2020-03-05 08:40:46 +01:00
Gaute Lindkvist 76019e7776 Get rid of Python class_keyword attribute and fix parameter sending for WBS 2020-03-05 08:40:46 +01:00
Gaute Lindkvist 554f9a1758 Translate data types to Python data types for Python generation 2020-03-05 08:40:46 +01:00
Gaute Lindkvist b2f55a3101 Make scriptability a CAF-feature 2020-03-05 08:40:46 +01:00