Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2018-10-03 11:20:16 +0300
committerJacques Lucke <mail@jlucke.com>2018-10-03 11:20:16 +0300
commit2d21eb79ad48485bc7b3385d6df5c2c25fd88ee0 (patch)
tree57d18e1020c8acc2d46110bd43c0721dc30b7d76 /source/blender/blenkernel/BKE_unit.h
parent1c3411ac899d1ae8dfd790249a53054698bdd1e8 (diff)
Units: Support for fixed units
Users can select the main unit they want to use now. Previously the displayed unit always depended on the magnitude of the value. The old behavior can be restored by switching to the "Adaptive" mode for length, mass and time units. Meters, kilograms and seconds are the default units for new and old scenes. The selected unit is also the default unit for user input. E.g. if cm is selected, whenever the user inputs a unitless number into a field of type length, it will be interpreted as cm. Reviewer: brecht Differential: https://developer.blender.org/D3740
Diffstat (limited to 'source/blender/blenkernel/BKE_unit.h')
-rw-r--r--source/blender/blenkernel/BKE_unit.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index 82a4659eec7..bb7fb006038 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -31,14 +31,23 @@
extern "C" {
#endif
+struct UnitSettings;
+
/* in all cases the value is assumed to be scaled by the user preference */
/* humanly readable representation of a value in units (used for button drawing) */
-size_t bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, bool split, bool pad);
+size_t bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, bool split, bool pad);
+size_t bUnit_AsString2(char *str, int len_max, double value, int prec, int type, const struct UnitSettings *settings, bool pad);
/* replace units with values, used before python button evaluation */
bool bUnit_ReplaceString(char *str, int len_max, const char *str_prev, double scale_pref, int system, int type);
+/* return true if the string contains any valid unit for the given type */
+bool bUnit_ContainsUnit(const char *str, int system, int type);
+
+/* if user does not specify a unit, multiply with this value */
+double bUnit_PreferredUnitScalar(const struct UnitSettings *settings, int type);
+
/* make string keyboard-friendly: 10µm --> 10um */
void bUnit_ToUnitAltName(char *str, int len_max, const char *orig_str, int system, int type);
@@ -56,9 +65,11 @@ bool bUnit_IsValid(int system, int type);
void bUnit_GetSystem(int system, int type, void const **r_usys_pt, int *r_len);
int bUnit_GetBaseUnit(const void *usys_pt);
+int bUnit_GetBaseUnitOfType(int system, int type);
const char *bUnit_GetName(const void *usys_pt, int index);
const char *bUnit_GetNameDisplay(const void *usys_pt, int index);
double bUnit_GetScaler(const void *usys_pt, int index);
+bool bUnit_IsSuppressed(const void *usys_pt, int index);
/* aligned with PropertyUnit */
enum {