1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 from bpy
.types
import Panel
8 # Draw Brush panel in Toolbar
9 class addTracerObjectPanel(Panel
):
10 bl_idname
= "BTRACE_PT_object_brush"
12 bl_space_type
= "VIEW_3D"
14 bl_context
= "objectmode"
15 bl_category
= "Create"
16 bl_options
= {'DEFAULT_CLOSED'}
18 def draw(self
, context
):
20 Btrace
= context
.window_manager
.curve_tracer
21 addon_prefs
= context
.preferences
.addons
[__package__
].preferences
22 switch_expand
= addon_prefs
.expand_enum
25 # Color Blender Panel options
27 # Buttons for Color Blender
29 row
.label(text
="Color palette")
30 row
.prop(Btrace
, "mmColors", text
="")
32 # Show Custom Colors if selected
33 if Btrace
.mmColors
== 'CUSTOM':
34 row
= box
.row(align
=True)
36 row
.prop(Btrace
, "mmColor" + str(i
), text
="")
38 elif Btrace
.mmColors
== 'BW':
39 row
= box
.row(align
=True)
40 row
.prop(Btrace
, "bwColor1", text
="")
41 row
.prop(Btrace
, "bwColor2", text
="")
43 elif Btrace
.mmColors
== 'BRIGHT':
44 row
= box
.row(align
=True)
46 row
.prop(Btrace
, "brightColor" + str(i
), text
="")
48 elif Btrace
.mmColors
== 'EARTH':
49 row
= box
.row(align
=True)
51 row
.prop(Btrace
, "earthColor" + str(i
), text
="")
53 elif Btrace
.mmColors
== 'GREENBLUE':
54 row
= box
.row(align
=True)
56 row
.prop(Btrace
, "greenblueColor" + str(i
), text
="")
57 elif Btrace
.mmColors
== 'RANDOM':
60 # Curve noise settings
63 row
.label(text
="F-Curve Noise", icon
='RNDCURVE')
64 row
= box
.row(align
=True)
65 row
.prop(Btrace
, "fcnoise_rot", toggle
=True)
66 row
.prop(Btrace
, "fcnoise_loc", toggle
=True)
67 row
.prop(Btrace
, "fcnoise_scale", toggle
=True)
69 col
= box
.column(align
=True)
70 col
.prop(Btrace
, "fcnoise_amp")
71 col
.prop(Btrace
, "fcnoise_timescale")
72 box
.prop(Btrace
, "fcnoise_key")
76 # Button for curve options
77 row
= self
.layout
.row()
78 row
= box
.row(align
=True)
80 row
.prop(Btrace
, "show_curve_settings",
81 icon
='CURVE_BEZCURVE', text
="Curve Settings")
82 row
.prop(Btrace
, "material_settings",
83 icon
='MATERIAL_DATA', text
="Material Settings")
85 if Btrace
.material_settings
:
87 row
.label(text
="Material Settings", icon
='COLOR')
89 row
.prop(Btrace
, "trace_mat_random")
90 if not Btrace
.trace_mat_random
:
92 row
.prop(Btrace
, "trace_mat_color", text
="")
94 row
.prop(Btrace
, "mat_run_color_blender")
95 if Btrace
.mat_run_color_blender
:
97 row
.operator("object.colorblenderclear",
98 text
="Reset Material Keyframes",
100 row
.prop(Btrace
, "mmSkip", text
="Keyframe every")
104 if Btrace
.show_curve_settings
:
105 # selected curve options
106 if len(context
.selected_objects
) > 0 and obj
.type == 'CURVE':
107 col
= box
.column(align
=True)
108 col
.label(text
="Edit Curves for:", icon
='IPO_BEZIER')
110 col
.label(text
="Selected Curve Bevel Options")
111 row
= col
.row(align
=True)
112 row
.prop(obj
.data
, "bevel_depth", text
="Depth")
113 row
.prop(obj
.data
, "bevel_resolution", text
="Resolution")
114 row
= col
.row(align
=True)
115 row
.prop(obj
.data
, "resolution_u")
116 else: # For new curve
117 box
.label(text
="New Curve Settings", icon
='CURVE_BEZCURVE')
118 box
.prop(Btrace
, "curve_spline")
119 box
.prop(Btrace
, "curve_handle")
120 box
.label(text
="Bevel Options")
121 col
= box
.column(align
=True)
122 row
= col
.row(align
=True)
123 row
.prop(Btrace
, "curve_depth", text
="Depth")
124 row
.prop(Btrace
, "curve_resolution", text
="Resolution")
125 row
= col
.row(align
=True)
126 row
.prop(Btrace
, "curve_u")
128 # Grow Animation Panel options
130 # Button for grow animation option
132 row
.label(text
="Animate Final Curve", icon
="NONE")
134 row
.prop(Btrace
, "animate", text
="Add Grow Curve Animation", icon
="META_BALL")
137 box
.label(text
="Frame Animation Settings:", icon
="META_BALL")
138 col
= box
.column(align
=True)
139 col
.prop(Btrace
, "anim_auto")
140 if not Btrace
.anim_auto
:
141 row
= col
.row(align
=True)
142 row
.prop(Btrace
, "anim_f_start")
143 row
.prop(Btrace
, "anim_length")
144 row
= col
.row(align
=True)
145 row
.prop(Btrace
, "anim_delay")
146 row
.prop(Btrace
, "anim_f_fade")
148 box
.label(text
="Additional Settings")
150 row
.prop(Btrace
, "anim_tails")
151 row
.prop(Btrace
, "anim_keepr")
154 if switch_expand
== 'list':
155 layout
.label(text
="Available Tools:", icon
="COLLAPSEMENU")
156 col
= layout
.column(align
=True)
157 col
.prop(Btrace
, "btrace_toolmenu", text
="")
158 elif switch_expand
== 'col':
159 col
= layout
.column(align
=True)
160 col
.prop(Btrace
, "btrace_toolmenu", expand
=True)
161 elif switch_expand
== 'row':
162 row
= layout
.row(align
=True)
163 row
.alignment
= 'CENTER'
164 row
.prop(Btrace
, "btrace_toolmenu", text
="", expand
=True)
167 sel
= context
.selected_objects
169 # Default option (can be expanded into help)
170 if Btrace
.btrace_toolmenu
== 'tool_help':
172 row
.label(text
="Pick an option", icon
="HELP")
175 elif Btrace
.btrace_toolmenu
== 'tool_objectTrace':
177 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
178 box
= self
.layout
.box()
180 row
.label(text
="Object Trace", icon
="FORCE_MAGNETIC")
181 row
.operator("object.btobjecttrace", text
="Run!", icon
="PLAY")
183 row
.prop(Btrace
, "settings_toggle", icon
="MODIFIER", text
="Settings")
184 myselected
= "Selected %d" % len(context
.selected_objects
)
185 row
.label(text
=myselected
)
186 if Btrace
.settings_toggle
:
187 box
.label(text
="Edge Type for Curves:", icon
="IPO_CONSTANT")
188 row
= box
.row(align
=True)
189 row
.prop(Btrace
, "convert_edgetype", text
="")
190 box
.prop(Btrace
, "object_duplicate")
192 box
.prop(Btrace
, "convert_joinbefore")
194 Btrace
.convert_joinbefore
= False
196 row
.prop(Btrace
, "distort_curve")
197 if Btrace
.distort_curve
:
198 col
= box
.column(align
=True)
199 col
.prop(Btrace
, "distort_modscale")
200 col
.prop(Btrace
, "distort_noise")
202 curve_settings() # Show Curve/material settings
203 add_grow() # Grow settings here
206 elif Btrace
.btrace_toolmenu
== 'tool_objectsConnect':
208 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
209 box
= self
.layout
.box()
211 row
.label(text
="Objects Connect", icon
="OUTLINER_OB_EMPTY")
212 row
.operator("object.btobjectsconnect", text
="Run!", icon
="PLAY")
214 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
216 if Btrace
.settings_toggle
:
218 row
.prop(Btrace
, "respect_order", text
="Selection Options")
219 if Btrace
.respect_order
:
220 box
.operator("object.select_order",
221 text
="Click to start order selection",
222 icon
='UV_SYNC_SELECT')
224 row
.prop(Btrace
, "connect_noise", text
="Add F-Curve Noise")
225 if Btrace
.connect_noise
:
226 curve_noise() # Show Curve Noise settings
228 curve_settings() # Show Curve/material settings
229 add_grow() # Grow settings here
232 elif Btrace
.btrace_toolmenu
== 'tool_meshFollow':
234 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
235 box
= self
.layout
.box()
237 row
.label(text
="Mesh Follow", icon
="DRIVER")
238 row
.operator("object.btmeshfollow", text
="Run!", icon
="PLAY")
240 if Btrace
.fol_mesh_type
== 'OBJECT':
241 a
, b
= "Trace Object", "SNAP_VOLUME"
242 if Btrace
.fol_mesh_type
== 'VERTS':
243 a
, b
= "Trace Verts", "SNAP_VERTEX"
244 if Btrace
.fol_mesh_type
== 'EDGES':
245 a
, b
= "Trace Edges", "SNAP_EDGE"
246 if Btrace
.fol_mesh_type
== 'FACES':
247 a
, b
= "Trace Faces", "SNAP_FACE"
248 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
249 row
.label(text
=a
, icon
=b
)
250 if Btrace
.settings_toggle
:
251 col
= box
.column(align
=True)
252 row
= col
.row(align
=True)
253 row
.prop(Btrace
, "fol_mesh_type", expand
=True)
254 row
= col
.row(align
=True)
255 if Btrace
.fol_mesh_type
!= 'OBJECT':
256 row
.prop(Btrace
, "fol_sel_option", expand
=True)
258 if Btrace
.fol_sel_option
== 'RANDOM':
259 row
.label(text
="Random Select of Total")
260 row
.prop(Btrace
, "fol_perc_verts", text
="%")
261 if Btrace
.fol_sel_option
== 'CUSTOM':
262 row
.label(text
="Choose selection in Edit Mode")
263 if Btrace
.fol_sel_option
== 'ALL':
264 row
.label(text
="Select All items")
265 col
= box
.column(align
=True)
266 col
.label(text
="Time Options", icon
="TIME")
267 col
.prop(Btrace
, "particle_step")
268 row
= col
.row(align
=True)
269 row
.prop(Btrace
, "fol_start_frame")
270 row
.prop(Btrace
, "fol_end_frame")
271 curve_settings() # Show Curve/material settings
272 add_grow() # Grow settings here
275 elif Btrace
.btrace_toolmenu
== 'tool_handwrite':
277 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
278 box
= self
.layout
.box()
280 row
.label(text
='Handwriting', icon
='BRUSH_DATA')
281 row
.operator("curve.btwriting", text
="Run!", icon
='PLAY')
284 row
.label(text
='Grease Pencil Writing Tools')
285 col
= box
.column(align
=True)
286 row
= col
.row(align
=True)
287 row
.operator("gpencil.draw", text
="Draw", icon
='BRUSH_DATA').mode
= 'DRAW'
288 row
.operator("gpencil.draw", text
="Poly", icon
='VPAINT_HLT').mode
= 'DRAW_POLY'
289 row
= col
.row(align
=True)
290 row
.operator("gpencil.draw", text
="Line", icon
='ZOOM_OUT').mode
= 'DRAW_STRAIGHT'
291 row
.operator("gpencil.draw", text
="Erase", icon
='TPAINT_HLT').mode
= 'ERASER'
293 row
.operator("gpencil.data_unlink", text
="Delete Grease Pencil Layer", icon
="CANCEL")
295 curve_settings() # Show Curve/material settings
296 add_grow() # Grow settings here
299 elif Btrace
.btrace_toolmenu
== 'tool_particleTrace':
301 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
302 box
= self
.layout
.box()
304 row
.label(text
="Particle Trace", icon
="PARTICLES")
305 row
.operator("particles.particletrace", text
="Run!", icon
="PLAY")
307 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
309 if Btrace
.settings_toggle
:
310 box
.prop(Btrace
, "particle_step")
312 row
.prop(Btrace
, "curve_join")
313 curve_settings() # Show Curve/material settings
314 add_grow() # Grow settings here
317 elif Btrace
.btrace_toolmenu
== 'tool_particleConnect':
319 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
320 box
= self
.layout
.box()
322 row
.label(text
='Particle Connect', icon
='MOD_PARTICLES')
323 row
.operator("particles.connect", icon
="PLAY", text
='Run!')
325 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
327 if Btrace
.settings_toggle
:
328 box
.prop(Btrace
, "particle_step")
330 row
.prop(Btrace
, 'particle_auto')
331 if not Btrace
.particle_auto
:
332 row
= box
.row(align
=True)
333 row
.prop(Btrace
, 'particle_f_start')
334 row
.prop(Btrace
, 'particle_f_end')
335 curve_settings() # Show Curve/material settings
336 add_grow() # Grow settings here
339 elif Btrace
.btrace_toolmenu
== 'tool_growCurve':
341 row
.label(text
=" Curve Tool:", icon
="OUTLINER_OB_CURVE")
342 box
= self
.layout
.box()
344 row
.label(text
="Grow Curve", icon
="META_BALL")
345 row
.operator("curve.btgrow", text
="Run!", icon
="PLAY")
347 row
.prop(Btrace
, "settings_toggle", icon
="MODIFIER", text
="Settings")
348 row
.operator("object.btreset", icon
="KEY_DEHLT")
349 if Btrace
.settings_toggle
:
350 box
.label(text
="Frame Animation Settings:")
351 col
= box
.column(align
=True)
352 col
.prop(Btrace
, "anim_auto")
353 if not Btrace
.anim_auto
:
354 row
= col
.row(align
=True)
355 row
.prop(Btrace
, "anim_f_start")
356 row
.prop(Btrace
, "anim_length")
357 row
= col
.row(align
=True)
358 row
.prop(Btrace
, "anim_delay")
359 row
.prop(Btrace
, "anim_f_fade")
361 box
.label(text
="Additional Settings")
363 row
.prop(Btrace
, "anim_tails")
364 row
.prop(Btrace
, "anim_keepr")
366 # F-Curve Noise Curve
367 elif Btrace
.btrace_toolmenu
== 'tool_fcurve':
369 row
.label(text
=" Curve Tool:", icon
="OUTLINER_OB_CURVE")
370 box
= self
.layout
.box()
372 row
.label(text
="F-Curve Noise", icon
='RNDCURVE')
373 row
.operator("object.btfcnoise", icon
='PLAY', text
="Run!")
375 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
376 row
.operator("object.btreset", icon
='KEY_DEHLT')
377 if Btrace
.settings_toggle
:
381 elif Btrace
.btrace_toolmenu
== 'tool_colorblender':
383 row
.label(text
=" Curve/Object Tool:", icon
="OUTLINER_OB_CURVE")
384 box
= self
.layout
.box()
386 row
.label(text
="Color Blender", icon
="COLOR")
387 row
.operator("object.colorblender", icon
='PLAY', text
="Run!")
389 row
.operator("object.colorblenderclear", text
="Reset Keyframes", icon
="KEY_DEHLT")
390 row
.prop(Btrace
, "mmSkip", text
="Keyframe every")