Blender  V3.3
transform_mode_baketime.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <stdlib.h>
9 
10 #include "BLI_math.h"
11 #include "BLI_string.h"
12 
13 #include "BKE_context.h"
14 #include "BKE_unit.h"
15 
16 #include "ED_screen.h"
17 
18 #include "UI_interface.h"
19 
20 #include "BLT_translation.h"
21 
22 #include "transform.h"
23 #include "transform_convert.h"
24 #include "transform_snap.h"
25 
26 #include "transform_mode.h"
27 
28 /* -------------------------------------------------------------------- */
32 static void applyBakeTime(TransInfo *t, const int mval[2])
33 {
34  float time;
35  int i;
36  char str[UI_MAX_DRAW_STR];
37 
38  float fac = 0.1f;
39 
40  /* XXX, disable precision for now,
41  * this isn't even accessible by the user */
42 #if 0
43  if (t->mouse.precision) {
44  /* calculate ratio for shiftkey pos, and for total, and blend these for precision */
45  time = (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac;
46  time += 0.1f * ((float)(t->center2d[0] * fac - mval[0]) - time);
47  }
48  else
49 #endif
50  {
51  time = (float)(t->center2d[0] - mval[0]) * fac;
52  }
53 
55 
56  applyNumInput(&t->num, &time);
57 
58  /* header print for NumInput */
59  if (hasNumInput(&t->num)) {
60  char c[NUM_STR_REP_LEN];
61 
62  outputNumInput(&(t->num), c, &t->scene->unit);
63 
64  if (time >= 0.0f) {
65  BLI_snprintf(str, sizeof(str), TIP_("Time: +%s %s"), c, t->proptext);
66  }
67  else {
68  BLI_snprintf(str, sizeof(str), TIP_("Time: %s %s"), c, t->proptext);
69  }
70  }
71  else {
72  /* default header print */
73  if (time >= 0.0f) {
74  BLI_snprintf(str, sizeof(str), TIP_("Time: +%.3f %s"), time, t->proptext);
75  }
76  else {
77  BLI_snprintf(str, sizeof(str), TIP_("Time: %.3f %s"), time, t->proptext);
78  }
79  }
80 
82  TransData *td = tc->data;
83  for (i = 0; i < tc->data_len; i++, td++) {
84  if (td->flag & TD_SKIP) {
85  continue;
86  }
87 
88  if (td->val) {
89  *td->val = td->ival + time * td->factor;
90  if (td->ext->size && *td->val < *td->ext->size) {
91  *td->val = *td->ext->size;
92  }
93  if (td->ext->quat && *td->val > *td->ext->quat) {
94  *td->val = *td->ext->quat;
95  }
96  }
97  }
98  }
99 
100  recalcData(t);
101 
102  ED_area_status_text(t->area, str);
103 }
104 
106 {
107  t->transform = applyBakeTime;
108  initMouseInputMode(t, &t->mouse, INPUT_NONE);
109 
110  t->idx_max = 0;
111  t->num.idx_max = 0;
112  t->snap[0] = 1.0f;
113  t->snap[1] = t->snap[0] * 0.1f;
114 
115  copy_v3_fl(t->num.val_inc, t->snap[0]);
116  t->num.unit_sys = t->scene->unit.system;
117  t->num.unit_type[0] = B_UNIT_NONE; /* Don't think this uses units? */
118 }
119 
typedef float(TangentPoint)[2]
@ B_UNIT_NONE
Definition: BKE_unit.h:100
MINLINE void copy_v3_fl(float r[3], float f)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define TIP_(msgid)
void outputNumInput(NumInput *n, char *str, struct UnitSettings *unit_settings)
Definition: numinput.c:87
#define NUM_STR_REP_LEN
Definition: ED_numinput.h:13
bool applyNumInput(NumInput *n, float *vec)
Definition: numinput.c:189
bool hasNumInput(const NumInput *n)
Definition: numinput.c:170
void ED_area_status_text(ScrArea *area, const char *str)
Definition: area.c:792
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
#define UI_MAX_DRAW_STR
Definition: UI_interface.h:91
double time
#define str(s)
static unsigned c
Definition: RandGen.cpp:83
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#define FOREACH_TRANS_DATA_CONTAINER(t, th)
TransDataExtension * ext
float * val
void recalcData(TransInfo *t)
conversion and adaptation of different datablocks to a common struct.
@ TD_SKIP
transform modes used by different operators.
static void applyBakeTime(TransInfo *t, const int mval[2])
void initBakeTime(TransInfo *t)
bool transform_snap_increment(const TransInfo *t, float *r_val)