Blender V5.0
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_utf8.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
56 str, "%s %s" BLI_STR_UTF8_DEGREE_SIGN " %s", IFACE_("Tilt:"), &c[0], t->proptext);
57
58 /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */
59 t->values_final[0] = final;
60 }
61 else {
63 "%s %.2f" BLI_STR_UTF8_DEGREE_SIGN " %s",
64 IFACE_("Tilt:"),
65 RAD2DEGF(final),
66 t->proptext);
67 }
68
70 TransData *td = tc->data;
71 for (i = 0; i < tc->data_len; i++, td++) {
72 if (td->flag & TD_SKIP) {
73 continue;
74 }
75
76 if (td->val) {
77 *td->val = td->ival + final * td->factor;
78 }
79 }
80 }
81
82 recalc_data(t);
83
85}
86
87static void initTilt(TransInfo *t, wmOperator * /*op*/)
88{
89 t->mode = TFM_TILT;
90
92
93 t->idx_max = 0;
94 t->num.idx_max = 0;
96
98 t->num.unit_sys = t->scene->unit.system;
101}
102
104
106 /*flags*/ T_NO_CONSTRAINT | T_NO_PROJECT,
107 /*init_fn*/ initTilt,
108 /*transform_fn*/ applyTilt,
109 /*transform_matrix_fn*/ nullptr,
110 /*handle_event_fn*/ nullptr,
111 /*snap_distance_fn*/ nullptr,
112 /*snap_apply_fn*/ nullptr,
113 /*draw_fn*/ nullptr,
114};
115
116} // namespace blender::ed::transform
@ B_UNIT_ROTATION
Definition BKE_unit.hh:141
#define RAD2DEGF(_rad)
MINLINE void copy_v3_fl(float r[3], float f)
#define SNPRINTF_UTF8(dst, format,...)
#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:190
void outputNumInput(NumInput *n, char *str, const UnitSettings &unit_settings)
Definition numinput.cc:88
bool hasNumInput(const NumInput *n)
Definition numinput.cc:171
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:851
#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.