doxygen: add newline after \file
[blender.git] / source / blender / editors / armature / armature_ops.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19
20 /** \file
21  * \ingroup edarmature
22  */
23
24 #include "RNA_access.h"
25
26 #include "WM_api.h"
27 #include "WM_types.h"
28
29 #include "ED_armature.h"
30 #include "ED_screen.h"
31 #include "ED_select_utils.h"
32 #include "ED_transform.h"
33
34 #include "armature_intern.h"
35
36 /* ************************** registration **********************************/
37
38 /* Both operators ARMATURE_OT_xxx and POSE_OT_xxx here */
39 void ED_operatortypes_armature(void)
40 {
41         /* EDIT ARMATURE */
42         WM_operatortype_append(ARMATURE_OT_bone_primitive_add);
43
44         WM_operatortype_append(ARMATURE_OT_align);
45         WM_operatortype_append(ARMATURE_OT_calculate_roll);
46         WM_operatortype_append(ARMATURE_OT_roll_clear);
47         WM_operatortype_append(ARMATURE_OT_switch_direction);
48         WM_operatortype_append(ARMATURE_OT_subdivide);
49
50         WM_operatortype_append(ARMATURE_OT_parent_set);
51         WM_operatortype_append(ARMATURE_OT_parent_clear);
52
53         WM_operatortype_append(ARMATURE_OT_select_all);
54         WM_operatortype_append(ARMATURE_OT_select_mirror);
55         WM_operatortype_append(ARMATURE_OT_select_more);
56         WM_operatortype_append(ARMATURE_OT_select_less);
57         WM_operatortype_append(ARMATURE_OT_select_hierarchy);
58         WM_operatortype_append(ARMATURE_OT_select_linked);
59         WM_operatortype_append(ARMATURE_OT_select_similar);
60         WM_operatortype_append(ARMATURE_OT_shortest_path_pick);
61
62         WM_operatortype_append(ARMATURE_OT_delete);
63         WM_operatortype_append(ARMATURE_OT_dissolve);
64         WM_operatortype_append(ARMATURE_OT_duplicate);
65         WM_operatortype_append(ARMATURE_OT_symmetrize);
66         WM_operatortype_append(ARMATURE_OT_extrude);
67         WM_operatortype_append(ARMATURE_OT_hide);
68         WM_operatortype_append(ARMATURE_OT_reveal);
69         WM_operatortype_append(ARMATURE_OT_click_extrude);
70         WM_operatortype_append(ARMATURE_OT_fill);
71         WM_operatortype_append(ARMATURE_OT_merge);
72         WM_operatortype_append(ARMATURE_OT_separate);
73         WM_operatortype_append(ARMATURE_OT_split);
74
75         WM_operatortype_append(ARMATURE_OT_autoside_names);
76         WM_operatortype_append(ARMATURE_OT_flip_names);
77
78         WM_operatortype_append(ARMATURE_OT_layers_show_all);
79         WM_operatortype_append(ARMATURE_OT_armature_layers);
80         WM_operatortype_append(ARMATURE_OT_bone_layers);
81
82         /* POSE */
83         WM_operatortype_append(POSE_OT_hide);
84         WM_operatortype_append(POSE_OT_reveal);
85
86         WM_operatortype_append(POSE_OT_armature_apply);
87         WM_operatortype_append(POSE_OT_visual_transform_apply);
88
89         WM_operatortype_append(POSE_OT_rot_clear);
90         WM_operatortype_append(POSE_OT_loc_clear);
91         WM_operatortype_append(POSE_OT_scale_clear);
92         WM_operatortype_append(POSE_OT_transforms_clear);
93         WM_operatortype_append(POSE_OT_user_transforms_clear);
94
95         WM_operatortype_append(POSE_OT_copy);
96         WM_operatortype_append(POSE_OT_paste);
97
98         WM_operatortype_append(POSE_OT_select_all);
99
100         WM_operatortype_append(POSE_OT_select_parent);
101         WM_operatortype_append(POSE_OT_select_hierarchy);
102         WM_operatortype_append(POSE_OT_select_linked);
103         WM_operatortype_append(POSE_OT_select_constraint_target);
104         WM_operatortype_append(POSE_OT_select_grouped);
105         WM_operatortype_append(POSE_OT_select_mirror);
106
107         WM_operatortype_append(POSE_OT_group_add);
108         WM_operatortype_append(POSE_OT_group_remove);
109         WM_operatortype_append(POSE_OT_group_move);
110         WM_operatortype_append(POSE_OT_group_sort);
111         WM_operatortype_append(POSE_OT_group_assign);
112         WM_operatortype_append(POSE_OT_group_unassign);
113         WM_operatortype_append(POSE_OT_group_select);
114         WM_operatortype_append(POSE_OT_group_deselect);
115
116         WM_operatortype_append(POSE_OT_paths_calculate);
117         WM_operatortype_append(POSE_OT_paths_update);
118         WM_operatortype_append(POSE_OT_paths_clear);
119         WM_operatortype_append(POSE_OT_paths_range_update);
120
121         WM_operatortype_append(POSE_OT_autoside_names);
122         WM_operatortype_append(POSE_OT_flip_names);
123
124         WM_operatortype_append(POSE_OT_rotation_mode_set);
125
126         WM_operatortype_append(POSE_OT_quaternions_flip);
127
128         WM_operatortype_append(POSE_OT_bone_layers);
129
130         WM_operatortype_append(POSE_OT_propagate);
131
132         /* POSELIB */
133         WM_operatortype_append(POSELIB_OT_browse_interactive);
134         WM_operatortype_append(POSELIB_OT_apply_pose);
135
136         WM_operatortype_append(POSELIB_OT_pose_add);
137         WM_operatortype_append(POSELIB_OT_pose_remove);
138         WM_operatortype_append(POSELIB_OT_pose_rename);
139         WM_operatortype_append(POSELIB_OT_pose_move);
140
141         WM_operatortype_append(POSELIB_OT_new);
142         WM_operatortype_append(POSELIB_OT_unlink);
143
144         WM_operatortype_append(POSELIB_OT_action_sanitize);
145
146         /* POSE SLIDING */
147         WM_operatortype_append(POSE_OT_push);
148         WM_operatortype_append(POSE_OT_relax);
149         WM_operatortype_append(POSE_OT_breakdown);
150 }
151
152 void ED_operatormacros_armature(void)
153 {
154         wmOperatorType *ot;
155         wmOperatorTypeMacro *otmacro;
156
157         ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate",
158                                           "Make copies of the selected bones within the same armature and move them",
159                                           OPTYPE_UNDO | OPTYPE_REGISTER);
160         WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
161         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
162         RNA_enum_set(otmacro->ptr, "proportional", 0);
163
164         ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude",
165                                           "Create new bones from the selected joints and move them",
166                                           OPTYPE_UNDO | OPTYPE_REGISTER);
167         otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
168         RNA_boolean_set(otmacro->ptr, "forked", false);
169         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
170         RNA_enum_set(otmacro->ptr, "proportional", 0);
171
172         /* XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate?
173          * that would require fixing a properties bug 19733 */
174         ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked",
175                                           "Create new bones from the selected joints and move them",
176                                           OPTYPE_UNDO | OPTYPE_REGISTER);
177         otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
178         RNA_boolean_set(otmacro->ptr, "forked", true);
179         otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
180         RNA_enum_set(otmacro->ptr, "proportional", 0);
181 }
182
183 void ED_keymap_armature(wmKeyConfig *keyconf)
184 {
185         wmKeyMap *keymap;
186
187         /* Armature ------------------------ */
188         /* only set in editmode armature, by space_view3d listener */
189         keymap = WM_keymap_ensure(keyconf, "Armature", 0, 0);
190         keymap->poll = ED_operator_editarmature;
191
192         /* Pose ------------------------ */
193         /* only set in posemode, by space_view3d listener */
194         keymap = WM_keymap_ensure(keyconf, "Pose", 0, 0);
195         keymap->poll = ED_operator_posemode;
196
197 }