#14192 Python: Update discrete property color legend in place instead of delete/create

Address review feedback on #14199: deleting and recreating the legend left
views bound to the old legend pointing at a deleted object. Add
RimColorLegendCollection::updateColorLegend and a matching UpdateColorLegend
scriptable method that mutate the existing custom legend (name and items) so
referring views keep their binding and are notified once. A new legend is only
created when none is registered for the result or the registered legend is a
standard legend.

set_discrete_property_category_names now performs a single atomic call instead
of delete + create + per-item appends. The empty-dict removal path still uses
DeleteColorLegend.
This commit is contained in:
Kristian Bendiksen authored and Magne Sjaastad committed 2026-06-10 18:02:07 +02:00
1 parent 5a083331b0
commit a4fe22508a
8 files changed
+200 -17

No files matched your search

@@ -22,6 +22,8 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfColor3.h"
class RimCase;
class RimColorLegend;
class RimColorLegendItem;
@@ -50,6 +52,12 @@ public:
void deleteCustomColorLegends();
RimColorLegend* createColorLegend( const QString& colorLegendName, const std::map<int, QString>& valuesAndNames );
RimColorLegend* updateColorLegend( const RimCase* rimCase,
const QString& resultName,
const QString& colorLegendName,
const std::vector<int>& categoryValues,
const std::vector<QString>& categoryNames,
const std::vector<cvf::Color3f>& colors );
void createColorLegendFromFormationNames( RimFormationNames* rimFormationNames );
void deleteColorLegend( const RimCase* rimCase, const QString& resultName );
void setDefaultColorLegendForResult( const RimCase* rimCase, const QString& resultName, RimColorLegend* colorLegend );