Blender V4.5
transform_mode_tilt.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "BLI_math_rotation.h"
12#include "BLI_math_vector.h"
13#include "BLI_string.h"
14
15#include "BKE_unit.hh"
16
17#include "ED_screen.hh"
18
19#include "UI_interface.hh"
20
21#include "BLT_translation.hh"
22
23#include "transform.hh"
24#include "transform_convert.hh"
25#include "transform_snap.hh"
26
27#include "transform_mode.hh"
28
29namespace blender::ed::transform {
30
31/* -------------------------------------------------------------------- */
34
35static void applyTilt(TransInfo *t)
36{
37 int i;
38 char str[UI_MAX_DRAW_STR];
39
40 float final;
41
42 final = t->values[0] + t->values_modal_offset[0];
43
44 transform_snap_increment(t, &final);
45
46 applyNumInput(&t->num, &final);
47
48 t->values_final[0] = final;
49
50 if (hasNumInput(&t->num)) {
51 char c[NUM_STR_REP_LEN];
52
53 outputNumInput(&(t->num), c, t->scene->unit);
54
55 SNPRINTF(str, "%s %s" BLI_STR_UTF8_DEGREE_SIGN " %s", IFACE_("Tilt:"), &c[0], t->proptext);
56
57 /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */
58 t->values_final[0] = final;
59 }
60 else {
62 "%s %.2f" BLI_STR_UTF8_DEGREE_SIGN " %s",
63 IFACE_("Tilt:"),
64 RAD2DEGF(final),
65 t->proptext);
66 }
67
69 TransData *td = tc->data;
70 for (i = 0; i < tc->data_len; i++, td++) {
71 if (td->flag & TD_SKIP) {
72 continue;
73 }
74
75 if (td->val) {
76 *td->val = td->ival + final * td->factor;
77 }
78 }
79 }
80
81 recalc_data(t);
82
84}
85
86static void initTilt(TransInfo *t, wmOperator * /*op*/)
87{
88 t->mode = TFM_TILT;
89
91
92 t->idx_max = 0;
93 t->num.idx_max = 0;
95
96 copy_v3_fl(t->num.val_inc, t->snap[1]);
97 t->num.unit_sys = t->scene->unit.system;
100}
101
103
105 /*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
106 /*init_fn*/ initTilt,
107 /*transform_fn*/ applyTilt,
108 /*transform_matrix_fn*/ nullptr,
109 /*handle_event_fn*/ nullptr,
110 /*snap_distance_fn*/ nullptr,
111 /*snap_apply_fn*/ nullptr,
112 /*draw_fn*/ nullptr,
113};
114
115} // namespace blender::ed::transform
@ B_UNIT_ROTATION
Definition BKE_unit.hh:128
#define RAD2DEGF(_rad)
MINLINE void copy_v3_fl(float r[3], float f)
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:599
#define BLI_STR_UTF8_DEGREE_SIGN
#define IFACE_(msgid)
@ USER_UNIT_ROT_RADIANS
#define NUM_STR_REP_LEN
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:189
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:87
bool hasNumInput(const NumInput *n)
Definition numinput.cc:170
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:872
#define UI_MAX_DRAW_STR
#define str(s)
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
void recalc_data(TransInfo *t)
bool transform_snap_increment(const TransInfo *t, float *r_val)
void initSnapAngleIncrements(TransInfo *t)
static void initTilt(TransInfo *t, wmOperator *)
static void applyTilt(TransInfo *t)
short idx_max
float val_inc[NUM_MAX_ELEMENTS]
int unit_type[NUM_MAX_ELEMENTS]
bool unit_use_radians
struct UnitSettings unit
i
Definition text_draw.cc:230
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
Definition transform.hh:42
conversion and adaptation of different datablocks to a common struct.
transform modes used by different operators.