Patch #32326: NDOF support of rotation and panning the view at the same time
[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_ndof_all);
68         WM_operatortype_append(VIEW3D_OT_view_all);
69         WM_operatortype_append(VIEW3D_OT_viewnumpad);
70         WM_operatortype_append(VIEW3D_OT_view_orbit);
71         WM_operatortype_append(VIEW3D_OT_view_pan);
72         WM_operatortype_append(VIEW3D_OT_view_persportho);
73         WM_operatortype_append(VIEW3D_OT_background_image_add);
74         WM_operatortype_append(VIEW3D_OT_background_image_remove);
75         WM_operatortype_append(VIEW3D_OT_view_selected);
76         WM_operatortype_append(VIEW3D_OT_view_lock_clear);
77         WM_operatortype_append(VIEW3D_OT_view_lock_to_active);
78         WM_operatortype_append(VIEW3D_OT_view_center_cursor);
79         WM_operatortype_append(VIEW3D_OT_view_center_camera);
80         WM_operatortype_append(VIEW3D_OT_select);
81         WM_operatortype_append(VIEW3D_OT_select_border);
82         WM_operatortype_append(VIEW3D_OT_clip_border);
83         WM_operatortype_append(VIEW3D_OT_select_circle);
84         WM_operatortype_append(VIEW3D_OT_smoothview);
85         WM_operatortype_append(VIEW3D_OT_render_border);
86         WM_operatortype_append(VIEW3D_OT_zoom_border);
87         WM_operatortype_append(VIEW3D_OT_manipulator);
88         WM_operatortype_append(VIEW3D_OT_enable_manipulator);
89         WM_operatortype_append(VIEW3D_OT_cursor3d);
90         WM_operatortype_append(VIEW3D_OT_select_lasso);
91         WM_operatortype_append(VIEW3D_OT_select_menu);
92         WM_operatortype_append(VIEW3D_OT_camera_to_view);
93         WM_operatortype_append(VIEW3D_OT_camera_to_view_selected);
94         WM_operatortype_append(VIEW3D_OT_object_as_camera);
95         WM_operatortype_append(VIEW3D_OT_localview);
96         WM_operatortype_append(VIEW3D_OT_game_start);
97         WM_operatortype_append(VIEW3D_OT_fly);
98         WM_operatortype_append(VIEW3D_OT_layers);
99         
100         WM_operatortype_append(VIEW3D_OT_properties);
101         WM_operatortype_append(VIEW3D_OT_toolshelf);
102         
103         WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid);
104         WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor);
105         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_grid);
106         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center);
107         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected);
108         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
109                 
110         transform_operatortypes();
111 }
112
113 void view3d_keymap(wmKeyConfig *keyconf)
114 {
115         wmKeyMap *keymap;
116         wmKeyMapItem *kmi;
117         
118         keymap = WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0);
119         
120         WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0);
121         WM_keymap_add_item(keymap, "VIEW3D_OT_toolshelf", TKEY, KM_PRESS, 0, 0);
122         
123         /* only for region 3D window */
124         keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
125         
126         kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
127         RNA_boolean_set(kmi->ptr, "release_confirm", TRUE);
128         /*
129          * Doesn't work with KM_SHIFT, have to use KM_ANY and filter in invoke
130          * */
131         // WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
132         
133         WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
134         
135         WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
136         WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
137         WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
138         WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
139         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
140         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0);
141
142         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0);
143         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0);
144
145         WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0);
146
147         WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0);
148         
149         WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEPAN, 0, KM_ALT, 0);
150         WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEROTATE, 0, 0, 0);
151         WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, 0, 0);
152         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0);
153         
154         /*numpad +/-*/
155         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
156         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1);
157
158         /*ctrl +/-*/
159         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", EQUALKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
160         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MINUSKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
161         
162         /*wheel mouse forward/back*/
163         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1);
164         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELOUTMOUSE, KM_PRESS, 0, 0)->ptr, "delta", -1);
165
166         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_camera_1_to_1", PADENTER, KM_PRESS, KM_SHIFT, 0);
167
168         WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_camera", HOMEKEY, KM_PRESS, 0, 0); /* only with camera view */
169
170         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
171         RNA_boolean_set(kmi->ptr, "center", FALSE); /* only without camera view */
172         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", CKEY, KM_PRESS, KM_SHIFT, 0);
173         RNA_boolean_set(kmi->ptr, "center", TRUE);
174
175         /* numpad view hotkeys*/
176         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA);
177         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
178         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD2, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPDOWN);
179         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
180         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
181         WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0);
182         
183         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
184         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
185         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP);
186         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BACK);
187         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_LEFT);
188         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
189         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD2, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANDOWN);
190         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD4, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
191         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
192         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANUP);
193         
194         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
195         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
196         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANUP);
197         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANDOWN);
198
199         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);
200         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);
201         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);
202         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);
203         
204         /* active aligned, replaces '*' key in 2.4x */
205         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0);
206         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
207         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
208         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT, 0);
209         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
210         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
211         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0);
212         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
213         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
214         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
215         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BACK);
216         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
217         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
218         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT);
219         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
220         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
221         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM);
222         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
223         
224         /* 3D mouse */
225         WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_orbit", NDOF_MOTION, 0, KM_CTRL, 0);
226         WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_pan", NDOF_MOTION, 0, KM_SHIFT, 0);
227         WM_keymap_add_item(keymap, "VIEW3D_OT_ndof_all", NDOF_MOTION, 0, 0, 0);
228         WM_keymap_add_item(keymap, "VIEW3D_OT_view_selected", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
229         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
230         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BACK, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BACK);
231         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_LEFT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_LEFT);
232         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
233         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
234         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
235
236         /* 3D mouse align */
237         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0);
238         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
239         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
240         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, KM_SHIFT, 0);
241         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
242         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
243         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, KM_SHIFT, 0);
244         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
245         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
246
247         WM_keymap_add_item(keymap, "VIEW3D_OT_localview", PADSLASHKEY, KM_PRESS, 0, 0);
248         
249         /* layers, shift + alt are properties set in invoke() */
250         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ACCENTGRAVEKEY, KM_PRESS, 0, 0)->ptr, "nr", 0);
251         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ONEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 1);
252         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", TWOKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 2);
253         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", THREEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 3);
254         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FOURKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 4);
255         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FIVEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 5);
256         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SIXKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 6);
257         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SEVENKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 7);
258         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", EIGHTKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 8);
259         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", NINEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 9);
260         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ZEROKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 10);
261         
262         /* drawtype */
263
264         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0);
265         RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shade");
266         RNA_string_set(kmi->ptr, "value_1", "SOLID");
267         RNA_string_set(kmi->ptr, "value_2", "WIREFRAME");
268
269         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0);
270         RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shade");
271         RNA_string_set(kmi->ptr, "value_1", "TEXTURED");
272         RNA_string_set(kmi->ptr, "value_2", "SOLID");
273
274         /* selection*/
275         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
276         RNA_boolean_set(kmi->ptr, "extend", FALSE);
277         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
278         RNA_boolean_set(kmi->ptr, "toggle", FALSE);
279         RNA_boolean_set(kmi->ptr, "center", FALSE);
280         RNA_boolean_set(kmi->ptr, "object", FALSE);
281         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
282         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
283         RNA_boolean_set(kmi->ptr, "extend", FALSE);
284         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
285         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
286         RNA_boolean_set(kmi->ptr, "center", FALSE);
287         RNA_boolean_set(kmi->ptr, "object", FALSE);
288         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
289         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
290         RNA_boolean_set(kmi->ptr, "extend", FALSE);
291         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
292         RNA_boolean_set(kmi->ptr, "toggle", FALSE);
293         RNA_boolean_set(kmi->ptr, "center", TRUE);
294         RNA_boolean_set(kmi->ptr, "object", TRUE); /* use Ctrl+Select for 2 purposes */
295         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
296         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
297         RNA_boolean_set(kmi->ptr, "extend", FALSE);
298         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
299         RNA_boolean_set(kmi->ptr, "toggle", FALSE);
300         RNA_boolean_set(kmi->ptr, "center", FALSE);
301         RNA_boolean_set(kmi->ptr, "object", FALSE);
302         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
303
304         /* selection key-combinations */
305         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
306         RNA_boolean_set(kmi->ptr, "extend", TRUE);
307         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
308         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
309         RNA_boolean_set(kmi->ptr, "center", TRUE);
310         RNA_boolean_set(kmi->ptr, "object", FALSE);
311         RNA_boolean_set(kmi->ptr, "enumerate", FALSE);
312         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0);
313         RNA_boolean_set(kmi->ptr, "extend", FALSE);
314         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
315         RNA_boolean_set(kmi->ptr, "toggle", FALSE);
316         RNA_boolean_set(kmi->ptr, "center", TRUE);
317         RNA_boolean_set(kmi->ptr, "object", FALSE);
318         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
319         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0);
320         RNA_boolean_set(kmi->ptr, "extend", FALSE);
321         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
322         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
323         RNA_boolean_set(kmi->ptr, "center", FALSE);
324         RNA_boolean_set(kmi->ptr, "object", FALSE);
325         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
326         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0);
327         RNA_boolean_set(kmi->ptr, "extend", FALSE);
328         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
329         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
330         RNA_boolean_set(kmi->ptr, "center", TRUE);
331         RNA_boolean_set(kmi->ptr, "object", FALSE);
332         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
333
334         WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
335         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
336         RNA_boolean_set(kmi->ptr, "deselect", FALSE);
337         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0);
338         RNA_boolean_set(kmi->ptr, "deselect", TRUE);
339         WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
340         
341         WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
342         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
343         WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
344         
345         WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT | KM_CTRL, 0);
346         WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0);
347         
348         WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
349         
350         /* context ops */
351         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
352         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
353         RNA_string_set(kmi->ptr, "value", "BOUNDING_BOX_CENTER");
354
355         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 */
356         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
357         RNA_string_set(kmi->ptr, "value", "MEDIAN_POINT");
358
359         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", COMMAKEY, KM_PRESS, KM_ALT, 0); /* new in 2.5 */
360         RNA_string_set(kmi->ptr, "data_path", "space_data.use_pivot_point_align");
361
362         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* new in 2.5 */
363         RNA_string_set(kmi->ptr, "data_path", "space_data.show_manipulator");
364
365         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0);
366         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
367         RNA_string_set(kmi->ptr, "value", "CURSOR");
368
369         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_CTRL, 0);
370         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
371         RNA_string_set(kmi->ptr, "value", "INDIVIDUAL_ORIGINS");
372
373         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_ALT, 0);
374         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
375         RNA_string_set(kmi->ptr, "value", "ACTIVE_ELEMENT");
376
377         transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D);
378
379         fly_modal_keymap(keyconf);
380         viewrotate_modal_keymap(keyconf);
381         viewmove_modal_keymap(keyconf);
382         viewzoom_modal_keymap(keyconf);
383         viewdolly_modal_keymap(keyconf);
384 }
385