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