disallow identifiers with spaces 'cap end' wasn't working with the python api and...
[blender-staging.git] / source / blender / editors / mesh / mesh_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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2009 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include <stdlib.h>
30 #include <math.h>
31
32 #include "MEM_guardedalloc.h"
33
34 #include "DNA_object_types.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_screen_types.h"
37 #include "DNA_space_types.h"
38 #include "DNA_userdef_types.h"
39 #include "DNA_view3d_types.h"
40 #include "DNA_windowmanager_types.h"
41
42 #include "BLI_arithb.h"
43 #include "BLI_blenlib.h"
44 #include "BLI_editVert.h"
45
46 #include "BKE_context.h"
47 #include "BKE_global.h"
48 #include "BKE_utildefines.h"
49
50 #include "RNA_access.h"
51 #include "RNA_define.h"
52
53 #include "WM_api.h"
54 #include "WM_types.h"
55
56 #include "ED_screen.h"
57 #include "ED_mesh.h"
58 #include "ED_view3d.h"
59
60 #include "mesh_intern.h"
61
62
63 /* ************************** registration **********************************/
64
65 void ED_operatortypes_mesh(void)
66 {
67         WM_operatortype_append(MESH_OT_de_select_all);
68         WM_operatortype_append(MESH_OT_select_more);
69         WM_operatortype_append(MESH_OT_select_less);
70         WM_operatortype_append(MESH_OT_selectswap_mesh);
71         WM_operatortype_append(MESH_OT_select_non_manifold);
72         WM_operatortype_append(MESH_OT_selectconnected_mesh_all);
73         WM_operatortype_append(MESH_OT_selectconnected_mesh);
74         WM_operatortype_append(MESH_OT_hide_mesh);
75         WM_operatortype_append(MESH_OT_reveal_mesh);
76         WM_operatortype_append(MESH_OT_righthandfaces);
77         WM_operatortype_append(MESH_OT_select_linked_flat_faces);
78         WM_operatortype_append(MESH_OT_select_sharp_edges);
79         WM_operatortype_append(MESH_OT_add_primitive_plane);
80         WM_operatortype_append(MESH_OT_add_primitive_cube);
81         WM_operatortype_append(MESH_OT_add_primitive_circle);
82         WM_operatortype_append(MESH_OT_add_primitive_cylinder);
83         WM_operatortype_append(MESH_OT_add_primitive_tube);
84         WM_operatortype_append(MESH_OT_add_primitive_cone);
85         WM_operatortype_append(MESH_OT_add_primitive_grid);
86         WM_operatortype_append(MESH_OT_add_primitive_monkey);
87
88 }
89
90 /* note mesh keymap also for other space? */
91 void ED_keymap_mesh(wmWindowManager *wm)
92 {
93         wmKeymapItem *circle,*cylinder,*tube, *cone;
94         
95         ListBase *keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0);
96         
97         /* selecting */
98         WM_keymap_add_item(keymap, "MESH_OT_de_select_all", AKEY, KM_PRESS, 0, 0);
99         WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
100         WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
101         WM_keymap_add_item(keymap, "MESH_OT_selectswap_mesh", IKEY, KM_PRESS, KM_CTRL, 0);
102         WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0);
103         WM_keymap_add_item(keymap, "MESH_OT_selectconnected_mesh_all", LKEY, KM_PRESS, KM_CTRL, 0);
104         WM_keymap_add_item(keymap, "MESH_OT_selectconnected_mesh", LKEY, KM_PRESS, 0, 0);
105         RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_linked_flat_faces", FKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"fsharpness",135.0);
106         RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_sharp_edges", SKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"fsharpness",135.0);          
107         
108         /* hide */
109         WM_keymap_add_item(keymap, "MESH_OT_hide_mesh", HKEY, KM_PRESS, 0, 0);
110         RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_hide_mesh", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "swap", 1);
111         WM_keymap_add_item(keymap, "MESH_OT_reveal_mesh", HKEY, KM_PRESS, KM_ALT, 0);
112         
113         /* tools */
114         RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "select", 2);
115         RNA_int_set(WM_keymap_add_item(keymap, "MESH_OT_righthandfaces", NKEY, KM_PRESS, KM_CTRL, 0)->ptr, "select", 1);
116         
117         /* add */
118         WM_keymap_add_item(keymap, "MESH_OT_add_primitive_plane", ZEROKEY, KM_PRESS, KM_CTRL, 0);
119         WM_keymap_add_item(keymap, "MESH_OT_add_primitive_cube", ONEKEY, KM_PRESS, KM_CTRL, 0);
120         circle = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_circle", TWOKEY, KM_PRESS, KM_CTRL, 0);
121         RNA_int_set(circle->ptr,"vertices",32);
122         RNA_boolean_set(circle->ptr,"fill",1);
123         RNA_float_set(circle->ptr,"radius",2);
124         
125         cylinder = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_cylinder", THREEKEY, KM_PRESS, KM_CTRL, 0);
126         RNA_int_set(cylinder->ptr,"vertices",32);
127         RNA_float_set(cylinder->ptr,"radius",2);
128         RNA_float_set(cylinder->ptr,"depth",3);
129         
130         tube = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_tube", FOURKEY, KM_PRESS, KM_CTRL, 0);
131         RNA_int_set(tube->ptr,"vertices",32);
132         RNA_float_set(tube->ptr,"radius",2);
133         RNA_float_set(tube->ptr,"depth",3);
134         
135         cone = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_cone", FIVEKEY, KM_PRESS, KM_CTRL, 0);
136         RNA_int_set(cone->ptr,"vertices",32);
137         RNA_float_set(cone->ptr,"radius",2);
138         RNA_float_set(cone->ptr,"depth",-3);
139         RNA_float_set(cone->ptr,"cap_end",0);
140
141         WM_keymap_add_item(keymap, "MESH_OT_add_primitive_grid", NINEKEY, KM_PRESS, KM_CTRL, 0);
142         
143         WM_keymap_add_item(keymap, "MESH_OT_add_primitive_monkey", SIXKEY, KM_PRESS, KM_CTRL, 0);
144
145 }
146