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) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 /** \file
21  * \ingroup editors
22  */
23 
24 #pragma once
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /* ******************* Registration Function ********************** */
31 
32 struct Object;
33 struct bContext;
34 struct wmKeyConfig;
35 struct wmMsgBus;
36 struct wmOperatorType;
37 
38 void ED_keymap_transform(struct wmKeyConfig *keyconf);
39 void transform_operatortypes(void);
40 
41 /* ******************** Macros & Prototypes *********************** */
42 
43 /* MODE AND NUMINPUT FLAGS */
44 enum TfmMode {
45   TFM_INIT = -1,
46   TFM_DUMMY,
47   TFM_TRANSLATION,
48   TFM_ROTATION,
49   TFM_RESIZE,
50   TFM_SKIN_RESIZE,
51   TFM_TOSPHERE,
52   TFM_SHEAR,
53   TFM_BEND,
54   TFM_SHRINKFATTEN,
55   TFM_TILT,
56   TFM_TRACKBALL,
57   TFM_PUSHPULL,
58   TFM_CREASE,
59   TFM_MIRROR,
60   TFM_BONESIZE,
61   TFM_BONE_ENVELOPE,
62   TFM_CURVE_SHRINKFATTEN,
63   TFM_MASK_SHRINKFATTEN,
64   TFM_GPENCIL_SHRINKFATTEN,
65   TFM_BONE_ROLL,
66   TFM_TIME_TRANSLATE,
67   TFM_TIME_SLIDE,
68   TFM_TIME_SCALE,
69   TFM_TIME_EXTEND,
70   TFM_TIME_DUPLICATE,
71   TFM_BAKE_TIME,
72   TFM_DEPRECATED, /* was BEVEL */
73   TFM_BWEIGHT,
74   TFM_ALIGN,
75   TFM_EDGE_SLIDE,
76   TFM_VERT_SLIDE,
77   TFM_SEQ_SLIDE,
78   TFM_BONE_ENVELOPE_DIST,
79   TFM_NORMAL_ROTATION,
80   TFM_GPENCIL_OPACITY,
81 };
82 
83 /* TRANSFORM CONTEXTS */
84 #define CTX_NONE 0
85 #define CTX_TEXTURE (1 << 0)
86 #define CTX_EDGE (1 << 1)
87 #define CTX_NO_PET (1 << 2)
88 #define CTX_NO_MIRROR (1 << 3)
89 #define CTX_AUTOCONFIRM (1 << 4)
90 #define CTX_MOVIECLIP (1 << 6)
91 #define CTX_MASK (1 << 7)
92 #define CTX_PAINT_CURVE (1 << 8)
93 #define CTX_GPENCIL_STROKES (1 << 9)
94 #define CTX_CURSOR (1 << 10)
95 /** When transforming object's, adjust the object data so it stays in the same place. */
96 #define CTX_OBMODE_XFORM_OBDATA (1 << 11)
97 /** Transform object parents without moving their children. */
98 #define CTX_OBMODE_XFORM_SKIP_CHILDREN (1 << 12)
99 
100 /* Standalone call to get the transformation center corresponding to the current situation
101  * returns 1 if successful, 0 otherwise (usually means there's no selection)
102  * (if 0 is returns, *vec is unmodified)
103  * */
104 bool calculateTransformCenter(struct bContext *C,
105                               int centerMode,
106                               float cent3d[3],
107                               float cent2d[2]);
108 
109 struct Object;
110 struct Scene;
111 struct wmGizmoGroup;
112 struct wmGizmoGroupType;
113 
114 /* UNUSED */
115 // int BIF_snappingSupported(struct Object *obedit);
116 
117 struct ReportList;
118 struct TransformOrientation;
119 struct bContext;
120 
121 void BIF_clearTransformOrientation(struct bContext *C);
122 void BIF_removeTransformOrientation(struct bContext *C, struct TransformOrientation *target);
123 void BIF_removeTransformOrientationIndex(struct bContext *C, int index);
124 bool BIF_createTransformOrientation(struct bContext *C,
125                                     struct ReportList *reports,
126                                     const char *name,
127                                     const bool use_view,
128                                     const bool activate,
129                                     const bool overwrite);
130 void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *target);
131 
132 void ED_getTransformOrientationMatrix(const struct bContext *C,
133                                       struct Object *ob,
134                                       struct Object *obedit,
135                                       const short around,
136                                       float r_orientation_mat[3][3]);
137 
138 int BIF_countTransformOrientation(const struct bContext *C);
139 
140 /* to be able to add operator properties to other operators */
141 
142 #define P_MIRROR (1 << 0)
143 #define P_MIRROR_DUMMY (P_MIRROR | (1 << 9))
144 #define P_PROPORTIONAL (1 << 1)
145 #define P_ORIENT_AXIS (1 << 2)
146 #define P_ORIENT_AXIS_ORTHO (1 << 16)
147 #define P_ORIENT_MATRIX (1 << 17)
148 #define P_SNAP (1 << 3)
149 #define P_GEO_SNAP (P_SNAP | (1 << 4))
150 #define P_ALIGN_SNAP (P_GEO_SNAP | (1 << 5))
151 #define P_CONSTRAINT (1 << 6)
152 #define P_OPTIONS (1 << 7)
153 #define P_CORRECT_UV (1 << 8)
154 #define P_NO_DEFAULTS (1 << 10)
155 #define P_NO_TEXSPACE (1 << 11)
156 #define P_CENTER (1 << 12)
157 #define P_GPENCIL_EDIT (1 << 13)
158 #define P_CURSOR_EDIT (1 << 14)
159 #define P_CLNOR_INVALIDATE (1 << 15)
160 /* For properties performed when confirming the transformation. */
161 #define P_POST_TRANSFORM (1 << 19)
162 
163 void Transform_Properties(struct wmOperatorType *ot, int flags);
164 
165 /* *** transform_orientations.c *** */
166 void ED_transform_calc_orientation_from_type(const struct bContext *C, float r_mat[3][3]);
167 short ED_transform_calc_orientation_from_type_ex(const struct bContext *C,
168                                                  float r_mat[3][3],
169                                                  /* extra args */
170                                                  struct Scene *scene,
171                                                  struct RegionView3D *rv3d,
172                                                  struct Object *ob,
173                                                  struct Object *obedit,
174                                                  const short orientation_type,
175                                                  int orientation_index_custom,
176                                                  const int pivot_point);
177 
178 /* transform gizmos */
179 
180 void VIEW3D_GGT_xform_gizmo(struct wmGizmoGroupType *gzgt);
181 void VIEW3D_GGT_xform_gizmo_context(struct wmGizmoGroupType *gzgt);
182 void VIEW3D_GGT_xform_cage(struct wmGizmoGroupType *gzgt);
183 void VIEW3D_GGT_xform_shear(struct wmGizmoGroupType *gzgt);
184 
185 /* *** transform_gizmo_extrude_3d.c *** */
186 void VIEW3D_GGT_xform_extrude(struct wmGizmoGroupType *gzgt);
187 
188 /* Generic 2D transform gizmo callback assignment. */
189 void ED_widgetgroup_gizmo2d_xform_callbacks_set(struct wmGizmoGroupType *gzgt);
190 void ED_widgetgroup_gizmo2d_xform_no_cage_callbacks_set(struct wmGizmoGroupType *gzgt);
191 void ED_widgetgroup_gizmo2d_resize_callbacks_set(struct wmGizmoGroupType *gzgt);
192 void ED_widgetgroup_gizmo2d_rotate_callbacks_set(struct wmGizmoGroupType *gzgt);
193 
194 #define SNAP_INCREMENTAL_ANGLE DEG2RAD(5.0)
195 
196 struct TransformBounds {
197   float center[3];      /* Center for transform widget. */
198   float min[3], max[3]; /* Boundbox of selection for transform widget. */
199 
200   /* Normalized axis */
201   float axis[3][3];
202   float axis_min[3], axis_max[3];
203 };
204 
205 struct TransformCalcParams {
206   uint use_only_center : 1;
207   uint use_local_axis : 1;
208   /* Use 'Scene.orientation_type' when zero, otherwise subtract one and use. */
209   ushort orientation_type;
210   ushort orientation_index_custom;
211 };
212 int ED_transform_calc_gizmo_stats(const struct bContext *C,
213                                   const struct TransformCalcParams *params,
214                                   struct TransformBounds *tbounds);
215 
216 #ifdef __cplusplus
217 }
218 #endif
219