svn merge ^/trunk/blender -r44562:45364
[blender-staging.git] / source / blender / editors / object / object_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/object/object_ops.c
28  *  \ingroup edobj
29  */
30
31
32 #include <stdlib.h>
33 #include <math.h>
34
35 #include "DNA_object_types.h"
36 #include "DNA_scene_types.h"
37
38 #include "BLI_math.h"
39 #include "BLI_blenlib.h"
40 #include "BLI_utildefines.h"
41
42 #include "BKE_context.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_transform_apply);
67         WM_operatortype_append(OBJECT_OT_origin_set);
68         
69         WM_operatortype_append(OBJECT_OT_mode_set);
70         WM_operatortype_append(OBJECT_OT_editmode_toggle);
71         WM_operatortype_append(OBJECT_OT_posemode_toggle);
72         WM_operatortype_append(OBJECT_OT_proxy_make);
73         WM_operatortype_append(OBJECT_OT_hide_view_clear);
74         WM_operatortype_append(OBJECT_OT_hide_view_set);
75         WM_operatortype_append(OBJECT_OT_hide_render_clear);
76         WM_operatortype_append(OBJECT_OT_hide_render_set);
77         WM_operatortype_append(OBJECT_OT_shade_smooth);
78         WM_operatortype_append(OBJECT_OT_shade_flat);
79         WM_operatortype_append(OBJECT_OT_paths_calculate);
80         WM_operatortype_append(OBJECT_OT_paths_clear);
81         WM_operatortype_append(OBJECT_OT_forcefield_toggle);
82
83         WM_operatortype_append(OBJECT_OT_parent_set);
84         WM_operatortype_append(OBJECT_OT_parent_no_inverse_set);
85         WM_operatortype_append(OBJECT_OT_parent_clear);
86         WM_operatortype_append(OBJECT_OT_vertex_parent_set);
87         WM_operatortype_append(OBJECT_OT_track_set);
88         WM_operatortype_append(OBJECT_OT_track_clear);
89         WM_operatortype_append(OBJECT_OT_slow_parent_set);
90         WM_operatortype_append(OBJECT_OT_slow_parent_clear);
91         WM_operatortype_append(OBJECT_OT_make_local);
92         WM_operatortype_append(OBJECT_OT_make_single_user);
93         WM_operatortype_append(OBJECT_OT_make_links_scene);
94         WM_operatortype_append(OBJECT_OT_make_links_data);
95         WM_operatortype_append(OBJECT_OT_move_to_layer);
96
97         WM_operatortype_append(OBJECT_OT_select_random);
98         WM_operatortype_append(OBJECT_OT_select_all);
99         WM_operatortype_append(OBJECT_OT_select_same_group);
100         WM_operatortype_append(OBJECT_OT_select_by_type);
101         WM_operatortype_append(OBJECT_OT_select_by_layer);
102         WM_operatortype_append(OBJECT_OT_select_linked);
103         WM_operatortype_append(OBJECT_OT_select_grouped);
104         WM_operatortype_append(OBJECT_OT_select_mirror);
105
106         WM_operatortype_append(GROUP_OT_create);
107         WM_operatortype_append(GROUP_OT_objects_remove);
108         WM_operatortype_append(GROUP_OT_objects_add_active);
109         WM_operatortype_append(GROUP_OT_objects_remove_active);
110
111         WM_operatortype_append(OBJECT_OT_delete);
112         WM_operatortype_append(OBJECT_OT_text_add);
113         WM_operatortype_append(OBJECT_OT_armature_add);
114         WM_operatortype_append(OBJECT_OT_lamp_add);
115         WM_operatortype_append(OBJECT_OT_camera_add);
116         WM_operatortype_append(OBJECT_OT_speaker_add);
117         WM_operatortype_append(OBJECT_OT_add);
118         WM_operatortype_append(OBJECT_OT_add_named);
119         WM_operatortype_append(OBJECT_OT_effector_add);
120         WM_operatortype_append(OBJECT_OT_group_instance_add);
121         WM_operatortype_append(OBJECT_OT_metaball_add);
122         WM_operatortype_append(OBJECT_OT_duplicates_make_real);
123         WM_operatortype_append(OBJECT_OT_duplicate);
124         WM_operatortype_append(OBJECT_OT_join);
125         WM_operatortype_append(OBJECT_OT_join_shapes);
126         WM_operatortype_append(OBJECT_OT_convert);
127
128         WM_operatortype_append(OBJECT_OT_modifier_add);
129         WM_operatortype_append(OBJECT_OT_modifier_remove);
130         WM_operatortype_append(OBJECT_OT_modifier_move_up);
131         WM_operatortype_append(OBJECT_OT_modifier_move_down);
132         WM_operatortype_append(OBJECT_OT_modifier_apply);
133         WM_operatortype_append(OBJECT_OT_modifier_convert);
134         WM_operatortype_append(OBJECT_OT_modifier_copy);
135         WM_operatortype_append(OBJECT_OT_multires_subdivide);
136         WM_operatortype_append(OBJECT_OT_multires_reshape);
137         WM_operatortype_append(OBJECT_OT_multires_higher_levels_delete);
138         WM_operatortype_append(OBJECT_OT_multires_base_apply);
139         WM_operatortype_append(OBJECT_OT_multires_external_save);
140         WM_operatortype_append(OBJECT_OT_multires_external_pack);
141         WM_operatortype_append(OBJECT_OT_meshdeform_bind);
142         WM_operatortype_append(OBJECT_OT_explode_refresh);
143         WM_operatortype_append(OBJECT_OT_ocean_bake);
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         WM_operatortype_append(CONSTRAINT_OT_objectsolver_set_inverse);
163         WM_operatortype_append(CONSTRAINT_OT_objectsolver_clear_inverse);
164
165         WM_operatortype_append(OBJECT_OT_vertex_group_add);
166         WM_operatortype_append(OBJECT_OT_vertex_group_remove);
167         WM_operatortype_append(OBJECT_OT_vertex_group_assign);
168         WM_operatortype_append(OBJECT_OT_vertex_group_remove_from);
169         WM_operatortype_append(OBJECT_OT_vertex_group_select);
170         WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
171         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
172         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected);
173         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected_single);
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         WM_operatortype_append(OBJECT_OT_vertex_group_lock);
178         WM_operatortype_append(OBJECT_OT_vertex_group_fix);
179         WM_operatortype_append(OBJECT_OT_vertex_group_invert);
180         WM_operatortype_append(OBJECT_OT_vertex_group_levels);
181         WM_operatortype_append(OBJECT_OT_vertex_group_blend);
182         WM_operatortype_append(OBJECT_OT_vertex_group_clean);
183         WM_operatortype_append(OBJECT_OT_vertex_group_mirror);
184         WM_operatortype_append(OBJECT_OT_vertex_group_set_active);
185         WM_operatortype_append(OBJECT_OT_vertex_group_sort);
186         WM_operatortype_append(OBJECT_OT_vertex_group_move);
187
188         WM_operatortype_append(OBJECT_OT_game_property_new);
189         WM_operatortype_append(OBJECT_OT_game_property_remove);
190         WM_operatortype_append(OBJECT_OT_game_property_copy);
191         WM_operatortype_append(OBJECT_OT_game_property_clear);
192         WM_operatortype_append(OBJECT_OT_logic_bricks_copy);
193         WM_operatortype_append(OBJECT_OT_game_physics_copy);
194
195         WM_operatortype_append(OBJECT_OT_shape_key_add);
196         WM_operatortype_append(OBJECT_OT_shape_key_remove);
197         WM_operatortype_append(OBJECT_OT_shape_key_clear);
198         WM_operatortype_append(OBJECT_OT_shape_key_mirror);
199         WM_operatortype_append(OBJECT_OT_shape_key_move);
200
201         WM_operatortype_append(LATTICE_OT_select_all);
202         WM_operatortype_append(LATTICE_OT_make_regular);
203
204         WM_operatortype_append(OBJECT_OT_group_add);
205         WM_operatortype_append(OBJECT_OT_group_link);
206         WM_operatortype_append(OBJECT_OT_group_remove);
207
208         WM_operatortype_append(OBJECT_OT_hook_add_selobj);
209         WM_operatortype_append(OBJECT_OT_hook_add_newobj);
210         WM_operatortype_append(OBJECT_OT_hook_remove);
211         WM_operatortype_append(OBJECT_OT_hook_select);
212         WM_operatortype_append(OBJECT_OT_hook_assign);
213         WM_operatortype_append(OBJECT_OT_hook_reset);
214         WM_operatortype_append(OBJECT_OT_hook_recenter);
215
216         WM_operatortype_append(OBJECT_OT_bake_image);
217         WM_operatortype_append(OBJECT_OT_drop_named_material);
218 }
219
220 void ED_operatormacros_object(void)
221 {
222         wmOperatorType *ot;
223         wmOperatorTypeMacro *otmacro;
224         
225         ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO|OPTYPE_REGISTER);
226         if (ot) {
227                 ot->description = "Duplicate selected objects and move them";
228                 WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
229                 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
230                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
231         }
232
233         /* grr, should be able to pass options on... */
234         ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO|OPTYPE_REGISTER);
235         if (ot) {
236                 ot->description = "Duplicate selected objects and move them";
237                 otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
238                 RNA_boolean_set(otmacro->ptr, "linked", TRUE);
239                 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
240                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
241         }
242         
243         /* XXX */
244         ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO|OPTYPE_REGISTER);
245         if (ot) {
246                 ot->description = "Add named object at cursor";
247                 RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add");
248
249                 WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d");
250                 WM_operatortype_macro_define(ot, "OBJECT_OT_add_named");
251         }
252 }
253
254 static int object_mode_poll(bContext *C)
255 {
256         Object *ob= CTX_data_active_object(C);
257         return (!ob || ob->mode == OB_MODE_OBJECT);
258 }
259
260 void ED_keymap_object(wmKeyConfig *keyconf)
261 {
262         wmKeyMap *keymap;
263         wmKeyMapItem *kmi;
264         int i;
265         
266         /* Objects, Regardless of Mode -------------------------------------------------- */
267         keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
268         
269         /* Note: this keymap works disregarding mode */
270         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
271         RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
272         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
273
274         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
275         RNA_enum_set(kmi->ptr, "mode", OB_MODE_POSE);
276         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
277
278         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0);
279         RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT);
280         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
281         
282         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
283         RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT);
284         RNA_boolean_set(kmi->ptr, "toggle", TRUE);
285         
286         WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT|KM_SHIFT|KM_CTRL, 0);
287
288         /* Object Mode ---------------------------------------------------------------- */
289         /* Note: this keymap gets disabled in non-objectmode,  */
290         keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0);
291         keymap->poll = object_mode_poll;
292         
293         /* object mode supports PET now */
294         ED_object_generic_keymap(keyconf, keymap, 1);
295
296         WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0);
297
298         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
299         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
300         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
301         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
302
303         WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
304         WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
305         WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
306         
307         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
308         RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
309         RNA_boolean_set(kmi->ptr, "extend", FALSE);
310
311         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
312         RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT");
313         RNA_boolean_set(kmi->ptr, "extend", TRUE);
314
315         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
316         RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD");
317         RNA_boolean_set(kmi->ptr, "extend", FALSE);
318
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", TRUE);
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         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0);
339         RNA_boolean_set(kmi->ptr, "unselected", FALSE);
340
341         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, KM_SHIFT, 0);
342         RNA_boolean_set(kmi->ptr, "unselected", TRUE);
343
344         /* same as above but for rendering */
345         WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_clear", HKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
346         WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_CTRL, 0);
347
348         /* conflicts, removing */
349 #if 0
350         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_render_set", HKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)
351         RNA_boolean_set(kmi->ptr, "unselected", TRUE);
352 #endif
353
354         WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0);
355         
356         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
357         RNA_boolean_set(kmi->ptr, "use_global", FALSE);
358
359         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0);
360         RNA_boolean_set(kmi->ptr, "use_global", TRUE);
361
362         WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, 0, 0);
363         RNA_boolean_set(kmi->ptr, "use_global", FALSE);
364         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0);
365         RNA_boolean_set(kmi->ptr, "use_global", TRUE);
366
367         WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
368
369         WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
370
371         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_apply", AKEY, KM_PRESS, KM_CTRL, 0);
372         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_single_user", UKEY, KM_PRESS, 0, 0);
373         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_links", LKEY, KM_PRESS, KM_CTRL, 0);
374
375         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
376         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0);
377         
378         WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0);
379         WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0);
380         WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
381         WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0);
382
383         // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
384         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
385         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
386         WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0);
387         
388         WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0);
389         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
390         WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
391         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
392
393         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0);
394
395         for (i=0; i<=5; i++) {
396                 kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0);
397                 RNA_int_set(kmi->ptr, "level", i);
398         }
399
400         /* ############################################################################ */
401         /* ################################ LATTICE ################################### */
402         /* ############################################################################ */
403
404         keymap = WM_keymap_find(keyconf, "Lattice", 0, 0);
405         keymap->poll = ED_operator_editlattice;
406
407         kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0);
408         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
409         kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
410         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
411
412         WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
413         
414         /* menus */
415         WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
416
417         ED_object_generic_keymap(keyconf, keymap, 2);
418 }
419
420 void ED_object_generic_keymap(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap, int do_pet)
421 {
422         wmKeyMapItem *kmi;
423
424         /* used by mesh, curve & lattice only */
425         if (do_pet) {
426                 /* context ops */
427                 kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0);
428                 RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit_falloff");
429
430                 // Object mode
431                 if (do_pet == 1) {
432
433                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
434                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_edit_objects");
435
436                 }
437                 else { // Edit mode
438
439                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
440                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
441                         RNA_string_set(kmi->ptr, "value_1", "DISABLED");
442                         RNA_string_set(kmi->ptr, "value_2", "ENABLED");
443
444                         /* for modes/object types that allow 'connected' mode, add the Alt O key */
445                         if (do_pet == 3) {
446                                 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0);
447                                 RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
448                                 RNA_string_set(kmi->ptr, "value_1", "DISABLED");
449                                 RNA_string_set(kmi->ptr, "value_2", "CONNECTED");
450                         }
451                 }
452         }
453 }
454