|
Blender V5.0
|
#include "BLI_sys_types.h"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_TIME_ABSOLUTE = 7 , B_UNIT_VELOCITY = 8 , B_UNIT_ACCELERATION = 9 , B_UNIT_CAMERA = 10 , B_UNIT_POWER = 11 , B_UNIT_TEMPERATURE = 12 , B_UNIT_WAVELENGTH = 13 , B_UNIT_COLOR_TEMPERATURE = 14 , B_UNIT_FREQUENCY = 15 , B_UNIT_TYPE_TOT = 16 } |
Functions | |
| size_t | BKE_unit_value_as_string (char *str, int str_maxncpy, double value, int prec, int type, const UnitSettings &settings, bool pad) |
| 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) |
| size_t | BKE_unit_value_as_string_scaled (char *str, int str_maxncpy, double value, int prec, int type, const UnitSettings &settings, bool pad) |
| bool | BKE_unit_replace_string (char *str, int str_maxncpy, 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 UnitSettings &settings, int type, double value) |
| void | BKE_unit_name_to_alt (char *str, int str_maxncpy, 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) |
| double | BKE_unit_value_scale (const UnitSettings &settings, int unit_type, double value) |
| 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) |
| anonymous enum |
Aligned with PropertyUnit and bpyunits_ucategories_items in bpy_utils_units.cc.
Definition at line 135 of file BKE_unit.hh.
| double BKE_unit_apply_preferred_unit | ( | const UnitSettings & | settings, |
| int | type, | ||
| double | value ) |
If user does not specify a unit, this converts it to the unit from the settings.
Definition at line 2345 of file unit.cc.
References bUnitDef::bias, BKE_unit_base_scalar(), get_preferred_display_unit_if_used(), preferred_units_from_UnitSettings(), bUnitDef::scalar, and PreferredUnits::system.
Referenced by user_string_to_number().
| int BKE_unit_base_get | ( | const void * | usys_pt | ) |
Definition at line 2532 of file unit.cc.
Referenced by ED_scene_grid_scale(), and view3d_grid_steps_ex().
| int BKE_unit_base_of_type_get | ( | int | system, |
| int | type ) |
Definition at line 2537 of file unit.cc.
References bUnitCollection::base_unit, and unit_get_system().
Referenced by blo_do_versions_280(), and scene_init_data().
| double BKE_unit_base_scalar | ( | int | system, |
| int | type ) |
Base scale for these units.
Definition at line 2504 of file unit.cc.
References bUnitDef::scalar, unit_default(), and unit_get_system().
Referenced by BKE_unit_apply_preferred_unit(), and ui_numedit_apply_snapf().
| double BKE_unit_closest_scalar | ( | double | value, |
| int | system, | ||
| int | type ) |
The size of the unit used for this value (used for calculating the click-step).
Definition at line 2488 of file unit.cc.
References bUnitDef::scalar, unit_best_fit(), and unit_get_system().
Referenced by ui_get_but_step_unit().
| const char * BKE_unit_display_name_get | ( | const void * | usys_pt, |
| int | index ) |
Definition at line 2548 of file unit.cc.
References BLI_assert, bUnitCollection::length, bUnitDef::name_display, and bUnitCollection::units.
Referenced by ED_scene_grid_scale(), and ED_view3d_grid_view_scale().
| const char * BKE_unit_identifier_get | ( | const void * | usys_pt, |
| int | index ) |
Definition at line 2554 of file unit.cc.
References BLI_assert, BLI_assert_msg, bUnitDef::identifier, bUnitCollection::length, and bUnitCollection::units.
| bool BKE_unit_is_suppressed | ( | const void * | usys_pt, |
| int | index ) |
Definition at line 2572 of file unit.cc.
References B_UNIT_DEF_SUPPRESS, BLI_assert, bUnitDef::flag, bUnitCollection::length, and bUnitCollection::units.
| bool BKE_unit_is_valid | ( | int | system, |
| int | type ) |
Definition at line 2514 of file unit.cc.
References B_UNIT_TYPE_TOT, and UNIT_SYSTEM_TOT.
Referenced by bpyunits_validate(), and ui_numedit_apply_snapf().
| const char * BKE_unit_name_get | ( | const void * | usys_pt, |
| int | index ) |
Definition at line 2542 of file unit.cc.
References BLI_assert, bUnitCollection::length, bUnitDef::name, and bUnitCollection::units.
| void BKE_unit_name_to_alt | ( | char * | str, |
| int | str_maxncpy, | ||
| const char * | orig_str, | ||
| int | system, | ||
| int | type ) |
Make string keyboard-friendly, e.g: 10µm -> 10um.
Definition at line 2447 of file unit.cc.
References B_UNIT_DEF_CASE_SENSITIVE, BLI_assert, BLI_strncpy(), BLI_strncpy_rlen(), bUnitDef::name, str, unit_find_str(), unit_get_system(), and bUnitCollection::units.
Referenced by bpyunits_to_string(), and ui_but_convert_to_unit_alt_name().
| bool BKE_unit_replace_string | ( | char * | str, |
| int | str_maxncpy, | ||
| const char * | str_prev, | ||
| double | scale_pref, | ||
| int | system, | ||
| int | type ) |
Replace units with values, used before python button evaluation.
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
| str_prev | is optional, when valid it is used to get a base unit when none is set. |
Definition at line 2357 of file unit.cc.
References BLI_strncpy(), ch_is_op(), ELEM, is_valid_unit_collection(), bUnitDef::name, bUnitDef::scalar, SEP_CHR, SNPRINTF, str, TEMP_STR_SIZE, 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().
| double BKE_unit_scalar_get | ( | const void * | usys_pt, |
| int | index ) |
Definition at line 2565 of file unit.cc.
References BLI_assert, bUnitCollection::length, bUnitDef::scalar, and bUnitCollection::units.
Referenced by ED_scene_grid_scale(), and view3d_grid_steps_ex().
| bool BKE_unit_string_contains_unit | ( | const char * | str, |
| int | type ) |
Definition at line 2331 of file unit.cc.
References is_valid_unit_collection(), str, unit_find_in_collection(), unit_get_system(), and UNIT_SYSTEM_TOT.
Referenced by user_string_to_number().
| void BKE_unit_system_get | ( | int | system, |
| int | type, | ||
| const void ** | r_usys_pt, | ||
| int * | r_len ) |
Loop over scales, could add names later.
Definition at line 2519 of file unit.cc.
References bUnitCollection::length, and unit_get_system().
Referenced by ED_scene_grid_scale(), and view3d_grid_steps_ex().
| size_t BKE_unit_value_as_string | ( | char * | str, |
| int | str_maxncpy, | ||
| double | value, | ||
| int | prec, | ||
| int | type, | ||
| const UnitSettings & | settings, | ||
| bool | pad ) |
Representation of a value in units.
| prec | Decimal places to show, Use a negative number to prevent trailing zeros being stripped. |
| pad | When true & prec is positive, stripped zeroes will be replaced with a space instead of being removed. |
Definition at line 1882 of file unit.cc.
References UnitSettings::flag, pad, preferred_units_from_UnitSettings(), str, unit_as_string_main(), and USER_UNIT_OPT_SPLIT.
Referenced by BKE_unit_value_as_string_scaled(), depthdropper_depth_sample_pt(), edbm_inset_update_header(), format_unit_value(), knifetool_draw_angle(), ruler_item_as_string(), and ui_get_but_string_unit().
| 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 ) |
Humanly readable representation of a value in units (used for button drawing).
Representation of a value in units.
| prec | Decimal places to show, Use a negative number to prevent trailing zeros being stripped. |
| pad | When true & prec is positive, stripped zeroes will be replaced with a space instead of being removed. |
Definition at line 1869 of file unit.cc.
References PreferredUnits::length, PreferredUnits::mass, pad, PreferredUnits::rotation, split(), str, PreferredUnits::system, PreferredUnits::temperature, PreferredUnits::time, unit_as_string_main(), and USER_UNIT_ADAPTIVE.
Referenced by bpyunits_to_string(), outputNumInput(), and value_to_editstr().
| size_t BKE_unit_value_as_string_scaled | ( | char * | str, |
| int | str_maxncpy, | ||
| double | value, | ||
| int | prec, | ||
| int | type, | ||
| const UnitSettings & | settings, | ||
| bool | pad ) |
A version of BKE_unit_value_as_string with the value scaled by BKE_unit_value_scale.
Representation of a value in units.
| prec | Decimal places to show, Use a negative number to prevent trailing zeros being stripped. |
| pad | When true & prec is positive, stripped zeroes will be replaced with a space instead of being removed. |
Definition at line 1895 of file unit.cc.
References BKE_unit_value_as_string(), BKE_unit_value_scale(), pad, and str.
Referenced by blender::ed::transform::applyShrinkFatten(), DRW_text_edit_mesh_measure_stats(), edbm_bevel_update_status_text(), knifetool_draw_visible_distances(), ruler_item_as_string(), blender::ed::transform::translate_dist_to_str(), and blender::ed::object::voxel_size_edit_draw().
| double BKE_unit_value_scale | ( | const UnitSettings & | settings, |
| int | unit_type, | ||
| double | value ) |
Apply the needed correction factor to value, based on unit_type (only length-related are affected currently) and unit->scale_length.
Definition at line 1907 of file unit.cc.
References B_UNIT_ACCELERATION, B_UNIT_AREA, B_UNIT_CAMERA, B_UNIT_LENGTH, B_UNIT_MASS, B_UNIT_POWER, B_UNIT_VELOCITY, B_UNIT_VOLUME, B_UNIT_WAVELENGTH, pow, UnitSettings::scale_length, UnitSettings::system, and USER_UNIT_NONE.
Referenced by BKE_unit_value_as_string_scaled(), format_unit_value(), outputNumInput(), ui_get_but_scale_unit(), and user_string_to_number().