2021-09-07 23:11:42 +02:00
|
|
|
import bpy
|
|
|
|
from bpy.types import Panel
|
|
|
|
# from .preferences import get_addon_prefs
|
|
|
|
|
|
|
|
|
2021-09-08 18:29:10 +02:00
|
|
|
# Node view panel
|
2021-09-07 23:11:42 +02:00
|
|
|
class GPEXP_PT_gp_node_ui(Panel):
|
2021-09-16 12:14:14 +02:00
|
|
|
bl_space_type = "NODE_EDITOR"
|
2021-09-07 23:11:42 +02:00
|
|
|
bl_region_type = "UI"
|
2021-09-16 12:14:14 +02:00
|
|
|
# bl_category = "View"
|
|
|
|
bl_category = "GP render"
|
2021-09-07 23:11:42 +02:00
|
|
|
bl_label = "Gpencil Render Manager"
|
|
|
|
|
|
|
|
def draw(self, context):
|
2021-09-14 18:54:30 +02:00
|
|
|
layout = self.layout
|
|
|
|
layout.operator('gp.render_scene_switch', icon='SCENE_DATA', text='Switch Scene')
|
|
|
|
|
2021-09-22 15:01:49 +02:00
|
|
|
scn = context.scene
|
|
|
|
|
|
|
|
## Camera swapping
|
|
|
|
row = layout.row()
|
|
|
|
cam = scn.camera
|
|
|
|
if cam:
|
|
|
|
text = f'{cam.name} : {scn.render.resolution_x}x{scn.render.resolution_y}' # Cam:
|
|
|
|
else:
|
|
|
|
text = f'None' # Cam:
|
|
|
|
|
|
|
|
# if cam and cam_name == 'draw_cam':
|
|
|
|
# cam_name = f'{cam.parent.name} > {cam_name}'
|
|
|
|
row.operator("gp.swap_render_cams", text=text, icon='OUTLINER_OB_CAMERA')
|
2021-09-22 18:35:52 +02:00
|
|
|
if not scn.use_nodes or not scn.node_tree:
|
|
|
|
return
|
2021-09-10 18:32:50 +02:00
|
|
|
|
2021-09-22 18:35:52 +02:00
|
|
|
layout.separator()
|
2021-09-10 18:32:50 +02:00
|
|
|
# TODO : add advanced bool checkbox to hide some options from the user
|
|
|
|
|
|
|
|
col = layout.column(align=True)
|
2021-09-08 18:29:10 +02:00
|
|
|
ct = len([n for n in context.scene.node_tree.nodes if n.type == 'R_LAYERS' and n.select])
|
|
|
|
txt = f'Merge {ct} Layer Nodes'
|
2021-09-10 18:32:50 +02:00
|
|
|
col.operator('gp.merge_selected_viewlayer_nodes', icon='NODETREE', text=txt).disconnect = True
|
|
|
|
col.operator('gp.merge_selected_viewlayer_nodes', icon='NODETREE', text='Merge (keep connect)').disconnect = False
|
|
|
|
col.enabled = ct > 1
|
2021-09-08 18:29:10 +02:00
|
|
|
|
|
|
|
layout.separator()
|
|
|
|
|
2021-09-10 18:32:50 +02:00
|
|
|
layout.label(text='All Outputs:')
|
2021-09-08 18:29:10 +02:00
|
|
|
row=layout.row()
|
|
|
|
row.operator('gp.mute_toggle_output_nodes', icon='NODE_INSERT_ON', text='Mute').mute = True
|
|
|
|
row.operator('gp.mute_toggle_output_nodes', icon='NODE_INSERT_OFF', text='Unmute').mute = False
|
|
|
|
|
2021-09-10 18:32:50 +02:00
|
|
|
layout.separator()
|
|
|
|
|
|
|
|
col=layout.column()
|
|
|
|
col.label(text='Clean and updates:')
|
|
|
|
|
|
|
|
row = col.row()
|
|
|
|
n = context.scene.node_tree.nodes.active
|
2021-09-15 18:28:16 +02:00
|
|
|
if n:
|
|
|
|
row.enabled = n and n.type == 'R_LAYERS' and not n.outputs[0].is_linked
|
|
|
|
else:
|
|
|
|
row.enabled = False
|
|
|
|
|
2021-09-10 18:32:50 +02:00
|
|
|
row.operator('gp.reconnect_render_layer', icon='ANIM', text='Reconnect')
|
|
|
|
|
|
|
|
col.operator('gp.clean_compo_tree', icon='BRUSHES_ALL', text='Clean Nodes') # NODE_CORNER
|
|
|
|
|
|
|
|
col.separator()
|
2021-09-14 18:54:30 +02:00
|
|
|
|
|
|
|
## (re)number exports
|
|
|
|
ct = len([n for n in context.scene.node_tree.nodes if n.type == 'OUTPUT_FILE' and n.select])
|
2021-09-22 12:06:40 +02:00
|
|
|
txt = f'Renumber {ct} Selected Outputs'
|
2021-09-14 18:54:30 +02:00
|
|
|
subcol = col.column()
|
|
|
|
subcol.enabled = bool(ct)
|
|
|
|
subcol.operator('gp.number_outputs', icon='LINENUMBERS_ON', text=txt).mode = 'SELECTED'
|
2021-09-22 12:06:40 +02:00
|
|
|
# subcol.operator('gp.normalize_outnames', icon='SYNTAX_OFF', text=f'Normalize Paths {ct} Selected Ouptut') # not ready
|
2021-09-14 18:54:30 +02:00
|
|
|
# col.operator('gp.number_outputs', icon='LINENUMBERS_ON', text='Renumber all outputs').mode = 'ALL'
|
2021-09-10 18:32:50 +02:00
|
|
|
|
2021-09-21 18:23:25 +02:00
|
|
|
subcol.operator('gp.set_output_node_format', icon='OUTPUT', text='Copy Active Output Format')
|
|
|
|
|
|
|
|
|
2021-09-08 18:29:10 +02:00
|
|
|
layout.separator()
|
|
|
|
|
|
|
|
col=layout.column()
|
2021-09-10 18:32:50 +02:00
|
|
|
col.label(text='Delete Options:')
|
2021-09-16 00:19:57 +02:00
|
|
|
col.operator('gp.clear_render_tree', icon='X', text='Clear Framed Nodes')
|
|
|
|
col.operator('gp.clear_render_tree', icon='X', text='Clear & Delete Render Scene').mode = "COMPLETE"
|
2021-09-10 18:32:50 +02:00
|
|
|
|
2021-09-07 23:11:42 +02:00
|
|
|
# layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Layer To Render').mode = 'ALL'
|
|
|
|
# layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='Layer To Render').mode = 'SELECTED'
|
2021-09-08 18:29:10 +02:00
|
|
|
|
2021-09-07 23:11:42 +02:00
|
|
|
# layout.operator('gp.merge_layers', icon='X', text='Merge selected nodes')
|
|
|
|
|
2021-09-08 18:29:10 +02:00
|
|
|
class GPEXP_PT_gp_dopesheet_ui(Panel):
|
|
|
|
bl_space_type = 'DOPESHEET_EDITOR'
|
|
|
|
bl_region_type = 'UI'
|
2021-09-16 00:19:57 +02:00
|
|
|
bl_category = "GP Render"
|
|
|
|
# bl_parent_id='DOPESHEET_PT_gpencil_mode'
|
2021-09-08 18:29:10 +02:00
|
|
|
bl_label = "Gpencil Render Manager"
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return context.object and context.object.type == 'GPENCIL'
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
2021-09-16 00:19:57 +02:00
|
|
|
if context.object:
|
2021-09-16 12:14:14 +02:00
|
|
|
layout.label(text=f'Object: {context.object.name}')
|
2021-09-16 00:19:57 +02:00
|
|
|
if context.object.data.users > 1:
|
|
|
|
row = layout.row()
|
|
|
|
row.label(text=f'Multiple users ({context.object.data.users})', icon='ERROR')
|
|
|
|
row.operator("wm.call_menu", text="", icon='QUESTION').name = "GPEXP_MT_multi_user_doc"
|
2021-09-21 18:23:25 +02:00
|
|
|
layout.label(text=f'viewlayer: {context.object.data.layers.active.viewlayer_render}')
|
|
|
|
|
2021-09-16 00:19:57 +02:00
|
|
|
|
2021-09-14 18:54:30 +02:00
|
|
|
## On layers
|
|
|
|
if context.object and context.object.type == 'GPENCIL':
|
|
|
|
txt = f'{len([l for l in context.object.data.layers if l.select])} Layer(s) To Render'
|
|
|
|
else:
|
|
|
|
txt = 'Layer To Render'
|
|
|
|
layout.operator('gp.add_layer_to_render', icon='RENDERLAYERS', text=txt)
|
|
|
|
|
2021-09-16 12:14:14 +02:00
|
|
|
|
2021-09-14 18:54:30 +02:00
|
|
|
# merge (only accessible if multiple layers selected)
|
|
|
|
row = layout.row()
|
2021-09-08 18:29:10 +02:00
|
|
|
ct = len([l for l in context.object.data.layers if l.select])
|
|
|
|
txt = f'Merge {ct} layers'
|
|
|
|
# merge layers from dopesheet
|
2021-09-21 18:23:25 +02:00
|
|
|
row.operator('gp.merge_viewlayers_to_active', text=txt, icon='SELECT_EXTEND')
|
2021-09-14 18:54:30 +02:00
|
|
|
row.enabled= ct > 1
|
2021-09-07 23:11:42 +02:00
|
|
|
|
2021-09-16 12:14:14 +02:00
|
|
|
|
2021-09-16 00:19:57 +02:00
|
|
|
## all and objects
|
2021-09-16 12:14:14 +02:00
|
|
|
layout.separator()
|
2021-09-17 16:31:26 +02:00
|
|
|
|
2021-09-16 12:14:14 +02:00
|
|
|
layout.label(text='Whole objects:')
|
2021-09-16 00:19:57 +02:00
|
|
|
if context.scene.name != 'Render':
|
|
|
|
txt = f'{len([o for o in context.selected_objects if o.type == "GPENCIL" and o.select_get()])} Selected Object(s) To Render'
|
|
|
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text=txt).mode='SELECTED'
|
2021-09-16 12:14:14 +02:00
|
|
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='All Visible GP To Render').mode='ALL'
|
2021-09-16 00:19:57 +02:00
|
|
|
|
2021-09-17 16:31:26 +02:00
|
|
|
layout.separator()
|
|
|
|
|
|
|
|
layout.operator('gp.layers_state', icon='CHECKMARK', text='Check layers')
|
2021-09-21 18:23:25 +02:00
|
|
|
layout.operator('gp.lower_layers_name', icon='SYNTAX_OFF', text='Rename Lowercase')
|
2021-09-17 16:31:26 +02:00
|
|
|
|
|
|
|
# row = layout.row()
|
|
|
|
layout.prop(bpy.context.preferences.edit, 'use_anim_channel_group_colors')
|
|
|
|
|
2021-09-16 00:19:57 +02:00
|
|
|
|
|
|
|
class GPEXP_MT_multi_user_doc(bpy.types.Menu):
|
|
|
|
# bl_idname = "OBJECT_MT_custom_menu"
|
|
|
|
bl_label = "Case of multiuser objects"
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
# call another menu
|
|
|
|
#layout.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map"
|
|
|
|
#**Behavior from context mode**
|
|
|
|
col = layout.column()
|
|
|
|
col.label(text='Multi user data will be rendered all together on last generated viewlayers.', icon='INFO')
|
|
|
|
col.label(text='Make them single user if needed to render separately.')
|
|
|
|
# col.label(text='Select objects > call search pop-up (F3) > "Make single user" > tick "object data" > ok')
|
|
|
|
col.label(text='Procedure:')
|
|
|
|
|
|
|
|
col.label(text='- select concerned objects')
|
|
|
|
col.label(text='- call search pop-up (F3)')
|
|
|
|
col.label(text='- search "Make single user"')
|
|
|
|
col.label(text='- tick only "object data"')
|
|
|
|
|
|
|
|
## not registered for now (better to place render menu in GP dopesheet)
|
2021-09-07 23:11:42 +02:00
|
|
|
def manager_ui(self, context):
|
|
|
|
'''appended to DATA_PT_gpencil_layers'''
|
|
|
|
|
|
|
|
layout = self.layout
|
2021-09-08 18:29:10 +02:00
|
|
|
|
|
|
|
## On layers
|
2021-09-07 23:11:42 +02:00
|
|
|
if context.object and context.object.type == 'GPENCIL':
|
|
|
|
txt = f'{len([l for l in context.object.data.layers if l.select])} Layer(s) To Render'
|
|
|
|
else:
|
|
|
|
txt = 'Layer To Render'
|
|
|
|
layout.operator('gp.add_layer_to_render', icon='RENDERLAYERS', text=txt)
|
|
|
|
|
2021-09-08 18:29:10 +02:00
|
|
|
## On objects
|
|
|
|
# txt = 'Selected Object To Render'
|
|
|
|
if context.scene.name != 'Render':
|
|
|
|
txt = f'{len([o for o in context.selected_objects if o.type == "GPENCIL" and o.select_get()])} Selected Object(s) To Render'
|
|
|
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text=txt).mode='SELECTED'
|
2021-09-07 23:11:42 +02:00
|
|
|
layout.operator('gp.add_object_to_render', icon='RENDERLAYERS', text='All GP at once').mode='ALL'
|
|
|
|
|
2021-09-08 18:29:10 +02:00
|
|
|
|
2021-09-07 23:11:42 +02:00
|
|
|
# ## function to append in a menu
|
|
|
|
# def palette_manager_menu(self, context):
|
|
|
|
# """Palette menu to append in existing menu"""
|
|
|
|
# # GPENCIL_MT_material_context_menu
|
|
|
|
# layout = self.layout
|
|
|
|
# # {'EDIT_GPENCIL', 'PAINT_GPENCIL','SCULPT_GPENCIL','WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
|
|
|
|
# layout.separator()
|
|
|
|
# prefs = get_addon_prefs()
|
|
|
|
|
|
|
|
# layout.operator("", text='do stuff from material submenu', icon='MATERIAL')
|
|
|
|
|
|
|
|
#-# REGISTER
|
|
|
|
|
|
|
|
classes=(
|
2021-09-16 00:19:57 +02:00
|
|
|
GPEXP_MT_multi_user_doc,
|
2021-09-07 23:11:42 +02:00
|
|
|
GPEXP_PT_gp_node_ui,
|
2021-09-08 18:29:10 +02:00
|
|
|
GPEXP_PT_gp_dopesheet_ui,
|
2021-09-07 23:11:42 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def register():
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
2021-09-16 00:19:57 +02:00
|
|
|
# bpy.types.DATA_PT_gpencil_layers.prepend(manager_ui)
|
2021-09-07 23:11:42 +02:00
|
|
|
|
|
|
|
def unregister():
|
2021-09-16 00:19:57 +02:00
|
|
|
# bpy.types.DATA_PT_gpencil_layers.remove(manager_ui)
|
2021-09-07 23:11:42 +02:00
|
|
|
for cls in reversed(classes):
|
|
|
|
bpy.utils.unregister_class(cls)
|