-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_interface.py
More file actions
320 lines (231 loc) · 12.8 KB
/
user_interface.py
File metadata and controls
320 lines (231 loc) · 12.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
import bpy
from bpy.types import Menu, Panel, Operator, UIList
class SATELLITE_OT_Add(Operator):
"""Add a new Satellite"""
bl_idname = "satl.add"
bl_label = "Add Satellite"
def execute(self, context):
sat_data = context.scene.SATL_SceneData
new_render = sat_data.sat_presets.add()
new_render.name = "Satellite " + str(len(sat_data.sat_presets))
return {'FINISHED'}
class SATELLITE_OT_Remove(Operator):
"""Remove the selected Satellite"""
bl_idname = "satl.remove"
bl_label = "Remove Satellite"
def execute(self, context):
sat_data = context.scene.SATL_SceneData
sat_data.sat_presets.remove(sat_data.sat_selected_list_index)
return {'FINISHED'}
class SATELLITE_OT_ShiftUp(Operator):
"""Moves the currently selected Satellite one up in the list"""
bl_idname = "satl.ui_shift_up"
bl_label = "Move Selection Up"
def execute(self, context):
sat_data = context.scene.SATL_SceneData
index = sat_data.sat_selected_list_index
if index <= 0:
return {'FINISHED'}
sat_data.sat_presets.move(index, index - 1)
sat_data.sat_selected_list_index -= 1
return {'FINISHED'}
class SATELLITE_OT_ShiftDown(Operator):
"""Moves the currently selected Satellite one down in the list"""
bl_idname = "satl.ui_shift_down"
bl_label = "Move Selection Down"
def execute(self, context):
sat_data = context.scene.SATL_SceneData
index = sat_data.sat_selected_list_index
if index >= len(sat_data.sat_presets) - 1:
return {'FINISHED'}
sat_data.sat_presets.move(index, index + 1)
sat_data.sat_selected_list_index += 1
return {'FINISHED'}
class SATELLITE_OT_Duplicate(Operator):
"""Duplicates a currently selected Satellite"""
bl_idname = "satl._ui_duplicate"
bl_label = "Duplicate Selection"
def execute(self, context):
sat_data = context.scene.SATL_SceneData
index = sat_data.sat_selected_list_index
selected_sat = sat_data.sat_presets[index]
new_render = sat_data.sat_presets.add()
new_render.name = selected_sat.name + "D"
for k, v in selected_sat.items():
new_render[k] = v
return {'FINISHED'}
class SATELLITE_UL_PresetList(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
layout.prop(item, "name", text="", emboss=False)
layout.prop(item, "is_active", text="")
class SATELLITE_UL_MainMenu(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Satellite"
bl_idname = "PROPERTIES_PT_Satellite"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "output"
def draw(self, context):
layout = self.layout
scene = bpy.context.scene
sat_data = scene.SATL_SceneData
# //////////////////////////////////
# LIST MENU
ui_list_area = layout.row(align = False)
ui_list_column = ui_list_area.column(align = True)
ui_list_column.template_list("SATELLITE_UL_PresetList", "default", sat_data, "sat_presets",
sat_data, "sat_selected_list_index", rows=3, maxrows=6)
ui_list_column.separator()
ui_list_column.operator("satl.render_selected", icon = "EXPORT")
ui_list_column.operator("satl.render_all", icon = "EXPORT")
ui_list_column.separator()
ui_list_column = ui_list_area.column(align = True)
ui_list_column.operator("satl.add", text="", icon="ADD")
ui_list_column.operator("satl.remove", text="", icon="REMOVE")
ui_list_column.separator()
ui_list_column.operator("satl.ui_shift_up", text="", icon="TRIA_UP")
ui_list_column.operator("satl.ui_shift_down", text="", icon="TRIA_DOWN")
ui_list_column.separator()
ui_list_column.operator("satl._ui_duplicate", text="", icon="DUPLICATE")
ui_list_column.separator()
# //////////////////////////////////
# PRESET OPTIONS
render_options_area = layout.column(align=False)
count = 0
for i, item in enumerate(sat_data.sat_presets, 1):
count += 1
list_index = sat_data.sat_selected_list_index
if list_index > -1 and list_index < count:
render_selected = sat_data.sat_presets[list_index]
render_output = render_options_area.column(align=True)
render_output.use_property_split = True
render_output.use_property_decorate = False
render_output.separator()
# render_options_list.prop(render_selected, "name")
render_output.prop(render_selected, "output_dir")
render_output.prop(render_selected, "output_name")
render_output.separator()
render_output.separator()
render_output.separator()
render_format_selector = render_options_area.row(align=True)
render_format_selector_split = render_format_selector.split(factor=0.4, align=True)
render_format_selector_split.label(text="Render Type", icon="RENDER_STILL")
render_format_selector_split.prop(render_selected, "render_type", text="")
render_options_area.separator()
render_format_box = render_options_area.box()
render_format_area = render_format_box.column(align=True)
render_format_area.separator()
if render_selected.render_type == 'Skybox':
render_format = render_selected.data_skybox
# First we have to splice the space up weirdly to get padding on each side
render_tab_area = render_format_area.row(align=True)
render_tab_area.separator()
render_format_options = render_tab_area.column(align=True)
render_format_options.use_property_split = True
render_format_options.use_property_decorate = False
# Scene Settings
render_format_options.prop(render_format, "world_material")
render_format_options.prop(render_format, "view_layer")
render_format_options.separator()
render_format_options.separator()
render_format_options.separator()
# Render Engine Settings
# render_format_options.prop(render_format, "render_engine")
render_format_options.separator()
render_format_options.prop(render_format, "resolution")
render_format_options.prop(render_format, "samples")
render_format_options.separator()
if render_format.render_engine == 'Cycles':
# This is used to ensure the boolean label is aligned.
render_format_list_denoiser = render_format_options.column(align=True,
heading="Use Denoiser")
render_format_list_denoiser.prop(render_format, "cycles_use_denoiser", text="")
elif render_format.render_engine == 'Eevee':
# This is used to ensure the boolean label is aligned.
render_format_list_denoiser = render_format_options.column(align=True,
heading="Disable Post-Processing")
render_format_list_denoiser.prop(render_format, "eevee_disable_pp", text="")
render_format_options.separator()
render_format_options.separator()
render_format_options.separator()
render_format_col_mode = render_format_options.row(align=True)
render_format_col_mode.prop(render_format, "color_mode", expand=True)
render_format_options.separator()
render_format_options.separator()
render_format_options.separator()
# Color Settings
render_format_options.prop(render_selected, "color_view_transform")
render_format_options.prop(render_selected, "color_look")
render_format_options.separator()
render_format_options.prop(render_selected, "color_exposure")
render_format_options.prop(render_selected, "color_gamma")
render_format_options.separator()
render_format_options.separator()
if render_selected.render_type == 'Direct Camera':
render_format = render_selected.data_camera
# First we have to splice the space up weirdly to get padding on each side
render_tab_area = render_format_area.row(align=True)
render_tab_area.separator()
# In order to get our tabs we have to use property split later
render_format_options = render_tab_area.column(align=True)
render_format_options.use_property_split = True
render_format_options.use_property_decorate = False
# Scene Settings
render_format_options.prop(render_format, "target_camera")
render_format_options.prop(render_format, "view_layer")
render_format_options.separator()
render_format_options.prop(render_format, "world_material")
render_format_options.prop(render_format, "replacement_material")
render_format_options.separator()
render_format_options.separator()
render_format_options.separator()
# Render Engine Settings
render_format_options.prop(render_format, "render_engine")
render_format_options.separator()
render_format_options.prop(render_format, "resolution_x")
render_format_options.prop(render_format, "resolution_y")
render_format_options.prop(render_format, "samples")
render_format_options.separator()
if render_format.render_engine == 'Cycles':
# This is used to ensure the boolean label is aligned.
render_format_list_denoiser = render_format_options.column(align=True,
heading="Use Denoiser")
render_format_list_denoiser.prop(render_format, "cycles_use_denoiser", text="")
elif render_format.render_engine == 'Eevee':
# This is used to ensure the boolean label is aligned.
render_format_list_denoiser = render_format_options.column(align=True,
heading="Disable Post-Processing")
render_format_list_denoiser.prop(render_format, "eevee_disable_pp", text="")
render_format_options.separator()
render_format_options.separator()
render_format_options.separator()
# Export Format Settings
render_format_options.prop(render_format, "file_format")
render_format_options.separator()
file_format = render_format.file_format
if file_format in ['JPEG', 'CINEON', 'HDR']:
render_format_col_mode = render_format_options.row(align=True)
render_format_col_mode.prop(render_format, "color_mode_bw", expand=True)
else:
render_format_col_mode = render_format_options.row(align=True)
render_format_col_mode.prop(render_format, "color_mode", expand=True)
if file_format in ['PNG']:
render_format_col_depth = render_format_options.row(align=True)
render_format_col_depth.prop(render_format, "color_depth", expand=True)
if file_format in ['PNG']:
render_format_options.prop(render_format, "compression")
if file_format in ['JPEG']:
render_format_options.prop(render_format, "quality")
render_format_options.separator()
render_format_options.separator()
render_format_options.separator()
# Color Settings
render_format_options.prop(render_selected, "color_view_transform")
render_format_options.prop(render_selected, "color_look")
render_format_options.separator()
render_format_options.prop(render_selected, "color_exposure")
render_format_options.prop(render_selected, "color_gamma")
render_format_options.separator()
render_format_options.separator()
# Adds the padding on the right side.
render_tab_area.separator()