Blender V2.61 - r43446

paint_ops.c

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * ***** END GPL LICENSE BLOCK *****
00019  */
00020 
00025 #include "MEM_guardedalloc.h"
00026 
00027 #include <stdlib.h>
00028 #include "BLI_string.h"
00029 #include "BLI_utildefines.h"
00030 
00031 #include "DNA_object_types.h"
00032 #include "DNA_scene_types.h"
00033 #include "DNA_brush_types.h"
00034 
00035 #include "BKE_brush.h"
00036 #include "BKE_context.h"
00037 #include "BKE_paint.h"
00038 #include "BKE_main.h"
00039 
00040 #include "ED_sculpt.h"
00041 #include "ED_screen.h"
00042 #include "UI_resources.h"
00043 
00044 #include "WM_api.h"
00045 #include "WM_types.h"
00046 
00047 #include "RNA_access.h"
00048 #include "RNA_define.h"
00049 #include "RNA_enum_types.h"
00050 
00051 #include "paint_intern.h"
00052 #include "sculpt_intern.h"
00053 
00054 #include <string.h>
00055 //#include <stdio.h>
00056 #include <stddef.h>
00057 
00058 /* Brush operators */
00059 static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
00060 {
00061     /*int type = RNA_enum_get(op->ptr, "type");*/
00062     Paint *paint = paint_get_active(CTX_data_scene(C));
00063     struct Brush *br = paint_brush(paint);
00064 
00065     if (br)
00066         br = copy_brush(br);
00067     else
00068         br = add_brush("Brush");
00069 
00070     paint_brush_set(paint_get_active(CTX_data_scene(C)), br);
00071 
00072     return OPERATOR_FINISHED;
00073 }
00074 
00075 static void BRUSH_OT_add(wmOperatorType *ot)
00076 {
00077     /* identifiers */
00078     ot->name= "Add Brush";
00079     ot->description= "Add brush by mode type";
00080     ot->idname= "BRUSH_OT_add";
00081     
00082     /* api callbacks */
00083     ot->exec= brush_add_exec;
00084     
00085     /* flags */
00086     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00087 }
00088 
00089 
00090 static int brush_scale_size_exec(bContext *C, wmOperator *op)
00091 {
00092     Scene *scene = CTX_data_scene(C);
00093     Paint  *paint=  paint_get_active(scene);
00094     struct Brush  *brush=  paint_brush(paint);
00095     // Object *ob=     CTX_data_active_object(C);
00096     float   scalar= RNA_float_get(op->ptr, "scalar");
00097 
00098     if (brush) {
00099         // pixel radius
00100         {
00101             const int old_size= brush_size(scene, brush);
00102             int size= (int)(scalar*old_size);
00103 
00104             if (old_size == size) {
00105                 if (scalar > 1) {
00106                     size++;
00107                 }
00108                 else if (scalar < 1) {
00109                     size--;
00110                 }
00111             }
00112             CLAMP(size, 1, 2000); // XXX magic number
00113 
00114             brush_set_size(scene, brush, size);
00115         }
00116 
00117         // unprojected radius
00118         {
00119             float unprojected_radius= scalar*brush_unprojected_radius(scene, brush);
00120 
00121             if (unprojected_radius < 0.001f) // XXX magic number
00122                 unprojected_radius= 0.001f;
00123 
00124             brush_set_unprojected_radius(scene, brush, unprojected_radius);
00125         }
00126     }
00127 
00128     return OPERATOR_FINISHED;
00129 }
00130 
00131 static void BRUSH_OT_scale_size(wmOperatorType *ot)
00132 {
00133     /* identifiers */
00134     ot->name= "Scale Sculpt/Paint Brush Size";
00135     ot->description= "Change brush size by a scalar";
00136     ot->idname= "BRUSH_OT_scale_size";
00137     
00138     /* api callbacks */
00139     ot->exec= brush_scale_size_exec;
00140     
00141     /* flags */
00142     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00143 
00144     RNA_def_float(ot->srna, "scalar", 1, 0, 2, "Scalar", "Factor to scale brush size by", 0, 2);
00145 }
00146 
00147 static int vertex_color_set_exec(bContext *C, wmOperator *UNUSED(op))
00148 {
00149     Scene *scene = CTX_data_scene(C);
00150     Object *obact = CTX_data_active_object(C);
00151     unsigned int paintcol = vpaint_get_current_col(scene->toolsettings->vpaint);
00152     vpaint_fill(obact, paintcol);
00153     
00154     ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
00155     return OPERATOR_FINISHED;
00156 }
00157 
00158 static void PAINT_OT_vertex_color_set(wmOperatorType *ot)
00159 {
00160     /* identifiers */
00161     ot->name= "Set Vertex Colors";
00162     ot->idname= "PAINT_OT_vertex_color_set";
00163     
00164     /* api callbacks */
00165     ot->exec= vertex_color_set_exec;
00166     ot->poll= vertex_paint_mode_poll;
00167     
00168     /* flags */
00169     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00170 }
00171 
00172 static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op))
00173 {
00174     Paint *paint = paint_get_active(CTX_data_scene(C));
00175     struct Brush *brush = paint_brush(paint);
00176     Object *ob = CTX_data_active_object(C);
00177 
00178     if(!ob) return OPERATOR_CANCELLED;
00179 
00180     if(ob->mode & OB_MODE_SCULPT)
00181         brush_reset_sculpt(brush);
00182     /* TODO: other modes */
00183 
00184     return OPERATOR_FINISHED;
00185 }
00186 
00187 static void BRUSH_OT_reset(wmOperatorType *ot)
00188 {
00189     /* identifiers */
00190     ot->name= "Reset Brush";
00191     ot->description= "Return brush to defaults based on current tool";
00192     ot->idname= "BRUSH_OT_reset";
00193     
00194     /* api callbacks */
00195     ot->exec= brush_reset_exec;
00196     
00197     /* flags */
00198     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00199 }
00200 
00201 /* generic functions for setting the active brush based on the tool */
00202 static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode)
00203 {
00204     struct Brush *brush;
00205 
00206     if(!brush_orig && !(brush_orig= bmain->brush.first)) {
00207         return NULL;
00208     }
00209 
00210     /* get the next brush with the active tool */
00211     for(    brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first;
00212             brush != brush_orig;
00213             brush= brush->id.next ? brush->id.next : bmain->brush.first)
00214     {
00215         if( (brush->ob_mode & ob_mode) &&
00216             (*(((char *)brush) + tool_offset) == tool)
00217         ) {
00218             return brush;
00219         }
00220     }
00221 
00222     return NULL;
00223 
00224 }
00225 
00226 static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, const size_t tool_offset, const int ob_mode)
00227 {
00228     struct Brush *brush, *brush_orig= paint_brush(paint);
00229 
00230     brush= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);
00231 
00232     if(brush) {
00233         paint_brush_set(paint, brush);
00234         WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush);
00235         return OPERATOR_FINISHED;
00236     }
00237     else {
00238         return OPERATOR_CANCELLED;
00239     }
00240 }
00241 
00242 static int brush_sculpt_tool_set_exec(bContext *C, wmOperator *op)
00243 {
00244     Main *bmain= CTX_data_main(C);
00245     Scene *scene= CTX_data_scene(C);
00246 
00247     return brush_generic_tool_set(bmain, &scene->toolsettings->sculpt->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, sculpt_tool), OB_MODE_SCULPT);
00248 }
00249 
00250 static void BRUSH_OT_sculpt_tool_set(wmOperatorType *ot)
00251 {
00252     /* identifiers */
00253     ot->name= "Sculpt Tool Set";
00254     ot->description= "Set the sculpt tool";
00255     ot->idname= "BRUSH_OT_sculpt_tool_set";
00256 
00257     /* api callbacks */
00258     ot->exec= brush_sculpt_tool_set_exec;
00259 
00260     /* flags */
00261     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00262 
00263     /* props */
00264     ot->prop= RNA_def_enum(ot->srna, "tool", brush_sculpt_tool_items, 0, "Tool", "");
00265 }
00266 
00267 static int brush_vertex_tool_set_exec(bContext *C, wmOperator *op)
00268 {
00269     Main *bmain= CTX_data_main(C);
00270     Scene *scene= CTX_data_scene(C);
00271 
00272     return brush_generic_tool_set(bmain, &scene->toolsettings->vpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_VERTEX_PAINT);
00273 }
00274 
00275 static void BRUSH_OT_vertex_tool_set(wmOperatorType *ot)
00276 {
00277     /* identifiers */
00278     ot->name= "Vertex Paint Tool Set";
00279     ot->description= "Set the vertex paint tool";
00280     ot->idname= "BRUSH_OT_vertex_tool_set";
00281 
00282     /* api callbacks */
00283     ot->exec= brush_vertex_tool_set_exec;
00284 
00285     /* flags */
00286     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00287 
00288     /* props */
00289     ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", "");
00290 }
00291 
00292 static int brush_weight_tool_set_exec(bContext *C, wmOperator *op)
00293 {
00294     Main *bmain= CTX_data_main(C);
00295     Scene *scene= CTX_data_scene(C);
00296     /* vertexpaint_tool is used for weight paint mode */
00297     return brush_generic_tool_set(bmain, &scene->toolsettings->wpaint->paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, vertexpaint_tool), OB_MODE_WEIGHT_PAINT);
00298 }
00299 
00300 static void BRUSH_OT_weight_tool_set(wmOperatorType *ot)
00301 {
00302     /* identifiers */
00303     ot->name= "Weight Paint Tool Set";
00304     ot->description= "Set the weight paint tool";
00305     ot->idname= "BRUSH_OT_weight_tool_set";
00306 
00307     /* api callbacks */
00308     ot->exec= brush_weight_tool_set_exec;
00309 
00310     /* flags */
00311     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00312 
00313     /* props */
00314     ot->prop= RNA_def_enum(ot->srna, "tool", brush_vertex_tool_items, 0, "Tool", "");
00315 }
00316 
00317 static int brush_image_tool_set_exec(bContext *C, wmOperator *op)
00318 {
00319     Main *bmain= CTX_data_main(C);
00320     Scene *scene= CTX_data_scene(C);
00321 
00322     return brush_generic_tool_set(bmain, &scene->toolsettings->imapaint.paint, RNA_enum_get(op->ptr, "tool"), offsetof(Brush, imagepaint_tool), OB_MODE_TEXTURE_PAINT);
00323 }
00324 
00325 static void BRUSH_OT_image_tool_set(wmOperatorType *ot)
00326 {
00327     /* identifiers */
00328     ot->name= "Image Paint Tool Set";
00329     ot->description= "Set the image tool";
00330     ot->idname= "BRUSH_OT_image_tool_set";
00331 
00332     /* api callbacks */
00333     ot->exec= brush_image_tool_set_exec;
00334 
00335     /* flags */
00336     ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
00337 
00338     /* props */
00339     ot->prop= RNA_def_enum(ot->srna, "tool", brush_image_tool_items, 0, "Tool", "");
00340 }
00341 
00342 
00343 /**************************** registration **********************************/
00344 
00345 void ED_operatortypes_paint(void)
00346 {
00347     /* brush */
00348     WM_operatortype_append(BRUSH_OT_add);
00349     WM_operatortype_append(BRUSH_OT_scale_size);
00350     WM_operatortype_append(BRUSH_OT_curve_preset);
00351     WM_operatortype_append(BRUSH_OT_reset);
00352 
00353     /* note, particle uses a different system, can be added with existing operators in wm.py */
00354     WM_operatortype_append(BRUSH_OT_sculpt_tool_set);
00355     WM_operatortype_append(BRUSH_OT_vertex_tool_set);
00356     WM_operatortype_append(BRUSH_OT_weight_tool_set);
00357     WM_operatortype_append(BRUSH_OT_image_tool_set);
00358 
00359     /* image */
00360     WM_operatortype_append(PAINT_OT_texture_paint_toggle);
00361     WM_operatortype_append(PAINT_OT_image_paint);
00362     WM_operatortype_append(PAINT_OT_sample_color);
00363     WM_operatortype_append(PAINT_OT_grab_clone);
00364     WM_operatortype_append(PAINT_OT_clone_cursor_set);
00365     WM_operatortype_append(PAINT_OT_project_image);
00366     WM_operatortype_append(PAINT_OT_image_from_view);
00367 
00368     /* weight */
00369     WM_operatortype_append(PAINT_OT_weight_paint_toggle);
00370     WM_operatortype_append(PAINT_OT_weight_paint);
00371     WM_operatortype_append(PAINT_OT_weight_set);
00372     WM_operatortype_append(PAINT_OT_weight_from_bones);
00373     WM_operatortype_append(PAINT_OT_weight_sample);
00374     WM_operatortype_append(PAINT_OT_weight_sample_group);
00375 
00376     /* vertex selection */
00377     WM_operatortype_append(PAINT_OT_vert_select_all);
00378     WM_operatortype_append(PAINT_OT_vert_select_inverse);
00379 
00380     /* vertex */
00381     WM_operatortype_append(PAINT_OT_vertex_paint_toggle);
00382     WM_operatortype_append(PAINT_OT_vertex_paint);
00383     WM_operatortype_append(PAINT_OT_vertex_color_set);
00384 
00385     /* face-select */
00386     WM_operatortype_append(PAINT_OT_face_select_linked);
00387     WM_operatortype_append(PAINT_OT_face_select_linked_pick);
00388     WM_operatortype_append(PAINT_OT_face_select_all);
00389     WM_operatortype_append(PAINT_OT_face_select_inverse);
00390     WM_operatortype_append(PAINT_OT_face_select_hide);
00391     WM_operatortype_append(PAINT_OT_face_select_reveal);
00392 }
00393 
00394 
00395 static void ed_keymap_paint_brush_switch(wmKeyMap *keymap, const char *mode)
00396 {
00397     wmKeyMapItem *kmi;
00398     int i;
00399     /* index 0-9 (zero key is tenth), shift key for index 10-19 */
00400     for (i = 0; i < 20; i++) {
00401         kmi= WM_keymap_add_item(keymap, "BRUSH_OT_active_index_set",
00402                                 ZEROKEY + ((i + 1) % 10), KM_PRESS, i < 10 ? 0 : KM_SHIFT, 0);
00403         RNA_string_set(kmi->ptr, "mode", mode);
00404         RNA_int_set(kmi->ptr, "index", i);
00405     }
00406 }
00407 
00408 static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path))
00409 {
00410     wmKeyMapItem *kmi;
00411 
00412     kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", LEFTBRACKETKEY, KM_PRESS, 0, 0);
00413     RNA_float_set(kmi->ptr, "scalar", 0.9);
00414 
00415     kmi= WM_keymap_add_item(keymap, "BRUSH_OT_scale_size", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
00416     RNA_float_set(kmi->ptr, "scalar", 10.0/9.0); // 1.1111....
00417 }
00418 
00419 typedef enum {
00420     RC_COLOR = 1,
00421     RC_ROTATION = 2,
00422     RC_ZOOM = 4,
00423 } RCFlags;
00424 
00425 static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
00426                               const char *output_name, const char *input_name)
00427 {
00428     char *path;
00429 
00430     path = BLI_sprintfN("%s.%s", brush_path, input_name);
00431     RNA_string_set(ptr, output_name, path);
00432     MEM_freeN(path);
00433 }
00434 
00435 static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
00436                                const char *prop, const char *secondary_prop,
00437                                RCFlags flags)
00438 {
00439     const char *ups_path = "tool_settings.unified_paint_settings";
00440     char *brush_path;
00441 
00442     brush_path = BLI_sprintfN("tool_settings.%s.brush", paint);
00443 
00444     set_brush_rc_path(ptr, brush_path, "data_path_primary", prop);
00445     if(secondary_prop) {
00446         set_brush_rc_path(ptr, ups_path, "use_secondary", secondary_prop);
00447         set_brush_rc_path(ptr, ups_path, "data_path_secondary", prop);
00448     }
00449     else {
00450         RNA_string_set(ptr, "use_secondary", "");
00451         RNA_string_set(ptr, "data_path_secondary", "");
00452     }
00453     set_brush_rc_path(ptr, brush_path, "color_path", "cursor_color_add");
00454     set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle");
00455     RNA_string_set(ptr, "image_id", brush_path);
00456 
00457     if(flags & RC_COLOR)
00458         set_brush_rc_path(ptr, brush_path, "fill_color_path", "color");
00459     else
00460         RNA_string_set(ptr, "fill_color_path", "");
00461     if(flags & RC_ZOOM)
00462         RNA_string_set(ptr, "zoom_path", "space_data.zoom");
00463     else
00464         RNA_string_set(ptr, "zoom_path", "");
00465 
00466     MEM_freeN(brush_path);
00467 }
00468 
00469 static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *paint,
00470                          RCFlags flags)
00471 {
00472     wmKeyMapItem *kmi;
00473 
00474     kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0);
00475     set_brush_rc_props(kmi->ptr, paint, "size", "use_unified_size", flags);
00476 
00477     kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0);
00478     set_brush_rc_props(kmi->ptr, paint, "strength", "use_unified_strength", flags);
00479 
00480     if(flags & RC_ROTATION) {
00481         kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0);
00482         set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags);
00483     }
00484 }
00485 
00486 void ED_keymap_paint(wmKeyConfig *keyconf)
00487 {
00488     wmKeyMap *keymap;
00489     wmKeyMapItem *kmi;
00490     int i;
00491     
00492     /* Sculpt mode */
00493     keymap= WM_keymap_find(keyconf, "Sculpt", 0, 0);
00494     keymap->poll= sculpt_poll;
00495 
00496     RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, 0,        0)->ptr, "mode", BRUSH_STROKE_NORMAL);
00497     RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL,  0)->ptr, "mode", BRUSH_STROKE_INVERT);
00498     RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_brush_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH);
00499 
00500     for(i=0; i<=5; i++)
00501         RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i);
00502 
00503     /* multires switch */
00504     kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0);
00505     RNA_int_set(kmi->ptr, "level", 1);
00506     RNA_boolean_set(kmi->ptr, "relative", TRUE);
00507 
00508     kmi= WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEDOWNKEY, KM_PRESS, 0, 0);
00509     RNA_int_set(kmi->ptr, "level", -1);
00510     RNA_boolean_set(kmi->ptr, "relative", TRUE);
00511 
00512     ed_keymap_paint_brush_switch(keymap, "sculpt");
00513     ed_keymap_paint_brush_size(keymap, "tool_settings.sculpt.brush.size");
00514     ed_keymap_paint_brush_radial_control(keymap, "sculpt", RC_ROTATION);
00515 
00516     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", DKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_DRAW);
00517     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", SKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_SMOOTH);
00518     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", PKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_PINCH);
00519     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", IKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_INFLATE);
00520     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", GKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_GRAB);
00521     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", LKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_LAYER);
00522     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", TKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_FLATTEN); /* was just TKEY in 2.4x */
00523     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, 0, 0)->ptr, "tool", SCULPT_TOOL_CLAY);
00524     RNA_enum_set(WM_keymap_add_item(keymap, "BRUSH_OT_sculpt_tool_set", CKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "tool", SCULPT_TOOL_CREASE);
00525 
00526     /* */
00527     kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0);
00528     RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.stroke_method");
00529 
00530     kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", SKEY, KM_PRESS, KM_SHIFT, 0);
00531     RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_smooth_stroke");
00532 
00533     kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", RKEY, KM_PRESS, 0, 0);
00534     RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.texture_angle_source_random");
00535 
00536     /* Vertex Paint mode */
00537     keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0);
00538     keymap->poll= vertex_paint_mode_poll;
00539 
00540     WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
00541     WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
00542 
00543     WM_keymap_add_item(keymap,
00544             "PAINT_OT_vertex_color_set",KKEY, KM_PRESS, KM_SHIFT, 0);
00545 
00546     ed_keymap_paint_brush_switch(keymap, "vertex_paint");
00547     ed_keymap_paint_brush_size(keymap, "tool_settings.vertex_paint.brush.size");
00548     ed_keymap_paint_brush_radial_control(keymap, "vertex_paint", RC_COLOR);
00549 
00550     kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
00551     RNA_string_set(kmi->ptr, "data_path", "vertex_paint_object.data.use_paint_mask");
00552 
00553     /* Weight Paint mode */
00554     keymap= WM_keymap_find(keyconf, "Weight Paint", 0, 0);
00555     keymap->poll= weight_paint_mode_poll;
00556 
00557     WM_keymap_verify_item(keymap, "PAINT_OT_weight_paint", LEFTMOUSE, KM_PRESS, 0, 0);
00558 
00559     /* these keys are from 2.4x but could be changed */
00560     WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
00561     WM_keymap_verify_item(keymap, "PAINT_OT_weight_sample_group", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
00562 
00563     WM_keymap_add_item(keymap,
00564             "PAINT_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0);
00565 
00566     ed_keymap_paint_brush_switch(keymap, "weight_paint");
00567     ed_keymap_paint_brush_size(keymap, "tool_settings.weight_paint.brush.size");
00568     ed_keymap_paint_brush_radial_control(keymap, "weight_paint", 0);
00569 
00570     kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* face mask toggle */
00571     RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask");
00572 
00573     /* note, conflicts with vertex paint, but this is more useful */
00574     kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", VKEY, KM_PRESS, 0, 0); /* vert mask toggle */
00575     RNA_string_set(kmi->ptr, "data_path", "weight_paint_object.data.use_paint_mask_vertex");
00576 
00577     WM_keymap_verify_item(keymap, "PAINT_OT_weight_from_bones", WKEY, KM_PRESS, 0, 0);
00578 
00579     
00580     /*Weight paint's Vertex Selection Mode */
00581     keymap= WM_keymap_find(keyconf, "Weight Paint Vertex Selection", 0, 0);
00582     keymap->poll= vert_paint_poll;
00583     WM_keymap_add_item(keymap, "PAINT_OT_vert_select_all", AKEY, KM_PRESS, 0, 0);
00584     WM_keymap_add_item(keymap, "PAINT_OT_vert_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
00585     WM_keymap_add_item(keymap, "VIEW3D_OT_select_border", BKEY, KM_PRESS, 0, 0);
00586     kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0);
00587     RNA_boolean_set(kmi->ptr, "deselect", FALSE);
00588     kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT|KM_CTRL, 0);
00589     RNA_boolean_set(kmi->ptr, "deselect", TRUE);
00590     WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0);
00591 
00592     /* Image/Texture Paint mode */
00593     keymap= WM_keymap_find(keyconf, "Image Paint", 0, 0);
00594     keymap->poll= image_texture_paint_poll;
00595 
00596     WM_keymap_add_item(keymap, "PAINT_OT_image_paint", LEFTMOUSE, KM_PRESS, 0, 0);
00597     WM_keymap_add_item(keymap, "PAINT_OT_grab_clone", RIGHTMOUSE, KM_PRESS, 0, 0);
00598     WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
00599     WM_keymap_add_item(keymap, "PAINT_OT_clone_cursor_set", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
00600 
00601     ed_keymap_paint_brush_switch(keymap, "image_paint");
00602     ed_keymap_paint_brush_size(keymap, "tool_settings.image_paint.brush.size");
00603     ed_keymap_paint_brush_radial_control(keymap, "image_paint", RC_COLOR|RC_ZOOM);
00604 
00605     kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", MKEY, KM_PRESS, 0, 0); /* mask toggle */
00606     RNA_string_set(kmi->ptr, "data_path", "image_paint_object.data.use_paint_mask");
00607 
00608     /* face-mask mode */
00609     keymap= WM_keymap_find(keyconf, "Face Mask", 0, 0);
00610     keymap->poll= facemask_paint_poll;
00611 
00612     WM_keymap_add_item(keymap, "PAINT_OT_face_select_all", AKEY, KM_PRESS, 0, 0);
00613     WM_keymap_add_item(keymap, "PAINT_OT_face_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
00614     kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, 0, 0);
00615     RNA_boolean_set(kmi->ptr, "unselected", FALSE);
00616     kmi = WM_keymap_add_item(keymap, "PAINT_OT_face_select_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
00617     RNA_boolean_set(kmi->ptr, "unselected", TRUE);
00618     WM_keymap_add_item(keymap, "PAINT_OT_face_select_reveal", HKEY, KM_PRESS, KM_ALT, 0);
00619 
00620     WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
00621     WM_keymap_add_item(keymap, "PAINT_OT_face_select_linked_pick", LKEY, KM_PRESS, 0, 0);
00622 }