user interface units, off by default.
- currently only distances work.
- user preferences, edit section to set the units and scale.
- option to display pairs (nicer for imperial display?)
- support for evaluating multiple comma separated values eg: 2',11" ..or.. 5ft, 4mil
- comma separated expressions/values accumulate 1+1,2**3,4cm/3
- attempted fast conversion from a value to a string so button drawing isn't too slow.
* imperial long/short *
- mile, mi
- yard, yd
- foot, '
- inch, "
- thou, mil
* metric long/short *
kilometer, km
meter, m
centimeter, cm
millimeter, mm
micrometer, um
nanometer, nm
picometer, pm
2009-08-11 20:53:01 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
user interface units, off by default.
- currently only distances work.
- user preferences, edit section to set the units and scale.
- option to display pairs (nicer for imperial display?)
- support for evaluating multiple comma separated values eg: 2',11" ..or.. 5ft, 4mil
- comma separated expressions/values accumulate 1+1,2**3,4cm/3
- attempted fast conversion from a value to a string so button drawing isn't too slow.
* imperial long/short *
- mile, mi
- yard, yd
- foot, '
- inch, "
- thou, mil
* metric long/short *
kilometer, km
meter, m
centimeter, cm
millimeter, mm
micrometer, um
nanometer, nm
picometer, pm
2009-08-11 20:53:01 +02:00
|
|
|
*
|
|
|
|
* Contributor(s): Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BKE_UNIT_H
|
|
|
|
#define BKE_UNIT_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 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) */
|
2009-08-13 19:05:27 +02:00
|
|
|
void bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad);
|
user interface units, off by default.
- currently only distances work.
- user preferences, edit section to set the units and scale.
- option to display pairs (nicer for imperial display?)
- support for evaluating multiple comma separated values eg: 2',11" ..or.. 5ft, 4mil
- comma separated expressions/values accumulate 1+1,2**3,4cm/3
- attempted fast conversion from a value to a string so button drawing isn't too slow.
* imperial long/short *
- mile, mi
- yard, yd
- foot, '
- inch, "
- thou, mil
* metric long/short *
kilometer, km
meter, m
centimeter, cm
millimeter, mm
micrometer, um
nanometer, nm
picometer, pm
2009-08-11 20:53:01 +02:00
|
|
|
|
|
|
|
/* replace units with values, used before python button evaluation */
|
2009-08-13 19:05:27 +02:00
|
|
|
int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type);
|
user interface units, off by default.
- currently only distances work.
- user preferences, edit section to set the units and scale.
- option to display pairs (nicer for imperial display?)
- support for evaluating multiple comma separated values eg: 2',11" ..or.. 5ft, 4mil
- comma separated expressions/values accumulate 1+1,2**3,4cm/3
- attempted fast conversion from a value to a string so button drawing isn't too slow.
* imperial long/short *
- mile, mi
- yard, yd
- foot, '
- inch, "
- thou, mil
* metric long/short *
kilometer, km
meter, m
centimeter, cm
millimeter, mm
micrometer, um
nanometer, nm
picometer, pm
2009-08-11 20:53:01 +02:00
|
|
|
|
patch [#23758] Better handling of UTF chars in UNITS fields (lengths, angles, etc.)
from Lorenzo Tozzi (oni_niubbo) with minor edits.
--- from the tracker
The present situation is this: due to bug#22274, during editing, UTF chars are stripped from buttons with a unit associated
(length, angles, etc.).
Example: if the button displays '90°' and you click on it with LMB, the editing string will become '90'.
The problem arises if you use microns: '34µm' becomes '34' that blender interprets as 34 meters. So clicking on a button
and hitting enter won't confirm the previous value, but will change it (very badly also).
Of course nobody is using microns in blender, but the problem will arise when we will implement areas and option 'Separate
Units' will be enabled. The value '2m² 3cm²' will become '2m' during editing.
This patch solves the problem rewriting the string in a smarter way than just stripping the UTF chars: the unit is translated
from unit->name_short ('µm') to unit->name_alt ('um'). So clicking on '34µm' the editing string will become
'34um'.
--- end
note: rather then allowing empty strings in name_alt field I made it so if the unit system was the default one a NULL name_alt will just strip the string, since its the default its not needed.
2010-09-15 19:37:00 +02:00
|
|
|
/* make string keyboard-friendly: 10µm --> 10um */
|
|
|
|
void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type);
|
|
|
|
|
2009-08-12 10:16:10 +02:00
|
|
|
/* the size of the unit used for this value (used for calculating the ckickstep) */
|
2009-08-12 16:11:53 +02:00
|
|
|
double bUnit_ClosestScalar(double value, int system, int type);
|
|
|
|
|
2009-08-12 19:02:03 +02:00
|
|
|
/* base scale for these units */
|
|
|
|
double bUnit_BaseScalar(int system, int type);
|
|
|
|
|
2010-09-16 06:19:22 +02:00
|
|
|
/* return true is the unit system exists */
|
|
|
|
int bUnit_IsValid(int system, int type);
|
|
|
|
|
2009-08-12 16:11:53 +02:00
|
|
|
/* loop over scales, coudl add names later */
|
|
|
|
//double bUnit_Iter(void **unit, char **name, int system, int type);
|
|
|
|
|
|
|
|
void bUnit_GetSystem(void **usys_pt, int *len, int system, int type);
|
|
|
|
char* bUnit_GetName(void *usys_pt, int index);
|
2009-08-17 14:48:56 +02:00
|
|
|
char* bUnit_GetNameDisplay(void *usys_pt, int index);
|
2009-08-12 16:11:53 +02:00
|
|
|
double bUnit_GetScaler(void *usys_pt, int index);
|
|
|
|
|
|
|
|
/* aligned with PropertyUnit */
|
|
|
|
#define B_UNIT_NONE 0
|
|
|
|
#define B_UNIT_LENGTH 1
|
|
|
|
#define B_UNIT_AREA 2
|
|
|
|
#define B_UNIT_VOLUME 3
|
|
|
|
#define B_UNIT_MASS 4
|
|
|
|
#define B_UNIT_ROTATION 5
|
|
|
|
#define B_UNIT_TIME 6
|
|
|
|
#define B_UNIT_VELOCITY 7
|
|
|
|
#define B_UNIT_ACCELERATION 8
|
2010-09-16 06:19:22 +02:00
|
|
|
#define B_UNIT_MAXDEF 9
|
2009-08-12 10:16:10 +02:00
|
|
|
|
user interface units, off by default.
- currently only distances work.
- user preferences, edit section to set the units and scale.
- option to display pairs (nicer for imperial display?)
- support for evaluating multiple comma separated values eg: 2',11" ..or.. 5ft, 4mil
- comma separated expressions/values accumulate 1+1,2**3,4cm/3
- attempted fast conversion from a value to a string so button drawing isn't too slow.
* imperial long/short *
- mile, mi
- yard, yd
- foot, '
- inch, "
- thou, mil
* metric long/short *
kilometer, km
meter, m
centimeter, cm
millimeter, mm
micrometer, um
nanometer, nm
picometer, pm
2009-08-11 20:53:01 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* BKE_UNIT_H */
|