Blender  V2.93
BKE_unit.h
Go to the documentation of this file.
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 
17 #pragma once
18 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 struct UnitSettings;
28 
29 /* in all cases the value is assumed to be scaled by the user preference */
30 
31 /* humanly readable representation of a value in units (used for button drawing) */
33  char *str, int len_max, double value, int prec, int system, int type, bool split, bool pad);
35  int len_max,
36  double value,
37  int prec,
38  int type,
39  const struct UnitSettings *settings,
40  bool pad);
41 
42 /* replace units with values, used before python button evaluation */
44  char *str, int len_max, const char *str_prev, double scale_pref, int system, int type);
45 
46 /* return true if the string contains any valid unit for the given type */
47 bool BKE_unit_string_contains_unit(const char *str, int type);
48 
49 /* If user does not specify a unit, this converts it to the unit from the settings. */
50 double BKE_unit_apply_preferred_unit(const struct UnitSettings *settings, int type, double value);
51 
52 /* make string keyboard-friendly: 10µm --> 10um */
53 void BKE_unit_name_to_alt(char *str, int len_max, const char *orig_str, int system, int type);
54 
55 /* the size of the unit used for this value (used for calculating the ckickstep) */
56 double BKE_unit_closest_scalar(double value, int system, int type);
57 
58 /* base scale for these units */
59 double BKE_unit_base_scalar(int system, int type);
60 
61 /* return true is the unit system exists */
62 bool BKE_unit_is_valid(int system, int type);
63 
64 /* loop over scales, could add names later */
65 // double bUnit_Iter(void **unit, char **name, int system, int type);
66 
67 void BKE_unit_system_get(int system, int type, const void **r_usys_pt, int *r_len);
68 int BKE_unit_base_get(const void *usys_pt);
70 const char *BKE_unit_name_get(const void *usys_pt, int index);
71 const char *BKE_unit_display_name_get(const void *usys_pt, int index);
72 const char *BKE_unit_identifier_get(const void *usys_pt, int index);
73 double BKE_unit_scalar_get(const void *usys_pt, int index);
74 bool BKE_unit_is_suppressed(const void *usys_pt, int index);
75 
76 /* aligned with PropertyUnit */
77 enum {
91 };
92 
93 #ifdef __cplusplus
94 }
95 #endif
int BKE_unit_base_of_type_get(int system, int type)
Definition: unit.c:1285
bool BKE_unit_is_valid(int system, int type)
Definition: unit.c:1262
size_t BKE_unit_value_as_string_adaptive(char *str, int len_max, double value, int prec, int system, int type, bool split, bool pad)
Definition: unit.c:665
const char * BKE_unit_display_name_get(const void *usys_pt, int index)
Definition: unit.c:1294
bool BKE_unit_is_suppressed(const void *usys_pt, int index)
Definition: unit.c:1312
void BKE_unit_system_get(int system, int type, const void **r_usys_pt, int *r_len)
Definition: unit.c:1267
@ B_UNIT_AREA
Definition: BKE_unit.h:80
@ B_UNIT_TYPE_TOT
Definition: BKE_unit.h:90
@ B_UNIT_VOLUME
Definition: BKE_unit.h:81
@ B_UNIT_LENGTH
Definition: BKE_unit.h:79
@ B_UNIT_ROTATION
Definition: BKE_unit.h:83
@ B_UNIT_TEMPERATURE
Definition: BKE_unit.h:89
@ B_UNIT_CAMERA
Definition: BKE_unit.h:87
@ B_UNIT_ACCELERATION
Definition: BKE_unit.h:86
@ B_UNIT_MASS
Definition: BKE_unit.h:82
@ B_UNIT_NONE
Definition: BKE_unit.h:78
@ B_UNIT_POWER
Definition: BKE_unit.h:88
@ B_UNIT_TIME
Definition: BKE_unit.h:84
@ B_UNIT_VELOCITY
Definition: BKE_unit.h:85
void BKE_unit_name_to_alt(char *str, int len_max, const char *orig_str, int system, int type)
Definition: unit.c:1196
const char * BKE_unit_identifier_get(const void *usys_pt, int index)
Definition: unit.c:1298
int BKE_unit_base_get(const void *usys_pt)
Definition: unit.c:1280
size_t BKE_unit_value_as_string(char *str, int len_max, double value, int prec, int type, const struct UnitSettings *settings, bool pad)
double BKE_unit_scalar_get(const void *usys_pt, int index)
Definition: unit.c:1307
double BKE_unit_closest_scalar(double value, int system, int type)
Definition: unit.c:1236
bool BKE_unit_replace_string(char *str, int len_max, const char *str_prev, double scale_pref, int system, int type)
Definition: unit.c:1106
double BKE_unit_apply_preferred_unit(const struct UnitSettings *settings, int type, double value)
Definition: unit.c:1079
double BKE_unit_base_scalar(int system, int type)
Definition: unit.c:1252
bool BKE_unit_string_contains_unit(const char *str, int type)
Definition: unit.c:1062
const char * BKE_unit_name_get(const void *usys_pt, int index)
Definition: unit.c:1290
_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 type
#define str(s)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition: abc_util.cc:115