2.5
[blender.git] / source / blender / editors / object / object_ops.c
1 /**
2  * $Id:
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
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. 
10  *
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.
15  *
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.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <stdlib.h>
30 #include <math.h>
31
32 #include "MEM_guardedalloc.h"
33
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"
41
42 #include "BLI_arithb.h"
43 #include "BLI_blenlib.h"
44
45 #include "BKE_context.h"
46 #include "BKE_global.h"
47 #include "BKE_utildefines.h"
48
49 #include "RNA_access.h"
50 #include "RNA_define.h"
51
52 #include "WM_api.h"
53 #include "WM_types.h"
54
55 #include "ED_screen.h"
56 #include "ED_object.h"
57
58 #include "object_intern.h"
59
60
61 /* ************************** registration **********************************/
62
63
64 void ED_operatortypes_object(void)
65 {
66         WM_operatortype_append(OBJECT_OT_toggle_editmode);
67         WM_operatortype_append(OBJECT_OT_make_parent);
68         WM_operatortype_append(OBJECT_OT_clear_parent);
69         WM_operatortype_append(OBJECT_OT_make_track);
70         WM_operatortype_append(OBJECT_OT_clear_track);
71         WM_operatortype_append(OBJECT_OT_select_invert);
72         WM_operatortype_append(OBJECT_OT_select_random);
73         WM_operatortype_append(OBJECT_OT_de_select_all);
74         WM_operatortype_append(OBJECT_OT_select_by_type);
75         WM_operatortype_append(OBJECT_OT_select_by_layer);
76         WM_operatortype_append(OBJECT_OT_select_linked);
77         WM_operatortype_append(OBJECT_OT_clear_location);
78         WM_operatortype_append(OBJECT_OT_clear_rotation);
79         WM_operatortype_append(OBJECT_OT_clear_scale);
80         WM_operatortype_append(OBJECT_OT_clear_origin);
81         WM_operatortype_append(OBJECT_OT_clear_restrictview);
82         WM_operatortype_append(OBJECT_OT_set_restrictview);
83         WM_operatortype_append(OBJECT_OT_set_slowparent);
84         WM_operatortype_append(OBJECT_OT_clear_slowparent);
85         WM_operatortype_append(OBJECT_OT_set_center);
86         WM_operatortype_append(OBJECT_OT_make_dupli_real);
87         WM_operatortype_append(OBJECT_OT_object_add);
88         WM_operatortype_append(OBJECT_OT_add_duplicate);
89         WM_operatortype_append(GROUP_OT_group_create);
90         WM_operatortype_append(GROUP_OT_group_remove);
91         WM_operatortype_append(GROUP_OT_objects_add_active);
92         WM_operatortype_append(GROUP_OT_objects_remove_active);
93 }
94
95 void ED_keymap_object(wmWindowManager *wm)
96 {
97         ListBase *keymap= WM_keymap_listbase(wm, "Object Non-modal", 0, 0);
98         
99         /* Note: this keymap works disregarding mode */
100         WM_keymap_add_item(keymap, "OBJECT_OT_toggle_editmode", TABKEY, KM_PRESS, 0, 0);
101         WM_keymap_add_item(keymap, "OBJECT_OT_set_center", CKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
102
103         /* Note: this keymap gets disabled in non-objectmode,  */
104         keymap= WM_keymap_listbase(wm, "Object Mode", 0, 0);
105         
106         WM_keymap_add_item(keymap, "OBJECT_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
107         WM_keymap_add_item(keymap, "OBJECT_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0);
108         WM_keymap_add_item(keymap, "OBJECT_OT_select_random", PADASTERKEY, KM_PRESS, 0, 0);
109         WM_keymap_add_item(keymap, "OBJECT_OT_select_by_type", PADASTERKEY, KM_PRESS, KM_CTRL, 0);
110         WM_keymap_add_item(keymap, "OBJECT_OT_select_by_layer", PADASTERKEY, KM_PRESS, KM_ALT, 0);
111         WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
112         
113         WM_keymap_verify_item(keymap, "OBJECT_OT_make_parent", PKEY, KM_PRESS, KM_CTRL, 0);
114         WM_keymap_verify_item(keymap, "OBJECT_OT_clear_parent", PKEY, KM_PRESS, KM_ALT, 0);
115         WM_keymap_verify_item(keymap, "OBJECT_OT_make_track", TKEY, KM_PRESS, KM_CTRL, 0);
116         WM_keymap_verify_item(keymap, "OBJECT_OT_clear_track", TKEY, KM_PRESS, KM_ALT, 0);
117         
118         WM_keymap_verify_item(keymap, "OBJECT_OT_clear_location", GKEY, KM_PRESS, KM_ALT, 0);
119         WM_keymap_verify_item(keymap, "OBJECT_OT_clear_rotation", RKEY, KM_PRESS, KM_ALT, 0);
120         WM_keymap_verify_item(keymap, "OBJECT_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0);
121         WM_keymap_verify_item(keymap, "OBJECT_OT_clear_origin", OKEY, KM_PRESS, KM_ALT, 0);
122         
123         WM_keymap_verify_item(keymap, "OBJECT_OT_clear_restrictview", HKEY, KM_PRESS, KM_ALT, 0);
124         WM_keymap_verify_item(keymap, "OBJECT_OT_set_restrictview", HKEY, KM_PRESS, 0, 0);
125         
126         WM_keymap_verify_item(keymap, "OBJECT_OT_object_add", AKEY, KM_PRESS, KM_SHIFT, 0);
127         WM_keymap_verify_item(keymap, "OBJECT_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
128         
129         // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
130         WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0);
131         WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe", IKEY, KM_PRESS, KM_ALT, 0);
132         
133         WM_keymap_verify_item(keymap, "GROUP_OT_group_create", GKEY, KM_PRESS, KM_CTRL, 0);
134         WM_keymap_verify_item(keymap, "GROUP_OT_group_remove", GKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
135         WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
136         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
137
138 }
139