svn merge -r36603:36628 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / editors / physics / physics_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) 2009 Blender Foundation.
21  * All rights reserved.
22  *
23  * Contributor(s): Blender Foundation
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file blender/editors/physics/physics_ops.c
29  *  \ingroup edphys
30  */
31
32
33 #include <stdlib.h>
34
35
36 #include "RNA_access.h"
37
38 #include "WM_api.h"
39 #include "WM_types.h"
40
41 #include "ED_physics.h"
42 #include "ED_object.h"
43
44 #include "physics_intern.h" // own include
45
46 /***************************** particles ***********************************/
47
48 static void operatortypes_particle(void)
49 {
50         WM_operatortype_append(PARTICLE_OT_select_all);
51         WM_operatortype_append(PARTICLE_OT_select_roots);
52         WM_operatortype_append(PARTICLE_OT_select_tips);
53         WM_operatortype_append(PARTICLE_OT_select_linked);
54         WM_operatortype_append(PARTICLE_OT_select_less);
55         WM_operatortype_append(PARTICLE_OT_select_more);
56         WM_operatortype_append(PARTICLE_OT_select_inverse);
57
58         WM_operatortype_append(PARTICLE_OT_hide);
59         WM_operatortype_append(PARTICLE_OT_reveal);
60
61         WM_operatortype_append(PARTICLE_OT_rekey);
62         WM_operatortype_append(PARTICLE_OT_subdivide);
63         WM_operatortype_append(PARTICLE_OT_remove_doubles);
64         WM_operatortype_append(PARTICLE_OT_weight_set); 
65         WM_operatortype_append(PARTICLE_OT_delete);
66         WM_operatortype_append(PARTICLE_OT_mirror);
67
68         WM_operatortype_append(PARTICLE_OT_brush_edit);
69
70         WM_operatortype_append(PARTICLE_OT_particle_edit_toggle);
71         WM_operatortype_append(PARTICLE_OT_edited_clear);
72
73
74         WM_operatortype_append(OBJECT_OT_particle_system_add);
75         WM_operatortype_append(OBJECT_OT_particle_system_remove);
76
77         WM_operatortype_append(PARTICLE_OT_new);
78         WM_operatortype_append(PARTICLE_OT_new_target);
79         WM_operatortype_append(PARTICLE_OT_target_remove);
80         WM_operatortype_append(PARTICLE_OT_target_move_up);
81         WM_operatortype_append(PARTICLE_OT_target_move_down);
82         WM_operatortype_append(PARTICLE_OT_connect_hair);
83         WM_operatortype_append(PARTICLE_OT_disconnect_hair);
84
85         WM_operatortype_append(PARTICLE_OT_dupliob_copy);
86         WM_operatortype_append(PARTICLE_OT_dupliob_remove);
87         WM_operatortype_append(PARTICLE_OT_dupliob_move_up);
88         WM_operatortype_append(PARTICLE_OT_dupliob_move_down);
89 }
90
91 static void keymap_particle(wmKeyConfig *keyconf)
92 {
93         wmKeyMapItem *kmi;
94         wmKeyMap *keymap;
95         
96         keymap= WM_keymap_find(keyconf, "Particle", 0, 0);
97         keymap->poll= PE_poll;
98         
99         WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0);
100         WM_keymap_add_item(keymap, "PARTICLE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
101         WM_keymap_add_item(keymap, "PARTICLE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
102         WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
103         RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
104         WM_keymap_add_item(keymap, "PARTICLE_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
105
106         WM_keymap_add_item(keymap, "PARTICLE_OT_delete", XKEY, KM_PRESS, 0, 0);
107         WM_keymap_add_item(keymap, "PARTICLE_OT_delete", DELKEY, KM_PRESS, 0, 0);
108
109         WM_keymap_add_item(keymap, "PARTICLE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
110         WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, 0, 0);
111         RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
112
113         WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0);
114         WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
115
116         /* size radial control */
117         kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
118         RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.size");
119
120         /* size radial control */
121         kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
122         RNA_string_set(kmi->ptr, "data_path", "tool_settings.particle_edit.brush.strength");
123
124         WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0);
125         
126         WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
127
128         ED_object_generic_keymap(keyconf, keymap, 2);
129 }
130
131 /******************************* boids *************************************/
132
133 static void operatortypes_boids(void)
134 {
135         WM_operatortype_append(BOID_OT_rule_add);
136         WM_operatortype_append(BOID_OT_rule_del);
137         WM_operatortype_append(BOID_OT_rule_move_up);
138         WM_operatortype_append(BOID_OT_rule_move_down);
139
140         WM_operatortype_append(BOID_OT_state_add);
141         WM_operatortype_append(BOID_OT_state_del);
142         WM_operatortype_append(BOID_OT_state_move_up);
143         WM_operatortype_append(BOID_OT_state_move_down);
144 }
145
146 /********************************* fluid ***********************************/
147
148 static void operatortypes_fluid(void)
149 {
150         WM_operatortype_append(FLUID_OT_bake);
151 }
152
153 /**************************** point cache **********************************/
154
155 static void operatortypes_pointcache(void)
156 {
157         WM_operatortype_append(PTCACHE_OT_bake_all);
158         WM_operatortype_append(PTCACHE_OT_free_bake_all);
159         WM_operatortype_append(PTCACHE_OT_bake);
160         WM_operatortype_append(PTCACHE_OT_free_bake);
161         WM_operatortype_append(PTCACHE_OT_bake_from_cache);
162         WM_operatortype_append(PTCACHE_OT_add);
163         WM_operatortype_append(PTCACHE_OT_remove);
164 }
165
166 //static void keymap_pointcache(wmWindowManager *wm)
167 //{
168 //      wmKeyMap *keymap= WM_keymap_find(wm, "Pointcache", 0, 0);
169 //      
170 //      WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0);
171 //      WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
172 //      WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0);
173 //      WM_keymap_add_item(keymap, "PHYSICS_OT_free_particle_system", LKEY, KM_PRESS, 0, 0);
174 //}
175
176 /****************************** general ************************************/
177
178 void ED_operatortypes_physics(void)
179 {
180         operatortypes_particle();
181         operatortypes_boids();
182         operatortypes_fluid();
183         operatortypes_pointcache();
184 }
185
186 void ED_keymap_physics(wmKeyConfig *keyconf)
187 {
188         keymap_particle(keyconf);
189         //keymap_pointcache(keyconf);
190 }
191
192
193