2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
2023-09-01 21:37:11 +02:00
|
|
|
#include "BLI_string.h"
|
2021-03-08 16:23:21 +01:00
|
|
|
|
2023-09-25 17:48:21 -04:00
|
|
|
#include "BKE_screen.hh"
|
2025-01-26 20:08:00 +01:00
|
|
|
#include "BKE_viewer_path.hh"
|
2021-03-08 16:23:21 +01:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "ED_screen.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "ED_space_api.hh"
|
|
|
|
|
#include "ED_spreadsheet.hh"
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
#include "ED_viewer_path.hh"
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
|
|
|
|
#include "UI_resources.hh"
|
|
|
|
|
#include "UI_view2d.hh"
|
2021-03-08 16:23:21 +01:00
|
|
|
|
2023-08-28 15:01:05 +02:00
|
|
|
#include "BLO_read_write.hh"
|
2022-09-28 11:52:22 +02:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph_query.hh"
|
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
2021-03-10 11:34:36 +01:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
2021-03-08 16:23:21 +01:00
|
|
|
|
2024-02-09 18:59:42 +01:00
|
|
|
#include "BLT_translation.hh"
|
2021-11-19 17:36:11 -05:00
|
|
|
|
2024-01-31 14:04:56 -05:00
|
|
|
#include "BLF_api.hh"
|
2021-04-09 10:20:46 +02:00
|
|
|
|
2025-01-26 20:08:00 +01:00
|
|
|
#include "spreadsheet_column.hh"
|
2021-04-09 10:20:46 +02:00
|
|
|
#include "spreadsheet_data_source_geometry.hh"
|
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
2021-03-10 11:34:36 +01:00
|
|
|
#include "spreadsheet_intern.hh"
|
2021-04-09 10:20:46 +02:00
|
|
|
#include "spreadsheet_layout.hh"
|
2021-06-18 16:33:02 -05:00
|
|
|
#include "spreadsheet_row_filter.hh"
|
|
|
|
|
#include "spreadsheet_row_filter_ui.hh"
|
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
2021-03-10 11:34:36 +01:00
|
|
|
|
Cleanup: fewer iostreams related includes from BLI/BKE headers
Including <iostream> or similar headers is quite expensive, since it
also pulls in things like <locale> and so on. In many BLI headers,
iostreams are only used to implement some sort of "debug print",
or an operator<< for ostream.
Change some of the commonly used places to instead include <iosfwd>,
which is the standard way of forward-declaring iostreams related
classes, and move the actual debug-print / operator<< implementations
into .cc files.
This is not done for templated classes though (it would be possible
to provide explicit operator<< instantiations somewhere in the
source file, but that would lead to hard-to-figure-out linker error
whenever someone would add a different template type). There, where
possible, I changed from full <iostream> include to only the needed
<ostream> part.
For Span<T>, I just removed print_as_lines since it's not used by
anything. It could be moved into a .cc file using a similar approach
as above if needed.
Doing full blender build changes include counts this way:
- <iostream> 1986 -> 978
- <sstream> 2880 -> 925
It does not affect the total build time much though, mostly because
towards the end of it there's just several CPU cores finishing
compiling OpenVDB related source files.
Pull Request: https://projects.blender.org/blender/blender/pulls/111046
2023-08-11 12:27:56 +03:00
|
|
|
#include <sstream>
|
|
|
|
|
|
2024-01-31 16:32:10 -05:00
|
|
|
namespace blender::ed::spreadsheet {
|
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
2021-03-10 11:34:36 +01:00
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static SpaceLink *spreadsheet_create(const ScrArea * /*area*/, const Scene * /*scene*/)
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
2021-12-24 22:17:49 -05:00
|
|
|
SpaceSpreadsheet *spreadsheet_space = MEM_cnew<SpaceSpreadsheet>("spreadsheet space");
|
2021-03-08 16:23:21 +01:00
|
|
|
spreadsheet_space->spacetype = SPACE_SPREADSHEET;
|
|
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
spreadsheet_space->filter_flag = SPREADSHEET_FILTER_ENABLE;
|
|
|
|
|
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
2021-03-15 09:58:38 +01:00
|
|
|
/* Header. */
|
2024-11-15 02:00:11 +01:00
|
|
|
ARegion *region = BKE_area_region_new();
|
2021-03-08 16:23:21 +01:00
|
|
|
BLI_addtail(&spreadsheet_space->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_HEADER;
|
|
|
|
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2021-03-15 09:58:38 +01:00
|
|
|
/* Footer. */
|
2024-11-15 02:00:11 +01:00
|
|
|
ARegion *region = BKE_area_region_new();
|
2021-03-15 09:58:38 +01:00
|
|
|
BLI_addtail(&spreadsheet_space->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_FOOTER;
|
|
|
|
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-25 07:57:24 +02:00
|
|
|
{
|
|
|
|
|
/* Dataset Region */
|
2024-11-15 02:00:11 +01:00
|
|
|
ARegion *region = BKE_area_region_new();
|
2021-06-25 07:57:24 +02:00
|
|
|
BLI_addtail(&spreadsheet_space->regionbase, region);
|
2021-12-28 11:05:31 -06:00
|
|
|
region->regiontype = RGN_TYPE_TOOLS;
|
2021-06-25 07:57:24 +02:00
|
|
|
region->alignment = RGN_ALIGN_LEFT;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
{
|
|
|
|
|
/* Properties region. */
|
2024-11-15 02:00:11 +01:00
|
|
|
ARegion *region = BKE_area_region_new();
|
2021-06-18 16:33:02 -05:00
|
|
|
BLI_addtail(&spreadsheet_space->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_UI;
|
|
|
|
|
region->alignment = RGN_ALIGN_RIGHT;
|
|
|
|
|
region->flag = RGN_FLAG_HIDDEN;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 09:58:38 +01:00
|
|
|
{
|
|
|
|
|
/* Main window. */
|
2024-11-15 02:00:11 +01:00
|
|
|
ARegion *region = BKE_area_region_new();
|
2021-03-08 16:23:21 +01:00
|
|
|
BLI_addtail(&spreadsheet_space->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_WINDOW;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (SpaceLink *)spreadsheet_space;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 09:58:38 +01:00
|
|
|
static void spreadsheet_free(SpaceLink *sl)
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
2021-03-15 09:58:38 +01:00
|
|
|
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
2021-06-18 16:33:02 -05:00
|
|
|
|
2021-12-17 15:40:06 +01:00
|
|
|
MEM_delete(sspreadsheet->runtime);
|
2021-04-09 10:20:46 +02:00
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
LISTBASE_FOREACH_MUTABLE (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
|
|
|
|
|
spreadsheet_row_filter_free(row_filter);
|
|
|
|
|
}
|
2021-04-09 10:20:46 +02:00
|
|
|
LISTBASE_FOREACH_MUTABLE (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
|
|
|
|
spreadsheet_column_free(column);
|
|
|
|
|
}
|
2024-07-29 20:42:08 +02:00
|
|
|
MEM_SAFE_FREE(sspreadsheet->instance_ids);
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
BKE_viewer_path_clear(&sspreadsheet->viewer_path);
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void spreadsheet_init(wmWindowManager * /*wm*/, ScrArea *area)
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
2021-03-15 09:58:38 +01:00
|
|
|
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)area->spacedata.first;
|
|
|
|
|
if (sspreadsheet->runtime == nullptr) {
|
2021-12-17 15:40:06 +01:00
|
|
|
sspreadsheet->runtime = MEM_new<SpaceSpreadsheet_Runtime>(__func__);
|
2021-03-15 09:58:38 +01:00
|
|
|
}
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SpaceLink *spreadsheet_duplicate(SpaceLink *sl)
|
|
|
|
|
{
|
2021-03-15 09:58:38 +01:00
|
|
|
const SpaceSpreadsheet *sspreadsheet_old = (SpaceSpreadsheet *)sl;
|
|
|
|
|
SpaceSpreadsheet *sspreadsheet_new = (SpaceSpreadsheet *)MEM_dupallocN(sspreadsheet_old);
|
2021-11-01 08:42:07 -07:00
|
|
|
if (sspreadsheet_old->runtime) {
|
2021-12-17 15:40:06 +01:00
|
|
|
sspreadsheet_new->runtime = MEM_new<SpaceSpreadsheet_Runtime>(__func__,
|
|
|
|
|
*sspreadsheet_old->runtime);
|
2021-11-01 08:42:07 -07:00
|
|
|
}
|
|
|
|
|
else {
|
2021-12-17 15:40:06 +01:00
|
|
|
sspreadsheet_new->runtime = MEM_new<SpaceSpreadsheet_Runtime>(__func__);
|
2021-11-01 08:42:07 -07:00
|
|
|
}
|
2021-03-15 09:58:38 +01:00
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
BLI_listbase_clear(&sspreadsheet_new->row_filters);
|
|
|
|
|
LISTBASE_FOREACH (const SpreadsheetRowFilter *, src_filter, &sspreadsheet_old->row_filters) {
|
|
|
|
|
SpreadsheetRowFilter *new_filter = spreadsheet_row_filter_copy(src_filter);
|
|
|
|
|
BLI_addtail(&sspreadsheet_new->row_filters, new_filter);
|
|
|
|
|
}
|
2021-04-09 10:20:46 +02:00
|
|
|
BLI_listbase_clear(&sspreadsheet_new->columns);
|
|
|
|
|
LISTBASE_FOREACH (SpreadsheetColumn *, src_column, &sspreadsheet_old->columns) {
|
|
|
|
|
SpreadsheetColumn *new_column = spreadsheet_column_copy(src_column);
|
|
|
|
|
BLI_addtail(&sspreadsheet_new->columns, new_column);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 20:42:08 +02:00
|
|
|
sspreadsheet_new->instance_ids = static_cast<SpreadsheetInstanceID *>(
|
|
|
|
|
MEM_dupallocN(sspreadsheet_old->instance_ids));
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
BKE_viewer_path_copy(&sspreadsheet_new->viewer_path, &sspreadsheet_old->viewer_path);
|
2021-04-15 08:57:10 +02:00
|
|
|
|
2021-03-15 09:58:38 +01:00
|
|
|
return (SpaceLink *)sspreadsheet_new;
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
static void spreadsheet_keymap(wmKeyConfig *keyconf)
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
2021-06-18 16:33:02 -05:00
|
|
|
/* Entire editor only. */
|
2023-09-14 13:32:42 +10:00
|
|
|
WM_keymap_ensure(keyconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW);
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-13 15:36:38 +01:00
|
|
|
static void spreadsheet_id_remap(ScrArea * /*area*/,
|
|
|
|
|
SpaceLink *slink,
|
|
|
|
|
const blender::bke::id::IDRemapper &mappings)
|
2021-04-15 08:57:10 +02:00
|
|
|
{
|
|
|
|
|
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)slink;
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
BKE_viewer_path_id_remap(&sspreadsheet->viewer_path, mappings);
|
2021-04-15 08:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
2023-08-17 14:42:04 +02:00
|
|
|
static void spreadsheet_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data)
|
|
|
|
|
{
|
|
|
|
|
SpaceSpreadsheet *sspreadsheet = reinterpret_cast<SpaceSpreadsheet *>(space_link);
|
|
|
|
|
BKE_viewer_path_foreach_id(data, &sspreadsheet->viewer_path);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 16:23:21 +01:00
|
|
|
static void spreadsheet_main_region_init(wmWindowManager *wm, ARegion *region)
|
|
|
|
|
{
|
2023-07-24 23:49:32 +02:00
|
|
|
region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM | V2D_SCROLL_VERTICAL_HIDE |
|
|
|
|
|
V2D_SCROLL_HORIZONTAL_HIDE;
|
2021-03-08 16:23:21 +01:00
|
|
|
region->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y;
|
|
|
|
|
region->v2d.keepzoom = V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT;
|
|
|
|
|
region->v2d.keeptot = V2D_KEEPTOT_STRICT;
|
|
|
|
|
region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
|
|
|
|
|
|
|
|
|
|
UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
|
|
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
{
|
2023-09-14 13:32:42 +10:00
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(
|
|
|
|
|
wm->defaultconf, "View2D Buttons List", SPACE_EMPTY, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2021-06-18 16:33:02 -05:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(
|
2023-09-14 13:32:42 +10:00
|
|
|
wm->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2021-06-18 16:33:02 -05:00
|
|
|
}
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
2024-01-31 16:32:10 -05:00
|
|
|
ID *get_current_id(const SpaceSpreadsheet *sspreadsheet)
|
2021-04-15 08:57:10 +02:00
|
|
|
{
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
if (BLI_listbase_is_empty(&sspreadsheet->viewer_path.path)) {
|
2021-04-15 08:57:10 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
ViewerPathElem *root_context = static_cast<ViewerPathElem *>(
|
|
|
|
|
sspreadsheet->viewer_path.path.first);
|
|
|
|
|
if (root_context->type != VIEWER_PATH_ELEM_TYPE_ID) {
|
2021-04-15 08:57:10 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
IDViewerPathElem *id_elem = reinterpret_cast<IDViewerPathElem *>(root_context);
|
|
|
|
|
return id_elem->id;
|
2021-04-15 08:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
static void view_active_object(const bContext *C, SpaceSpreadsheet *sspreadsheet)
|
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
2021-03-10 11:34:36 +01:00
|
|
|
{
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
BKE_viewer_path_clear(&sspreadsheet->viewer_path);
|
|
|
|
|
Object *ob = CTX_data_active_object(C);
|
|
|
|
|
if (ob == nullptr) {
|
|
|
|
|
return;
|
2021-04-15 08:57:10 +02:00
|
|
|
}
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
IDViewerPathElem *id_elem = BKE_viewer_path_elem_new_id();
|
|
|
|
|
id_elem->id = &ob->id;
|
|
|
|
|
BLI_addtail(&sspreadsheet->viewer_path.path, id_elem);
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
2021-04-15 08:57:10 +02:00
|
|
|
}
|
|
|
|
|
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
static void spreadsheet_update_context(const bContext *C)
|
2021-04-15 08:57:10 +02:00
|
|
|
{
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
using blender::ed::viewer_path::ViewerPathForGeometryNodesViewer;
|
|
|
|
|
|
2021-04-15 08:57:10 +02:00
|
|
|
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
Object *active_object = CTX_data_active_object(C);
|
|
|
|
|
Object *context_object = blender::ed::viewer_path::parse_object_only(sspreadsheet->viewer_path);
|
|
|
|
|
switch (eSpaceSpreadsheet_ObjectEvalState(sspreadsheet->object_eval_state)) {
|
|
|
|
|
case SPREADSHEET_OBJECT_EVAL_STATE_ORIGINAL:
|
|
|
|
|
case SPREADSHEET_OBJECT_EVAL_STATE_EVALUATED: {
|
|
|
|
|
if (sspreadsheet->flag & SPREADSHEET_FLAG_PINNED) {
|
|
|
|
|
if (context_object == nullptr) {
|
|
|
|
|
/* Object is not available anymore, so clear the pinning. */
|
|
|
|
|
sspreadsheet->flag &= ~SPREADSHEET_FLAG_PINNED;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* The object is still pinned, do nothing. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (active_object != context_object) {
|
|
|
|
|
/* The active object has changed, so view the new active object. */
|
|
|
|
|
view_active_object(C, sspreadsheet);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Nothing changed. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2021-04-15 08:57:10 +02:00
|
|
|
}
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
case SPREADSHEET_OBJECT_EVAL_STATE_VIEWER_NODE: {
|
|
|
|
|
WorkSpace *workspace = CTX_wm_workspace(C);
|
|
|
|
|
if (sspreadsheet->flag & SPREADSHEET_FLAG_PINNED) {
|
|
|
|
|
const std::optional<ViewerPathForGeometryNodesViewer> parsed_path =
|
|
|
|
|
blender::ed::viewer_path::parse_geometry_nodes_viewer(sspreadsheet->viewer_path);
|
|
|
|
|
if (parsed_path.has_value()) {
|
|
|
|
|
if (blender::ed::viewer_path::exists_geometry_nodes_viewer(*parsed_path)) {
|
|
|
|
|
/* The pinned path is still valid, do nothing. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-10-05 13:44:02 -05:00
|
|
|
/* The pinned path does not exist anymore, clear pinning. */
|
|
|
|
|
sspreadsheet->flag &= ~SPREADSHEET_FLAG_PINNED;
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Unknown pinned path, clear pinning. */
|
|
|
|
|
sspreadsheet->flag &= ~SPREADSHEET_FLAG_PINNED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Now try to update the viewer path from the workspace. */
|
|
|
|
|
const std::optional<ViewerPathForGeometryNodesViewer> workspace_parsed_path =
|
|
|
|
|
blender::ed::viewer_path::parse_geometry_nodes_viewer(workspace->viewer_path);
|
|
|
|
|
if (workspace_parsed_path.has_value()) {
|
|
|
|
|
if (BKE_viewer_path_equal(&sspreadsheet->viewer_path, &workspace->viewer_path)) {
|
|
|
|
|
/* Nothing changed. */
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-10-05 13:44:02 -05:00
|
|
|
/* Update the viewer path from the workspace. */
|
|
|
|
|
BKE_viewer_path_clear(&sspreadsheet->viewer_path);
|
|
|
|
|
BKE_viewer_path_copy(&sspreadsheet->viewer_path, &workspace->viewer_path);
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* No active viewer node, change back to showing evaluated active object. */
|
|
|
|
|
sspreadsheet->object_eval_state = SPREADSHEET_OBJECT_EVAL_STATE_EVALUATED;
|
|
|
|
|
view_active_object(C, sspreadsheet);
|
|
|
|
|
}
|
2021-04-15 08:57:10 +02:00
|
|
|
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2021-04-15 08:57:10 +02:00
|
|
|
}
|
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
2021-03-10 11:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-25 07:57:24 +02:00
|
|
|
Object *spreadsheet_get_object_eval(const SpaceSpreadsheet *sspreadsheet,
|
|
|
|
|
const Depsgraph *depsgraph)
|
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
2021-03-10 11:34:36 +01:00
|
|
|
{
|
2024-01-31 16:32:10 -05:00
|
|
|
ID *used_id = get_current_id(sspreadsheet);
|
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
2021-03-10 11:34:36 +01:00
|
|
|
if (used_id == nullptr) {
|
2021-06-25 07:57:24 +02:00
|
|
|
return nullptr;
|
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
2021-03-10 11:34:36 +01:00
|
|
|
}
|
|
|
|
|
const ID_Type id_type = GS(used_id->name);
|
|
|
|
|
if (id_type != ID_OB) {
|
2021-06-25 07:57:24 +02:00
|
|
|
return nullptr;
|
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
2021-03-10 11:34:36 +01:00
|
|
|
}
|
|
|
|
|
Object *object_orig = (Object *)used_id;
|
2022-04-15 09:07:00 +02:00
|
|
|
if (!ELEM(object_orig->type,
|
|
|
|
|
OB_MESH,
|
|
|
|
|
OB_POINTCLOUD,
|
|
|
|
|
OB_VOLUME,
|
|
|
|
|
OB_CURVES_LEGACY,
|
|
|
|
|
OB_FONT,
|
2023-10-10 16:49:30 +02:00
|
|
|
OB_CURVES,
|
|
|
|
|
OB_GREASE_PENCIL))
|
2022-04-15 09:07:00 +02:00
|
|
|
{
|
2021-06-25 07:57:24 +02:00
|
|
|
return nullptr;
|
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
2021-03-10 11:34:36 +01:00
|
|
|
}
|
2021-06-25 07:57:24 +02:00
|
|
|
|
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
2021-03-10 11:34:36 +01:00
|
|
|
Object *object_eval = DEG_get_evaluated_object(depsgraph, object_orig);
|
|
|
|
|
if (object_eval == nullptr) {
|
2021-06-25 07:57:24 +02:00
|
|
|
return nullptr;
|
2021-04-09 10:20:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-06-25 07:57:24 +02:00
|
|
|
return object_eval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::unique_ptr<DataSource> get_data_source(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
|
|
|
|
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
|
|
|
|
|
|
|
|
|
|
Object *object_eval = spreadsheet_get_object_eval(sspreadsheet, depsgraph);
|
|
|
|
|
if (object_eval) {
|
|
|
|
|
return data_source_from_geometry(C, object_eval);
|
|
|
|
|
}
|
|
|
|
|
return {};
|
2021-04-09 10:20:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-26 11:25:32 +02:00
|
|
|
static float get_default_column_width(const ColumnValues &values)
|
2021-04-09 10:20:46 +02:00
|
|
|
{
|
2021-10-26 11:25:32 +02:00
|
|
|
if (values.default_width > 0.0f) {
|
2021-04-12 09:14:41 +02:00
|
|
|
return values.default_width;
|
2021-04-09 10:20:46 +02:00
|
|
|
}
|
2021-10-26 11:25:32 +02:00
|
|
|
static const float float_width = 3;
|
|
|
|
|
switch (values.type()) {
|
|
|
|
|
case SPREADSHEET_VALUE_TYPE_BOOL:
|
2024-02-13 18:59:36 +01:00
|
|
|
case SPREADSHEET_VALUE_TYPE_FLOAT4X4:
|
2021-10-26 11:25:32 +02:00
|
|
|
return 2.0f;
|
2022-06-03 15:52:28 +02:00
|
|
|
case SPREADSHEET_VALUE_TYPE_INT8:
|
2021-10-26 11:25:32 +02:00
|
|
|
case SPREADSHEET_VALUE_TYPE_INT32:
|
|
|
|
|
return float_width;
|
|
|
|
|
case SPREADSHEET_VALUE_TYPE_FLOAT:
|
|
|
|
|
return float_width;
|
2023-04-14 16:08:05 +02:00
|
|
|
case SPREADSHEET_VALUE_TYPE_INT32_2D:
|
2021-10-26 11:25:32 +02:00
|
|
|
case SPREADSHEET_VALUE_TYPE_FLOAT2:
|
|
|
|
|
return 2.0f * float_width;
|
|
|
|
|
case SPREADSHEET_VALUE_TYPE_FLOAT3:
|
|
|
|
|
return 3.0f * float_width;
|
|
|
|
|
case SPREADSHEET_VALUE_TYPE_COLOR:
|
2022-06-29 13:01:38 +02:00
|
|
|
case SPREADSHEET_VALUE_TYPE_BYTE_COLOR:
|
2023-06-12 10:47:06 -04:00
|
|
|
case SPREADSHEET_VALUE_TYPE_QUATERNION:
|
2021-10-26 11:25:32 +02:00
|
|
|
return 4.0f * float_width;
|
|
|
|
|
case SPREADSHEET_VALUE_TYPE_INSTANCES:
|
|
|
|
|
return 8.0f;
|
2021-11-04 11:29:04 +01:00
|
|
|
case SPREADSHEET_VALUE_TYPE_STRING:
|
|
|
|
|
return 5.0f;
|
2021-12-15 09:34:13 -06:00
|
|
|
case SPREADSHEET_VALUE_TYPE_UNKNOWN:
|
|
|
|
|
return 2.0f;
|
2021-10-26 11:25:32 +02:00
|
|
|
}
|
|
|
|
|
return float_width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float get_column_width(const ColumnValues &values)
|
|
|
|
|
{
|
|
|
|
|
float data_width = get_default_column_width(values);
|
2021-04-09 10:20:46 +02:00
|
|
|
const int fontid = UI_style_get()->widget.uifont_id;
|
2023-03-17 04:19:05 +01:00
|
|
|
BLF_size(fontid, UI_DEFAULT_TEXT_POINTS * UI_SCALE_FAC);
|
2021-04-09 10:20:46 +02:00
|
|
|
const StringRefNull name = values.name();
|
|
|
|
|
const float name_width = BLF_width(fontid, name.data(), name.size());
|
2021-10-26 11:25:32 +02:00
|
|
|
return std::max<float>(name_width / UI_UNIT_X + 1.0f, data_width);
|
2021-04-12 09:14:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float get_column_width_in_pixels(const ColumnValues &values)
|
|
|
|
|
{
|
|
|
|
|
return get_column_width(values) * SPREADSHEET_WIDTH_UNIT;
|
2021-04-09 10:20:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int get_index_column_width(const int tot_rows)
|
|
|
|
|
{
|
|
|
|
|
const int fontid = UI_style_get()->widget.uifont_id;
|
2023-03-17 04:19:05 +01:00
|
|
|
BLF_size(fontid, UI_style_get_dpi()->widget.points * UI_SCALE_FAC);
|
2021-04-09 10:20:46 +02:00
|
|
|
return std::to_string(std::max(0, tot_rows - 1)).size() * BLF_width(fontid, "0", 1) +
|
|
|
|
|
UI_UNIT_X * 0.75;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void update_visible_columns(ListBase &columns, DataSource &data_source)
|
|
|
|
|
{
|
|
|
|
|
Set<SpreadsheetColumnID> used_ids;
|
|
|
|
|
LISTBASE_FOREACH_MUTABLE (SpreadsheetColumn *, column, &columns) {
|
|
|
|
|
std::unique_ptr<ColumnValues> values = data_source.get_column_values(*column->id);
|
|
|
|
|
/* Remove columns that don't exist anymore. */
|
|
|
|
|
if (!values) {
|
|
|
|
|
BLI_remlink(&columns, column);
|
|
|
|
|
spreadsheet_column_free(column);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 09:09:50 +02:00
|
|
|
if (!used_ids.add(*column->id)) {
|
|
|
|
|
/* Remove duplicate columns for now. */
|
|
|
|
|
BLI_remlink(&columns, column);
|
|
|
|
|
spreadsheet_column_free(column);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
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
2021-03-10 11:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-26 11:25:32 +02:00
|
|
|
data_source.foreach_default_column_ids(
|
|
|
|
|
[&](const SpreadsheetColumnID &column_id, const bool is_extra) {
|
|
|
|
|
std::unique_ptr<ColumnValues> values = data_source.get_column_values(column_id);
|
|
|
|
|
if (values) {
|
|
|
|
|
if (used_ids.add(column_id)) {
|
|
|
|
|
SpreadsheetColumnID *new_id = spreadsheet_column_id_copy(&column_id);
|
|
|
|
|
SpreadsheetColumn *new_column = spreadsheet_column_new(new_id);
|
|
|
|
|
if (is_extra) {
|
|
|
|
|
BLI_addhead(&columns, new_column);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_addtail(&columns, new_column);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
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
2021-03-10 11:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void spreadsheet_main_region_draw(const bContext *C, ARegion *region)
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
2021-03-15 09:58:38 +01:00
|
|
|
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
|
2021-10-26 11:25:32 +02:00
|
|
|
sspreadsheet->runtime->cache.set_all_unused();
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
spreadsheet_update_context(C);
|
2021-03-15 12:19:48 +01:00
|
|
|
|
2021-04-09 10:20:46 +02:00
|
|
|
std::unique_ptr<DataSource> data_source = get_data_source(C);
|
|
|
|
|
if (!data_source) {
|
|
|
|
|
data_source = std::make_unique<DataSource>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_visible_columns(sspreadsheet->columns, *data_source);
|
|
|
|
|
|
|
|
|
|
SpreadsheetLayout spreadsheet_layout;
|
|
|
|
|
ResourceScope scope;
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
|
|
|
|
std::unique_ptr<ColumnValues> values_ptr = data_source->get_column_values(*column->id);
|
|
|
|
|
/* Should have been removed before if it does not exist anymore. */
|
|
|
|
|
BLI_assert(values_ptr);
|
2021-09-14 16:08:09 +02:00
|
|
|
const ColumnValues *values = scope.add(std::move(values_ptr));
|
2021-04-12 09:14:41 +02:00
|
|
|
const int width = get_column_width_in_pixels(*values);
|
2021-04-09 10:20:46 +02:00
|
|
|
spreadsheet_layout.columns.append({values, width});
|
2021-06-18 16:33:02 -05:00
|
|
|
|
|
|
|
|
spreadsheet_column_assign_runtime_data(column, values->type(), values->name());
|
2021-04-09 10:20:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int tot_rows = data_source->tot_rows();
|
|
|
|
|
spreadsheet_layout.index_column_width = get_index_column_width(tot_rows);
|
2021-06-18 16:33:02 -05:00
|
|
|
spreadsheet_layout.row_indices = spreadsheet_filter_rows(
|
|
|
|
|
*sspreadsheet, spreadsheet_layout, *data_source, scope);
|
2021-03-15 12:19:48 +01:00
|
|
|
|
2021-04-09 10:20:46 +02:00
|
|
|
sspreadsheet->runtime->tot_columns = spreadsheet_layout.columns.size();
|
|
|
|
|
sspreadsheet->runtime->tot_rows = tot_rows;
|
|
|
|
|
sspreadsheet->runtime->visible_rows = spreadsheet_layout.row_indices.size();
|
2021-03-15 12:19:48 +01:00
|
|
|
|
2021-04-09 10:20:46 +02:00
|
|
|
std::unique_ptr<SpreadsheetDrawer> drawer = spreadsheet_drawer_from_layout(spreadsheet_layout);
|
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
2021-03-10 11:34:36 +01:00
|
|
|
draw_spreadsheet_in_region(C, region, *drawer);
|
2021-03-15 09:58:38 +01:00
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
/* Tag other regions for redraw, because the main region updates data for them. */
|
2021-03-15 09:58:38 +01:00
|
|
|
ARegion *footer = BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_FOOTER);
|
|
|
|
|
ED_region_tag_redraw(footer);
|
2021-06-18 16:33:02 -05:00
|
|
|
ARegion *sidebar = BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_UI);
|
|
|
|
|
ED_region_tag_redraw(sidebar);
|
2021-10-26 11:25:32 +02:00
|
|
|
|
|
|
|
|
/* Free all cache items that have not been used. */
|
|
|
|
|
sspreadsheet->runtime->cache.remove_all_unused();
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void spreadsheet_main_region_listener(const wmRegionListenerParams *params)
|
|
|
|
|
{
|
|
|
|
|
ARegion *region = params->region;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
SpaceSpreadsheet *sspreadsheet = static_cast<SpaceSpreadsheet *>(params->area->spacedata.first);
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
switch (wmn->category) {
|
|
|
|
|
case NC_SCENE: {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_MODE:
|
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
2021-03-10 11:34:36 +01:00
|
|
|
case ND_FRAME:
|
2021-03-08 16:23:21 +01:00
|
|
|
case ND_OB_ACTIVE: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NC_OBJECT: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NC_SPACE: {
|
|
|
|
|
if (wmn->data == ND_SPACE_SPREADSHEET) {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-04-28 14:57:58 +02:00
|
|
|
case NC_TEXTURE:
|
2021-03-08 16:23:21 +01:00
|
|
|
case NC_GEOM: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-10-12 16:51:44 +02:00
|
|
|
case NC_GPENCIL: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
case NC_VIEWER_PATH: {
|
|
|
|
|
if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_VIEWER_NODE) {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void spreadsheet_header_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
|
|
|
|
ED_region_header_init(region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void spreadsheet_header_region_draw(const bContext *C, ARegion *region)
|
|
|
|
|
{
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
spreadsheet_update_context(C);
|
2021-03-08 16:23:21 +01:00
|
|
|
ED_region_header(C, region);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
static void spreadsheet_header_region_free(ARegion * /*region*/) {}
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
static void spreadsheet_header_region_listener(const wmRegionListenerParams *params)
|
|
|
|
|
{
|
|
|
|
|
ARegion *region = params->region;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
SpaceSpreadsheet *sspreadsheet = static_cast<SpaceSpreadsheet *>(params->area->spacedata.first);
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
switch (wmn->category) {
|
|
|
|
|
case NC_SCENE: {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_MODE:
|
|
|
|
|
case ND_OB_ACTIVE: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NC_OBJECT: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NC_SPACE: {
|
|
|
|
|
if (wmn->data == ND_SPACE_SPREADSHEET) {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NC_GEOM: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-10-12 16:51:44 +02:00
|
|
|
case NC_GPENCIL: {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
case NC_VIEWER_PATH: {
|
|
|
|
|
if (sspreadsheet->object_eval_state == SPREADSHEET_OBJECT_EVAL_STATE_VIEWER_NODE) {
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void spreadsheet_footer_region_init(wmWindowManager * /*wm*/, ARegion *region)
|
2021-03-15 09:58:38 +01:00
|
|
|
{
|
|
|
|
|
ED_region_header_init(region);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void spreadsheet_footer_region_draw(const bContext *C, ARegion *region)
|
|
|
|
|
{
|
|
|
|
|
SpaceSpreadsheet *sspreadsheet = CTX_wm_space_spreadsheet(C);
|
|
|
|
|
SpaceSpreadsheet_Runtime *runtime = sspreadsheet->runtime;
|
|
|
|
|
std::stringstream ss;
|
2022-09-17 01:50:55 +02:00
|
|
|
ss << IFACE_("Rows:") << " ";
|
2021-03-15 16:10:23 +01:00
|
|
|
if (runtime->visible_rows != runtime->tot_rows) {
|
2023-03-02 17:38:36 +01:00
|
|
|
char visible_rows_str[BLI_STR_FORMAT_INT32_GROUPED_SIZE];
|
2021-03-23 10:40:54 +01:00
|
|
|
BLI_str_format_int_grouped(visible_rows_str, runtime->visible_rows);
|
|
|
|
|
ss << visible_rows_str << " / ";
|
2021-03-15 16:10:23 +01:00
|
|
|
}
|
2023-03-02 17:38:36 +01:00
|
|
|
char tot_rows_str[BLI_STR_FORMAT_INT32_GROUPED_SIZE];
|
2021-03-23 10:40:54 +01:00
|
|
|
BLI_str_format_int_grouped(tot_rows_str, runtime->tot_rows);
|
2022-09-17 01:50:55 +02:00
|
|
|
ss << tot_rows_str << " | " << IFACE_("Columns:") << " " << runtime->tot_columns;
|
2021-03-15 09:58:38 +01:00
|
|
|
std::string stats_str = ss.str();
|
|
|
|
|
|
|
|
|
|
UI_ThemeClearColor(TH_BACK);
|
|
|
|
|
|
|
|
|
|
uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS);
|
|
|
|
|
const uiStyle *style = UI_style_get_dpi();
|
|
|
|
|
uiLayout *layout = UI_block_layout(block,
|
|
|
|
|
UI_LAYOUT_HORIZONTAL,
|
|
|
|
|
UI_LAYOUT_HEADER,
|
|
|
|
|
UI_HEADER_OFFSET,
|
|
|
|
|
region->winy - (region->winy - UI_UNIT_Y) / 2.0f,
|
2022-02-04 15:23:45 +01:00
|
|
|
region->winx,
|
2021-03-15 09:58:38 +01:00
|
|
|
1,
|
|
|
|
|
0,
|
|
|
|
|
style);
|
|
|
|
|
uiItemSpacer(layout);
|
|
|
|
|
uiLayoutSetAlignment(layout, UI_LAYOUT_ALIGN_RIGHT);
|
2024-12-06 14:08:10 +01:00
|
|
|
uiItemL(layout, stats_str, ICON_NONE);
|
2021-03-15 09:58:38 +01:00
|
|
|
UI_block_layout_resolve(block, nullptr, nullptr);
|
|
|
|
|
UI_block_align_end(block);
|
|
|
|
|
UI_block_end(C, block);
|
|
|
|
|
UI_block_draw(C, block);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
static void spreadsheet_footer_region_free(ARegion * /*region*/) {}
|
2021-03-15 09:58:38 +01:00
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
static void spreadsheet_footer_region_listener(const wmRegionListenerParams * /*params*/) {}
|
2021-03-15 09:58:38 +01:00
|
|
|
|
2021-06-25 07:57:24 +02:00
|
|
|
static void spreadsheet_dataset_region_listener(const wmRegionListenerParams *params)
|
|
|
|
|
{
|
|
|
|
|
ARegion *region = params->region;
|
2022-08-27 12:50:43 +10:00
|
|
|
const wmNotifier *wmn = params->notifier;
|
2021-06-25 07:57:24 +02:00
|
|
|
|
|
|
|
|
switch (wmn->category) {
|
|
|
|
|
case NC_SCENE: {
|
|
|
|
|
switch (wmn->data) {
|
|
|
|
|
case ND_FRAME:
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NC_TEXTURE:
|
|
|
|
|
ED_region_tag_redraw(region);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spreadsheet_header_region_listener(params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void spreadsheet_dataset_region_draw(const bContext *C, ARegion *region)
|
|
|
|
|
{
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
spreadsheet_update_context(C);
|
2021-11-19 17:36:11 -05:00
|
|
|
ED_region_panels(C, region);
|
2021-06-25 07:57:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
static void spreadsheet_sidebar_init(wmWindowManager *wm, ARegion *region)
|
|
|
|
|
{
|
|
|
|
|
UI_panel_category_active_set_default(region, "Filters");
|
|
|
|
|
ED_region_panels_init(wm, region);
|
|
|
|
|
|
|
|
|
|
wmKeyMap *keymap = WM_keymap_ensure(
|
2023-09-14 13:32:42 +10:00
|
|
|
wm->defaultconf, "Spreadsheet Generic", SPACE_SPREADSHEET, RGN_TYPE_WINDOW);
|
2024-11-21 19:34:53 +01:00
|
|
|
WM_event_add_keymap_handler(®ion->runtime->handlers, keymap);
|
2021-06-18 16:33:02 -05:00
|
|
|
}
|
|
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
static void spreadsheet_right_region_free(ARegion * /*region*/) {}
|
2021-06-18 16:33:02 -05:00
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
static void spreadsheet_right_region_listener(const wmRegionListenerParams * /*params*/) {}
|
2021-06-18 16:33:02 -05:00
|
|
|
|
2022-09-28 11:52:22 +02:00
|
|
|
static void spreadsheet_blend_read_data(BlendDataReader *reader, SpaceLink *sl)
|
|
|
|
|
{
|
|
|
|
|
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
|
|
|
|
|
|
|
|
|
sspreadsheet->runtime = nullptr;
|
2024-04-24 17:01:22 +02:00
|
|
|
BLO_read_struct_list(reader, SpreadsheetRowFilter, &sspreadsheet->row_filters);
|
2022-09-28 11:52:22 +02:00
|
|
|
LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
|
2024-04-24 17:01:22 +02:00
|
|
|
BLO_read_string(reader, &row_filter->value_string);
|
2022-09-28 11:52:22 +02:00
|
|
|
}
|
2024-04-24 17:01:22 +02:00
|
|
|
BLO_read_struct_list(reader, SpreadsheetColumn, &sspreadsheet->columns);
|
2022-09-28 11:52:22 +02:00
|
|
|
LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
2024-04-24 17:01:22 +02:00
|
|
|
BLO_read_struct(reader, SpreadsheetColumnID, &column->id);
|
|
|
|
|
BLO_read_string(reader, &column->id->name);
|
2022-09-28 11:52:22 +02:00
|
|
|
/* While the display name is technically runtime data, it is loaded here, otherwise the row
|
|
|
|
|
* filters might not now their type if their region draws before the main region.
|
|
|
|
|
* This would ideally be cleared here. */
|
2024-04-24 17:01:22 +02:00
|
|
|
BLO_read_string(reader, &column->display_name);
|
2022-09-28 11:52:22 +02:00
|
|
|
}
|
|
|
|
|
|
2024-07-29 20:42:08 +02:00
|
|
|
BLO_read_struct_array(
|
|
|
|
|
reader, SpreadsheetInstanceID, sspreadsheet->instance_ids_num, &sspreadsheet->instance_ids);
|
|
|
|
|
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
BKE_viewer_path_blend_read_data(reader, &sspreadsheet->viewer_path);
|
2022-09-28 11:52:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void spreadsheet_blend_write(BlendWriter *writer, SpaceLink *sl)
|
|
|
|
|
{
|
|
|
|
|
BLO_write_struct(writer, SpaceSpreadsheet, sl);
|
|
|
|
|
SpaceSpreadsheet *sspreadsheet = (SpaceSpreadsheet *)sl;
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (SpreadsheetRowFilter *, row_filter, &sspreadsheet->row_filters) {
|
|
|
|
|
BLO_write_struct(writer, SpreadsheetRowFilter, row_filter);
|
|
|
|
|
BLO_write_string(writer, row_filter->value_string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (SpreadsheetColumn *, column, &sspreadsheet->columns) {
|
|
|
|
|
BLO_write_struct(writer, SpreadsheetColumn, column);
|
|
|
|
|
BLO_write_struct(writer, SpreadsheetColumnID, column->id);
|
|
|
|
|
BLO_write_string(writer, column->id->name);
|
|
|
|
|
/* While the display name is technically runtime data, we write it here, otherwise the row
|
|
|
|
|
* filters might not now their type if their region draws before the main region.
|
|
|
|
|
* This would ideally be cleared here. */
|
|
|
|
|
BLO_write_string(writer, column->display_name);
|
|
|
|
|
}
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
|
2024-07-29 20:42:08 +02:00
|
|
|
BLO_write_struct_array(
|
|
|
|
|
writer, SpreadsheetInstanceID, sspreadsheet->instance_ids_num, sspreadsheet->instance_ids);
|
Geometry Nodes: viewport preview
This adds support for showing geometry passed to the Viewer in the 3d
viewport (instead of just in the spreadsheet). The "viewer geometry"
bypasses the group output. So it is not necessary to change the final
output of the node group to be able to see the intermediate geometry.
**Activation and deactivation of a viewer node**
* A viewer node is activated by clicking on it.
* Ctrl+shift+click on any node/socket connects it to the viewer and
makes it active.
* Ctrl+shift+click in empty space deactivates the active viewer.
* When the active viewer is not visible anymore (e.g. another object
is selected, or the current node group is exit), it is deactivated.
* Clicking on the icon in the header of the Viewer node toggles whether
its active or not.
**Pinning**
* The spreadsheet still allows pinning the active viewer as before.
When pinned, the spreadsheet still references the viewer node even
when it becomes inactive.
* The viewport does not support pinning at the moment. It always shows
the active viewer.
**Attribute**
* When a field is linked to the second input of the viewer node it is
displayed as an overlay in the viewport.
* When possible the correct domain for the attribute is determined
automatically. This does not work in all cases. It falls back to the
face corner domain on meshes and the point domain on curves. When
necessary, the domain can be picked manually.
* The spreadsheet now only shows the "Viewer" column for the domain
that is selected in the Viewer node.
* Instance attributes are visualized as a constant color per instance.
**Viewport Options**
* The attribute overlay opacity can be controlled with the "Viewer Node"
setting in the overlays popover.
* A viewport can be configured not to show intermediate viewer-geometry
by disabling the "Viewer Node" option in the "View" menu.
**Implementation Details**
* The "spreadsheet context path" was generalized to a "viewer path" that
is used in more places now.
* The viewer node itself determines the attribute domain, evaluates the
field and stores the result in a `.viewer` attribute.
* A new "viewer attribute' overlay displays the data from the `.viewer`
attribute.
* The ground truth for the active viewer node is stored in the workspace
now. Node editors, spreadsheets and viewports retrieve the active
viewer from there unless they are pinned.
* The depsgraph object iterator has a new "viewer path" setting. When set,
the viewed geometry of the corresponding object is part of the iterator
instead of the final evaluated geometry.
* To support the instance attribute overlay `DupliObject` was extended
to contain the information necessary for drawing the overlay.
* The ctrl+shift+click operator has been refactored so that it can make
existing links to viewers active again.
* The auto-domain-detection in the Viewer node works by checking the
"preferred domain" for every field input. If there is not exactly one
preferred domain, the fallback is used.
Known limitations:
* Loose edges of meshes don't have the attribute overlay. This could be
added separately if necessary.
* Some attributes are hard to visualize as a color directly. For example,
the values might have to be normalized or some should be drawn as arrays.
For now, we encourage users to build node groups that generate appropriate
viewer-geometry. We might include some of that functionality in future versions.
Support for displaying attribute values as text in the viewport is planned as well.
* There seems to be an issue with the attribute overlay for pointclouds on
nvidia gpus, to be investigated.
Differential Revision: https://developer.blender.org/D15954
2022-09-28 17:54:59 +02:00
|
|
|
BKE_viewer_path_blend_write(writer, &sspreadsheet->viewer_path);
|
2022-09-28 11:52:22 +02:00
|
|
|
}
|
|
|
|
|
|
2024-01-31 16:32:10 -05:00
|
|
|
void register_spacetype()
|
2021-03-08 16:23:21 +01:00
|
|
|
{
|
2024-02-02 20:59:20 +01:00
|
|
|
std::unique_ptr<SpaceType> st = std::make_unique<SpaceType>();
|
2021-03-08 16:23:21 +01:00
|
|
|
ARegionType *art;
|
|
|
|
|
|
|
|
|
|
st->spaceid = SPACE_SPREADSHEET;
|
2022-09-10 16:51:15 +10:00
|
|
|
STRNCPY(st->name, "Spreadsheet");
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
st->create = spreadsheet_create;
|
|
|
|
|
st->free = spreadsheet_free;
|
|
|
|
|
st->init = spreadsheet_init;
|
|
|
|
|
st->duplicate = spreadsheet_duplicate;
|
|
|
|
|
st->operatortypes = spreadsheet_operatortypes;
|
|
|
|
|
st->keymap = spreadsheet_keymap;
|
2021-04-15 08:57:10 +02:00
|
|
|
st->id_remap = spreadsheet_id_remap;
|
2023-08-17 14:42:04 +02:00
|
|
|
st->foreach_id = spreadsheet_foreach_id;
|
2022-09-28 11:52:22 +02:00
|
|
|
st->blend_read_data = spreadsheet_blend_read_data;
|
2023-03-11 18:07:59 +01:00
|
|
|
st->blend_read_after_liblink = nullptr;
|
2022-09-28 11:52:22 +02:00
|
|
|
st->blend_write = spreadsheet_blend_write;
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
/* regions: main window */
|
2021-12-24 22:17:49 -05:00
|
|
|
art = MEM_cnew<ARegionType>("spacetype spreadsheet region");
|
2021-03-08 16:23:21 +01:00
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2023-07-25 00:35:06 +02:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
|
2023-05-25 11:24:11 +02:00
|
|
|
art->lock = 1;
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
art->init = spreadsheet_main_region_init;
|
|
|
|
|
art->draw = spreadsheet_main_region_draw;
|
|
|
|
|
art->listener = spreadsheet_main_region_listener;
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
|
|
/* regions: header */
|
2021-12-24 22:17:49 -05:00
|
|
|
art = MEM_cnew<ARegionType>("spacetype spreadsheet header region");
|
2021-03-08 16:23:21 +01:00
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
|
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
|
art->keymapflag = 0;
|
2023-07-25 00:35:06 +02:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER | ED_KEYMAP_FRAMES;
|
2023-05-25 11:24:11 +02:00
|
|
|
art->lock = 1;
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
art->init = spreadsheet_header_region_init;
|
|
|
|
|
art->draw = spreadsheet_header_region_draw;
|
|
|
|
|
art->free = spreadsheet_header_region_free;
|
|
|
|
|
art->listener = spreadsheet_header_region_listener;
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
2021-03-15 09:58:38 +01:00
|
|
|
/* regions: footer */
|
2021-12-24 22:17:49 -05:00
|
|
|
art = MEM_cnew<ARegionType>("spacetype spreadsheet footer region");
|
2021-03-15 09:58:38 +01:00
|
|
|
art->regionid = RGN_TYPE_FOOTER;
|
|
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
|
art->keymapflag = 0;
|
2023-07-25 00:35:06 +02:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER | ED_KEYMAP_FRAMES;
|
2023-05-25 11:24:11 +02:00
|
|
|
art->lock = 1;
|
2021-03-15 09:58:38 +01:00
|
|
|
|
|
|
|
|
art->init = spreadsheet_footer_region_init;
|
|
|
|
|
art->draw = spreadsheet_footer_region_draw;
|
|
|
|
|
art->free = spreadsheet_footer_region_free;
|
|
|
|
|
art->listener = spreadsheet_footer_region_listener;
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
/* regions: right panel buttons */
|
2021-12-24 22:17:49 -05:00
|
|
|
art = MEM_cnew<ARegionType>("spacetype spreadsheet right region");
|
2021-06-18 16:33:02 -05:00
|
|
|
art->regionid = RGN_TYPE_UI;
|
|
|
|
|
art->prefsizex = UI_SIDEBAR_PANEL_WIDTH;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
|
2023-05-25 11:24:11 +02:00
|
|
|
art->lock = 1;
|
2021-06-18 16:33:02 -05:00
|
|
|
|
|
|
|
|
art->init = spreadsheet_sidebar_init;
|
|
|
|
|
art->layout = ED_region_panels_layout;
|
|
|
|
|
art->draw = ED_region_panels_draw;
|
|
|
|
|
art->free = spreadsheet_right_region_free;
|
|
|
|
|
art->listener = spreadsheet_right_region_listener;
|
|
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
|
|
|
|
register_row_filter_panels(*art);
|
|
|
|
|
|
2021-06-25 07:57:24 +02:00
|
|
|
/* regions: channels */
|
2021-12-24 22:17:49 -05:00
|
|
|
art = MEM_cnew<ARegionType>("spreadsheet dataset region");
|
2021-12-28 11:05:31 -06:00
|
|
|
art->regionid = RGN_TYPE_TOOLS;
|
2021-11-19 17:36:11 -05:00
|
|
|
art->prefsizex = 150 + V2D_SCROLL_WIDTH;
|
2023-07-25 00:35:06 +02:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES;
|
2023-05-25 11:24:11 +02:00
|
|
|
art->lock = 1;
|
2021-11-19 17:36:11 -05:00
|
|
|
art->init = ED_region_panels_init;
|
2021-06-25 07:57:24 +02:00
|
|
|
art->draw = spreadsheet_dataset_region_draw;
|
|
|
|
|
art->listener = spreadsheet_dataset_region_listener;
|
2024-01-31 16:32:10 -05:00
|
|
|
spreadsheet_data_set_region_panels_register(*art);
|
2021-06-25 07:57:24 +02:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
|
|
|
|
|
2024-02-02 20:59:20 +01:00
|
|
|
BKE_spacetype_register(std::move(st));
|
2021-03-08 16:23:21 +01:00
|
|
|
}
|
2024-01-31 16:32:10 -05:00
|
|
|
|
|
|
|
|
} // namespace blender::ed::spreadsheet
|