Merge branch 'blender-v2.91-release'
[blender.git] / source / blender / editors / curve / curve_ops.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19
20 /** \file
21  * \ingroup edcurve
22  */
23
24 #include <math.h>
25 #include <stdlib.h>
26
27 #include "DNA_curve_types.h"
28 #include "DNA_scene_types.h"
29
30 #include "RNA_access.h"
31
32 #include "WM_api.h"
33 #include "WM_types.h"
34
35 #include "ED_curve.h"
36 #include "ED_screen.h"
37
38 #include "curve_intern.h"
39
40 /************************* registration ****************************/
41
42 void ED_operatortypes_curve(void)
43 {
44   WM_operatortype_append(FONT_OT_text_insert);
45   WM_operatortype_append(FONT_OT_line_break);
46
47   WM_operatortype_append(FONT_OT_case_toggle);
48   WM_operatortype_append(FONT_OT_case_set);
49   WM_operatortype_append(FONT_OT_style_toggle);
50   WM_operatortype_append(FONT_OT_style_set);
51
52   WM_operatortype_append(FONT_OT_select_all);
53
54   WM_operatortype_append(FONT_OT_text_copy);
55   WM_operatortype_append(FONT_OT_text_cut);
56   WM_operatortype_append(FONT_OT_text_paste);
57   WM_operatortype_append(FONT_OT_text_paste_from_file);
58
59   WM_operatortype_append(FONT_OT_move);
60   WM_operatortype_append(FONT_OT_move_select);
61   WM_operatortype_append(FONT_OT_delete);
62
63   WM_operatortype_append(FONT_OT_change_character);
64   WM_operatortype_append(FONT_OT_change_spacing);
65
66   WM_operatortype_append(FONT_OT_open);
67   WM_operatortype_append(FONT_OT_unlink);
68
69   WM_operatortype_append(FONT_OT_textbox_add);
70   WM_operatortype_append(FONT_OT_textbox_remove);
71
72   WM_operatortype_append(CURVE_OT_hide);
73   WM_operatortype_append(CURVE_OT_reveal);
74
75   WM_operatortype_append(CURVE_OT_separate);
76   WM_operatortype_append(CURVE_OT_split);
77   WM_operatortype_append(CURVE_OT_duplicate);
78   WM_operatortype_append(CURVE_OT_delete);
79   WM_operatortype_append(CURVE_OT_dissolve_verts);
80
81   WM_operatortype_append(CURVE_OT_spline_type_set);
82   WM_operatortype_append(CURVE_OT_radius_set);
83   WM_operatortype_append(CURVE_OT_spline_weight_set);
84   WM_operatortype_append(CURVE_OT_handle_type_set);
85   WM_operatortype_append(CURVE_OT_normals_make_consistent);
86   WM_operatortype_append(CURVE_OT_decimate);
87   WM_operatortype_append(CURVE_OT_shade_smooth);
88   WM_operatortype_append(CURVE_OT_shade_flat);
89   WM_operatortype_append(CURVE_OT_tilt_clear);
90
91   WM_operatortype_append(CURVE_OT_primitive_bezier_curve_add);
92   WM_operatortype_append(CURVE_OT_primitive_bezier_circle_add);
93   WM_operatortype_append(CURVE_OT_primitive_nurbs_curve_add);
94   WM_operatortype_append(CURVE_OT_primitive_nurbs_circle_add);
95   WM_operatortype_append(CURVE_OT_primitive_nurbs_path_add);
96
97   WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_curve_add);
98   WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_circle_add);
99   WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_surface_add);
100   WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_cylinder_add);
101   WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_sphere_add);
102   WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_torus_add);
103
104   WM_operatortype_append(CURVE_OT_smooth);
105   WM_operatortype_append(CURVE_OT_smooth_weight);
106   WM_operatortype_append(CURVE_OT_smooth_radius);
107   WM_operatortype_append(CURVE_OT_smooth_tilt);
108
109   WM_operatortype_append(CURVE_OT_de_select_first);
110   WM_operatortype_append(CURVE_OT_de_select_last);
111   WM_operatortype_append(CURVE_OT_select_all);
112   WM_operatortype_append(CURVE_OT_select_linked);
113   WM_operatortype_append(CURVE_OT_select_linked_pick);
114   WM_operatortype_append(CURVE_OT_select_row);
115   WM_operatortype_append(CURVE_OT_select_next);
116   WM_operatortype_append(CURVE_OT_select_previous);
117   WM_operatortype_append(CURVE_OT_select_more);
118   WM_operatortype_append(CURVE_OT_select_less);
119   WM_operatortype_append(CURVE_OT_select_random);
120   WM_operatortype_append(CURVE_OT_select_nth);
121   WM_operatortype_append(CURVE_OT_select_similar);
122   WM_operatortype_append(CURVE_OT_shortest_path_pick);
123
124   WM_operatortype_append(CURVE_OT_switch_direction);
125   WM_operatortype_append(CURVE_OT_subdivide);
126   WM_operatortype_append(CURVE_OT_make_segment);
127   WM_operatortype_append(CURVE_OT_spin);
128   WM_operatortype_append(CURVE_OT_vertex_add);
129   WM_operatortype_append(CURVE_OT_draw);
130   WM_operatortype_append(CURVE_OT_extrude);
131   WM_operatortype_append(CURVE_OT_cyclic_toggle);
132
133   WM_operatortype_append(CURVE_OT_match_texture_space);
134 }
135
136 void ED_operatormacros_curve(void)
137 {
138   wmOperatorType *ot;
139   wmOperatorTypeMacro *otmacro;
140
141   ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move",
142                                     "Add Duplicate",
143                                     "Duplicate curve and move",
144                                     OPTYPE_UNDO | OPTYPE_REGISTER);
145   WM_operatortype_macro_define(ot, "CURVE_OT_duplicate");
146   otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
147   RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
148   RNA_boolean_set(otmacro->ptr, "mirror", false);
149
150   ot = WM_operatortype_append_macro("CURVE_OT_extrude_move",
151                                     "Extrude Curve and Move",
152                                     "Extrude curve and move result",
153                                     OPTYPE_UNDO | OPTYPE_REGISTER);
154   WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
155   otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
156   RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
157   RNA_boolean_set(otmacro->ptr, "mirror", false);
158 }
159
160 void ED_keymap_curve(wmKeyConfig *keyconf)
161 {
162   /* only set in editmode font, by space_view3d listener */
163   wmKeyMap *keymap = WM_keymap_ensure(keyconf, "Font", 0, 0);
164   keymap->poll = ED_operator_editfont;
165
166   /* only set in editmode curve, by space_view3d listener */
167   keymap = WM_keymap_ensure(keyconf, "Curve", 0, 0);
168   keymap->poll = ED_operator_editsurfcurve;
169 }