Blender V5.0
BKE_unit.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "BLI_sys_types.h"
8
12
13struct UnitSettings;
14
15/* In all cases the value is assumed to be scaled by the user-preference. */
16
29size_t BKE_unit_value_as_string(char *str,
30 int str_maxncpy,
31 double value,
32 int prec,
33 int type,
34 const UnitSettings &settings,
35 bool pad);
36
43 int str_maxncpy,
44 double value,
45 int prec,
46 int system,
47 int type,
48 bool split,
49 bool pad);
50
57 int str_maxncpy,
58 double value,
59 int prec,
60 int type,
61 const UnitSettings &settings,
62 bool pad);
63
82 char *str, int str_maxncpy, const char *str_prev, double scale_pref, int system, int type);
83
87bool BKE_unit_string_contains_unit(const char *str, int type);
88
92double BKE_unit_apply_preferred_unit(const UnitSettings &settings, int type, double value);
93
97void BKE_unit_name_to_alt(char *str, int str_maxncpy, const char *orig_str, int system, int type);
98
102double BKE_unit_closest_scalar(double value, int system, int type);
103
107double BKE_unit_base_scalar(int system, int type);
108
112bool BKE_unit_is_valid(int system, int type);
113
118double BKE_unit_value_scale(const UnitSettings &settings, int unit_type, double value);
119
123// double bUnit_Iter(void **unit, char **name, int system, int type);
124
125void BKE_unit_system_get(int system, int type, const void **r_usys_pt, int *r_len);
126int BKE_unit_base_get(const void *usys_pt);
127int BKE_unit_base_of_type_get(int system, int type);
128const char *BKE_unit_name_get(const void *usys_pt, int index);
129const char *BKE_unit_display_name_get(const void *usys_pt, int index);
130const char *BKE_unit_identifier_get(const void *usys_pt, int index);
131double BKE_unit_scalar_get(const void *usys_pt, int index);
132bool BKE_unit_is_suppressed(const void *usys_pt, int index);
133
135enum {
153};
void BKE_unit_name_to_alt(char *str, int str_maxncpy, const char *orig_str, int system, int type)
Definition unit.cc:2447
int BKE_unit_base_of_type_get(int system, int type)
Definition unit.cc:2537
@ B_UNIT_TIME_ABSOLUTE
Definition BKE_unit.hh:143
@ B_UNIT_AREA
Definition BKE_unit.hh:138
@ B_UNIT_FREQUENCY
Definition BKE_unit.hh:151
@ B_UNIT_TYPE_TOT
Definition BKE_unit.hh:152
@ B_UNIT_VOLUME
Definition BKE_unit.hh:139
@ B_UNIT_LENGTH
Definition BKE_unit.hh:137
@ B_UNIT_ROTATION
Definition BKE_unit.hh:141
@ B_UNIT_TEMPERATURE
Definition BKE_unit.hh:148
@ B_UNIT_CAMERA
Definition BKE_unit.hh:146
@ B_UNIT_ACCELERATION
Definition BKE_unit.hh:145
@ B_UNIT_MASS
Definition BKE_unit.hh:140
@ B_UNIT_WAVELENGTH
Definition BKE_unit.hh:149
@ B_UNIT_NONE
Definition BKE_unit.hh:136
@ B_UNIT_POWER
Definition BKE_unit.hh:147
@ B_UNIT_COLOR_TEMPERATURE
Definition BKE_unit.hh:150
@ B_UNIT_TIME
Definition BKE_unit.hh:142
@ B_UNIT_VELOCITY
Definition BKE_unit.hh:144
bool BKE_unit_is_valid(int system, int type)
Definition unit.cc:2514
size_t BKE_unit_value_as_string(char *str, int str_maxncpy, double value, int prec, int type, const UnitSettings &settings, bool pad)
Definition unit.cc:1882
double BKE_unit_value_scale(const UnitSettings &settings, int unit_type, double value)
Definition unit.cc:1907
size_t BKE_unit_value_as_string_scaled(char *str, int str_maxncpy, double value, int prec, int type, const UnitSettings &settings, bool pad)
Definition unit.cc:1895
const char * BKE_unit_identifier_get(const void *usys_pt, int index)
Definition unit.cc:2554
bool BKE_unit_is_suppressed(const void *usys_pt, int index)
Definition unit.cc:2572
void BKE_unit_system_get(int system, int type, const void **r_usys_pt, int *r_len)
Definition unit.cc:2519
const char * BKE_unit_display_name_get(const void *usys_pt, int index)
Definition unit.cc:2548
const char * BKE_unit_name_get(const void *usys_pt, int index)
Definition unit.cc:2542
int BKE_unit_base_get(const void *usys_pt)
Definition unit.cc:2532
bool BKE_unit_replace_string(char *str, int str_maxncpy, const char *str_prev, double scale_pref, int system, int type)
Definition unit.cc:2357
double BKE_unit_apply_preferred_unit(const UnitSettings &settings, int type, double value)
Definition unit.cc:2345
double BKE_unit_scalar_get(const void *usys_pt, int index)
Definition unit.cc:2565
double BKE_unit_closest_scalar(double value, int system, int type)
Definition unit.cc:2488
double BKE_unit_base_scalar(int system, int type)
Definition unit.cc:2504
bool BKE_unit_string_contains_unit(const char *str, int type)
Definition unit.cc:2331
size_t BKE_unit_value_as_string_adaptive(char *str, int str_maxncpy, double value, int prec, int system, int type, bool split, bool pad)
Definition unit.cc:1869
static void split(const char *text, const char *seps, char ***str, int *count)
int pad[32 - sizeof(int)]
#define str(s)