glTF: Replace Separate RGB shader node by new Separate Color node
[blender-addons.git] / btrace / bTrace_panel.py
blob6783207a6ba86359f7ecd74b9152f0dc2da38dda
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 import bpy
4 from bpy.types import Panel
6 # Draw Brush panel in Toolbar
7 class addTracerObjectPanel(Panel):
8 bl_idname = "BTRACE_PT_object_brush"
9 bl_label = "BTracer"
10 bl_space_type = "VIEW_3D"
11 bl_region_type = "UI"
12 bl_context = "objectmode"
13 bl_category = "Create"
14 bl_options = {'DEFAULT_CLOSED'}
16 def draw(self, context):
17 layout = self.layout
18 Btrace = context.window_manager.curve_tracer
19 addon_prefs = context.preferences.addons[__package__].preferences
20 switch_expand = addon_prefs.expand_enum
21 obj = context.object
23 # Color Blender Panel options
24 def color_blender():
25 # Buttons for Color Blender
26 row = box.row()
27 row.label(text="Color palette")
28 row.prop(Btrace, "mmColors", text="")
30 # Show Custom Colors if selected
31 if Btrace.mmColors == 'CUSTOM':
32 row = box.row(align=True)
33 for i in range(1, 9):
34 row.prop(Btrace, "mmColor" + str(i), text="")
35 # Show Earth Colors
36 elif Btrace.mmColors == 'BW':
37 row = box.row(align=True)
38 row.prop(Btrace, "bwColor1", text="")
39 row.prop(Btrace, "bwColor2", text="")
40 # Show Earth Colors
41 elif Btrace.mmColors == 'BRIGHT':
42 row = box.row(align=True)
43 for i in range(1, 5):
44 row.prop(Btrace, "brightColor" + str(i), text="")
45 # Show Earth Colors
46 elif Btrace.mmColors == 'EARTH':
47 row = box.row(align=True)
48 for i in range(1, 6):
49 row.prop(Btrace, "earthColor" + str(i), text="")
50 # Show Earth Colors
51 elif Btrace.mmColors == 'GREENBLUE':
52 row = box.row(align=True)
53 for i in range(1, 4):
54 row.prop(Btrace, "greenblueColor" + str(i), text="")
55 elif Btrace.mmColors == 'RANDOM':
56 row = box.row()
58 # Curve noise settings
59 def curve_noise():
60 row = box.row()
61 row.label(text="F-Curve Noise", icon='RNDCURVE')
62 row = box.row(align=True)
63 row.prop(Btrace, "fcnoise_rot", toggle=True)
64 row.prop(Btrace, "fcnoise_loc", toggle=True)
65 row.prop(Btrace, "fcnoise_scale", toggle=True)
67 col = box.column(align=True)
68 col.prop(Btrace, "fcnoise_amp")
69 col.prop(Btrace, "fcnoise_timescale")
70 box.prop(Btrace, "fcnoise_key")
72 # Curve Panel options
73 def curve_settings():
74 # Button for curve options
75 row = self.layout.row()
76 row = box.row(align=True)
78 row.prop(Btrace, "show_curve_settings",
79 icon='CURVE_BEZCURVE', text="Curve Settings")
80 row.prop(Btrace, "material_settings",
81 icon='MATERIAL_DATA', text="Material Settings")
83 if Btrace.material_settings:
84 row = box.row()
85 row.label(text="Material Settings", icon='COLOR')
86 row = box.row()
87 row.prop(Btrace, "trace_mat_random")
88 if not Btrace.trace_mat_random:
89 row = box.row()
90 row.prop(Btrace, "trace_mat_color", text="")
91 else:
92 row.prop(Btrace, "mat_run_color_blender")
93 if Btrace.mat_run_color_blender:
94 row = box.row()
95 row.operator("object.colorblenderclear",
96 text="Reset Material Keyframes",
97 icon="KEY_DEHLT")
98 row.prop(Btrace, "mmSkip", text="Keyframe every")
99 color_blender()
100 row = box.row()
102 if Btrace.show_curve_settings:
103 # selected curve options
104 if len(context.selected_objects) > 0 and obj.type == 'CURVE':
105 col = box.column(align=True)
106 col.label(text="Edit Curves for:", icon='IPO_BEZIER')
107 col.separator()
108 col.label(text="Selected Curve Bevel Options")
109 row = col.row(align=True)
110 row.prop(obj.data, "bevel_depth", text="Depth")
111 row.prop(obj.data, "bevel_resolution", text="Resolution")
112 row = col.row(align=True)
113 row.prop(obj.data, "resolution_u")
114 else: # For new curve
115 box.label(text="New Curve Settings", icon='CURVE_BEZCURVE')
116 box.prop(Btrace, "curve_spline")
117 box.prop(Btrace, "curve_handle")
118 box.label(text="Bevel Options")
119 col = box.column(align=True)
120 row = col.row(align=True)
121 row.prop(Btrace, "curve_depth", text="Depth")
122 row.prop(Btrace, "curve_resolution", text="Resolution")
123 row = col.row(align=True)
124 row.prop(Btrace, "curve_u")
126 # Grow Animation Panel options
127 def add_grow():
128 # Button for grow animation option
129 row = box.row()
130 row.label(text="Animate Final Curve", icon="NONE")
131 row = box.row()
132 row.prop(Btrace, "animate", text="Add Grow Curve Animation", icon="META_BALL")
133 box.separator()
134 if Btrace.animate:
135 box.label(text="Frame Animation Settings:", icon="META_BALL")
136 col = box.column(align=True)
137 col.prop(Btrace, "anim_auto")
138 if not Btrace.anim_auto:
139 row = col.row(align=True)
140 row.prop(Btrace, "anim_f_start")
141 row.prop(Btrace, "anim_length")
142 row = col.row(align=True)
143 row.prop(Btrace, "anim_delay")
144 row.prop(Btrace, "anim_f_fade")
146 box.label(text="Additional Settings")
147 row = box.row()
148 row.prop(Btrace, "anim_tails")
149 row.prop(Btrace, "anim_keepr")
151 # Start Btrace Panel
152 if switch_expand == 'list':
153 layout.label(text="Available Tools:", icon="COLLAPSEMENU")
154 col = layout.column(align=True)
155 col.prop(Btrace, "btrace_toolmenu", text="")
156 elif switch_expand == 'col':
157 col = layout.column(align=True)
158 col.prop(Btrace, "btrace_toolmenu", expand=True)
159 elif switch_expand == 'row':
160 row = layout.row(align=True)
161 row.alignment = 'CENTER'
162 row.prop(Btrace, "btrace_toolmenu", text="", expand=True)
164 # Start Object Tools
165 sel = context.selected_objects
167 # Default option (can be expanded into help)
168 if Btrace.btrace_toolmenu == 'tool_help':
169 row = layout.row()
170 row.label(text="Pick an option", icon="HELP")
172 # Object Trace
173 elif Btrace.btrace_toolmenu == 'tool_objectTrace':
174 row = layout.row()
175 row.label(text=" Trace Tool:", icon="FORCE_CURVE")
176 box = self.layout.box()
177 row = box.row()
178 row.label(text="Object Trace", icon="FORCE_MAGNETIC")
179 row.operator("object.btobjecttrace", text="Run!", icon="PLAY")
180 row = box.row()
181 row.prop(Btrace, "settings_toggle", icon="MODIFIER", text="Settings")
182 myselected = "Selected %d" % len(context.selected_objects)
183 row.label(text=myselected)
184 if Btrace.settings_toggle:
185 box.label(text="Edge Type for Curves:", icon="IPO_CONSTANT")
186 row = box.row(align=True)
187 row.prop(Btrace, "convert_edgetype", text="")
188 box.prop(Btrace, "object_duplicate")
189 if len(sel) > 1:
190 box.prop(Btrace, "convert_joinbefore")
191 else:
192 Btrace.convert_joinbefore = False
193 row = box.row()
194 row.prop(Btrace, "distort_curve")
195 if Btrace.distort_curve:
196 col = box.column(align=True)
197 col.prop(Btrace, "distort_modscale")
198 col.prop(Btrace, "distort_noise")
199 row = box.row()
200 curve_settings() # Show Curve/material settings
201 add_grow() # Grow settings here
203 # Objects Connect
204 elif Btrace.btrace_toolmenu == 'tool_objectsConnect':
205 row = layout.row()
206 row.label(text=" Trace Tool:", icon="FORCE_CURVE")
207 box = self.layout.box()
208 row = box.row()
209 row.label(text="Objects Connect", icon="OUTLINER_OB_EMPTY")
210 row.operator("object.btobjectsconnect", text="Run!", icon="PLAY")
211 row = box.row()
212 row.prop(Btrace, "settings_toggle", icon='MODIFIER', text='Settings')
213 row.label(text="")
214 if Btrace.settings_toggle:
215 row = box.row()
216 row.prop(Btrace, "respect_order", text="Selection Options")
217 if Btrace.respect_order:
218 box.operator("object.select_order",
219 text="Click to start order selection",
220 icon='UV_SYNC_SELECT')
221 row = box.row()
222 row.prop(Btrace, "connect_noise", text="Add F-Curve Noise")
223 if Btrace.connect_noise:
224 curve_noise() # Show Curve Noise settings
226 curve_settings() # Show Curve/material settings
227 add_grow() # Grow settings here
229 # Mesh Follow
230 elif Btrace.btrace_toolmenu == 'tool_meshFollow':
231 row = layout.row()
232 row.label(text=" Trace Tool:", icon="FORCE_CURVE")
233 box = self.layout.box()
234 row = box.row()
235 row.label(text="Mesh Follow", icon="DRIVER")
236 row.operator("object.btmeshfollow", text="Run!", icon="PLAY")
237 row = box.row()
238 if Btrace.fol_mesh_type == 'OBJECT':
239 a, b = "Trace Object", "SNAP_VOLUME"
240 if Btrace.fol_mesh_type == 'VERTS':
241 a, b = "Trace Verts", "SNAP_VERTEX"
242 if Btrace.fol_mesh_type == 'EDGES':
243 a, b = "Trace Edges", "SNAP_EDGE"
244 if Btrace.fol_mesh_type == 'FACES':
245 a, b = "Trace Faces", "SNAP_FACE"
246 row.prop(Btrace, "settings_toggle", icon='MODIFIER', text='Settings')
247 row.label(text=a, icon=b)
248 if Btrace.settings_toggle:
249 col = box.column(align=True)
250 row = col.row(align=True)
251 row.prop(Btrace, "fol_mesh_type", expand=True)
252 row = col.row(align=True)
253 if Btrace.fol_mesh_type != 'OBJECT':
254 row.prop(Btrace, "fol_sel_option", expand=True)
255 row = box.row()
256 if Btrace.fol_sel_option == 'RANDOM':
257 row.label(text="Random Select of Total")
258 row.prop(Btrace, "fol_perc_verts", text="%")
259 if Btrace.fol_sel_option == 'CUSTOM':
260 row.label(text="Choose selection in Edit Mode")
261 if Btrace.fol_sel_option == 'ALL':
262 row.label(text="Select All items")
263 col = box.column(align=True)
264 col.label(text="Time Options", icon="TIME")
265 col.prop(Btrace, "particle_step")
266 row = col.row(align=True)
267 row.prop(Btrace, "fol_start_frame")
268 row.prop(Btrace, "fol_end_frame")
269 curve_settings() # Show Curve/material settings
270 add_grow() # Grow settings here
272 # Handwriting Tools
273 elif Btrace.btrace_toolmenu == 'tool_handwrite':
274 row = layout.row()
275 row.label(text=" Trace Tool:", icon="FORCE_CURVE")
276 box = self.layout.box()
277 row = box.row()
278 row.label(text='Handwriting', icon='BRUSH_DATA')
279 row.operator("curve.btwriting", text="Run!", icon='PLAY')
280 row = box.row()
281 row = box.row()
282 row.label(text='Grease Pencil Writing Tools')
283 col = box.column(align=True)
284 row = col.row(align=True)
285 row.operator("gpencil.draw", text="Draw", icon='BRUSH_DATA').mode = 'DRAW'
286 row.operator("gpencil.draw", text="Poly", icon='VPAINT_HLT').mode = 'DRAW_POLY'
287 row = col.row(align=True)
288 row.operator("gpencil.draw", text="Line", icon='ZOOM_OUT').mode = 'DRAW_STRAIGHT'
289 row.operator("gpencil.draw", text="Erase", icon='TPAINT_HLT').mode = 'ERASER'
290 row = box.row()
291 row.operator("gpencil.data_unlink", text="Delete Grease Pencil Layer", icon="CANCEL")
292 row = box.row()
293 curve_settings() # Show Curve/material settings
294 add_grow() # Grow settings here
296 # Particle Trace
297 elif Btrace.btrace_toolmenu == 'tool_particleTrace':
298 row = layout.row()
299 row.label(text=" Trace Tool:", icon="FORCE_CURVE")
300 box = self.layout.box()
301 row = box.row()
302 row.label(text="Particle Trace", icon="PARTICLES")
303 row.operator("particles.particletrace", text="Run!", icon="PLAY")
304 row = box.row()
305 row.prop(Btrace, "settings_toggle", icon='MODIFIER', text='Settings')
306 row.label(text="")
307 if Btrace.settings_toggle:
308 box.prop(Btrace, "particle_step")
309 row = box.row()
310 row.prop(Btrace, "curve_join")
311 curve_settings() # Show Curve/material settings
312 add_grow() # Grow settings here
314 # Connect Particles
315 elif Btrace.btrace_toolmenu == 'tool_particleConnect':
316 row = layout.row()
317 row.label(text=" Trace Tool:", icon="FORCE_CURVE")
318 box = self.layout.box()
319 row = box.row()
320 row.label(text='Particle Connect', icon='MOD_PARTICLES')
321 row.operator("particles.connect", icon="PLAY", text='Run!')
322 row = box.row()
323 row.prop(Btrace, "settings_toggle", icon='MODIFIER', text='Settings')
324 row.label(text="")
325 if Btrace.settings_toggle:
326 box.prop(Btrace, "particle_step")
327 row = box.row()
328 row.prop(Btrace, 'particle_auto')
329 if not Btrace.particle_auto:
330 row = box.row(align=True)
331 row.prop(Btrace, 'particle_f_start')
332 row.prop(Btrace, 'particle_f_end')
333 curve_settings() # Show Curve/material settings
334 add_grow() # Grow settings here
336 # Grow Animation
337 elif Btrace.btrace_toolmenu == 'tool_growCurve':
338 row = layout.row()
339 row.label(text=" Curve Tool:", icon="OUTLINER_OB_CURVE")
340 box = self.layout.box()
341 row = box.row()
342 row.label(text="Grow Curve", icon="META_BALL")
343 row.operator("curve.btgrow", text="Run!", icon="PLAY")
344 row = box.row()
345 row.prop(Btrace, "settings_toggle", icon="MODIFIER", text="Settings")
346 row.operator("object.btreset", icon="KEY_DEHLT")
347 if Btrace.settings_toggle:
348 box.label(text="Frame Animation Settings:")
349 col = box.column(align=True)
350 col.prop(Btrace, "anim_auto")
351 if not Btrace.anim_auto:
352 row = col.row(align=True)
353 row.prop(Btrace, "anim_f_start")
354 row.prop(Btrace, "anim_length")
355 row = col.row(align=True)
356 row.prop(Btrace, "anim_delay")
357 row.prop(Btrace, "anim_f_fade")
359 box.label(text="Additional Settings")
360 row = box.row()
361 row.prop(Btrace, "anim_tails")
362 row.prop(Btrace, "anim_keepr")
364 # F-Curve Noise Curve
365 elif Btrace.btrace_toolmenu == 'tool_fcurve':
366 row = layout.row()
367 row.label(text=" Curve Tool:", icon="OUTLINER_OB_CURVE")
368 box = self.layout.box()
369 row = box.row()
370 row.label(text="F-Curve Noise", icon='RNDCURVE')
371 row.operator("object.btfcnoise", icon='PLAY', text="Run!")
372 row = box.row()
373 row.prop(Btrace, "settings_toggle", icon='MODIFIER', text='Settings')
374 row.operator("object.btreset", icon='KEY_DEHLT')
375 if Btrace.settings_toggle:
376 curve_noise()
378 # Color Blender
379 elif Btrace.btrace_toolmenu == 'tool_colorblender':
380 row = layout.row()
381 row.label(text=" Curve/Object Tool:", icon="OUTLINER_OB_CURVE")
382 box = self.layout.box()
383 row = box.row()
384 row.label(text="Color Blender", icon="COLOR")
385 row.operator("object.colorblender", icon='PLAY', text="Run!")
386 row = box.row()
387 row.operator("object.colorblenderclear", text="Reset Keyframes", icon="KEY_DEHLT")
388 row.prop(Btrace, "mmSkip", text="Keyframe every")
389 color_blender()