Differential D12938 Diff 43876 source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_spreadsheet/spreadsheet_data_source_geometry.hh
| Show All 22 Lines | |||||
| #include "BKE_geometry_set.hh" | #include "BKE_geometry_set.hh" | ||||
| #include "spreadsheet_data_source.hh" | #include "spreadsheet_data_source.hh" | ||||
| struct bContext; | struct bContext; | ||||
| namespace blender::ed::spreadsheet { | namespace blender::ed::spreadsheet { | ||||
| /** | |||||
HooglyBoogly: Do you expect this to be used for something else soon too? Otherwise, `ViewerNodeColumns` would… | |||||
| * 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. | |||||
Not Done Inline ActionsMaybe add a comment here mentioning what the key and value mean in this map. Particularly that the span references data stored in the spreadsheet cache. HooglyBoogly: Maybe add a comment here mentioning what the key and value mean in this map. Particularly that… | |||||
| */ | |||||
| 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 { | class GeometryDataSource : public DataSource { | ||||
| private: | private: | ||||
| Object *object_eval_; | Object *object_eval_; | ||||
| const GeometrySet geometry_set_; | const GeometrySet geometry_set_; | ||||
| const GeometryComponent *component_; | const GeometryComponent *component_; | ||||
| AttributeDomain domain_; | AttributeDomain domain_; | ||||
| ExtraColumns extra_columns_; | |||||
| /* Some data is computed on the fly only when it is requested. Computing it does not change the | /* 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 | * logical state of this data source. Therefore, the corresponding methods are const and need to | ||||
| * be protected with a mutex. */ | * be protected with a mutex. */ | ||||
| mutable std::mutex mutex_; | mutable std::mutex mutex_; | ||||
| mutable ResourceScope scope_; | mutable ResourceScope scope_; | ||||
| public: | public: | ||||
| GeometryDataSource(Object *object_eval, | GeometryDataSource(Object *object_eval, | ||||
| GeometrySet geometry_set, | GeometrySet geometry_set, | ||||
| const GeometryComponentType component_type, | const GeometryComponentType component_type, | ||||
| const AttributeDomain domain) | const AttributeDomain domain, | ||||
| ExtraColumns extra_columns) | |||||
| : object_eval_(object_eval), | : object_eval_(object_eval), | ||||
| geometry_set_(std::move(geometry_set)), | geometry_set_(std::move(geometry_set)), | ||||
| component_(geometry_set_.get_component_for_read(component_type)), | component_(geometry_set_.get_component_for_read(component_type)), | ||||
| domain_(domain) | domain_(domain), | ||||
| extra_columns_(std::move(extra_columns)) | |||||
| { | { | ||||
| } | } | ||||
| Object *object_eval() const | Object *object_eval() const | ||||
| { | { | ||||
| return object_eval_; | return object_eval_; | ||||
| } | } | ||||
| bool has_selection_filter() const override; | bool has_selection_filter() const override; | ||||
| void apply_selection_filter(MutableSpan<bool> rows_included) const; | void apply_selection_filter(MutableSpan<bool> rows_included) const; | ||||
| void foreach_default_column_ids( | 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( | std::unique_ptr<ColumnValues> get_column_values( | ||||
| const SpreadsheetColumnID &column_id) const override; | const SpreadsheetColumnID &column_id) const override; | ||||
| int tot_rows() const override; | int tot_rows() const override; | ||||
| }; | }; | ||||
| class InstancesDataSource : public DataSource { | class InstancesDataSource : public DataSource { | ||||
| const GeometrySet geometry_set_; | const GeometrySet geometry_set_; | ||||
| const InstancesComponent *component_; | const InstancesComponent *component_; | ||||
| ExtraColumns extra_columns_; | |||||
| public: | public: | ||||
| InstancesDataSource(GeometrySet geometry_set) | InstancesDataSource(GeometrySet geometry_set, ExtraColumns extra_columns) | ||||
| : geometry_set_(std::move(geometry_set)), | : 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( | 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( | std::unique_ptr<ColumnValues> get_column_values( | ||||
| const SpreadsheetColumnID &column_id) const override; | const SpreadsheetColumnID &column_id) const override; | ||||
| int tot_rows() const override; | int tot_rows() const override; | ||||
| }; | }; | ||||
| std::unique_ptr<DataSource> data_source_from_geometry(const bContext *C, Object *object_eval); | std::unique_ptr<DataSource> data_source_from_geometry(const bContext *C, Object *object_eval); | ||||
| } // namespace blender::ed::spreadsheet | } // namespace blender::ed::spreadsheet | ||||
Do you expect this to be used for something else soon too? Otherwise, ViewerNodeColumns would be a bit more to the point.