diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-09 16:41:15 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-09 16:41:15 +0300 |
commit | 842f52d418aaccae45c8e400eb0a8bddef0dbb51 (patch) | |
tree | 800dc6f6db8b2dbf4d2c4c78713e79bdce6d025c /source/blender/editors | |
parent | 6dc7266cf1f4ee4e6e6eaa7e4949fcff11372479 (diff) |
Cleanup: Rename public "bUnit" functions
This commit renames the functions in "BKE_unit.h` to be consistent
with the naming in the rest of blenkernel.
bUnit_AsString -> BKE_unit_value_as_string_adaptive
bUnit_AsString2 -> BKE_unit_value_as_string
bUnit_ReplaceString -> BKE_unit_replace_string
bUnit_ApplyPreferredUnit -> BKE_unit_apply_preferred_unit
bUnit_ToUnitAltName -> BKE_unit_name_to_alt
bUnit_ClosestScalar -> BKE_unit_closest_scalar
bUnit_BaseScalar -> BKE_unit_base_scalar
bUnit_IsValid -> BKE_unit_is_valid
bUnit_GetSystem -> BKE_unit_system_get
bUnit_GetBaseUnit -> BKE_unit_base_get
bUnit_GetBaseUnitOfType -> BKE_unit_base_of_type_get
bUnit_GetName -> BKE_unit_name_get
bUnit_GetNameDisplay -> BKE_unit_display_name_get
bUnit_GetIdentifier -> BKE_unit_identifier_get
bUnit_GetScaler -> BKE_unit_scalar_get
bUnit_IsSuppressed -> BKE_unit_is_suppressed
Differential Revision: https://developer.blender.org/D8828
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface.c | 21 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_eyedropper_depth.c | 14 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_bevel.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 18 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_gizmo_ruler.c | 16 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_mode_translate.c | 28 | ||||
-rw-r--r-- | source/blender/editors/util/numinput.c | 40 |
8 files changed, 78 insertions, 77 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index ce9db09e340..0bd4934dd0f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2571,7 +2571,7 @@ void ui_but_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) orig_str = BLI_strdup(str); - bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type)); + BKE_unit_name_to_alt(str, maxlen, orig_str, unit->system, RNA_SUBTYPE_UNIT_VALUE(unit_type)); MEM_freeN(orig_str); } @@ -2606,13 +2606,13 @@ static void ui_get_but_string_unit( precision = float_precision; } - bUnit_AsString2(str, - len_max, - ui_get_but_scale_unit(but, value), - precision, - RNA_SUBTYPE_UNIT_VALUE(unit_type), - unit, - pad); + BKE_unit_value_as_string(str, + len_max, + ui_get_but_scale_unit(but, value), + precision, + RNA_SUBTYPE_UNIT_VALUE(unit_type), + unit, + pad); } static float ui_get_but_step_unit(uiBut *but, float step_default) @@ -2622,12 +2622,13 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) /* Scaling up 'step_origg ' here is a bit arbitrary, * its just giving better scales from user POV */ const double scale_step = ui_get_but_scale_unit(but, step_orig * 10); - const double step = bUnit_ClosestScalar(scale_step, but->block->unit->system, unit_type); + const double step = BKE_unit_closest_scalar(scale_step, but->block->unit->system, unit_type); /* -1 is an error value */ if (step != -1.0) { const double scale_unit = ui_get_but_scale_unit(but, 1.0); - const double step_unit = bUnit_ClosestScalar(scale_unit, but->block->unit->system, unit_type); + const double step_unit = BKE_unit_closest_scalar( + scale_unit, but->block->unit->system, unit_type); double step_final; BLI_assert(step > 0.0); diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index fbc0ed1fc1f..ead65a62226 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -193,13 +193,13 @@ static void depthdropper_depth_sample_pt( *r_depth = len_v3v3(view_co, co_align); - bUnit_AsString2(ddr->name, - sizeof(ddr->name), - (double)*r_depth, - 4, - B_UNIT_LENGTH, - &scene->unit, - false); + BKE_unit_value_as_string(ddr->name, + sizeof(ddr->name), + (double)*r_depth, + 4, + B_UNIT_LENGTH, + &scene->unit, + false); } else { BLI_strncpy(ddr->name, "Nothing under cursor", sizeof(ddr->name)); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a4042ab8265..6a6914daf47 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4614,8 +4614,8 @@ static float ui_numedit_apply_snapf( UnitSettings *unit = but->block->unit; const int unit_type = RNA_SUBTYPE_UNIT_VALUE(UI_but_unit_type_get(but)); - if (bUnit_IsValid(unit->system, unit_type)) { - fac = (float)bUnit_BaseScalar(unit->system, unit_type); + if (BKE_unit_is_valid(unit->system, unit_type)) { + fac = (float)BKE_unit_base_scalar(unit->system, unit_type); if (ELEM(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) { fac /= unit->scale_length; } diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index dd4b8146154..a90d6530453 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -158,13 +158,13 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) } else { double offset_val = (double)RNA_float_get(op->ptr, "offset"); - bUnit_AsString2(offset_str, - NUM_STR_REP_LEN, - offset_val * sce->unit.scale_length, - 3, - B_UNIT_LENGTH, - &sce->unit, - true); + BKE_unit_value_as_string(offset_str, + NUM_STR_REP_LEN, + offset_val * sce->unit.scale_length, + 3, + B_UNIT_LENGTH, + &sce->unit, + true); } prop = RNA_struct_find_property(op->ptr, "offset_type"); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 6cd940244b4..da44815b31a 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -879,14 +879,14 @@ float ED_scene_grid_scale(const Scene *scene, const char **r_grid_unit) const void *usys; int len; - bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len); + BKE_unit_system_get(scene->unit.system, B_UNIT_LENGTH, &usys, &len); if (usys) { - int i = bUnit_GetBaseUnit(usys); + int i = BKE_unit_base_get(usys); if (r_grid_unit) { - *r_grid_unit = bUnit_GetNameDisplay(usys, i); + *r_grid_unit = BKE_unit_display_name_get(usys, i); } - return (float)bUnit_GetScaler(usys, i) / scene->unit.scale_length; + return (float)BKE_unit_scalar_get(usys, i) / scene->unit.scale_length; } } @@ -906,20 +906,20 @@ void ED_view3d_grid_steps(const Scene *scene, { const void *usys; int i, len; - bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len); + BKE_unit_system_get(scene->unit.system, B_UNIT_LENGTH, &usys, &len); float grid_scale = v3d->grid; BLI_assert(STEPS_LEN >= len); if (usys) { if (rv3d->view == RV3D_VIEW_USER) { /* Skip steps */ - len = bUnit_GetBaseUnit(usys) + 1; + len = BKE_unit_base_get(usys) + 1; } grid_scale /= scene->unit.scale_length; for (i = 0; i < len; i++) { - r_grid_steps[i] = (float)bUnit_GetScaler(usys, len - 1 - i) * grid_scale; + r_grid_steps[i] = (float)BKE_unit_scalar_get(usys, len - 1 - i) * grid_scale; } for (; i < STEPS_LEN; i++) { /* Fill last slots */ @@ -971,10 +971,10 @@ float ED_view3d_grid_view_scale(Scene *scene, if (r_grid_unit) { const void *usys; int len; - bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len); + BKE_unit_system_get(scene->unit.system, B_UNIT_LENGTH, &usys, &len); if (usys) { - *r_grid_unit = bUnit_GetNameDisplay(usys, len - i - 1); + *r_grid_unit = BKE_unit_display_name_get(usys, len - i - 1); } } } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 5aba1fecc53..990b7952e39 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -179,7 +179,7 @@ static void ruler_item_as_string( BLI_snprintf(numstr, numstr_size, "%.*f°", prec, RAD2DEGF(ruler_angle)); } else { - bUnit_AsString2( + BKE_unit_value_as_string( numstr, numstr_size, (double)ruler_angle, prec, B_UNIT_ROTATION, unit, false); } } @@ -190,13 +190,13 @@ static void ruler_item_as_string( BLI_snprintf(numstr, numstr_size, "%.*f", prec, ruler_len); } else { - bUnit_AsString2(numstr, - numstr_size, - (double)(ruler_len * unit->scale_length), - prec, - B_UNIT_LENGTH, - unit, - false); + BKE_unit_value_as_string(numstr, + numstr_size, + (double)(ruler_len * unit->scale_length), + prec, + B_UNIT_LENGTH, + unit, + false); } } } diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index 36be26049d3..866b9d921c8 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -89,13 +89,13 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ dist = len_v3(vec); if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) { for (int i = 0; i < 3; i++) { - bUnit_AsString2(&tvec[NUM_STR_REP_LEN * i], - NUM_STR_REP_LEN, - dvec[i] * t->scene->unit.scale_length, - 4, - B_UNIT_LENGTH, - &t->scene->unit, - true); + BKE_unit_value_as_string(&tvec[NUM_STR_REP_LEN * i], + NUM_STR_REP_LEN, + dvec[i] * t->scene->unit.scale_length, + 4, + B_UNIT_LENGTH, + &t->scene->unit, + true); } } else { @@ -106,13 +106,13 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ } if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) { - bUnit_AsString2(distvec, - sizeof(distvec), - dist * t->scene->unit.scale_length, - 4, - B_UNIT_LENGTH, - &t->scene->unit, - false); + BKE_unit_value_as_string(distvec, + sizeof(distvec), + dist * t->scene->unit.scale_length, + 4, + B_UNIT_LENGTH, + &t->scene->unit, + false); } else if (dist > 1e10f || dist < -1e10f) { /* prevent string buffer overflow */ diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index f8e3dda0ed3..ba22bcca0e1 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -136,14 +136,14 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings) BLI_strncpy(val, "Invalid", sizeof(val)); } else { - bUnit_AsString(val, - sizeof(val), - (double)(n->val[i] * fac), - prec, - n->unit_sys, - n->unit_type[i], - true, - false); + BKE_unit_value_as_string_adaptive(val, + sizeof(val), + (double)(n->val[i] * fac), + prec, + n->unit_sys, + n->unit_type[i], + true, + false); } /* +1 because of trailing '\0' */ @@ -165,7 +165,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings) } else { char tstr[NUM_STR_REP_LEN]; - bUnit_AsString( + BKE_unit_value_as_string_adaptive( tstr, ln, (double)n->val[i], prec, n->unit_sys, n->unit_type[i], true, false); BLI_snprintf(&str[j * ln], ln, "%s%s%s", cur, tstr, cur); } @@ -252,14 +252,14 @@ bool applyNumInput(NumInput *n, float *vec) static void value_to_editstr(NumInput *n, int idx) { const int prec = 6; /* editing, higher precision needed. */ - n->str_cur = bUnit_AsString(n->str, - NUM_STR_REP_LEN, - (double)n->val[idx], - prec, - n->unit_sys, - n->unit_type[idx], - true, - false); + n->str_cur = BKE_unit_value_as_string_adaptive(n->str, + NUM_STR_REP_LEN, + (double)n->val[idx], + prec, + n->unit_sys, + n->unit_type[idx], + true, + false); } static bool editstr_insert_at_cursor(NumInput *n, const char *buf, const int buf_len) @@ -288,17 +288,17 @@ bool user_string_to_number(bContext *C, { #ifdef WITH_PYTHON double unit_scale = BKE_scene_unit_scale(unit, type, 1.0); - if (bUnit_ContainsUnit(str, type)) { + if (BKE_unit_string_contains_unit(str, type)) { char str_unit_convert[256]; BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); - bUnit_ReplaceString( + BKE_unit_replace_string( str_unit_convert, sizeof(str_unit_convert), str, unit_scale, unit->system, type); return BPY_run_string_as_number(C, NULL, str_unit_convert, error_prefix, r_value); } int success = BPY_run_string_as_number(C, NULL, str, error_prefix, r_value); - *r_value = bUnit_ApplyPreferredUnit(unit, type, *r_value); + *r_value = BKE_unit_apply_preferred_unit(unit, type, *r_value); *r_value /= unit_scale; return success; |