Python: Add option to create discrete grid property#13899
Merged
Conversation
kriben
requested changes
Apr 20, 2026
Add a data_type parameter to set_active_cell_property, set_active_cell_property_async and set_grid_property so callers can upload INTEGER-typed discrete properties in addition to the existing FLOAT properties. Previously a discrete property required the result name to end with "NUM"; the explicit data type makes the intent independent of the name. The gRPC service now forwards the selected data type to RigCaseCellResultsData::createCategoryResult, and the Python tests cover both float and integer property uploads.
Expose RimColorLegendCollection and RimColorLegend to Python via CAF_PDM_OBJECT_METHOD entries that let callers create a legend, append category items with a hex-string color, bind a legend to a (case, resultName) pair and delete that binding. Scriptable fields on RimColorLegend and RimColorLegendItem make the created objects inspectable from Python. The (case, resultName) binding interface in RimColorLegendCollection, RimRegularLegendConfig and RimEclipseCellColors now takes a const RimCase* instead of a case id, matching the caller patterns and avoiding ambiguity when multiple cases share an id domain.
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.
0f59a6a to
14bd043
Compare
Introduce set_discrete_property_category_names on Case to bind integer result values to text labels and optional colors. Internally it creates a custom ColorLegend, appends one item per value (with an auto-assigned palette color when the caller does not provide one) and registers the legend as the default for the (case, resultName) pair. Also add Project.color_legend_collection() as a dedicated accessor for the project's ColorLegendCollection, pytest coverage for legend creation and the default-legend-for-result binding, and two PythonExamples demonstrating the end-to-end discrete property + category label flow. #13806 Python: Silence mypy warnings for category_mapping module
14bd043 to
6586002
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13806