Merge branch 'master' into blender2.8
[blender.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_utildefines.h"
39
40 #include "BKE_context.h"
41
42 #include "RNA_access.h"
43
44 #include "WM_api.h"
45 #include "WM_types.h"
46
47 #include "ED_screen.h"
48 #include "ED_object.h"
49
50 #include "object_intern.h"
51
52
53 /* ************************** registration **********************************/
54
55
56 void ED_operatortypes_object(void)
57 {
58         WM_operatortype_append(OBJECT_OT_location_clear);
59         WM_operatortype_append(OBJECT_OT_rotation_clear);
60         WM_operatortype_append(OBJECT_OT_scale_clear);
61         WM_operatortype_append(OBJECT_OT_origin_clear);
62         WM_operatortype_append(OBJECT_OT_visual_transform_apply);
63         WM_operatortype_append(OBJECT_OT_transform_apply);
64         WM_operatortype_append(OBJECT_OT_origin_set);
65         
66         WM_operatortype_append(OBJECT_OT_mode_set);
67         WM_operatortype_append(OBJECT_OT_editmode_toggle);
68         WM_operatortype_append(OBJECT_OT_posemode_toggle);
69         WM_operatortype_append(OBJECT_OT_proxy_make);
70         WM_operatortype_append(OBJECT_OT_shade_smooth);
71         WM_operatortype_append(OBJECT_OT_shade_flat);
72         WM_operatortype_append(OBJECT_OT_paths_calculate);
73         WM_operatortype_append(OBJECT_OT_paths_update);
74         WM_operatortype_append(OBJECT_OT_paths_clear);
75         WM_operatortype_append(OBJECT_OT_forcefield_toggle);
76
77         WM_operatortype_append(OBJECT_OT_parent_set);
78         WM_operatortype_append(OBJECT_OT_parent_no_inverse_set);
79         WM_operatortype_append(OBJECT_OT_parent_clear);
80         WM_operatortype_append(OBJECT_OT_vertex_parent_set);
81         WM_operatortype_append(OBJECT_OT_track_set);
82         WM_operatortype_append(OBJECT_OT_track_clear);
83         WM_operatortype_append(OBJECT_OT_slow_parent_set);
84         WM_operatortype_append(OBJECT_OT_slow_parent_clear);
85         WM_operatortype_append(OBJECT_OT_make_local);
86         WM_operatortype_append(OBJECT_OT_make_single_user);
87         WM_operatortype_append(OBJECT_OT_make_links_scene);
88         WM_operatortype_append(OBJECT_OT_make_links_data);
89
90         WM_operatortype_append(OBJECT_OT_select_random);
91         WM_operatortype_append(OBJECT_OT_select_all);
92         WM_operatortype_append(OBJECT_OT_select_same_group);
93         WM_operatortype_append(OBJECT_OT_select_by_type);
94         WM_operatortype_append(OBJECT_OT_select_linked);
95         WM_operatortype_append(OBJECT_OT_select_grouped);
96         WM_operatortype_append(OBJECT_OT_select_mirror);
97         WM_operatortype_append(OBJECT_OT_select_more);
98         WM_operatortype_append(OBJECT_OT_select_less);
99
100         WM_operatortype_append(GROUP_OT_create);
101         WM_operatortype_append(GROUP_OT_objects_remove_all);
102         WM_operatortype_append(GROUP_OT_objects_remove);
103         WM_operatortype_append(GROUP_OT_objects_add_active);
104         WM_operatortype_append(GROUP_OT_objects_remove_active);
105
106         WM_operatortype_append(OBJECT_OT_delete);
107         WM_operatortype_append(OBJECT_OT_text_add);
108         WM_operatortype_append(OBJECT_OT_armature_add);
109         WM_operatortype_append(OBJECT_OT_empty_add);
110         WM_operatortype_append(OBJECT_OT_drop_named_image);
111         WM_operatortype_append(OBJECT_OT_lamp_add);
112         WM_operatortype_append(OBJECT_OT_camera_add);
113         WM_operatortype_append(OBJECT_OT_speaker_add);
114         WM_operatortype_append(OBJECT_OT_add);
115         WM_operatortype_append(OBJECT_OT_add_named);
116         WM_operatortype_append(OBJECT_OT_effector_add);
117         WM_operatortype_append(OBJECT_OT_group_instance_add);
118         WM_operatortype_append(OBJECT_OT_metaball_add);
119         WM_operatortype_append(OBJECT_OT_duplicates_make_real);
120         WM_operatortype_append(OBJECT_OT_duplicate);
121         WM_operatortype_append(OBJECT_OT_join);
122         WM_operatortype_append(OBJECT_OT_join_shapes);
123         WM_operatortype_append(OBJECT_OT_convert);
124
125         WM_operatortype_append(OBJECT_OT_modifier_add);
126         WM_operatortype_append(OBJECT_OT_modifier_remove);
127         WM_operatortype_append(OBJECT_OT_modifier_move_up);
128         WM_operatortype_append(OBJECT_OT_modifier_move_down);
129         WM_operatortype_append(OBJECT_OT_modifier_apply);
130         WM_operatortype_append(OBJECT_OT_modifier_convert);
131         WM_operatortype_append(OBJECT_OT_modifier_copy);
132         WM_operatortype_append(OBJECT_OT_multires_subdivide);
133         WM_operatortype_append(OBJECT_OT_multires_reshape);
134         WM_operatortype_append(OBJECT_OT_multires_higher_levels_delete);
135         WM_operatortype_append(OBJECT_OT_multires_base_apply);
136         WM_operatortype_append(OBJECT_OT_multires_external_save);
137         WM_operatortype_append(OBJECT_OT_multires_external_pack);
138         WM_operatortype_append(OBJECT_OT_skin_root_mark);
139         WM_operatortype_append(OBJECT_OT_skin_loose_mark_clear);
140         WM_operatortype_append(OBJECT_OT_skin_radii_equalize);
141         WM_operatortype_append(OBJECT_OT_skin_armature_create);
142
143         WM_operatortype_append(OBJECT_OT_correctivesmooth_bind);
144         WM_operatortype_append(OBJECT_OT_meshdeform_bind);
145         WM_operatortype_append(OBJECT_OT_explode_refresh);
146         WM_operatortype_append(OBJECT_OT_ocean_bake);
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         WM_operatortype_append(CONSTRAINT_OT_objectsolver_set_inverse);
166         WM_operatortype_append(CONSTRAINT_OT_objectsolver_clear_inverse);
167         WM_operatortype_append(CONSTRAINT_OT_followpath_path_animate);
168
169         WM_operatortype_append(OBJECT_OT_vertex_group_add);
170         WM_operatortype_append(OBJECT_OT_vertex_group_remove);
171         WM_operatortype_append(OBJECT_OT_vertex_group_assign);
172         WM_operatortype_append(OBJECT_OT_vertex_group_assign_new);
173         WM_operatortype_append(OBJECT_OT_vertex_group_remove_from);
174         WM_operatortype_append(OBJECT_OT_vertex_group_select);
175         WM_operatortype_append(OBJECT_OT_vertex_group_deselect);
176         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_linked);
177         WM_operatortype_append(OBJECT_OT_vertex_group_copy_to_selected);
178         WM_operatortype_append(OBJECT_OT_vertex_group_copy);
179         WM_operatortype_append(OBJECT_OT_vertex_group_normalize);
180         WM_operatortype_append(OBJECT_OT_vertex_group_normalize_all);
181         WM_operatortype_append(OBJECT_OT_vertex_group_lock);
182         WM_operatortype_append(OBJECT_OT_vertex_group_fix);
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_smooth);
186         WM_operatortype_append(OBJECT_OT_vertex_group_clean);
187         WM_operatortype_append(OBJECT_OT_vertex_group_quantize);
188         WM_operatortype_append(OBJECT_OT_vertex_group_limit_total);
189         WM_operatortype_append(OBJECT_OT_vertex_group_mirror);
190         WM_operatortype_append(OBJECT_OT_vertex_group_set_active);
191         WM_operatortype_append(OBJECT_OT_vertex_group_sort);
192         WM_operatortype_append(OBJECT_OT_vertex_group_move);
193         WM_operatortype_append(OBJECT_OT_vertex_weight_paste);
194         WM_operatortype_append(OBJECT_OT_vertex_weight_delete);
195         WM_operatortype_append(OBJECT_OT_vertex_weight_set_active);
196         WM_operatortype_append(OBJECT_OT_vertex_weight_normalize_active_vertex);
197         WM_operatortype_append(OBJECT_OT_vertex_weight_copy);
198
199         WM_operatortype_append(TRANSFORM_OT_vertex_warp);
200
201         WM_operatortype_append(OBJECT_OT_game_property_new);
202         WM_operatortype_append(OBJECT_OT_game_property_remove);
203         WM_operatortype_append(OBJECT_OT_game_property_copy);
204         WM_operatortype_append(OBJECT_OT_game_property_clear);
205         WM_operatortype_append(OBJECT_OT_game_property_move);
206         WM_operatortype_append(OBJECT_OT_logic_bricks_copy);
207         WM_operatortype_append(OBJECT_OT_game_physics_copy);
208
209         WM_operatortype_append(OBJECT_OT_shape_key_add);
210         WM_operatortype_append(OBJECT_OT_shape_key_remove);
211         WM_operatortype_append(OBJECT_OT_shape_key_clear);
212         WM_operatortype_append(OBJECT_OT_shape_key_retime);
213         WM_operatortype_append(OBJECT_OT_shape_key_mirror);
214         WM_operatortype_append(OBJECT_OT_shape_key_move);
215
216         WM_operatortype_append(LATTICE_OT_select_all);
217         WM_operatortype_append(LATTICE_OT_select_more);
218         WM_operatortype_append(LATTICE_OT_select_less);
219         WM_operatortype_append(LATTICE_OT_select_ungrouped);
220         WM_operatortype_append(LATTICE_OT_select_random);
221         WM_operatortype_append(LATTICE_OT_select_mirror);
222         WM_operatortype_append(LATTICE_OT_make_regular);
223         WM_operatortype_append(LATTICE_OT_flip);
224
225         WM_operatortype_append(OBJECT_OT_group_add);
226         WM_operatortype_append(OBJECT_OT_group_link);
227         WM_operatortype_append(OBJECT_OT_group_remove);
228         WM_operatortype_append(OBJECT_OT_group_unlink);
229         WM_operatortype_append(OBJECT_OT_grouped_select);
230
231         WM_operatortype_append(OBJECT_OT_hook_add_selob);
232         WM_operatortype_append(OBJECT_OT_hook_add_newob);
233         WM_operatortype_append(OBJECT_OT_hook_remove);
234         WM_operatortype_append(OBJECT_OT_hook_select);
235         WM_operatortype_append(OBJECT_OT_hook_assign);
236         WM_operatortype_append(OBJECT_OT_hook_reset);
237         WM_operatortype_append(OBJECT_OT_hook_recenter);
238
239         WM_operatortype_append(OBJECT_OT_bake_image);
240         WM_operatortype_append(OBJECT_OT_bake);
241         WM_operatortype_append(OBJECT_OT_drop_named_material);
242         WM_operatortype_append(OBJECT_OT_unlink_data);
243         WM_operatortype_append(OBJECT_OT_laplaciandeform_bind);
244
245         WM_operatortype_append(OBJECT_OT_lod_add);
246         WM_operatortype_append(OBJECT_OT_lod_remove);
247
248         WM_operatortype_append(TRANSFORM_OT_vertex_random);
249
250         WM_operatortype_append(OBJECT_OT_data_transfer);
251         WM_operatortype_append(OBJECT_OT_datalayout_transfer);
252         WM_operatortype_append(OBJECT_OT_surfacedeform_bind);
253 }
254
255 void ED_operatormacros_object(void)
256 {
257         wmOperatorType *ot;
258         wmOperatorTypeMacro *otmacro;
259         
260         ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects",
261                                           "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER);
262         if (ot) {
263                 WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
264                 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
265                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
266         }
267
268         /* grr, should be able to pass options on... */
269         ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked",
270                                           "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER);
271         if (ot) {
272                 otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate");
273                 RNA_boolean_set(otmacro->ptr, "linked", true);
274                 otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
275                 RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF);
276         }
277         
278 }
279
280 static int object_mode_poll(bContext *C)
281 {
282         Object *ob = CTX_data_active_object(C);
283         return (!ob || ob->mode == OB_MODE_OBJECT);
284 }
285
286 void ED_keymap_object(wmKeyConfig *keyconf)
287 {
288         wmKeyMap *keymap;
289         wmKeyMapItem *kmi;
290         int i;
291         
292         /* Objects, Regardless of Mode -------------------------------------------------- */
293         keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0);
294         
295         /* Note: this keymap works disregarding mode */
296         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0);
297         RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT);
298         RNA_boolean_set(kmi->ptr, "toggle", true);
299
300         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
301         RNA_enum_set(kmi->ptr, "mode", OB_MODE_POSE);
302         RNA_boolean_set(kmi->ptr, "toggle", true);
303
304         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0);
305         RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT);
306         RNA_boolean_set(kmi->ptr, "toggle", true);
307         
308         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0);
309         RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT);
310         RNA_boolean_set(kmi->ptr, "toggle", true);
311         
312         WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0);
313
314         /* Object Mode ---------------------------------------------------------------- */
315         /* Note: this keymap gets disabled in non-objectmode,  */
316         keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0);
317         keymap->poll = object_mode_poll;
318         
319         /* object mode supports PET now */
320         ED_keymap_proportional_cycle(keyconf, keymap);
321         ED_keymap_proportional_obmode(keyconf, keymap);
322
323         /* game-engine only, leave free for users to define */
324         WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0);
325
326         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0);
327         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
328         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
329         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
330
331         WM_keymap_add_item(keymap, "OBJECT_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
332         WM_keymap_add_item(keymap, "OBJECT_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
333
334         WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0);
335         WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
336         WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
337         
338         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
339         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT");
340         RNA_boolean_set(kmi->ptr, "extend", false);
341
342         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
343         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT");
344         RNA_boolean_set(kmi->ptr, "extend", true);
345
346         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
347         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "CHILD");
348         RNA_boolean_set(kmi->ptr, "extend", false);
349
350         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
351         RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "CHILD");
352         RNA_boolean_set(kmi->ptr, "extend", true);
353
354         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
355         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
356         WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
357         WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0);
358         WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0);
359         
360         WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
361         WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
362         
363         
364         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0);
365         RNA_boolean_set(kmi->ptr, "clear_delta", false);
366         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0);
367         RNA_boolean_set(kmi->ptr, "clear_delta", false);
368         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
369         RNA_boolean_set(kmi->ptr, "clear_delta", false);
370         
371         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
372         RNA_boolean_set(kmi->ptr, "clear_delta", true);
373         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
374         RNA_boolean_set(kmi->ptr, "clear_delta", true);
375         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
376         RNA_boolean_set(kmi->ptr, "clear_delta", true);
377         
378         WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0);
379         
380         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0);
381         RNA_boolean_set(kmi->ptr, "use_global", false);
382
383         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, KM_SHIFT, 0);
384         RNA_boolean_set(kmi->ptr, "use_global", true);
385
386         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, 0, 0);
387         RNA_boolean_set(kmi->ptr, "use_global", false);
388         kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", DELKEY, KM_PRESS, KM_SHIFT, 0);
389         RNA_boolean_set(kmi->ptr, "use_global", true);
390
391         WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
392
393         WM_keymap_add_item(keymap, "OBJECT_OT_duplicates_make_real", AKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
394
395         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_apply", AKEY, KM_PRESS, KM_CTRL, 0);
396         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_single_user", UKEY, KM_PRESS, 0, 0);
397         WM_keymap_add_menu(keymap, "VIEW3D_MT_make_links", LKEY, KM_PRESS, KM_CTRL, 0);
398
399         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
400         WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0);
401         
402         WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0);
403         WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0);
404         WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
405         WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0);
406
407         /* XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith */
408         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
409         WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
410         WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0);
411         
412         WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0);
413         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
414         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0);
415         WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
416         WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
417         
418         WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0);
419
420         WM_keymap_verify_item(keymap, "OBJECT_OT_data_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
421         /* XXX No more available 'T' shortcuts... :/ */
422         /* WM_keymap_verify_item(keymap, "OBJECT_OT_datalayout_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); */
423
424         for (i = 0; i <= 5; i++) {
425                 kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
426                 RNA_int_set(kmi->ptr, "level", i);
427         }
428
429         /* ############################################################################ */
430         /* ################################ LATTICE ################################### */
431         /* ############################################################################ */
432
433         keymap = WM_keymap_find(keyconf, "Lattice", 0, 0);
434         keymap->poll = ED_operator_editlattice;
435
436         kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", AKEY, KM_PRESS, 0, 0);
437         RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
438         kmi = WM_keymap_add_item(keymap, "LATTICE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
439         RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
440         WM_keymap_add_item(keymap, "LATTICE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
441         WM_keymap_add_item(keymap, "LATTICE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
442
443         WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
444         
445         WM_keymap_add_item(keymap, "LATTICE_OT_flip", FKEY, KM_PRESS, KM_CTRL, 0);
446         
447         /* menus */
448         WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0);
449
450         ED_keymap_proportional_cycle(keyconf, keymap);
451         ED_keymap_proportional_editmode(keyconf, keymap, false);
452 }
453
454 void ED_keymap_proportional_cycle(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
455 {
456         wmKeyMapItem *kmi;
457
458         kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0);
459         RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit_falloff");
460         RNA_boolean_set(kmi->ptr, "wrap", true);
461 }
462
463 void ED_keymap_proportional_obmode(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
464 {
465         wmKeyMapItem *kmi;
466
467         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
468         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_edit_objects");
469 }
470
471 void ED_keymap_proportional_maskmode(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap)
472 {
473         wmKeyMapItem *kmi;
474
475         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0);
476         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_edit_mask");
477 }
478
479 void ED_keymap_proportional_editmode(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyMap *keymap,
480                                      const bool do_connected)
481 {
482         wmKeyMapItem *kmi;
483
484         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0);
485         RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
486         RNA_string_set(kmi->ptr, "value_1", "DISABLED");
487         RNA_string_set(kmi->ptr, "value_2", "ENABLED");
488
489         /* for modes/object types that allow 'connected' mode, add the Alt O key */
490         if (do_connected) {
491                 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, KM_ALT, 0);
492                 RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit");
493                 RNA_string_set(kmi->ptr, "value_1", "DISABLED");
494                 RNA_string_set(kmi->ptr, "value_2", "CONNECTED");
495         }
496 }