767b163d3c2c803a18386a3c8cd3857a8c9e872c
[blender-staging.git] / release / scripts / ui / properties_data_armature.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
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.
7 #
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.
12 #
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.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23
24 class ArmatureButtonsPanel():
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "data"
28
29     @classmethod
30     def poll(cls, context):
31         return context.armature
32
33
34 class DATA_PT_context_arm(ArmatureButtonsPanel, bpy.types.Panel):
35     bl_label = ""
36     bl_show_header = False
37
38     def draw(self, context):
39         layout = self.layout
40
41         ob = context.object
42         arm = context.armature
43         space = context.space_data
44
45         split = layout.split(percentage=0.65)
46         if ob:
47             split.template_ID(ob, "data")
48             split.separator()
49         elif arm:
50             split.template_ID(space, "pin_id")
51             split.separator()
52
53
54 class DATA_PT_skeleton(ArmatureButtonsPanel, bpy.types.Panel):
55     bl_label = "Skeleton"
56
57     def draw(self, context):
58         layout = self.layout
59
60         arm = context.armature
61
62         layout.prop(arm, "pose_position", expand=True)
63
64         split = layout.split()
65
66         col = split.column()
67         col.label(text="Layers:")
68         col.prop(arm, "layers", text="")
69         col.label(text="Protected Layers:")
70         col.prop(arm, "layer_protection", text="")
71
72         col.label(text="Deform:")
73
74         split = layout.split()
75
76         col = split.column()
77         col.prop(arm, "deform_vertexgroups", text="Vertex Groups")
78         col.prop(arm, "deform_envelope", text="Envelopes")
79
80         col = split.column()
81         col.prop(arm, "deform_quaternion", text="Quaternion")
82
83
84 class DATA_PT_display(ArmatureButtonsPanel, bpy.types.Panel):
85     bl_label = "Display"
86
87     def draw(self, context):
88         layout = self.layout
89
90         ob = context.object
91         arm = context.armature
92
93         layout.row().prop(arm, "drawtype", expand=True)
94
95         split = layout.split()
96
97         col = split.column()
98         col.prop(arm, "show_names", text="Names")
99         col.prop(arm, "show_axes", text="Axes")
100         col.prop(arm, "show_bone_custom_shapes", text="Shapes")
101
102         col = split.column()
103         col.prop(arm, "show_group_colors", text="Colors")
104         col.prop(ob, "show_x_ray", text="X-Ray")
105         col.prop(arm, "delay_deform", text="Delay Refresh")
106
107
108 class DATA_PT_bone_groups(ArmatureButtonsPanel, bpy.types.Panel):
109     bl_label = "Bone Groups"
110
111     @classmethod
112     def poll(cls, context):
113         return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
114
115     def draw(self, context):
116         layout = self.layout
117
118         ob = context.object
119         pose = ob.pose
120
121         row = layout.row()
122         row.template_list(pose, "bone_groups", pose, "active_bone_group_index", rows=2)
123
124         col = row.column(align=True)
125         col.active = (ob.proxy is None)
126         col.operator("pose.group_add", icon='ZOOMIN', text="")
127         col.operator("pose.group_remove", icon='ZOOMOUT', text="")
128
129         group = pose.active_bone_group
130         if group:
131             col = layout.column()
132             col.active = (ob.proxy is None)
133             col.prop(group, "name")
134
135             split = layout.split()
136             split.active = (ob.proxy is None)
137
138             col = split.column()
139             col.prop(group, "color_set")
140             if group.color_set:
141                 col = split.column()
142                 col.template_triColorSet(group, "colors")
143
144         row = layout.row()
145         row.active = (ob.proxy is None)
146
147         sub = row.row(align=True)
148         sub.operator("pose.group_assign", text="Assign")
149         sub.operator("pose.group_unassign", text="Remove") #row.operator("pose.bone_group_remove_from", text="Remove")
150
151         sub = row.row(align=True)
152         sub.operator("pose.group_select", text="Select")
153         sub.operator("pose.group_deselect", text="Deselect")
154
155
156 # TODO: this panel will soon be depreceated too
157 class DATA_PT_ghost(ArmatureButtonsPanel, bpy.types.Panel):
158     bl_label = "Ghost"
159
160     def draw(self, context):
161         layout = self.layout
162
163         arm = context.armature
164
165         layout.prop(arm, "ghost_type", expand=True)
166
167         split = layout.split()
168
169         col = split.column()
170
171         sub = col.column(align=True)
172         if arm.ghost_type == 'RANGE':
173             sub.prop(arm, "ghost_frame_start", text="Start")
174             sub.prop(arm, "ghost_frame_end", text="End")
175             sub.prop(arm, "ghost_size", text="Step")
176         elif arm.ghost_type == 'CURRENT_FRAME':
177             sub.prop(arm, "ghost_step", text="Range")
178             sub.prop(arm, "ghost_size", text="Step")
179
180         col = split.column()
181         col.label(text="Display:")
182         col.prop(arm, "show_only_ghost_selected", text="Selected Only")
183
184
185 class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, bpy.types.Panel):
186     bl_label = "iTaSC parameters"
187     bl_default_closed = True
188
189     @classmethod
190     def poll(cls, context):
191         ob = context.object
192         return (ob and ob.pose)
193
194     def draw(self, context):
195         layout = self.layout
196
197         ob = context.object
198
199         itasc = ob.pose.ik_param
200
201         row = layout.row()
202         row.prop(ob.pose, "ik_solver")
203
204         if itasc:
205             layout.prop(itasc, "mode", expand=True)
206             simulation = (itasc.mode == 'SIMULATION')
207             if simulation:
208                 layout.label(text="Reiteration:")
209                 layout.prop(itasc, "reiteration_method", expand=True)
210
211             split = layout.split()
212             split.active = not simulation or itasc.reiteration_method != 'NEVER'
213             col = split.column()
214             col.prop(itasc, "precision")
215
216             col = split.column()
217             col.prop(itasc, "iterations")
218
219
220             if simulation:
221                 layout.prop(itasc, "use_auto_step")
222                 row = layout.row()
223                 if itasc.use_auto_step:
224                     row.prop(itasc, "step_min", text="Min")
225                     row.prop(itasc, "step_max", text="Max")
226                 else:
227                     row.prop(itasc, "step_count")
228
229             layout.prop(itasc, "solver")
230             if simulation:
231                 layout.prop(itasc, "feedback")
232                 layout.prop(itasc, "velocity_max")
233             if itasc.solver == 'DLS':
234                 row = layout.row()
235                 row.prop(itasc, "damping_max", text="Damp", slider=True)
236                 row.prop(itasc, "damping_epsilon", text="Eps", slider=True)
237
238 from properties_animviz import MotionPathButtonsPanel, OnionSkinButtonsPanel
239
240 class DATA_PT_motion_paths(MotionPathButtonsPanel, bpy.types.Panel):
241     #bl_label = "Bones Motion Paths"
242     bl_context = "data"
243
244     @classmethod
245     def poll(cls, context):
246         # XXX: include posemode check?
247         return (context.object) and (context.armature)
248
249     def draw(self, context):
250         layout = self.layout
251
252         ob = context.object
253
254         self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
255
256         layout.separator()
257
258         split = layout.split()
259
260         col = split.column()
261         col.operator("pose.paths_calculate", text="Calculate Paths")
262
263         col = split.column()
264         col.operator("pose.paths_clear", text="Clear Paths")
265
266
267 class DATA_PT_onion_skinning(OnionSkinButtonsPanel): #, bpy.types.Panel): # inherit from panel when ready
268     #bl_label = "Bones Onion Skinning"
269     bl_context = "data"
270
271     @classmethod
272     def poll(cls, context):
273         # XXX: include posemode check?
274         return (context.object) and (context.armature)
275
276     def draw(self, context):
277         layout = self.layout
278
279         ob = context.object
280
281         self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
282
283
284 class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, bpy.types.Panel):
285     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
286     _context_path = "object.data"
287
288 def register():
289     pass
290
291
292 def unregister():
293     pass
294
295 if __name__ == "__main__":
296     register()