1 # SPDX-License-Identifier: GPL-2.0-or-later
4 from bpy
.types
import Panel
6 # Draw Brush panel in Toolbar
7 class addTracerObjectPanel(Panel
):
8 bl_idname
= "BTRACE_PT_object_brush"
10 bl_space_type
= "VIEW_3D"
12 bl_context
= "objectmode"
13 bl_category
= "Create"
14 bl_options
= {'DEFAULT_CLOSED'}
16 def draw(self
, context
):
18 Btrace
= context
.window_manager
.curve_tracer
19 addon_prefs
= context
.preferences
.addons
[__package__
].preferences
20 switch_expand
= addon_prefs
.expand_enum
23 # Color Blender Panel options
25 # Buttons for Color Blender
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)
34 row
.prop(Btrace
, "mmColor" + str(i
), text
="")
36 elif Btrace
.mmColors
== 'BW':
37 row
= box
.row(align
=True)
38 row
.prop(Btrace
, "bwColor1", text
="")
39 row
.prop(Btrace
, "bwColor2", text
="")
41 elif Btrace
.mmColors
== 'BRIGHT':
42 row
= box
.row(align
=True)
44 row
.prop(Btrace
, "brightColor" + str(i
), text
="")
46 elif Btrace
.mmColors
== 'EARTH':
47 row
= box
.row(align
=True)
49 row
.prop(Btrace
, "earthColor" + str(i
), text
="")
51 elif Btrace
.mmColors
== 'GREENBLUE':
52 row
= box
.row(align
=True)
54 row
.prop(Btrace
, "greenblueColor" + str(i
), text
="")
55 elif Btrace
.mmColors
== 'RANDOM':
58 # Curve noise settings
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")
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
:
85 row
.label(text
="Material Settings", icon
='COLOR')
87 row
.prop(Btrace
, "trace_mat_random")
88 if not Btrace
.trace_mat_random
:
90 row
.prop(Btrace
, "trace_mat_color", text
="")
92 row
.prop(Btrace
, "mat_run_color_blender")
93 if Btrace
.mat_run_color_blender
:
95 row
.operator("object.colorblenderclear",
96 text
="Reset Material Keyframes",
98 row
.prop(Btrace
, "mmSkip", text
="Keyframe every")
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')
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
128 # Button for grow animation option
130 row
.label(text
="Animate Final Curve", icon
="NONE")
132 row
.prop(Btrace
, "animate", text
="Add Grow Curve Animation", icon
="META_BALL")
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")
148 row
.prop(Btrace
, "anim_tails")
149 row
.prop(Btrace
, "anim_keepr")
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)
165 sel
= context
.selected_objects
167 # Default option (can be expanded into help)
168 if Btrace
.btrace_toolmenu
== 'tool_help':
170 row
.label(text
="Pick an option", icon
="HELP")
173 elif Btrace
.btrace_toolmenu
== 'tool_objectTrace':
175 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
176 box
= self
.layout
.box()
178 row
.label(text
="Object Trace", icon
="FORCE_MAGNETIC")
179 row
.operator("object.btobjecttrace", text
="Run!", icon
="PLAY")
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")
190 box
.prop(Btrace
, "convert_joinbefore")
192 Btrace
.convert_joinbefore
= False
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")
200 curve_settings() # Show Curve/material settings
201 add_grow() # Grow settings here
204 elif Btrace
.btrace_toolmenu
== 'tool_objectsConnect':
206 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
207 box
= self
.layout
.box()
209 row
.label(text
="Objects Connect", icon
="OUTLINER_OB_EMPTY")
210 row
.operator("object.btobjectsconnect", text
="Run!", icon
="PLAY")
212 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
214 if Btrace
.settings_toggle
:
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')
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
230 elif Btrace
.btrace_toolmenu
== 'tool_meshFollow':
232 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
233 box
= self
.layout
.box()
235 row
.label(text
="Mesh Follow", icon
="DRIVER")
236 row
.operator("object.btmeshfollow", text
="Run!", icon
="PLAY")
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)
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
273 elif Btrace
.btrace_toolmenu
== 'tool_handwrite':
275 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
276 box
= self
.layout
.box()
278 row
.label(text
='Handwriting', icon
='BRUSH_DATA')
279 row
.operator("curve.btwriting", text
="Run!", icon
='PLAY')
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'
291 row
.operator("gpencil.data_unlink", text
="Delete Grease Pencil Layer", icon
="CANCEL")
293 curve_settings() # Show Curve/material settings
294 add_grow() # Grow settings here
297 elif Btrace
.btrace_toolmenu
== 'tool_particleTrace':
299 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
300 box
= self
.layout
.box()
302 row
.label(text
="Particle Trace", icon
="PARTICLES")
303 row
.operator("particles.particletrace", text
="Run!", icon
="PLAY")
305 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
307 if Btrace
.settings_toggle
:
308 box
.prop(Btrace
, "particle_step")
310 row
.prop(Btrace
, "curve_join")
311 curve_settings() # Show Curve/material settings
312 add_grow() # Grow settings here
315 elif Btrace
.btrace_toolmenu
== 'tool_particleConnect':
317 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
318 box
= self
.layout
.box()
320 row
.label(text
='Particle Connect', icon
='MOD_PARTICLES')
321 row
.operator("particles.connect", icon
="PLAY", text
='Run!')
323 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
325 if Btrace
.settings_toggle
:
326 box
.prop(Btrace
, "particle_step")
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
337 elif Btrace
.btrace_toolmenu
== 'tool_growCurve':
339 row
.label(text
=" Curve Tool:", icon
="OUTLINER_OB_CURVE")
340 box
= self
.layout
.box()
342 row
.label(text
="Grow Curve", icon
="META_BALL")
343 row
.operator("curve.btgrow", text
="Run!", icon
="PLAY")
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")
361 row
.prop(Btrace
, "anim_tails")
362 row
.prop(Btrace
, "anim_keepr")
364 # F-Curve Noise Curve
365 elif Btrace
.btrace_toolmenu
== 'tool_fcurve':
367 row
.label(text
=" Curve Tool:", icon
="OUTLINER_OB_CURVE")
368 box
= self
.layout
.box()
370 row
.label(text
="F-Curve Noise", icon
='RNDCURVE')
371 row
.operator("object.btfcnoise", icon
='PLAY', text
="Run!")
373 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
374 row
.operator("object.btreset", icon
='KEY_DEHLT')
375 if Btrace
.settings_toggle
:
379 elif Btrace
.btrace_toolmenu
== 'tool_colorblender':
381 row
.label(text
=" Curve/Object Tool:", icon
="OUTLINER_OB_CURVE")
382 box
= self
.layout
.box()
384 row
.label(text
="Color Blender", icon
="COLOR")
385 row
.operator("object.colorblender", icon
='PLAY', text
="Run!")
387 row
.operator("object.colorblenderclear", text
="Reset Keyframes", icon
="KEY_DEHLT")
388 row
.prop(Btrace
, "mmSkip", text
="Keyframe every")