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