1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Panel
22 from rna_prop_ui import PropertyPanel
24 from bpy.types import Curve, SurfaceCurve, TextCurve
27 class CurveButtonsPanel:
28 bl_space_type = 'PROPERTIES'
29 bl_region_type = 'WINDOW'
33 def poll(cls, context):
34 return (context.curve is not None)
37 class CurveButtonsPanelCurve(CurveButtonsPanel):
39 def poll(cls, context):
40 return (type(context.curve) is Curve)
43 class CurveButtonsPanelSurface(CurveButtonsPanel):
45 def poll(cls, context):
46 return (type(context.curve) is SurfaceCurve)
49 class CurveButtonsPanelText(CurveButtonsPanel):
51 def poll(cls, context):
52 return (type(context.curve) is TextCurve)
55 class CurveButtonsPanelActive(CurveButtonsPanel):
56 """Same as above but for curves only"""
59 def poll(cls, context):
61 return (curve and type(curve) is not TextCurve and curve.splines.active)
64 class DATA_PT_context_curve(CurveButtonsPanel, Panel):
66 bl_options = {'HIDE_HEADER'}
68 def draw(self, context):
73 space = context.space_data
76 layout.template_ID(obj, "data")
78 layout.template_ID(space, "pin_id")
81 class DATA_PT_shape_curve(CurveButtonsPanel, Panel):
84 def draw(self, context):
88 is_surf = type(curve) is SurfaceCurve
89 is_curve = type(curve) is Curve
90 is_text = type(curve) is TextCurve
94 row.prop(curve, "dimensions", expand=True)
96 split = layout.split()
99 col.label(text="Resolution:")
100 sub = col.column(align=True)
101 sub.prop(curve, "resolution_u", text="Preview U")
102 sub.prop(curve, "render_resolution_u", text="Render U")
104 col.label(text="Twisting:")
105 col.prop(curve, "twist_mode", text="")
106 col.prop(curve, "twist_smooth", text="Smooth")
108 col.label(text="Display:")
109 col.prop(curve, "use_fast_edit", text="Fast Editing")
116 sub = col.column(align=True)
117 sub.prop(curve, "resolution_v", text="Preview V")
118 sub.prop(curve, "render_resolution_v", text="Render V")
120 if is_curve or is_text:
121 col.label(text="Fill:")
123 sub.active = (curve.dimensions == '2D' or (curve.bevel_object is None and curve.dimensions == '3D'))
124 sub.prop(curve, "fill_mode", text="")
125 col.prop(curve, "use_fill_deform")
128 col.label(text="Path / Curve-Deform:")
131 subsub.prop(curve, "use_radius")
132 subsub.prop(curve, "use_stretch")
133 sub.prop(curve, "use_deform_bounds")
136 class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel):
137 bl_label = "Texture Space"
138 bl_options = {'DEFAULT_CLOSED'}
139 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
141 def draw(self, context):
144 curve = context.curve
147 row.prop(curve, "use_auto_texspace")
148 row.prop(curve, "use_uv_as_generated")
151 row.column().prop(curve, "texspace_location", text="Location")
152 row.column().prop(curve, "texspace_size", text="Size")
154 layout.operator("curve.match_texture_space")
157 class DATA_PT_geometry_curve(CurveButtonsPanelCurve, Panel):
158 bl_label = "Geometry"
161 def poll(cls, context):
162 return (type(context.curve) in {Curve, TextCurve})
164 def draw(self, context):
167 curve = context.curve
169 split = layout.split()
172 col.label(text="Modification:")
173 col.prop(curve, "offset")
174 col.prop(curve, "extrude")
175 col.label(text="Taper Object:")
176 col.prop(curve, "taper_object", text="")
179 col.label(text="Bevel:")
180 col.prop(curve, "bevel_depth", text="Depth")
181 col.prop(curve, "bevel_resolution", text="Resolution")
182 col.label(text="Bevel Object:")
183 col.prop(curve, "bevel_object", text="")
185 if type(curve) is not TextCurve:
186 col = layout.column(align=True)
188 row.label(text="Bevel Factor:")
190 col = layout.column()
191 col.active = (curve.bevel_depth > 0 or curve.bevel_object is not None)
192 row = col.row(align=True)
193 row.prop(curve, "bevel_factor_mapping_start", text="")
194 row.prop(curve, "bevel_factor_start", text="Start")
195 row = col.row(align=True)
196 row.prop(curve, "bevel_factor_mapping_end", text="")
197 row.prop(curve, "bevel_factor_end", text="End")
201 sub.active = curve.taper_object is not None
202 sub.prop(curve, "use_map_taper")
204 sub.active = curve.bevel_object is not None
205 sub.prop(curve, "use_fill_caps")
208 class DATA_PT_pathanim(CurveButtonsPanelCurve, Panel):
209 bl_label = "Path Animation"
211 def draw_header(self, context):
212 curve = context.curve
214 self.layout.prop(curve, "use_path", text="")
216 def draw(self, context):
219 curve = context.curve
221 layout.active = curve.use_path
223 col = layout.column()
224 col.prop(curve, "path_duration", text="Frames")
225 col.prop(curve, "eval_time")
227 # these are for paths only
229 row.prop(curve, "use_path_follow")
232 class DATA_PT_active_spline(CurveButtonsPanelActive, Panel):
233 bl_label = "Active Spline"
235 def draw(self, context):
238 curve = context.curve
239 act_spline = curve.splines.active
240 is_surf = type(curve) is SurfaceCurve
241 is_poly = (act_spline.type == 'POLY')
243 split = layout.split()
246 # These settings are below but its easier to have
247 # polys set aside since they use so few settings
249 row.label(text="Cyclic:")
250 row.prop(act_spline, "use_cyclic_u", text="U")
252 layout.prop(act_spline, "use_smooth")
255 col.label(text="Cyclic:")
256 if act_spline.type == 'NURBS':
257 col.label(text="Bezier:")
258 col.label(text="Endpoint:")
259 col.label(text="Order:")
261 col.label(text="Resolution:")
264 col.prop(act_spline, "use_cyclic_u", text="U")
266 if act_spline.type == 'NURBS':
268 # sub.active = (not act_spline.use_cyclic_u)
269 sub.prop(act_spline, "use_bezier_u", text="U")
270 sub.prop(act_spline, "use_endpoint_u", text="U")
273 sub.prop(act_spline, "order_u", text="U")
274 col.prop(act_spline, "resolution_u", text="U")
278 col.prop(act_spline, "use_cyclic_v", text="V")
280 # its a surface, assume its a nurbs
282 sub.active = (not act_spline.use_cyclic_v)
283 sub.prop(act_spline, "use_bezier_v", text="V")
284 sub.prop(act_spline, "use_endpoint_v", text="V")
286 sub.prop(act_spline, "order_v", text="V")
287 sub.prop(act_spline, "resolution_v", text="V")
289 if act_spline.type == 'BEZIER':
290 col = layout.column()
291 col.label(text="Interpolation:")
294 sub.active = (curve.dimensions == '3D')
295 sub.prop(act_spline, "tilt_interpolation", text="Tilt")
297 col.prop(act_spline, "radius_interpolation", text="Radius")
299 layout.prop(act_spline, "use_smooth")
302 class DATA_PT_font(CurveButtonsPanelText, Panel):
305 def draw(self, context):
309 char = context.curve.edit_format
311 row = layout.split(percentage=0.25)
312 row.label(text="Regular")
313 row.template_ID(text, "font", open="font.open", unlink="font.unlink")
314 row = layout.split(percentage=0.25)
315 row.label(text="Bold")
316 row.template_ID(text, "font_bold", open="font.open", unlink="font.unlink")
317 row = layout.split(percentage=0.25)
318 row.label(text="Italic")
319 row.template_ID(text, "font_italic", open="font.open", unlink="font.unlink")
320 row = layout.split(percentage=0.25)
321 row.label(text="Bold & Italic")
322 row.template_ID(text, "font_bold_italic", open="font.open", unlink="font.unlink")
324 # layout.prop(text, "font")
326 split = layout.split()
329 col.prop(text, "size", text="Size")
331 col.prop(text, "shear")
333 split = layout.split()
336 col.label(text="Object Font:")
337 col.prop(text, "family", text="")
340 col.label(text="Text on Curve:")
341 col.prop(text, "follow_curve", text="")
343 split = layout.split()
346 sub = col.column(align=True)
347 sub.label(text="Underline:")
348 sub.prop(text, "underline_position", text="Position")
349 sub.prop(text, "underline_height", text="Thickness")
352 col.label(text="Character:")
353 col.prop(char, "use_bold")
354 col.prop(char, "use_italic")
355 col.prop(char, "use_underline")
358 row.prop(text, "small_caps_scale", text="Small Caps")
359 row.prop(char, "use_small_caps")
362 class DATA_PT_paragraph(CurveButtonsPanelText, Panel):
363 bl_label = "Paragraph"
365 def draw(self, context):
370 layout.label(text="Align:")
371 layout.prop(text, "align", expand=True)
373 split = layout.split()
375 col = split.column(align=True)
376 col.label(text="Spacing:")
377 col.prop(text, "space_character", text="Letter")
378 col.prop(text, "space_word", text="Word")
379 col.prop(text, "space_line", text="Line")
381 col = split.column(align=True)
382 col.label(text="Offset:")
383 col.prop(text, "offset_x", text="X")
384 col.prop(text, "offset_y", text="Y")
387 class DATA_PT_text_boxes(CurveButtonsPanelText, Panel):
388 bl_label = "Text Boxes"
390 def draw(self, context):
395 split = layout.split()
397 col.operator("font.textbox_add", icon='ZOOMIN')
400 for i, box in enumerate(text.text_boxes):
408 col = split.column(align=True)
410 col.label(text="Dimensions:")
411 col.prop(box, "width", text="Width")
412 col.prop(box, "height", text="Height")
414 col = split.column(align=True)
416 col.label(text="Offset:")
417 col.prop(box, "x", text="X")
418 col.prop(box, "y", text="Y")
420 row.operator("font.textbox_remove", text="", icon='X', emboss=False).index = i
423 class DATA_PT_custom_props_curve(CurveButtonsPanel, PropertyPanel, Panel):
424 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
425 _context_path = "object.data"
426 _property_type = bpy.types.Curve
428 if __name__ == "__main__": # only for live edit.
429 bpy.utils.register_module(__name__)