made scripts pass the pep8 test (though not fully pep8 yet)
[blender-staging.git] / release / scripts / ui / properties_data_curve.py
1 # This software is distributable under the terms of the GNU
2 # General Public License (GPL) v2, the text of which can be found at
3 # http://www.gnu.org/copyleft/gpl.html. Installing, importing or otherwise
4 # using this module constitutes acceptance of the terms of this License.
5
6 # <pep8 compliant>
7 import bpy
8
9
10 class DataButtonsPanel(bpy.types.Panel):
11     bl_space_type = 'PROPERTIES'
12     bl_region_type = 'WINDOW'
13     bl_context = "data"
14
15     def poll(self, context):
16         return (context.object and context.object.type in ('CURVE', 'SURFACE') and context.curve)
17
18
19 class DataButtonsPanelCurve(DataButtonsPanel):
20     '''Same as above but for curves only'''
21
22     def poll(self, context):
23         return (context.object and context.object.type == 'CURVE' and context.curve)
24
25
26 class DataButtonsPanelActive(DataButtonsPanel):
27     '''Same as above but for curves only'''
28
29     def poll(self, context):
30         curve = context.curve
31         return (curve and curve.active_spline)
32
33
34 class DATA_PT_context_curve(DataButtonsPanel):
35     bl_label = ""
36     bl_show_header = False
37
38     def draw(self, context):
39         layout = self.layout
40
41         ob = context.object
42         curve = context.curve
43         space = context.space_data
44
45         split = layout.split(percentage=0.65)
46
47         if ob:
48             split.template_ID(ob, "data")
49             split.itemS()
50         elif curve:
51             split.template_ID(space, "pin_id")
52             split.itemS()
53
54
55 class DATA_PT_shape_curve(DataButtonsPanel):
56     bl_label = "Shape"
57
58     def draw(self, context):
59         layout = self.layout
60
61         ob = context.object
62         curve = context.curve
63         space = context.space_data
64         is_surf = (ob.type == 'SURFACE')
65
66         if not is_surf:
67             row = layout.row()
68             row.itemR(curve, "dimensions", expand=True)
69
70         split = layout.split()
71
72         col = split.column()
73
74         if not is_surf:
75             sub = col.column()
76             sub.active = (curve.dimensions == '2D')
77             sub.itemL(text="Caps:")
78             row = sub.row()
79             row.itemR(curve, "front")
80             row.itemR(curve, "back")
81
82         col.itemL(text="Textures:")
83 #               col.itemR(curve, "uv_orco")
84         col.itemR(curve, "auto_texspace")
85
86         col = split.column()
87         col.itemL(text="Resolution:")
88         sub = col.column(align=True)
89         sub.itemR(curve, "resolution_u", text="Preview U")
90         sub.itemR(curve, "render_resolution_u", text="Render U")
91
92         if is_surf:
93             sub = col.column(align=True)
94             sub.itemR(curve, "resolution_v", text="Preview V")
95             sub.itemR(curve, "render_resolution_v", text="Render V")
96
97         # XXX - put somewhere nicer.
98         row = layout.row()
99         row.itemR(curve, "twist_mode")
100         row.itemR(curve, "twist_smooth") # XXX - may not be kept
101
102 #               col.itemL(text="Display:")
103 #               col.itemL(text="HANDLES")
104 #               col.itemL(text="NORMALS")
105 #               col.itemR(curve, "vertex_normal_flip")
106
107
108 class DATA_PT_geometry_curve(DataButtonsPanel):
109     bl_label = "Geometry"
110
111     def draw(self, context):
112         layout = self.layout
113
114         curve = context.curve
115
116         split = layout.split()
117
118         col = split.column()
119         col.itemL(text="Modification:")
120         col.itemR(curve, "width")
121         col.itemR(curve, "extrude")
122         col.itemL(text="Taper Object:")
123         col.itemR(curve, "taper_object", text="")
124
125         col = split.column()
126         col.itemL(text="Bevel:")
127         col.itemR(curve, "bevel_depth", text="Depth")
128         col.itemR(curve, "bevel_resolution", text="Resolution")
129         col.itemL(text="Bevel Object:")
130         col.itemR(curve, "bevel_object", text="")
131
132
133 class DATA_PT_pathanim(DataButtonsPanelCurve):
134     bl_label = "Path Animation"
135
136     def draw_header(self, context):
137         curve = context.curve
138
139         self.layout.itemR(curve, "use_path", text="")
140
141     def draw(self, context):
142         layout = self.layout
143
144         curve = context.curve
145
146         layout.active = curve.use_path
147
148         split = layout.split()
149
150         col = split.column()
151         col.itemR(curve, "path_length", text="Frames")
152         col.itemR(curve, "use_path_follow")
153
154         col = split.column()
155         col.itemR(curve, "use_stretch")
156         col.itemR(curve, "use_radius")
157         col.itemR(curve, "use_time_offset", text="Offset Children")
158
159
160 class DATA_PT_active_spline(DataButtonsPanelActive):
161     bl_label = "Active Spline"
162
163     def draw(self, context):
164         layout = self.layout
165
166         ob = context.object
167         curve = context.curve
168         act_spline = curve.active_spline
169         is_surf = (ob.type == 'SURFACE')
170         is_poly = (act_spline.type == 'POLY')
171
172         split = layout.split()
173
174         if is_poly:
175             # These settings are below but its easier to have
176             # poly's set aside since they use so few settings
177             col = split.column()
178             col.itemL(text="Cyclic:")
179             col.itemR(act_spline, "smooth")
180             col = split.column()
181             col.itemR(act_spline, "cyclic_u", text="U")
182
183         else:
184             col = split.column()
185             col.itemL(text="Cyclic:")
186             if act_spline.type == 'NURBS':
187                 col.itemL(text="Bezier:")
188                 col.itemL(text="Endpoint:")
189                 col.itemL(text="Order:")
190
191             col.itemL(text="Resolution:")
192
193             col = split.column()
194             col.itemR(act_spline, "cyclic_u", text="U")
195
196             if act_spline.type == 'NURBS':
197                 sub = col.column()
198                 # sub.active = (not act_spline.cyclic_u)
199                 sub.itemR(act_spline, "bezier_u", text="U")
200                 sub.itemR(act_spline, "endpoint_u", text="U")
201
202                 sub = col.column()
203                 sub.itemR(act_spline, "order_u", text="U")
204             col.itemR(act_spline, "resolution_u", text="U")
205
206             if is_surf:
207                 col = split.column()
208                 col.itemR(act_spline, "cyclic_v", text="V")
209
210                 # its a surface, assume its a nurb.
211                 sub = col.column()
212                 sub.active = (not act_spline.cyclic_v)
213                 sub.itemR(act_spline, "bezier_v", text="V")
214                 sub.itemR(act_spline, "endpoint_v", text="V")
215                 sub = col.column()
216                 sub.itemR(act_spline, "order_v", text="V")
217                 sub.itemR(act_spline, "resolution_v", text="V")
218
219
220             if not is_surf:
221                 split = layout.split()
222                 col = split.column()
223                 col.active = (curve.dimensions == '3D')
224
225                 col.itemL(text="Interpolation:")
226                 col.itemR(act_spline, "tilt_interpolation", text="Tilt")
227                 col.itemR(act_spline, "radius_interpolation", text="Radius")
228
229             split = layout.split()
230             col = split.column()
231             col.itemR(act_spline, "smooth")
232
233 bpy.types.register(DATA_PT_context_curve)
234 bpy.types.register(DATA_PT_shape_curve)
235 bpy.types.register(DATA_PT_geometry_curve)
236 bpy.types.register(DATA_PT_pathanim)
237 bpy.types.register(DATA_PT_active_spline)