feature request from VenomGfx- lock to active as an operator since its tedious settin...
[blender.git] / source / blender / editors / space_view3d / view3d_ops.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version. 
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2008 Blender Foundation.
19  * All rights reserved.
20  *
21  * 
22  * Contributor(s): Blender Foundation
23  *
24  * ***** END GPL LICENSE BLOCK *****
25  */
26
27 /** \file blender/editors/space_view3d/view3d_ops.c
28  *  \ingroup spview3d
29  */
30
31
32 #include <stdlib.h>
33 #include <math.h>
34
35
36 #include "DNA_object_types.h"
37 #include "DNA_scene_types.h"
38 #include "DNA_screen_types.h"
39 #include "DNA_space_types.h"
40 #include "DNA_view3d_types.h"
41
42 #include "BLI_math.h"
43 #include "BLI_blenlib.h"
44 #include "BLI_utildefines.h"
45
46 #include "RNA_access.h"
47
48 #include "WM_api.h"
49 #include "WM_types.h"
50
51 #include "ED_transform.h"
52
53 #include "view3d_intern.h"
54
55
56 /* ************************** registration **********************************/
57
58 void view3d_operatortypes(void)
59 {
60         WM_operatortype_append(VIEW3D_OT_rotate);
61         WM_operatortype_append(VIEW3D_OT_move);
62         WM_operatortype_append(VIEW3D_OT_zoom);
63         WM_operatortype_append(VIEW3D_OT_zoom_camera_1_to_1);
64         WM_operatortype_append(VIEW3D_OT_dolly);
65         WM_operatortype_append(VIEW3D_OT_ndof_orbit);
66         WM_operatortype_append(VIEW3D_OT_ndof_pan);
67         WM_operatortype_append(VIEW3D_OT_view_all);
68         WM_operatortype_append(VIEW3D_OT_viewnumpad);
69         WM_operatortype_append(VIEW3D_OT_view_orbit);
70         WM_operatortype_append(VIEW3D_OT_view_pan);
71         WM_operatortype_append(VIEW3D_OT_view_persportho);
72         WM_operatortype_append(VIEW3D_OT_background_image_add);
73         WM_operatortype_append(VIEW3D_OT_background_image_remove);
74         WM_operatortype_append(VIEW3D_OT_view_selected);
75         WM_operatortype_append(VIEW3D_OT_view_lock_clear);
76         WM_operatortype_append(VIEW3D_OT_view_lock_to_active);
77         WM_operatortype_append(VIEW3D_OT_view_center_cursor);
78         WM_operatortype_append(VIEW3D_OT_view_center_camera);
79         WM_operatortype_append(VIEW3D_OT_select);
80         WM_operatortype_append(VIEW3D_OT_select_border);
81         WM_operatortype_append(VIEW3D_OT_clip_border);
82         WM_operatortype_append(VIEW3D_OT_select_circle);
83         WM_operatortype_append(VIEW3D_OT_smoothview);
84         WM_operatortype_append(VIEW3D_OT_render_border);
85         WM_operatortype_append(VIEW3D_OT_zoom_border);
86         WM_operatortype_append(VIEW3D_OT_manipulator);
87         WM_operatortype_append(VIEW3D_OT_enable_manipulator);
88         WM_operatortype_append(VIEW3D_OT_cursor3d);
89         WM_operatortype_append(VIEW3D_OT_select_lasso);
90         WM_operatortype_append(VIEW3D_OT_select_menu);
91         WM_operatortype_append(VIEW3D_OT_camera_to_view);
92         WM_operatortype_append(VIEW3D_OT_camera_to_view_selected);
93         WM_operatortype_append(VIEW3D_OT_object_as_camera);
94         WM_operatortype_append(VIEW3D_OT_localview);
95         WM_operatortype_append(VIEW3D_OT_game_start);
96         WM_operatortype_append(VIEW3D_OT_fly);
97         WM_operatortype_append(VIEW3D_OT_layers);
98         
99         WM_operatortype_append(VIEW3D_OT_properties);
100         WM_operatortype_append(VIEW3D_OT_toolshelf);
101         
102         WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid);
103         WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor);
104         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_grid);
105         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center);
106         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected);
107         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
108                 
109         transform_operatortypes();
110 }
111
112 void view3d_keymap(wmKeyConfig *keyconf)
113 {
114         wmKeyMap *keymap;
115         wmKeyMapItem *kmi;
116         
117         keymap = WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0);
118         
119         WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0);
120         WM_keymap_add_item(keymap, "VIEW3D_OT_toolshelf", TKEY, KM_PRESS, 0, 0);
121         
122         /* only for region 3D window */
123         keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
124         
125         kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
126         RNA_boolean_set(kmi->ptr, "release_confirm", TRUE);
127         /*
128          * Doesn't work with KM_SHIFT, have to use KM_ANY and filter in invoke
129          * */
130         // WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
131         
132         WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
133         
134         WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
135         WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
136         WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
137         WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
138         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
139         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0);
140
141         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0);
142         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0);
143
144         WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0);
145
146         WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0);
147         
148         WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEPAN, 0, KM_ALT, 0);
149         WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEROTATE, 0, 0, 0);
150         WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, 0, 0);
151         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0);
152         
153         /*numpad +/-*/
154         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
155         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1);
156
157         /*ctrl +/-*/
158         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", EQUALKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
159         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MINUSKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
160         
161         /*wheel mouse forward/back*/
162         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1);
163         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELOUTMOUSE, KM_PRESS, 0, 0)->ptr, "delta", -1);
164
165         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_camera_1_to_1", PADENTER, KM_PRESS, KM_SHIFT, 0);
166
167         WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_camera", HOMEKEY, KM_PRESS, 0, 0); /* only with camera view */
168
169         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
170         RNA_boolean_set(kmi->ptr, "center", FALSE); /* only without camera view */
171         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", CKEY, KM_PRESS, KM_SHIFT, 0);
172         RNA_boolean_set(kmi->ptr, "center", TRUE);
173
174         /* numpad view hotkeys*/
175         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA);
176         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
177         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD2, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPDOWN);
178         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
179         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
180         WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0);
181         
182         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
183         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
184         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP);
185         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BACK);
186         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_LEFT);
187         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
188         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD2, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANDOWN);
189         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD4, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
190         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
191         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANUP);
192         
193         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
194         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
195         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANUP);
196         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANDOWN);
197
198         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
199         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
200         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPUP);
201         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPDOWN);
202         
203         /* active aligned, replaces '*' key in 2.4x */
204         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0);
205         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
206         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
207         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT, 0);
208         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
209         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
210         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0);
211         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
212         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
213         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
214         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BACK);
215         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
216         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
217         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT);
218         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
219         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
220         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM);
221         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
222         
223         /* 3D mouse */
224         WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, 0, 0);
225         WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_pan", NDOF_MOTION, 0, KM_SHIFT, 0);
226         WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
227         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
228         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK);
229         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_LEFT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_LEFT);
230         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
231         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
232         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
233
234         /* 3D mouse align */
235         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0);
236         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
237         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
238         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, KM_SHIFT, 0);
239         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
240         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
241         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0);
242         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
243         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
244
245         WM_keymap_add_item(keymap, "VIEW3D_OT_localview", PADSLASHKEY, KM_PRESS, 0, 0);
246         
247         /* layers, shift + alt are properties set in invoke() */
248         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ACCENTGRAVEKEY, KM_PRESS, 0, 0)->ptr, "nr", 0);
249         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ONEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 1);
250         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", TWOKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 2);
251         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", THREEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 3);
252         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FOURKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 4);
253         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FIVEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 5);
254         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SIXKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 6);
255         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SEVENKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 7);
256         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", EIGHTKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 8);
257         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", NINEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 9);
258         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ZEROKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 10);
259         
260         /* drawtype */
261
262         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0);
263         RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shade");
264         RNA_string_set(kmi->ptr, "value_1", "SOLID");
265         RNA_string_set(kmi->ptr, "value_2", "WIREFRAME");
266
267         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0);
268         RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shade");
269         RNA_string_set(kmi->ptr, "value_1", "TEXTURED");
270         RNA_string_set(kmi->ptr, "value_2", "SOLID");
271
272         /* selection*/
273         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
274         RNA_boolean_set(kmi->ptr, "extend", FALSE);
275         RNA_boolean_set(kmi->ptr, "center", FALSE);
276         RNA_boolean_set(kmi->ptr, "object", FALSE);
277         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
278         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
279         RNA_boolean_set(kmi->ptr, "extend", TRUE);
280         RNA_boolean_set(kmi->ptr, "center", FALSE);
281         RNA_boolean_set(kmi->ptr, "object", FALSE);
282         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
283         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
284         RNA_boolean_set(kmi->ptr, "extend", FALSE);
285         RNA_boolean_set(kmi->ptr, "center", TRUE);
286         RNA_boolean_set(kmi->ptr, "object", TRUE); /* use Ctrl+Select for 2 purposes */
287         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
288         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
289         RNA_boolean_set(kmi->ptr, "extend", FALSE);
290         RNA_boolean_set(kmi->ptr, "center", FALSE);
291         RNA_boolean_set(kmi->ptr, "object", FALSE);
292         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
293
294         /* selection key-combinations */
295         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
296         RNA_boolean_set(kmi->ptr, "extend", TRUE);
297         RNA_boolean_set(kmi->ptr, "center", TRUE);
298         RNA_boolean_set(kmi->ptr, "object", FALSE);
299         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
300         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0);
301         RNA_boolean_set(kmi->ptr, "extend", FALSE);
302         RNA_boolean_set(kmi->ptr, "center", TRUE);
303         RNA_boolean_set(kmi->ptr, "object", FALSE);
304         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
305         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0);
306         RNA_boolean_set(kmi->ptr, "extend", TRUE);
307         RNA_boolean_set(kmi->ptr, "center", FALSE);
308         RNA_boolean_set(kmi->ptr, "object", FALSE);
309         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
310         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0);
311         RNA_boolean_set(kmi->ptr, "extend", TRUE);
312         RNA_boolean_set(kmi->ptr, "center", TRUE);
313         RNA_boolean_set(kmi->ptr, "object", FALSE);
314         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
315
316         WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
317         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
318         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
319         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0);
320         RNA_boolean_set(kmi->ptr, "deselect", TRUE);
321         WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
322         
323         WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
324         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
325         WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
326         
327         WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT | KM_CTRL, 0);
328         WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0);
329         
330         WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
331         
332         /* context ops */
333         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
334         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
335         RNA_string_set(kmi->ptr, "value", "BOUNDING_BOX_CENTER");
336
337         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, KM_CTRL, 0); /* 2.4x allowed Comma+Shift too, rather not use both */
338         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
339         RNA_string_set(kmi->ptr, "value", "MEDIAN_POINT");
340
341         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", COMMAKEY, KM_PRESS, KM_ALT, 0); /* new in 2.5 */
342         RNA_string_set(kmi->ptr, "data_path", "space_data.use_pivot_point_align");
343
344         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* new in 2.5 */
345         RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator");
346
347         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0);
348         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
349         RNA_string_set(kmi->ptr, "value", "CURSOR");
350
351         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_CTRL, 0);
352         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
353         RNA_string_set(kmi->ptr, "value", "INDIVIDUAL_ORIGINS");
354
355         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_ALT, 0);
356         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
357         RNA_string_set(kmi->ptr, "value", "ACTIVE_ELEMENT");
358
359         transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D);
360
361         fly_modal_keymap(keyconf);
362         viewrotate_modal_keymap(keyconf);
363         viewmove_modal_keymap(keyconf);
364         viewzoom_modal_keymap(keyconf);
365         viewdolly_modal_keymap(keyconf);
366 }
367