|
Blender V5.0
|
#include <algorithm>#include <cctype>#include <cstdio>#include <cstdlib>#include <cstring>#include "BLI_math_base.h"#include "BLI_string.h"#include "BLI_string_utf8.h"#include "BLI_string_utf8_symbols.h"#include "BLI_sys_types.h"#include "DNA_scene_types.h"#include "BKE_unit.hh"Go to the source code of this file.
Classes | |
| struct | bUnitDef |
| struct | bUnitCollection |
| struct | PreferredUnits |
Macros | |
| #define | TEMP_STR_SIZE 256 |
| #define | SEP_CHR '#' |
| #define | SEP_STR "#" |
| #define | EPS 0.001 |
| #define | UN_SC_KM 1000.0f |
| #define | UN_SC_HM 100.0f |
| #define | UN_SC_DAM 10.0f |
| #define | UN_SC_M 1.0f |
| #define | UN_SC_DM 0.1f |
| #define | UN_SC_CM 0.01f |
| #define | UN_SC_MM 0.001f |
| #define | UN_SC_UM 0.000001f |
| #define | UN_SC_MI 1609.344f |
| #define | UN_SC_FUR 201.168f |
| #define | UN_SC_CH 20.1168f |
| #define | UN_SC_YD 0.9144f |
| #define | UN_SC_FT 0.3048f |
| #define | UN_SC_IN 0.0254f |
| #define | UN_SC_MIL 0.0000254f |
| #define | UN_SC_MTON 1000.0f /* Metric ton. */ |
| #define | UN_SC_QL 100.0f |
| #define | UN_SC_KG 1.0f |
| #define | UN_SC_HG 0.1f |
| #define | UN_SC_DAG 0.01f |
| #define | UN_SC_G 0.001f |
| #define | UN_SC_MG 0.000001f |
| #define | UN_SC_ITON 907.18474f /* Imperial ton. */ |
| #define | UN_SC_CWT 45.359237f |
| #define | UN_SC_ST 6.35029318f |
| #define | UN_SC_LB 0.45359237f |
| #define | UN_SC_OZ 0.028349523125f |
| #define | UN_SC_FAH 0.555555555555f |
| #define | UNIT_COLLECTION_LENGTH(def) |
| #define | NULL_UNIT |
| #define | UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / B_UNIT_TYPE_TOT) / sizeof(void *)) - 1) |
Enumerations | |
| enum | { B_UNIT_DEF_NONE = 0 , B_UNIT_DEF_SUPPRESS = 1 , B_UNIT_DEF_TENTH = 2 , B_UNIT_DEF_CASE_SENSITIVE = 4 , B_UNIT_DEF_NO_SPACE = 8 } |
Functions | |
| static const bUnitCollection * | unit_get_system (int system, int type) |
| static const bUnitDef * | unit_default (const bUnitCollection *usys) |
| static const bUnitDef * | unit_best_fit (double value, const bUnitCollection *usys, const bUnitDef *unit_start, int suppress) |
| static void | unit_dual_convert (double value, const bUnitCollection *usys, bUnitDef const **r_unit_a, bUnitDef const **r_unit_b, double *r_value_a, double *r_value_b, const bUnitDef *main_unit) |
| static size_t | unit_as_string (char *str, int str_maxncpy, double value, int prec, const bool do_rstrip_zero, const bUnitCollection *usys, const bUnitDef *unit, char pad) |
| static bool | unit_should_be_split (int type) |
| static PreferredUnits | preferred_units_from_UnitSettings (const UnitSettings &settings) |
| static size_t | unit_as_string_split_pair (char *str, int str_maxncpy, double value, int prec, const bool do_rstrip_zero, const bUnitCollection *usys, const bUnitDef *main_unit) |
| static bool | is_valid_unit_collection (const bUnitCollection *usys) |
| static const bUnitDef * | get_preferred_display_unit_if_used (int type, const PreferredUnits &units) |
| static size_t | unit_as_string_main (char *str, int str_maxncpy, double value, int prec, int type, bool split, bool pad, const PreferredUnits &units) |
| 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 (char *str, int str_maxncpy, double value, int prec, int type, const UnitSettings &settings, 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) |
| double | BKE_unit_value_scale (const UnitSettings &settings, const int unit_type, double value) |
| BLI_INLINE bool | isalpha_or_utf8 (const int ch) |
| static const char * | unit_find_str (const char *str, const char *substr, bool case_sensitive) |
| static bool | ch_is_op (char op) |
| static bool | ch_is_op_unary (char op) |
| static const char * | find_next_negative (const char *str, const char *remaining_str) |
| static char * | find_next_op (const char *str, char *remaining_str, int remaining_str_maxncpy) |
| static char * | skip_unary_op (char *str) |
| static bool | unit_distribute_negatives (char *str, const int str_maxncpy) |
| static int | find_previous_non_value_char (const char *str, const int start_ofs) |
| static int | find_end_of_value_chars (const char *str, const int str_maxncpy, const int start_ofs) |
| static int | unit_scale_str (char *str, int str_maxncpy, char *str_tmp, double scale_pref, const bUnitDef *unit, const char *replace_str, bool case_sensitive) |
| static int | unit_replace (char *str, int str_maxncpy, char *str_tmp, double scale_pref, const bUnitDef *unit) |
| static bool | unit_find (const char *str, const bUnitDef *unit) |
| static const bUnitDef * | unit_find_in_collection (const bUnitCollection *usys, const char *str) |
| static const bUnitDef * | unit_detect_from_str (const bUnitCollection *usys, const char *str, const char *str_prev) |
| bool | BKE_unit_string_contains_unit (const char *str, int type) |
| double | BKE_unit_apply_preferred_unit (const UnitSettings &settings, int type, double value) |
| bool | BKE_unit_replace_string (char *str, int str_maxncpy, const char *str_prev, double scale_pref, int system, int type) |
| 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) |
| void | BKE_unit_system_get (int system, int type, void const **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) |
| #define EPS 0.001 |
Definition at line 42 of file unit.cc.
Referenced by GHOST_DirectManipulationViewportEventHandler::OnContentUpdated(), and unit_best_fit().
| #define NULL_UNIT |
| #define SEP_CHR '#' |
Definition at line 38 of file unit.cc.
Referenced by BKE_unit_replace_string().
| #define SEP_STR "#" |
Definition at line 39 of file unit.cc.
Referenced by appdir_app_template_directories(), BKE_appdir_folder_caches(), blf_load_datafiles_dir(), blender::gpu::cache_dir_get(), blender::io::obj::OBJMTLParserTest::check(), blender::io::obj::OBJMTLParserTest::check_string(), blender::io::obj::OBJExportRegressionTest::compare_obj_export_to_golden(), blender::io::stl::STLExportTest::compare_to_golden(), blender::io::usd::export_endjob_usdz_cleanup(), filelist_readjob_list_lib_add_datablock(), filelist_readjob_main_assets_add_items(), fsmenu_insert_entry(), fsmenu_xdg_user_dirs_parse(), get_proxy_filepath(), blender::io::stl::STLExportTest::get_temp_filename(), blender::io::obj::ObjExporterWriterTest::get_temp_obj_filename(), blender::io::ply::PLYExportTest::get_temp_ply_filename(), get_thumb_dir(), blender::ed::asset::index::AssetLibraryIndex::init_indices_base_path(), blender::asset_system::AssetRepresentation::library_relative_identifier(), blender::bke::tests::ImageTest::load_image(), blender::asset_system::AssetLibraryService::normalize_asset_weak_reference_relative_asset_identifier(), path_normalize_impl(), blender::gpu::read_spirv_from_disk(), blender::asset_system::AssetLibraryService::resolve_asset_weak_reference_to_full_path(), blender::asset_system::AssetLibraryService::rfind_blendfile_extension(), blender::ed::geometry::run_node_group_get_name(), blender::asset_system::tests::AssetCatalogTest::save_from_memory_into_existing_asset_lib(), blender::seq::seq_proxy_get_filepath(), blender::asset_system::tests::AssetLibraryServiceTest::SetUp(), blender::asset_system::tests::AssetLibraryTestBase::SetUp(), blender::tests::FileOpsTest::SetUp(), strip_sound_proxy_update_cb(), blender::io::usd::temp_textures_dir(), blender::io::obj::TEST(), blender::io::obj::TEST(), blender::io::obj::TEST(), blender::io::obj::TEST(), blender::io::ply::TEST(), blender::tests::TEST(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::asset_system::tests::TEST_F(), blender::bke::tests::TEST_F(), blender::bke::tests::TEST_F(), blender::bke::tests::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::obj::TEST_F(), blender::io::stl::TEST_F(), blender::io::stl::TEST_F(), blender::io::stl::TEST_F(), blender::io::stl::TEST_F(), blender::io::TEST_F(), blender::io::TEST_F(), blender::io::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), TEST_F(), unit_scale_str(), blender::asset_system::tests::AssetLibraryServiceTest::use_temp_path(), blender::asset_system::tests::AssetLibraryTestBase::use_temp_path(), and blender::gpu::write_spirv_to_disk().
| #define TEMP_STR_SIZE 256 |
Definition at line 35 of file unit.cc.
Referenced by BKE_unit_replace_string(), and unit_scale_str().
| #define UNIT_COLLECTION_LENGTH | ( | def | ) |
| #define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / B_UNIT_TYPE_TOT) / sizeof(void *)) - 1) |
Definition at line 1519 of file unit.cc.
Referenced by BKE_unit_is_valid(), BKE_unit_replace_string(), BKE_unit_string_contains_unit(), and unit_get_system().
| anonymous enum |
| 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().
|
static |
Definition at line 1991 of file unit.cc.
Referenced by BKE_unit_replace_string(), find_next_op(), and find_previous_non_value_char().
|
static |
Definition at line 2013 of file unit.cc.
Referenced by skip_unary_op().
|
static |
Helper for unit_scale_str for the process of correctly applying the order of operations for the unit's bias term.
Definition at line 2163 of file unit.cc.
Referenced by unit_scale_str().
|
static |
Helper function for unit_distribute_negatives to find the next negative to distribute.
Definition at line 2031 of file unit.cc.
References ELEM, find_next_negative(), and str.
Referenced by find_next_negative(), and unit_distribute_negatives().
|
static |
Helper function for unit_distribute_negatives to find the next operation, including "-".
Definition at line 2057 of file unit.cc.
References BLI_assert_msg, ch_is_op(), ELEM, i, and str.
Referenced by unit_distribute_negatives().
|
static |
Helper for unit_scale_str for the process of correctly applying the order of operations for the unit's bias term.
Definition at line 2149 of file unit.cc.
References ch_is_op(), i, and str.
Referenced by unit_scale_str().
|
static |
Definition at line 1784 of file unit.cc.
References B_UNIT_AREA, B_UNIT_LENGTH, B_UNIT_MASS, B_UNIT_ROTATION, B_UNIT_TEMPERATURE, B_UNIT_TIME, B_UNIT_VOLUME, is_valid_unit_collection(), bUnitCollection::length, PreferredUnits::length, PreferredUnits::mass, PreferredUnits::rotation, PreferredUnits::system, PreferredUnits::temperature, PreferredUnits::time, unit_get_system(), bUnitCollection::units, USER_UNIT_ADAPTIVE, and USER_UNIT_ROT_RADIANS.
Referenced by BKE_unit_apply_preferred_unit(), and unit_as_string_main().
|
static |
Definition at line 1779 of file unit.cc.
References bUnitDef::name, and bUnitCollection::units.
Referenced by BKE_unit_replace_string(), BKE_unit_string_contains_unit(), get_preferred_display_unit_if_used(), and unit_as_string_main().
| BLI_INLINE bool isalpha_or_utf8 | ( | const int | ch | ) |
|
static |
Definition at line 1731 of file unit.cc.
References PreferredUnits::length, UnitSettings::length_unit, PreferredUnits::mass, UnitSettings::mass_unit, PreferredUnits::rotation, PreferredUnits::system, UnitSettings::system, UnitSettings::system_rotation, PreferredUnits::temperature, UnitSettings::temperature_unit, PreferredUnits::time, and UnitSettings::time_unit.
Referenced by BKE_unit_apply_preferred_unit(), and BKE_unit_value_as_string().
|
static |
Skip over multiple successive unary operators (typically -), skipping spaces. This allows for --90d to be handled properly, see: #117783.
Definition at line 2097 of file unit.cc.
References ch_is_op_unary(), and str.
Referenced by unit_distribute_negatives().
|
static |
Definition at line 1641 of file unit.cc.
References B_UNIT_DEF_NO_SPACE, bUnitDef::bias, BLI_assert, BLI_snprintf_rlen(), CLAMP, bUnitDef::flag, i, integer_digits_d(), len, bUnitDef::name_short, pad, bUnitDef::scalar, str, unit_best_fit(), and unit_default().
Referenced by unit_as_string_main(), and unit_as_string_split_pair().
|
static |
Definition at line 1831 of file unit.cc.
References buDummyCollection, get_preferred_display_unit_if_used(), is_valid_unit_collection(), length(), pad, split(), str, PreferredUnits::system, unit_as_string(), unit_as_string_split_pair(), unit_get_system(), and unit_should_be_split().
Referenced by BKE_unit_value_as_string(), and BKE_unit_value_as_string_adaptive().
|
static |
Definition at line 1743 of file unit.cc.
References BLI_assert, i, integer_digits_d(), max_ii(), bUnitDef::scalar, str, unit_as_string(), and unit_dual_convert().
Referenced by unit_as_string_main().
|
static |
Definition at line 1593 of file unit.cc.
References B_UNIT_DEF_SUPPRESS, B_UNIT_DEF_TENTH, EPS, bUnitDef::name, unit_default(), bUnitCollection::units, and UNLIKELY.
Referenced by BKE_unit_closest_scalar(), unit_as_string(), and unit_dual_convert().
|
static |
Definition at line 1588 of file unit.cc.
References bUnitCollection::base_unit, and bUnitCollection::units.
Referenced by BKE_unit_base_scalar(), unit_as_string(), unit_best_fit(), and unit_detect_from_str().
|
static |
Try to find a default unit from current or previous string. This allows us to handle cases like 2 + 2mm, people would expect to get 4mm, not 2.002m!
Definition at line 2312 of file unit.cc.
References str, unit_default(), and unit_find_in_collection().
Referenced by BKE_unit_replace_string().
|
static |
Put parentheses around blocks of values after negative signs to get rid of an implied "+" between numbers without an operation between them. For example:
"-1m50cm + 1 - 2m50cm" -> "-(1m50cm) + 1 - (2m50cm)"
Definition at line 2111 of file unit.cc.
References find_next_negative(), find_next_op(), skip_unary_op(), and str.
Referenced by BKE_unit_replace_string().
|
static |
Definition at line 1623 of file unit.cc.
References bUnitDef::scalar, and unit_best_fit().
Referenced by unit_as_string_split_pair().
|
static |
Definition at line 2277 of file unit.cc.
References B_UNIT_DEF_CASE_SENSITIVE, bUnitDef::flag, bUnitDef::name, bUnitDef::name_alt, bUnitDef::name_plural, bUnitDef::name_short, str, and unit_find_str().
Referenced by unit_find_in_collection().
|
static |
Definition at line 2296 of file unit.cc.
References bUnitDef::name, str, unit_find(), and bUnitCollection::units.
Referenced by BKE_unit_string_contains_unit(), and unit_detect_from_str().
|
static |
Definition at line 1938 of file unit.cc.
References BLI_str_find_prev_char_utf8(), BLI_strcasestr(), isalpha_or_utf8(), and str.
Referenced by BKE_unit_name_to_alt(), unit_find(), and unit_scale_str().
|
static |
Definition at line 1581 of file unit.cc.
References B_UNIT_TYPE_TOT, BLI_assert, bUnitSystems, and UNIT_SYSTEM_TOT.
Referenced by BKE_unit_base_of_type_get(), BKE_unit_base_scalar(), BKE_unit_closest_scalar(), BKE_unit_name_to_alt(), BKE_unit_replace_string(), BKE_unit_string_contains_unit(), BKE_unit_system_get(), get_preferred_display_unit_if_used(), and unit_as_string_main().
|
static |
Definition at line 2261 of file unit.cc.
References B_UNIT_DEF_CASE_SENSITIVE, bUnitDef::flag, bUnitDef::name, bUnitDef::name_alt, bUnitDef::name_plural, bUnitDef::name_short, str, and unit_scale_str().
Referenced by BKE_unit_replace_string().
|
static |
Definition at line 2174 of file unit.cc.
References bUnitDef::bias, BLI_snprintf_rlen(), find_end_of_value_chars(), find_previous_non_value_char(), len, bUnitDef::scalar, SEP_STR, str, TEMP_STR_SIZE, and unit_find_str().
Referenced by unit_replace().
|
static |
Definition at line 1716 of file unit.cc.
References B_UNIT_CAMERA, B_UNIT_LENGTH, B_UNIT_MASS, B_UNIT_TIME, B_UNIT_WAVELENGTH, and ELEM.
Referenced by unit_as_string_main().
|
static |
|
static |
|
static |
|
static |
Definition at line 167 of file unit.cc.
Referenced by unit_as_string_main().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 1520 of file unit.cc.
Referenced by unit_get_system().
|
static |
|
static |