patch [#22901] pixel- and aspectratio corrected camera representation in 3dview
[blender.git] / source / blender / editors / space_view3d / view3d_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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_view3d_types.h"
39
40 #include "BLI_math.h"
41 #include "BLI_blenlib.h"
42
43 #include "BKE_context.h"
44 #include "BKE_global.h"
45 #include "BKE_utildefines.h"
46
47 #include "RNA_access.h"
48
49 #include "WM_api.h"
50 #include "WM_types.h"
51
52 #include "ED_transform.h"
53
54 #include "view3d_intern.h"
55
56
57 /* ************************** registration **********************************/
58
59 void view3d_operatortypes(void)
60 {
61         WM_operatortype_append(VIEW3D_OT_rotate);
62         WM_operatortype_append(VIEW3D_OT_move);
63         WM_operatortype_append(VIEW3D_OT_zoom);
64         WM_operatortype_append(VIEW3D_OT_view_all);
65         WM_operatortype_append(VIEW3D_OT_viewnumpad);
66         WM_operatortype_append(VIEW3D_OT_view_orbit);
67         WM_operatortype_append(VIEW3D_OT_view_pan);
68         WM_operatortype_append(VIEW3D_OT_view_persportho);
69         WM_operatortype_append(VIEW3D_OT_add_background_image);
70         WM_operatortype_append(VIEW3D_OT_remove_background_image);
71         WM_operatortype_append(VIEW3D_OT_view_selected);
72         WM_operatortype_append(VIEW3D_OT_view_center_cursor);
73         WM_operatortype_append(VIEW3D_OT_view_center_camera);
74         WM_operatortype_append(VIEW3D_OT_select);
75         WM_operatortype_append(VIEW3D_OT_select_border);
76         WM_operatortype_append(VIEW3D_OT_clip_border);
77         WM_operatortype_append(VIEW3D_OT_select_circle);
78         WM_operatortype_append(VIEW3D_OT_smoothview);
79         WM_operatortype_append(VIEW3D_OT_render_border);
80         WM_operatortype_append(VIEW3D_OT_zoom_border);
81         WM_operatortype_append(VIEW3D_OT_manipulator);
82         WM_operatortype_append(VIEW3D_OT_enable_manipulator);
83         WM_operatortype_append(VIEW3D_OT_cursor3d);
84         WM_operatortype_append(VIEW3D_OT_select_lasso);
85         WM_operatortype_append(VIEW3D_OT_setcameratoview);
86         WM_operatortype_append(VIEW3D_OT_object_as_camera);
87         WM_operatortype_append(VIEW3D_OT_localview);
88         WM_operatortype_append(VIEW3D_OT_game_start);
89         WM_operatortype_append(VIEW3D_OT_fly);
90         WM_operatortype_append(VIEW3D_OT_layers);
91         
92         WM_operatortype_append(VIEW3D_OT_properties);
93         WM_operatortype_append(VIEW3D_OT_toolshelf);
94         
95         WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid);
96         WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor);
97         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_grid);
98         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_center);
99         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_selected);
100         WM_operatortype_append(VIEW3D_OT_snap_cursor_to_active);
101                 
102         transform_operatortypes();
103 }
104
105 void view3d_keymap(wmKeyConfig *keyconf)
106 {
107         wmKeyMap *keymap;
108         wmKeyMapItem *kmi;
109         
110         keymap= WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0);
111         
112         WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0);
113         WM_keymap_add_item(keymap, "VIEW3D_OT_toolshelf", TKEY, KM_PRESS, 0, 0);
114         
115         /* only for region 3D window */
116         keymap= WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
117         
118         kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
119         RNA_boolean_set(kmi->ptr, "release_confirm", 1);
120         /*
121          * Doesn't work with KM_SHIFT, have to use KM_ANY and filter in invoke
122          * */
123         // WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
124         
125         WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
126         
127         WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
128         WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0);
129         WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0);
130         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
131         WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0);
132         
133         WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0);
134
135         WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0);
136         
137         WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEPAN, 0, KM_ALT, 0);
138         WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEROTATE, 0, 0, 0);
139         WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, 0, 0);
140         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0);
141         
142         /*numpad +/-*/
143         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
144         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1);
145
146         /*ctrl +/-*/
147         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", EQUALKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
148         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MINUSKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
149         
150         /*wheel mouse forward/back*/
151         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1);
152         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELOUTMOUSE, KM_PRESS, 0, 0)->ptr, "delta", -1);
153
154         WM_keymap_add_item(keymap, "VIEW3D_OT_view_center_camera", HOMEKEY, KM_PRESS, 0, 0); /* only with camera view */
155         RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", HOMEKEY, KM_PRESS, 0, 0)->ptr, "center", 0); /* only without camera view */
156         RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_all", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "center", 1);
157
158         /* numpad view hotkeys*/
159         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD0, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_CAMERA);
160         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_FRONT);
161         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD2, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPDOWN);
162         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT);
163         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT);
164         WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0);
165         
166         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT);
167         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP);
168         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP);
169         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BACK);
170         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_LEFT);
171         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_CTRL, 0)->ptr, "type", RV3D_VIEW_BOTTOM);
172         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD2, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANDOWN);
173         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD4, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
174         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
175         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANUP);
176         
177         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANRIGHT);
178         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "type", V3D_VIEW_PANLEFT);
179         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELUPMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANUP);
180         RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_pan", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", V3D_VIEW_PANDOWN);
181
182         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);
183         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);
184         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);
185         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);
186         
187         /* active aligned, replaces '*' key in 2.4x */
188         kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT, 0);
189         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT);
190         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
191         kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT, 0);
192         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_RIGHT);
193         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
194         kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT, 0);
195         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_TOP);
196         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
197         kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD1, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
198         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BACK);
199         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
200         kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
201         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_LEFT);
202         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
203         kmi= WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
204         RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_BOTTOM);
205         RNA_boolean_set(kmi->ptr, "align_active", TRUE);
206
207         WM_keymap_add_item(keymap, "VIEW3D_OT_localview", PADSLASHKEY, KM_PRESS, 0, 0);
208         
209         /* layers, shift + alt are properties set in invoke() */
210         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ACCENTGRAVEKEY, KM_PRESS, 0, 0)->ptr, "nr", 0);
211         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ONEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 1);
212         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", TWOKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 2);
213         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", THREEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 3);
214         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FOURKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 4);
215         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", FIVEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 5);
216         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SIXKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 6);
217         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", SEVENKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 7);
218         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", EIGHTKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 8);
219         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", NINEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 9);
220         RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ZEROKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 10);
221         
222         /* drawtype */
223
224         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0);
225         RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shading");
226         RNA_string_set(kmi->ptr, "value_1", "SOLID");
227         RNA_string_set(kmi->ptr, "value_2", "WIREFRAME");
228
229         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, KM_ALT, 0);
230         RNA_string_set(kmi->ptr, "data_path", "space_data.viewport_shading");
231         RNA_string_set(kmi->ptr, "value_1", "TEXTURED");
232         RNA_string_set(kmi->ptr, "value_2", "SOLID");
233
234         /* selection*/
235         WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
236         RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE);
237         RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "center", TRUE);
238         RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "enumerate", TRUE);
239
240         /* selection key-combinations */
241         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
242         RNA_boolean_set(kmi->ptr, "center", TRUE);
243         RNA_boolean_set(kmi->ptr, "extend", TRUE);
244         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
245         RNA_boolean_set(kmi->ptr, "center", TRUE);
246         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
247         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
248         RNA_boolean_set(kmi->ptr, "extend", TRUE);
249         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
250         kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0);
251         RNA_boolean_set(kmi->ptr, "center", TRUE);
252         RNA_boolean_set(kmi->ptr, "extend", TRUE);
253         RNA_boolean_set(kmi->ptr, "enumerate", TRUE);
254
255         WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
256         WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
257         RNA_boolean_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0)->ptr, "deselect", 1);
258         WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
259         
260         WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0);
261         WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0);
262         WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
263         
264         WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT|KM_CTRL, 0);
265         WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0);
266         
267         WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
268         
269         /* context ops */
270         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0);
271         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
272         RNA_string_set(kmi->ptr, "value", "BOUNDING_BOX_CENTER");
273
274         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 */
275         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
276         RNA_string_set(kmi->ptr, "value", "MEDIAN_POINT");
277
278         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", COMMAKEY, KM_PRESS, KM_ALT, 0); /* new in 2.5 */
279         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point_align");
280
281         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* new in 2.5 */
282         RNA_string_set(kmi->ptr, "data_path", "space_data.manipulator");
283
284         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0);
285         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
286         RNA_string_set(kmi->ptr, "value", "CURSOR");
287
288         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_CTRL, 0);
289         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
290         RNA_string_set(kmi->ptr, "value", "INDIVIDUAL_ORIGINS");
291
292         kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_ALT, 0);
293         RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point");
294         RNA_string_set(kmi->ptr, "value", "ACTIVE_ELEMENT");
295
296         transform_keymap_for_space(keyconf, keymap, SPACE_VIEW3D);
297
298         fly_modal_keymap(keyconf);
299         viewrotate_modal_keymap(keyconf);
300         viewmove_modal_keymap(keyconf);
301         viewzoom_modal_keymap(keyconf);
302 }
303