diff options
Diffstat (limited to 'source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh')
-rw-r--r-- | source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh index d1b5dc6845e..6c88a94f585 100644 --- a/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh +++ b/source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh @@ -28,12 +28,34 @@ struct bContext; namespace blender::ed::spreadsheet { +/** + * Contains additional named columns that should be displayed that are not stored on the geometry + * directly. This is used for displaying the evaluated fields connected to a viewer node. + */ +class ExtraColumns { + private: + /** Maps column names to their data. The data is actually stored in the spreadsheet cache. */ + Map<std::string, fn::GSpan> columns_; + + public: + void add(std::string name, fn::GSpan data) + { + columns_.add(std::move(name), data); + } + + void foreach_default_column_ids( + FunctionRef<void(const SpreadsheetColumnID &, bool is_extra)> fn) const; + + std::unique_ptr<ColumnValues> get_column_values(const SpreadsheetColumnID &column_id) const; +}; + class GeometryDataSource : public DataSource { private: Object *object_eval_; const GeometrySet geometry_set_; const GeometryComponent *component_; AttributeDomain domain_; + ExtraColumns extra_columns_; /* Some data is computed on the fly only when it is requested. Computing it does not change the * logical state of this data source. Therefore, the corresponding methods are const and need to @@ -45,11 +67,13 @@ class GeometryDataSource : public DataSource { GeometryDataSource(Object *object_eval, GeometrySet geometry_set, const GeometryComponentType component_type, - const AttributeDomain domain) + const AttributeDomain domain, + ExtraColumns extra_columns) : object_eval_(object_eval), geometry_set_(std::move(geometry_set)), component_(geometry_set_.get_component_for_read(component_type)), - domain_(domain) + domain_(domain), + extra_columns_(std::move(extra_columns)) { } @@ -62,7 +86,7 @@ class GeometryDataSource : public DataSource { void apply_selection_filter(MutableSpan<bool> rows_included) const; void foreach_default_column_ids( - FunctionRef<void(const SpreadsheetColumnID &)> fn) const override; + FunctionRef<void(const SpreadsheetColumnID &, bool is_extra)> fn) const override; std::unique_ptr<ColumnValues> get_column_values( const SpreadsheetColumnID &column_id) const override; @@ -73,16 +97,18 @@ class GeometryDataSource : public DataSource { class InstancesDataSource : public DataSource { const GeometrySet geometry_set_; const InstancesComponent *component_; + ExtraColumns extra_columns_; public: - InstancesDataSource(GeometrySet geometry_set) + InstancesDataSource(GeometrySet geometry_set, ExtraColumns extra_columns) : geometry_set_(std::move(geometry_set)), - component_(geometry_set_.get_component_for_read<InstancesComponent>()) + component_(geometry_set_.get_component_for_read<InstancesComponent>()), + extra_columns_(std::move(extra_columns)) { } void foreach_default_column_ids( - FunctionRef<void(const SpreadsheetColumnID &)> fn) const override; + FunctionRef<void(const SpreadsheetColumnID &, bool is_extra)> fn) const override; std::unique_ptr<ColumnValues> get_column_values( const SpreadsheetColumnID &column_id) const override; |