Blender  V2.93
Enumerations | Functions
BKE_unit.h File Reference

Go to the source code of this file.

Enumerations

enum  {
  B_UNIT_NONE = 0 , B_UNIT_LENGTH = 1 , B_UNIT_AREA = 2 , B_UNIT_VOLUME = 3 ,
  B_UNIT_MASS = 4 , B_UNIT_ROTATION = 5 , B_UNIT_TIME = 6 , B_UNIT_VELOCITY = 7 ,
  B_UNIT_ACCELERATION = 8 , B_UNIT_CAMERA = 9 , B_UNIT_POWER = 10 , B_UNIT_TEMPERATURE = 11 ,
  B_UNIT_TYPE_TOT = 12
}
 

Functions

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)
 
size_t BKE_unit_value_as_string (char *str, int len_max, double value, int prec, int type, const struct UnitSettings *settings, bool pad)
 
bool BKE_unit_replace_string (char *str, int len_max, const char *str_prev, double scale_pref, int system, int type)
 
bool BKE_unit_string_contains_unit (const char *str, int type)
 
double BKE_unit_apply_preferred_unit (const struct UnitSettings *settings, int type, double value)
 
void BKE_unit_name_to_alt (char *str, int len_max, const char *orig_str, int system, int type)
 
double BKE_unit_closest_scalar (double value, int system, int type)
 
double BKE_unit_base_scalar (int system, int type)
 
bool BKE_unit_is_valid (int system, int type)
 
void BKE_unit_system_get (int system, int type, const void **r_usys_pt, int *r_len)
 
int BKE_unit_base_get (const void *usys_pt)
 
int BKE_unit_base_of_type_get (int system, int type)
 
const char * BKE_unit_name_get (const void *usys_pt, int index)
 
const char * BKE_unit_display_name_get (const void *usys_pt, int index)
 
const char * BKE_unit_identifier_get (const void *usys_pt, int index)
 
double BKE_unit_scalar_get (const void *usys_pt, int index)
 
bool BKE_unit_is_suppressed (const void *usys_pt, int index)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
B_UNIT_NONE 
B_UNIT_LENGTH 
B_UNIT_AREA 
B_UNIT_VOLUME 
B_UNIT_MASS 
B_UNIT_ROTATION 
B_UNIT_TIME 
B_UNIT_VELOCITY 
B_UNIT_ACCELERATION 
B_UNIT_CAMERA 
B_UNIT_POWER 
B_UNIT_TEMPERATURE 
B_UNIT_TYPE_TOT 

Definition at line 77 of file BKE_unit.h.

Function Documentation

◆ BKE_unit_apply_preferred_unit()

double BKE_unit_apply_preferred_unit ( const struct UnitSettings settings,
int  type,
double  value 
)

◆ BKE_unit_base_get()

int BKE_unit_base_get ( const void *  usys_pt)

Definition at line 1280 of file unit.c.

Referenced by ED_scene_grid_scale(), and ED_view3d_grid_steps().

◆ BKE_unit_base_of_type_get()

int BKE_unit_base_of_type_get ( int  system,
int  type 
)

Definition at line 1285 of file unit.c.

References bUnitCollection::base_unit, type, and unit_get_system().

Referenced by blo_do_versions_280(), and scene_init_data().

◆ BKE_unit_base_scalar()

double BKE_unit_base_scalar ( int  system,
int  type 
)

◆ BKE_unit_closest_scalar()

double BKE_unit_closest_scalar ( double  value,
int  system,
int  type 
)

Definition at line 1236 of file unit.c.

References NULL, bUnitDef::scalar, type, unit_best_fit(), and unit_get_system().

Referenced by ui_get_but_step_unit().

◆ BKE_unit_display_name_get()

const char* BKE_unit_display_name_get ( const void *  usys_pt,
int  index 
)

Definition at line 1294 of file unit.c.

Referenced by ED_scene_grid_scale(), and ED_view3d_grid_view_scale().

◆ BKE_unit_identifier_get()

const char* BKE_unit_identifier_get ( const void *  usys_pt,
int  index 
)

Definition at line 1298 of file unit.c.

References BLI_assert, bUnitDef::identifier, and NULL.

◆ BKE_unit_is_suppressed()

bool BKE_unit_is_suppressed ( const void *  usys_pt,
int  index 
)

Definition at line 1312 of file unit.c.

References B_UNIT_DEF_SUPPRESS.

◆ BKE_unit_is_valid()

bool BKE_unit_is_valid ( int  system,
int  type 
)

Definition at line 1262 of file unit.c.

References B_UNIT_TYPE_TOT, and UNIT_SYSTEM_TOT.

Referenced by bpyunits_validate(), and ui_numedit_apply_snapf().

◆ BKE_unit_name_get()

const char* BKE_unit_name_get ( const void *  usys_pt,
int  index 
)

Definition at line 1290 of file unit.c.

◆ BKE_unit_name_to_alt()

void BKE_unit_name_to_alt ( char *  str,
int  len_max,
const char *  orig_str,
int  system,
int  type 
)

◆ BKE_unit_replace_string()

bool BKE_unit_replace_string ( char *  str,
int  len_max,
const char *  str_prev,
double  scale_pref,
int  system,
int  type 
)

Make a copy of the string that replaces the units with numbers.

This is only used when evaluating user input and can afford to be a bit slower

This is to be used before python evaluation so.. 10.1km -> 10.1*1000.0 ...will be resolved by python.

Values will be split by an add sign. 5'2" -> 5*0.3048 + 2*0.0254

Parameters
str_previs optional, when valid it is used to get a base unit when none is set.
Returns
True of a change was made.

Definition at line 1106 of file unit.c.

References BLI_snprintf(), ch_is_op(), ELEM, is_valid_unit_collection(), bUnitDef::name, bUnitDef::scalar, SEP_CHR, str, TEMP_STR_SIZE, type, unit_detect_from_str(), unit_distribute_negatives(), unit_get_system(), unit_replace(), UNIT_SYSTEM_TOT, and bUnitCollection::units.

Referenced by bpyunits_to_value(), and user_string_to_number().

◆ BKE_unit_scalar_get()

double BKE_unit_scalar_get ( const void *  usys_pt,
int  index 
)

Definition at line 1307 of file unit.c.

Referenced by ED_scene_grid_scale(), and ED_view3d_grid_steps().

◆ BKE_unit_string_contains_unit()

bool BKE_unit_string_contains_unit ( const char *  str,
int  type 
)

◆ BKE_unit_system_get()

void BKE_unit_system_get ( int  system,
int  type,
const void **  r_usys_pt,
int *  r_len 
)

◆ BKE_unit_value_as_string()

size_t BKE_unit_value_as_string ( char *  str,
int  len_max,
double  value,
int  prec,
int  type,
const struct UnitSettings settings,
bool  pad 
)

◆ BKE_unit_value_as_string_adaptive()

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 
)