2023-08-16 00:20:26 +10:00
|
|
|
# SPDX-FileCopyrightText: 2009-2023 Blender Authors
|
2023-06-15 13:09:04 +10:00
|
|
|
#
|
2022-02-11 09:07:11 +11:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2021-03-08 16:23:21 +01:00
|
|
|
|
|
|
|
|
import bpy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SPREADSHEET_HT_header(bpy.types.Header):
|
|
|
|
|
bl_space_type = 'SPREADSHEET'
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
space = context.space_data
|
|
|
|
|
|
|
|
|
|
layout.template_header()
|
2025-05-22 15:04:41 +02:00
|
|
|
SPREADSHEET_MT_editor_menus.draw_collapsible(context, 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
|
|
|
layout.separator_spacer()
|
2021-07-06 12:05:27 +10:00
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
row = layout.row(align=True)
|
|
|
|
|
sub = row.row(align=True)
|
2025-06-10 11:26:33 +10:00
|
|
|
sub.active = self._selection_filter_available(space)
|
2021-06-18 16:33:02 -05:00
|
|
|
sub.prop(space, "show_only_selected", text="")
|
|
|
|
|
row.prop(space, "use_filter", toggle=True, icon='FILTER', icon_only=True)
|
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
|
|
|
|
2025-06-10 11:26:33 +10:00
|
|
|
@staticmethod
|
|
|
|
|
def _selection_filter_available(space):
|
|
|
|
|
path = space.viewer_path.path
|
|
|
|
|
if not path:
|
2025-06-09 16:27:46 +10:00
|
|
|
return False
|
2025-06-10 11:26:33 +10:00
|
|
|
root_context = path[0]
|
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 root_context.type != 'ID':
|
|
|
|
|
return False
|
2025-06-10 11:26:33 +10:00
|
|
|
data_block = root_context.id
|
|
|
|
|
if isinstance(data_block, bpy.types.Object):
|
|
|
|
|
obj = data_block
|
|
|
|
|
match obj.type:
|
|
|
|
|
case 'MESH' | 'POINTCLOUD':
|
|
|
|
|
return obj.mode == 'EDIT'
|
|
|
|
|
case 'CURVES':
|
|
|
|
|
return obj.mode in {'SCULPT_CURVES', 'EDIT'}
|
2023-06-28 12:03:36 -04:00
|
|
|
return False
|
2021-06-18 16:33:02 -05:00
|
|
|
|
2021-07-06 12:05:27 +10:00
|
|
|
|
2025-05-22 15:04:41 +02:00
|
|
|
class SPREADSHEET_MT_editor_menus(bpy.types.Menu):
|
|
|
|
|
bl_idname = "SPREADSHEET_MT_editor_menus"
|
|
|
|
|
bl_label = ""
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
2025-05-23 03:58:31 +00:00
|
|
|
del context
|
2025-05-22 15:04:41 +02:00
|
|
|
layout = self.layout
|
|
|
|
|
layout.menu("SPREADSHEET_MT_view")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SPREADSHEET_MT_view(bpy.types.Menu):
|
|
|
|
|
bl_label = "View"
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
sspreadsheet = context.space_data
|
|
|
|
|
|
|
|
|
|
layout.prop(sspreadsheet, "show_region_toolbar")
|
|
|
|
|
layout.prop(sspreadsheet, "show_region_ui")
|
|
|
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
|
2025-05-29 04:12:28 +02:00
|
|
|
layout.prop(sspreadsheet, "show_internal_attributes", text="Internal Attributes")
|
|
|
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
|
2025-05-22 15:04:41 +02:00
|
|
|
layout.menu("INFO_MT_area")
|
|
|
|
|
|
|
|
|
|
|
2021-03-08 16:23:21 +01:00
|
|
|
classes = (
|
|
|
|
|
SPREADSHEET_HT_header,
|
2025-05-22 15:04:41 +02:00
|
|
|
|
|
|
|
|
SPREADSHEET_MT_editor_menus,
|
|
|
|
|
SPREADSHEET_MT_view,
|
2021-03-08 16:23:21 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # Only for live edit.
|
|
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|