2021-03-08 16:23:21 +01:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
#
|
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
2021-04-15 08:57:10 +02:00
|
|
|
if len(space.context_path) == 0:
|
|
|
|
|
self.draw_without_context_path(layout)
|
|
|
|
|
return
|
|
|
|
|
root_context = space.context_path[0]
|
|
|
|
|
if root_context.type != 'OBJECT':
|
|
|
|
|
self.draw_without_context_path(layout)
|
|
|
|
|
return
|
|
|
|
|
obj = root_context.object
|
|
|
|
|
if obj is None:
|
|
|
|
|
self.draw_without_context_path(layout)
|
|
|
|
|
return
|
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-03-15 10:16:11 +01:00
|
|
|
layout.prop(space, "object_eval_state", text="")
|
2021-03-11 12:23:01 +01:00
|
|
|
|
2021-04-15 08:57:10 +02:00
|
|
|
context_path = space.context_path
|
|
|
|
|
if space.object_eval_state == 'ORIGINAL':
|
|
|
|
|
# Only show first context.
|
|
|
|
|
context_path = context_path[:1]
|
|
|
|
|
if space.display_context_path_collapsed:
|
|
|
|
|
self.draw_collapsed_context_path(context, layout, context_path)
|
|
|
|
|
else:
|
|
|
|
|
self.draw_full_context_path(context, layout, context_path)
|
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-04-15 08:57:10 +02:00
|
|
|
pin_icon = 'PINNED' if space.is_pinned else 'UNPINNED'
|
|
|
|
|
layout.operator("spreadsheet.toggle_pin", text="", icon=pin_icon, emboss=False)
|
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-07-05 10:46:00 +02:00
|
|
|
if space.object_eval_state == 'VIEWER_NODE' and len(context_path) < 3:
|
|
|
|
|
layout.label(text="No active viewer node.", icon='INFO')
|
|
|
|
|
|
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)
|
|
|
|
|
sub.active = self.selection_filter_available(space)
|
|
|
|
|
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
|
|
|
|
2021-04-15 08:57:10 +02:00
|
|
|
def draw_without_context_path(self, layout):
|
|
|
|
|
layout.label(text="No active context")
|
|
|
|
|
|
|
|
|
|
def draw_full_context_path(self, context, layout, context_path):
|
|
|
|
|
space = context.space_data
|
|
|
|
|
row = layout.row()
|
|
|
|
|
for ctx in context_path[:-1]:
|
|
|
|
|
subrow = row.row(align=True)
|
|
|
|
|
self.draw_spreadsheet_context(subrow, ctx)
|
|
|
|
|
self.draw_spreadsheet_context_path_icon(subrow, space)
|
|
|
|
|
|
|
|
|
|
self.draw_spreadsheet_context(row, context_path[-1])
|
|
|
|
|
|
|
|
|
|
def draw_collapsed_context_path(self, context, layout, context_path):
|
|
|
|
|
space = context.space_data
|
|
|
|
|
row = layout.row(align=True)
|
|
|
|
|
self.draw_spreadsheet_context(row, context_path[0])
|
|
|
|
|
if len(context_path) == 1:
|
|
|
|
|
return
|
|
|
|
|
self.draw_spreadsheet_context_path_icon(row, space)
|
|
|
|
|
if len(context_path) > 2:
|
|
|
|
|
self.draw_spreadsheet_context_path_icon(row, space, icon='DOT')
|
|
|
|
|
self.draw_spreadsheet_context_path_icon(row, space)
|
|
|
|
|
self.draw_spreadsheet_context(row, context_path[-1])
|
|
|
|
|
|
|
|
|
|
def draw_spreadsheet_context(self, layout, ctx):
|
|
|
|
|
if ctx.type == 'OBJECT':
|
|
|
|
|
if ctx.object is None:
|
|
|
|
|
layout.label(text="<no object>", icon='OBJECT_DATA')
|
|
|
|
|
else:
|
|
|
|
|
layout.label(text=ctx.object.name, icon='OBJECT_DATA')
|
|
|
|
|
elif ctx.type == 'MODIFIER':
|
|
|
|
|
layout.label(text=ctx.modifier_name, icon='MODIFIER')
|
|
|
|
|
elif ctx.type == 'NODE':
|
|
|
|
|
layout.label(text=ctx.node_name, icon='NODE')
|
|
|
|
|
|
|
|
|
|
def draw_spreadsheet_context_path_icon(self, layout, space, icon='RIGHTARROW_THIN'):
|
|
|
|
|
layout.prop(space, "display_context_path_collapsed", icon_only=True, emboss=False, icon=icon)
|
2021-03-08 16:23:21 +01:00
|
|
|
|
2021-06-18 16:33:02 -05:00
|
|
|
def selection_filter_available(self, space):
|
|
|
|
|
root_context = space.context_path[0]
|
|
|
|
|
if root_context.type != 'OBJECT':
|
|
|
|
|
return False
|
|
|
|
|
obj = root_context.object
|
|
|
|
|
if obj is None:
|
|
|
|
|
return False
|
|
|
|
|
if obj.type != 'MESH' or obj.mode != 'EDIT':
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
2021-07-06 12:05:27 +10:00
|
|
|
|
2021-03-08 16:23:21 +01:00
|
|
|
classes = (
|
|
|
|
|
SPREADSHEET_HT_header,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": # Only for live edit.
|
|
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|