synched with trunk at revision 30243
[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., 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
37 #include "BLI_math.h"
38 #include "BLI_blenlib.h"
39
40 #include "BKE_context.h"
41 #include "BKE_global.h"
42 #include "BKE_utildefines.h"
43
44 #include "RNA_access.h"
45 #include "RNA_define.h"
46
47 #include "WM_api.h"
48 #include "WM_types.h"
49
50 #include "ED_screen.h"
51 #include "ED_object.h"
52
53 #include "object_intern.h"
54
55
56 /* ************************** registration **********************************/
57
58
59 void ED_operatortypes_object(void)
60 {
61         WM_operatortype_append(OBJECT_OT_location_clear);
62         WM_operatortype_append(OBJECT_OT_rotation_clear);
63         WM_operatortype_append(OBJECT_OT_scale_clear);
64         WM_operatortype_append(OBJECT_OT_origin_clear);
65         WM_operatortype_append(OBJECT_OT_visual_transform_apply);
66         WM_operatortype_append(OBJECT_OT_location_apply);
67         WM_operatortype_append(OBJECT_OT_scale_apply);
68         WM_operatortype_append(OBJECT_OT_rotation_apply);
69         WM_operatortype_append(OBJECT_OT_origin_set);
70         
71         WM_operatortype_append(OBJECT_OT_mode_set);
72         WM_operatortype_append(OBJECT_OT_editmode_toggle);
73         WM_operatortype_append(OBJECT_OT_posemode_toggle);
74         WM_operatortype_append(OBJECT_OT_proxy_make);
75         WM_operatortype_append(OBJECT_OT_restrictview_clear);
76         WM_operatortype_append(OBJECT_OT_restrictview_set);
77         WM_operatortype_append(OBJECT_OT_restrictrender_clear);
78         WM_operatortype_append(OBJECT_OT_restrictrender_set);
79         WM_operatortype_append(OBJECT_OT_shade_smooth);
80         WM_operatortype_append(OBJECT_OT_shade_flat);
81         WM_operatortype_append(OBJECT_OT_paths_calculate);
82         WM_operatortype_append(OBJECT_OT_paths_clear);
83
84         WM_operatortype_append(OBJECT_OT_parent_set);
85         WM_operatortype_append(OBJECT_OT_parent_no_inverse_set);
86         WM_operatortype_append(OBJECT_OT_parent_clear);
87         WM_operatortype_append(OBJECT_OT_vertex_parent_set);
88         WM_operatortype_append(OBJECT_OT_track_set);
89         WM_operatortype_append(OBJECT_OT_track_clear);
90         WM_operatortype_append(OBJECT_OT_slow_parent_set);
91         WM_operatortype_append(OBJECT_OT_slow_parent_clear);
92         WM_operatortype_append(OBJECT_OT_make_local);
93         WM_operatortype_append(OBJECT_OT_make_single_user);
94         WM_operatortype_append(OBJECT_OT_make_links_scene);
95         WM_operatortype_append(OBJECT_OT_make_links_data);
96         WM_operatortype_append(OBJECT_OT_move_to_layer);
97
98         WM_operatortype_append(OBJECT_OT_select_inverse);
99         WM_operatortype_append(OBJECT_OT_select_random);
100         WM_operatortype_append(OBJECT_OT_select_all);
101         WM_operatortype_append(OBJECT_OT_select_same_group);
102         WM_operatortype_append(OBJECT_OT_select_by_type);
103         WM_operatortype_append(OBJECT_OT_select_by_layer);
104         WM_operatortype_append(OBJECT_OT_select_linked);
105         WM_operatortype_append(OBJECT_OT_select_grouped);
106         WM_operatortype_append(OBJECT_OT_select_mirror);
107         WM_operatortype_append(OBJECT_OT_select_name); /* XXX - weak, not compat with linked objects */
108
109         WM_operatortype_append(GROUP_OT_create);
110         WM_operatortype_append(GROUP_OT_objects_remove);
111         WM_operatortype_append(GROUP_OT_objects_add_active);
112         WM_operatortype_append(GROUP_OT_objects_remove_active);
113
114         WM_operatortype_append(OBJECT_OT_delete);
115         WM_operatortype_append(OBJECT_OT_text_add);
116         WM_operatortype_append(OBJECT_OT_armature_add);
117         WM_operatortype_append(OBJECT_OT_lamp_add);
118         WM_operatortype_append(OBJECT_OT_camera_add);
119         WM_operatortype_append(OBJECT_OT_add);
120         WM_operatortype_append(OBJECT_OT_add_named);
121         WM_operatortype_append(OBJECT_OT_effector_add);
122         WM_operatortype_append(OBJECT_OT_group_instance_add);
123         WM_operatortype_append(OBJECT_OT_metaball_add);
124         WM_operatortype_append(OBJECT_OT_duplicates_make_real);
125         WM_operatortype_append(OBJECT_OT_duplicate);
126         WM_operatortype_append(OBJECT_OT_join);
127         WM_operatortype_append(OBJECT_OT_join_shapes);
128         WM_operatortype_append(OBJECT_OT_convert);
129
130         WM_operatortype_append(OBJECT_OT_modifier_add);
131         WM_operatortype_append(OBJECT_OT_modifier_remove);
132         WM_operatortype_append(OBJECT_OT_modifier_move_up);
133         WM_operatortype_append(OBJECT_OT_modifier_move_down);
134         WM_operatortype_append(OBJECT_OT_modifier_apply);
135         WM_operatortype_append(OBJECT_OT_modifier_convert);
136         WM_operatortype_append(OBJECT_OT_modifier_copy);
137         WM_operatortype_append(OBJECT_OT_multires_subdivide);
138         WM_operatortype_append(OBJECT_OT_multires_reshape);
139         WM_operatortype_append(OBJECT_OT_multires_higher_levels_delete);
140         WM_operatortype_append(OBJECT_OT_multires_external_save);
141         WM_operatortype_append(OBJECT_OT_multires_external_pack);
142         WM_operatortype_append(OBJECT_OT_meshdeform_bind);
143         WM_operatortype_append(OBJECT_OT_explode_refresh);
144         
145         WM_operatortype_append(OBJECT_OT_constraint_add);
146         WM_operatortype_append(OBJECT_OT_constraint_add_with_targets);
147         WM_operatortype_append(POSE_OT_constraint_add);
148         WM_operatortype_append(POSE_OT_constraint_add_with_targets);
149         WM_operatortype_append(OBJECT_OT_constraints_copy);
150         WM_operatortype_append(POSE_OT_constraints_copy);
151         WM_operatortype_append(OBJECT_OT_constraints_clear);
152         WM_operatortype_append(POSE_OT_constraints_clear);
153         WM_operatortype_append(POSE_OT_ik_add);
154         WM_operatortype_append(POSE_OT_ik_clear);
155         WM_operatortype_append(CONSTRAINT_OT_delete);
156         WM_operatortype_append(CONSTRAINT_OT_move_up);
157         WM_operatortype_append(CONSTRAINT_OT_move_down);
158         WM_operatortype_append(CONSTRAINT_OT_stretchto_reset);
159         WM_operatortype_append(CONSTRAINT_OT_limitdistance_reset);
160         WM_operatortype_append(CONSTRAINT_OT_childof_set_inverse);
161         WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse);
162
163         WM_operatortype_append(OBJECT_OT_vertex_group_add);
164         WM_operatortype_append(OBJECT_OT_vertex_group_remove);
165         WM_operatortype_append(OBJECT_OT_vertex_group_assign);
166         WM_operatortype_append(OBJECT_OT_vertex_group_remove_from);
167         WM_operatortype_append(OBJECT_OT_vertex_group_select);
168         WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
169         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
170         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected);
171         WM_operatortype_append(OBJECT_OT_vertex_group_copy);
172         WM_operatortype_append(OBJECT_OT_vertex_group_normalize);
173         WM_operatortype_append(OBJECT_OT_vertex_group_normalize_all);
174         WM_operatortype_append(OBJECT_OT_vertex_group_invert);
175         WM_operatortype_append(OBJECT_OT_vertex_group_levels);
176         WM_operatortype_append(OBJECT_OT_vertex_group_blend);
177         WM_operatortype_append(OBJECT_OT_vertex_group_clean);
178         WM_operatortype_append(OBJECT_OT_vertex_group_mirror);
179         WM_operatortype_append(OBJECT_OT_vertex_group_set_active);
180         WM_operatortype_append(OBJECT_OT_vertex_group_sort);
181         WM_operatortype_append(OBJECT_OT_vertex_group_move);
182
183         WM_operatortype_append(OBJECT_OT_game_property_new);
184         WM_operatortype_append(OBJECT_OT_game_property_remove);
185         WM_operatortype_append(OBJECT_OT_game_property_copy);
186         WM_operatortype_append(OBJECT_OT_game_property_clear);
187         WM_operatortype_append(OBJECT_OT_logic_bricks_copy);
188
189         WM_operatortype_append(OBJECT_OT_shape_key_add);
190         WM_operatortype_append(OBJECT_OT_shape_key_remove);
191         WM_operatortype_append(OBJECT_OT_shape_key_clear);
192         WM_operatortype_append(OBJECT_OT_shape_key_mirror);
193         WM_operatortype_append(OBJECT_OT_shape_key_move);
194
195         WM_operatortype_append(LATTICE_OT_select_all);
196         WM_operatortype_append(LATTICE_OT_make_regular);
197
198         WM_operatortype_append(OBJECT_OT_group_add);
199         WM_operatortype_append(OBJECT_OT_group_link);
200         WM_operatortype_append(OBJECT_OT_group_remove);
201
202         WM_operatortype_append(OBJECT_OT_hook_add_selobj);
203         WM_operatortype_append(OBJECT_OT_hook_add_newobj);
204         WM_operatortype_append(OBJECT_OT_hook_remove);
205         WM_operatortype_append(OBJECT_OT_hook_select);
206         WM_operatortype_append(OBJECT_OT_hook_assign);
207         WM_operatortype_append(OBJECT_OT_hook_reset);
208         WM_operatortype_append(OBJECT_OT_hook_recenter);
209
210         WM_operatortype_append(OBJECT_OT_bake_image);
211         WM_operatortype_append(OBJECT_OT_drop_named_material);
212
213         WM_operatortype_append(OBJECT_OT_create_navmesh);
214 }
215
216 void ED_operatormacros_object(void)
217 {
218         wmOperatorType *ot;
219         wmOperatorTypeMacro *otmacro;
220         
221         ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
222         if(ot) {
223                 WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
224                 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
225                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
226         }
227
228         /* grr, should be able to pass options on... */
229         ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO|OPTYPE_REGISTER);
230         if(ot) {
231                 otmacro= WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
232                 RNA_boolean_set(otmacro->ptr, "linked", 1);
233                 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
234                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
235         }
236         
237         /* XXX */
238         ot= WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO|OPTYPE_REGISTER);
239         if(ot) {
240                 RNA_def_string(ot->srna, "name", "Cube", 24, "Name", "Object name to add.");
241
242                 WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d");
243                 WM_operatortype_macro_define(ot, "OBJECT_OT_add_named");
244         }
245 }
246
247 static int object_mode_poll(bContext *C)
248 {
249         Object *ob= CTX_data_active_object(C);
250         return (!ob || ob->mode == OB_MODE_OBJECT);
251 }
252
253 void ED_keymap_object(wmKeyConfig *keyconf)
254 {
255         wmKeyMap *keymap;
256         wmKeyMapItem *kmi;
257         int i;
258         
259         /* Objects, Regardless of Mode -------------------------------------------------- */
260         keymap= WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
261         
262         /* Note: this keymap works disregarding mode */
263         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
264                 RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
265                 RNA_boolean_set(kmi->ptr, "toggle", 1);
266
267         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
268                 RNA_enum_set(kmi->ptr, "mode", OB_MODE_POSE);
269                 RNA_boolean_set(kmi->ptr, "toggle", 1);
270
271         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0);
272                 RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT);
273                 RNA_boolean_set(kmi->ptr, "toggle", 1);
274         
275         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
276                 RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT);
277                 RNA_boolean_set(kmi->ptr, "toggle", 1);
278         
279         WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0);
280
281         /* Object Mode ---------------------------------------------------------------- */
282         /* Note: this keymap gets disabled in non-objectmode,  */
283         keymap= WM_keymap_find(keyconf, "Object Mode", 0, 0);
284         keymap->poll= object_mode_poll;
285         
286         /* object mode supports PET now */
287         ED_object_generic_keymap(keyconf, keymap, 1);
288
289         WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0);
290
291         WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
292         WM_keymap_add_item(keymap, "OBJECT_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
293         WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
294         WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
295         WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
296         
297         kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
298                 RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
299         kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
300                 RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
301                 RNA_boolean_set(kmi->ptr, "extend", 1);
302
303         kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
304                 RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
305         kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
306                 RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
307                 RNA_boolean_set(kmi->ptr, "extend", 1);
308
309         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
310         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
311         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
312         WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0);
313         WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0);
314         
315         WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
316         WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
317         
318         WM_keymap_verify_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0);
319         WM_keymap_verify_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0);
320         WM_keymap_verify_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
321         WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0);
322         
323         WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_clear", HKEY, KM_PRESS, KM_ALT, 0);
324         WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, 0, 0);
325         RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_restrictview_set", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
326
327         /* same as above but for rendering */
328         WM_keymap_add_item(keymap, "OBJECT_OT_restrictrender_clear", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
329         WM_keymap_add_item(keymap, "OBJECT_OT_restrictrender_set", HKEY, KM_PRESS, KM_CTRL, 0);
330 //      RNA_boolean_set(WM_keymap_add_item(keymap, "OBJECT_OT_restrictrender_set", HKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "unselected", 1); // conflicts, removing
331
332         WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0);
333         
334         WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
335         WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, 0, 0);
336         WM_keymap_add_item(keymap, "OBJECT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0);
337         WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
338
339         WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
340
341         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_apply", AKEY, KM_PRESS, KM_CTRL, 0);
342         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_single_user", UKEY, KM_PRESS, 0, 0);
343         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_links", LKEY, KM_PRESS, KM_CTRL, 0);
344
345         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
346         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0);
347         
348         WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0);
349         WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0);
350         WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
351         WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0);
352
353         // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
354         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
355         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
356         WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0);
357         
358         WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0);
359         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
360         WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
361         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
362
363         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0);
364
365         for(i=0; i<=5; i++) {
366                 kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0);
367                 RNA_int_set(kmi->ptr, "level", i);
368         }
369
370         /* Lattice -------------------------------------------------------------------- */
371         keymap= WM_keymap_find(keyconf, "Lattice", 0, 0);
372         keymap->poll= ED_operator_editlattice;
373
374         WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0);
375         
376         WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
377         
378                 /* menus */
379         WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
380
381         ED_object_generic_keymap(keyconf, keymap, 1);
382 }
383
384 void ED_object_generic_keymap(struct wmKeyConfig *keyconf, struct wmKeyMap *keymap, int do_pet)
385 {
386         wmKeyMapItem *kmi;
387
388         /* used by mesh, curve & lattice only */
389         if(do_pet > 0) {
390                 /* context ops */
391                 kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0);
392                 RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing_falloff");
393
394                 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
395                 RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing");
396                 RNA_string_set(kmi->ptr, "value_1", "DISABLED");
397                 RNA_string_set(kmi->ptr, "value_2", "ENABLED");
398
399                 /* for modes/object types that allow 'conencted' mode, add the Alt O key */
400                 if (do_pet > 1) {
401                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0);
402                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_editing");
403                         RNA_string_set(kmi->ptr, "value_1", "DISABLED");
404                         RNA_string_set(kmi->ptr, "value_2", "CONNECTED");
405                 }
406         }
407 }
408