Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-03-10 13:34:36 +0300
committerJacques Lucke <jacques@blender.org>2021-03-10 13:35:42 +0300
commit3dab6f8b7b8988b727719e7487e793262669f2ee (patch)
tree0a78525982b22a83e890147c5d1bce5f571a2ef6 /source/blender/editors/space_spreadsheet/space_spreadsheet.cc
parentf247a14468ce5e0813c1fa708dc9da456bd00efb (diff)
Spreadsheet: new spreadsheet editor
This implements the MVP for the new spreadsheet editor (T85879). The functionality is still very limited, but it proved to be useful already. A more complete picture of where we want to go with the new editor can be found in T86279. Supported features: * Show point attributes of evaluated meshes (no original data, no other domains, no other geometry types, yet). Since only meshes are supported right now, the output of the Point Distribute is not shown, because it is a point cloud. * Only show data for selected vertices when the mesh is in edit mode. Different parts of Blender keep track of selection state and original-indices with varying degrees of success. Therefore, when the selected-only filter is used, the result might be a bit confusing when using some modifiers or nodes. This will be improved in the future. * All data is readonly. Since only evaluated data is displayed currently, it has to be readonly. However, this is not an inherent limitation of the spreadsheet editor. In the future editable data will be displayed as well. Some boilerplate code for the new editor has been committed before in rB9cb5f0a2282a7a84f7f8636b43a32bdc04b51cd5. It would be good to let the spreadsheet editor mature for a couple of weeks as part of the geometry nodes project. Then other modules are invited to show their own data in the new editor! Differential Revision: https://developer.blender.org/D10566
Diffstat (limited to 'source/blender/editors/space_spreadsheet/space_spreadsheet.cc')
-rw-r--r--source/blender/editors/space_spreadsheet/space_spreadsheet.cc52
1 files changed, 50 insertions, 2 deletions
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
index 27276b4bedc..53424c60d59 100644
--- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
+++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
@@ -32,6 +32,8 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "DEG_depsgraph_query.h"
+
#include "RNA_access.h"
#include "WM_api.h"
@@ -39,6 +41,11 @@
#include "spreadsheet_intern.hh"
+#include "spreadsheet_from_geometry.hh"
+#include "spreadsheet_intern.hh"
+
+using namespace blender::ed::spreadsheet;
+
static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
SpaceSpreadsheet *spreadsheet_space = (SpaceSpreadsheet *)MEM_callocN(sizeof(SpaceSpreadsheet),
@@ -94,9 +101,49 @@ static void spreadsheet_main_region_init(wmWindowManager *wm, ARegion *region)
WM_event_add_keymap_handler(&region->handlers, keymap);
}
-static void spreadsheet_main_region_draw(const bContext *UNUSED(C), ARegion *UNUSED(region))
+static ID *get_used_id(const bContext *C)
+{
+ SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
+ if (sspreadsheet->pinned_id != nullptr) {
+ return sspreadsheet->pinned_id;
+ }
+ Object *active_object = CTX_data_active_object(C);
+ return (ID *)active_object;
+}
+
+class FallbackSpreadsheetDrawer : public SpreadsheetDrawer {
+};
+
+static std::unique_ptr<SpreadsheetDrawer> generate_spreadsheet_drawer(const bContext *C)
+{
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
+ ID *used_id = get_used_id(C);
+ if (used_id == nullptr) {
+ return {};
+ }
+ const ID_Type id_type = GS(used_id->name);
+ if (id_type != ID_OB) {
+ return {};
+ }
+ Object *object_orig = (Object *)used_id;
+ if (object_orig->type != OB_MESH) {
+ return {};
+ }
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, object_orig);
+ if (object_eval == nullptr) {
+ return {};
+ }
+
+ return spreadsheet_drawer_from_geometry_attributes(C, object_eval);
+}
+
+static void spreadsheet_main_region_draw(const bContext *C, ARegion *region)
{
- UI_ThemeClearColor(TH_BACK);
+ std::unique_ptr<SpreadsheetDrawer> drawer = generate_spreadsheet_drawer(C);
+ if (!drawer) {
+ drawer = std::make_unique<FallbackSpreadsheetDrawer>();
+ }
+ draw_spreadsheet_in_region(C, region, *drawer);
}
static void spreadsheet_main_region_listener(const wmRegionListenerParams *params)
@@ -108,6 +155,7 @@ static void spreadsheet_main_region_listener(const wmRegionListenerParams *param
case NC_SCENE: {
switch (wmn->data) {
case ND_MODE:
+ case ND_FRAME:
case ND_OB_ACTIVE: {
ED_region_tag_redraw(region);
break;