Blender V5.0
transform_mode_maskshrinkfatten.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_vector.h"
12#include "BLI_string_utf8.h"
13
14#include "BKE_unit.hh"
15
16#include "ED_screen.hh"
17
18#include "BLT_translation.hh"
19
20#include "UI_interface_types.hh"
21
22#include "transform.hh"
23#include "transform_convert.hh"
24#include "transform_snap.hh"
25
26#include "transform_mode.hh"
27
28namespace blender::ed::transform {
29
30/* -------------------------------------------------------------------- */
33
35{
36 float ratio;
37 int i;
38 bool initial_feather = false;
39 char str[UI_MAX_DRAW_STR];
40
41 ratio = t->values[0] + t->values_modal_offset[0];
42
43 transform_snap_increment(t, &ratio);
44
45 applyNumInput(&t->num, &ratio);
46
47 t->values_final[0] = ratio;
48
49 /* Header print for NumInput. */
50 if (hasNumInput(&t->num)) {
51 char c[NUM_STR_REP_LEN];
52
53 outputNumInput(&(t->num), c, t->scene->unit);
54 SNPRINTF_UTF8(str, IFACE_("Feather Shrink/Fatten: %s"), c);
55 }
56 else {
57 SNPRINTF_UTF8(str, IFACE_("Feather Shrink/Fatten: %3f"), ratio);
58 }
59
60 /* Detect if no points have feather yet. */
61 if (ratio > 1.0f) {
62 initial_feather = true;
63
65 TransData *td = tc->data;
66 for (i = 0; i < tc->data_len; i++, td++) {
67 if (td->flag & TD_SKIP) {
68 continue;
69 }
70
71 if (td->ival >= 0.001f) {
72 initial_feather = false;
73 }
74 }
75 }
76 }
77
78 /* Apply shrink/fatten. */
80 TransData *td;
81 for (td = tc->data, i = 0; i < tc->data_len; i++, td++) {
82 if (td->flag & TD_SKIP) {
83 continue;
84 }
85
86 if (td->val) {
87 if (initial_feather) {
88 *td->val = td->ival + (ratio - 1.0f) * 0.01f;
89 }
90 else {
91 *td->val = td->ival * ratio;
92 }
93
94 /* Apply proportional editing. */
95 *td->val = interpf(*td->val, td->ival, td->factor);
96 if (*td->val <= 0.0f) {
97 *td->val = 0.001f;
98 }
99 }
100 }
101 }
102
103 recalc_data(t);
104
106}
107
109{
111
113
114 t->idx_max = 0;
115 t->num.idx_max = 0;
116 t->increment[0] = 0.1f;
117 t->increment_precision = 0.1f;
118
119 copy_v3_fl(t->num.val_inc, t->increment[0]);
120 t->num.unit_sys = t->scene->unit.system;
121 t->num.unit_type[0] = B_UNIT_NONE;
122
123#ifdef USE_NUM_NO_ZERO
124 t->num.val_flag[0] |= NUM_NO_ZERO;
125#endif
126}
127
129
131 /*flags*/ T_NO_CONSTRAINT,
132 /*init_fn*/ initMaskShrinkFatten,
133 /*transform_fn*/ applyMaskShrinkFatten,
134 /*transform_matrix_fn*/ nullptr,
135 /*handle_event_fn*/ nullptr,
136 /*snap_distance_fn*/ nullptr,
137 /*snap_apply_fn*/ nullptr,
138 /*draw_fn*/ nullptr,
139};
140
141} // namespace blender::ed::transform
@ B_UNIT_NONE
Definition BKE_unit.hh:136
MINLINE float interpf(float target, float origin, float t)
MINLINE void copy_v3_fl(float r[3], float f)
#define SNPRINTF_UTF8(dst, format,...)
#define IFACE_(msgid)
#define NUM_STR_REP_LEN
bool applyNumInput(NumInput *n, float *vec)
Definition numinput.cc:190
@ NUM_NO_ZERO
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)
static void initMaskShrinkFatten(TransInfo *t, wmOperator *)
static void applyMaskShrinkFatten(TransInfo *t)
short idx_max
short val_flag[NUM_MAX_ELEMENTS]
float val_inc[NUM_MAX_ELEMENTS]
int unit_type[NUM_MAX_ELEMENTS]
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.