Blender V2.61 - r43446
|
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 * The Original Code is Copyright (C) 2009 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * 00022 * Contributor(s): Blender Foundation 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #include <stdlib.h> 00033 #include <math.h> 00034 00035 00036 #include "DNA_curve_types.h" 00037 00038 #include "BLI_math.h" 00039 #include "BLI_blenlib.h" 00040 00041 00042 #include "RNA_access.h" 00043 00044 #include "WM_api.h" 00045 #include "WM_types.h" 00046 00047 #include "ED_curve.h" 00048 #include "ED_object.h" 00049 #include "ED_screen.h" 00050 #include "ED_transform.h" 00051 00052 #include "curve_intern.h" 00053 00054 /************************* registration ****************************/ 00055 00056 void ED_operatortypes_curve(void) 00057 { 00058 WM_operatortype_append(FONT_OT_text_insert); 00059 WM_operatortype_append(FONT_OT_line_break); 00060 WM_operatortype_append(FONT_OT_insert_lorem); 00061 00062 WM_operatortype_append(FONT_OT_case_toggle); 00063 WM_operatortype_append(FONT_OT_case_set); 00064 WM_operatortype_append(FONT_OT_style_toggle); 00065 WM_operatortype_append(FONT_OT_style_set); 00066 00067 WM_operatortype_append(FONT_OT_text_copy); 00068 WM_operatortype_append(FONT_OT_text_cut); 00069 WM_operatortype_append(FONT_OT_text_paste); 00070 WM_operatortype_append(FONT_OT_file_paste); 00071 00072 WM_operatortype_append(FONT_OT_move); 00073 WM_operatortype_append(FONT_OT_move_select); 00074 WM_operatortype_append(FONT_OT_delete); 00075 00076 WM_operatortype_append(FONT_OT_change_character); 00077 WM_operatortype_append(FONT_OT_change_spacing); 00078 00079 WM_operatortype_append(FONT_OT_open); 00080 WM_operatortype_append(FONT_OT_unlink); 00081 00082 WM_operatortype_append(FONT_OT_textbox_add); 00083 WM_operatortype_append(FONT_OT_textbox_remove); 00084 00085 WM_operatortype_append(CURVE_OT_hide); 00086 WM_operatortype_append(CURVE_OT_reveal); 00087 00088 WM_operatortype_append(CURVE_OT_separate); 00089 WM_operatortype_append(CURVE_OT_duplicate); 00090 WM_operatortype_append(CURVE_OT_delete); 00091 00092 WM_operatortype_append(CURVE_OT_spline_type_set); 00093 WM_operatortype_append(CURVE_OT_radius_set); 00094 WM_operatortype_append(CURVE_OT_spline_weight_set); 00095 WM_operatortype_append(CURVE_OT_handle_type_set); 00096 WM_operatortype_append(CURVE_OT_shade_smooth); 00097 WM_operatortype_append(CURVE_OT_shade_flat); 00098 WM_operatortype_append(CURVE_OT_tilt_clear); 00099 00100 WM_operatortype_append(CURVE_OT_primitive_bezier_curve_add); 00101 WM_operatortype_append(CURVE_OT_primitive_bezier_circle_add); 00102 WM_operatortype_append(CURVE_OT_primitive_nurbs_curve_add); 00103 WM_operatortype_append(CURVE_OT_primitive_nurbs_circle_add); 00104 WM_operatortype_append(CURVE_OT_primitive_nurbs_path_add); 00105 00106 WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_curve_add); 00107 WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_circle_add); 00108 WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_surface_add); 00109 WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_cylinder_add); 00110 WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_sphere_add); 00111 WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_torus_add); 00112 00113 WM_operatortype_append(CURVE_OT_smooth); 00114 WM_operatortype_append(CURVE_OT_smooth_radius); 00115 00116 WM_operatortype_append(CURVE_OT_de_select_first); 00117 WM_operatortype_append(CURVE_OT_de_select_last); 00118 WM_operatortype_append(CURVE_OT_select_all); 00119 WM_operatortype_append(CURVE_OT_select_linked); 00120 WM_operatortype_append(CURVE_OT_select_linked_pick); 00121 WM_operatortype_append(CURVE_OT_select_row); 00122 WM_operatortype_append(CURVE_OT_select_next); 00123 WM_operatortype_append(CURVE_OT_select_previous); 00124 WM_operatortype_append(CURVE_OT_select_more); 00125 WM_operatortype_append(CURVE_OT_select_less); 00126 WM_operatortype_append(CURVE_OT_select_random); 00127 WM_operatortype_append(CURVE_OT_select_nth); 00128 00129 WM_operatortype_append(CURVE_OT_switch_direction); 00130 WM_operatortype_append(CURVE_OT_subdivide); 00131 WM_operatortype_append(CURVE_OT_make_segment); 00132 WM_operatortype_append(CURVE_OT_spin); 00133 WM_operatortype_append(CURVE_OT_vertex_add); 00134 WM_operatortype_append(CURVE_OT_extrude); 00135 WM_operatortype_append(CURVE_OT_cyclic_toggle); 00136 } 00137 00138 void ED_operatormacros_curve(void) 00139 { 00140 wmOperatorType *ot; 00141 wmOperatorTypeMacro *otmacro; 00142 00143 ot= WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); 00144 ot->description = "Duplicate curve and move"; 00145 WM_operatortype_macro_define(ot, "CURVE_OT_duplicate"); 00146 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00147 RNA_enum_set(otmacro->ptr, "proportional", 0); 00148 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00149 00150 ot= WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", OPTYPE_UNDO|OPTYPE_REGISTER); 00151 ot->description = "Extrude curve and move result"; 00152 WM_operatortype_macro_define(ot, "CURVE_OT_extrude"); 00153 otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00154 RNA_enum_set(otmacro->ptr, "proportional", 0); 00155 RNA_boolean_set(otmacro->ptr, "mirror", FALSE); 00156 } 00157 00158 void ED_keymap_curve(wmKeyConfig *keyconf) 00159 { 00160 wmKeyMap *keymap; 00161 wmKeyMapItem *kmi; 00162 00163 keymap= WM_keymap_find(keyconf, "Font", 0, 0); 00164 keymap->poll= ED_operator_editfont; 00165 00166 /* only set in editmode font, by space_view3d listener */ 00167 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_BOLD); 00168 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_ITALIC); 00169 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", UKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_UNDERLINE); 00170 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", PKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_SMALLCAPS); 00171 00172 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_SEL); 00173 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_SEL); 00174 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_SEL); /* same as above [#26623] */ 00175 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_ALL); 00176 00177 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN); 00178 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END); 00179 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR); 00180 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_CHAR); 00181 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD); 00182 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD); 00183 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_LINE); 00184 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_LINE); 00185 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_PAGE); 00186 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_PAGE); 00187 00188 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", HOMEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", LINE_BEGIN); 00189 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", ENDKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", LINE_END); 00190 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_CHAR); 00191 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_CHAR); 00192 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", PREV_WORD); 00193 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", NEXT_WORD); 00194 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_LINE); 00195 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_LINE); 00196 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_PAGE); 00197 RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_PAGE); 00198 00199 RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_spacing", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); 00200 RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_spacing", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); 00201 RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", UPARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); 00202 RNA_int_set(WM_keymap_add_item(keymap, "FONT_OT_change_character", DOWNARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); 00203 00204 WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_CTRL, 0); 00205 WM_keymap_add_item(keymap, "FONT_OT_text_copy", CKEY, KM_PRESS, KM_OSKEY, 0); 00206 WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_CTRL, 0); 00207 WM_keymap_add_item(keymap, "FONT_OT_text_cut", XKEY, KM_PRESS, KM_OSKEY, 0); 00208 WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_CTRL, 0); 00209 WM_keymap_add_item(keymap, "FONT_OT_text_paste", VKEY, KM_PRESS, KM_OSKEY, 0); 00210 00211 WM_keymap_add_item(keymap, "FONT_OT_line_break", RETKEY, KM_PRESS, 0, 0); 00212 WM_keymap_add_item(keymap, "FONT_OT_text_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last! 00213 kmi = WM_keymap_add_item(keymap, "FONT_OT_text_insert", BACKSPACEKEY, KM_PRESS, KM_ALT, 0); 00214 RNA_boolean_set(kmi->ptr, "accent", TRUE); /* accented characters */ 00215 00216 /* only set in editmode curve, by space_view3d listener */ 00217 keymap= WM_keymap_find(keyconf, "Curve", 0, 0); 00218 keymap->poll= ED_operator_editsurfcurve; 00219 00220 WM_keymap_add_menu(keymap, "INFO_MT_edit_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); 00221 00222 WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", VKEY, KM_PRESS, 0, 0); 00223 00224 WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", LEFTMOUSE, KM_CLICK, KM_CTRL, 0); 00225 00226 kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0); 00227 RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); 00228 kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); 00229 RNA_enum_set(kmi->ptr, "action", SEL_INVERT); 00230 00231 WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0); 00232 WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); 00233 WM_keymap_add_item(keymap, "CURVE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); 00234 WM_keymap_add_item(keymap, "CURVE_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); 00235 00236 kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); 00237 RNA_boolean_set(kmi->ptr, "deselect", FALSE); 00238 kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); 00239 RNA_boolean_set(kmi->ptr, "deselect", TRUE); 00240 00241 WM_keymap_add_item(keymap, "CURVE_OT_separate", PKEY, KM_PRESS, 0, 0); 00242 WM_keymap_add_item(keymap, "CURVE_OT_extrude_move", EKEY, KM_PRESS, 0, 0); 00243 WM_keymap_add_item(keymap, "CURVE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); 00244 WM_keymap_add_item(keymap, "CURVE_OT_make_segment", FKEY, KM_PRESS, 0, 0); 00245 WM_keymap_add_item(keymap, "CURVE_OT_cyclic_toggle", CKEY, KM_PRESS, KM_ALT, 0); 00246 WM_keymap_add_item(keymap, "CURVE_OT_delete", XKEY, KM_PRESS, 0, 0); 00247 WM_keymap_add_item(keymap, "CURVE_OT_delete", DELKEY, KM_PRESS, 0, 0); 00248 00249 WM_keymap_add_item(keymap, "CURVE_OT_tilt_clear", TKEY, KM_PRESS, KM_ALT, 0); 00250 WM_keymap_add_item(keymap, "TRANSFORM_OT_tilt", TKEY, KM_PRESS, KM_CTRL, 0); 00251 00252 RNA_enum_set(WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", TFM_CURVE_SHRINKFATTEN); 00253 00254 WM_keymap_add_item(keymap, "CURVE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); 00255 kmi = WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, 0, 0); 00256 RNA_boolean_set(kmi->ptr, "unselected", FALSE); 00257 kmi = WM_keymap_add_item(keymap, "CURVE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); 00258 RNA_boolean_set(kmi->ptr, "unselected", TRUE); 00259 00260 WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); 00261 00262 WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_specials", WKEY, KM_PRESS, 0, 0); 00263 00264 /* menus */ 00265 WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); 00266 00267 ED_object_generic_keymap(keyconf, keymap, 3); 00268 } 00269