4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2009 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
32 #include "MEM_guardedalloc.h"
34 #include "DNA_object_types.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_screen_types.h"
37 #include "DNA_space_types.h"
38 #include "DNA_userdef_types.h"
39 #include "DNA_view3d_types.h"
40 #include "DNA_windowmanager_types.h"
42 #include "BLI_arithb.h"
43 #include "BLI_blenlib.h"
45 #include "BKE_context.h"
46 #include "BKE_global.h"
47 #include "BKE_utildefines.h"
49 #include "RNA_access.h"
50 #include "RNA_define.h"
55 #include "ED_armature.h"
56 #include "ED_screen.h"
57 #include "ED_object.h"
59 #include "armature_intern.h"
61 /* ************************** quick tests **********************************/
63 /* XXX This is a quick test operator to print names of all EditBones in context
64 * that should be removed once tool coding starts...
67 static int armature_test_exec (bContext *C, wmOperator *op)
69 printf("EditMode Armature Test: \n");
71 printf("\tSelected Bones \n");
72 CTX_DATA_BEGIN(C, EditBone*, ebone, selected_bones)
74 printf("\t\tEditBone '%s' \n", ebone->name);
78 printf("\tEditable Bones \n");
79 CTX_DATA_BEGIN(C, EditBone*, ebone, selected_editable_bones)
81 printf("\t\tEditBone '%s' \n", ebone->name);
85 printf("\tActive Bone \n");
87 EditBone *ebone= CTX_data_active_bone(C);
88 if (ebone) printf("\t\tEditBone '%s' \n", ebone->name);
89 else printf("\t\t<None> \n");
92 return OPERATOR_FINISHED;
95 void ARMATURE_OT_test(wmOperatorType *ot)
98 ot->name= "Test Context";
99 ot->idname= "ARMATURE_OT_test";
102 ot->exec= armature_test_exec;
105 /* ************************** registration **********************************/
107 /* Both operators ARMATURE_OT_xxx and POSE_OT_xxx here */
108 void ED_operatortypes_armature(void)
110 WM_operatortype_append(ARMATURE_OT_align_bones);
111 WM_operatortype_append(ARMATURE_OT_calculate_roll);
113 WM_operatortype_append(POSE_OT_hide);
114 WM_operatortype_append(POSE_OT_reveil);
115 WM_operatortype_append(POSE_OT_rot_clear);
116 WM_operatortype_append(POSE_OT_loc_clear);
117 WM_operatortype_append(POSE_OT_scale_clear);
119 WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed
122 void ED_keymap_armature(wmWindowManager *wm)
127 /* Armature ------------------------ */
128 keymap= WM_keymap_listbase(wm, "Armature", 0, 0);
130 /* only set in editmode armature, by space_view3d listener */
131 // WM_keymap_add_item(keymap, "ARMATURE_OT_hide", HKEY, KM_PRESS, 0, 0);
132 WM_keymap_add_item(keymap, "ARMATURE_OT_align_bones", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
133 WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
135 WM_keymap_add_item(keymap, "ARMATURE_OT_test", TKEY, KM_PRESS, 0, 0); // XXX temp test for context iterators... to be removed
137 /* Pose ------------------------ */
138 /* only set in posemode, by space_view3d listener */
139 keymap= WM_keymap_listbase(wm, "Pose", 0, 0);
141 WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, 0, 0);
142 kmi= WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
143 RNA_boolean_set(kmi->ptr, "invert", 1);
144 WM_keymap_add_item(keymap, "POSE_OT_reveil", HKEY, KM_PRESS, KM_ALT, 0);
146 WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0);
147 WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0);
148 WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);