Blender  V2.59
BKE_unit.h
Go to the documentation of this file.
00001 /*
00002  *
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * Contributor(s): Campbell Barton
00020  *
00021  * ***** END GPL LICENSE BLOCK *****
00022  */
00023 
00024 #ifndef BKE_UNIT_H
00025 #define BKE_UNIT_H
00026 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00035 /* in all cases the value is assumed to be scaled by the user preference */
00036 
00037 /* humanly readable representation of a value in units (used for button drawing) */
00038 void    bUnit_AsString(char *str, int len_max, double value, int prec, int system, int type, int split, int pad);
00039 
00040 /* replace units with values, used before python button evaluation */
00041 int             bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pref, int system, int type);
00042 
00043 /* make string keyboard-friendly: 10µm --> 10um */
00044 void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type);
00045 
00046 /* the size of the unit used for this value (used for calculating the ckickstep) */
00047 double bUnit_ClosestScalar(double value, int system, int type);
00048 
00049 /* base scale for these units */
00050 double bUnit_BaseScalar(int system, int type);
00051 
00052 /* return true is the unit system exists */
00053 int bUnit_IsValid(int system, int type);
00054 
00055 /* loop over scales, coudl add names later */
00056 //double bUnit_Iter(void **unit, char **name, int system, int type);
00057 
00058 void            bUnit_GetSystem(void **usys_pt, int *len, int system, int type);
00059 int                     bUnit_GetBaseUnit(void *usys_pt);
00060 const char*     bUnit_GetName(void *usys_pt, int index);
00061 const char*     bUnit_GetNameDisplay(void *usys_pt, int index);
00062 double          bUnit_GetScaler(void *usys_pt, int index);
00063 
00064 /* aligned with PropertyUnit */
00065 #define         B_UNIT_NONE 0
00066 #define         B_UNIT_LENGTH 1
00067 #define         B_UNIT_AREA 2
00068 #define         B_UNIT_VOLUME 3
00069 #define         B_UNIT_MASS 4
00070 #define         B_UNIT_ROTATION 5
00071 #define         B_UNIT_TIME 6
00072 #define         B_UNIT_VELOCITY 7
00073 #define         B_UNIT_ACCELERATION 8
00074 #define         B_UNIT_TYPE_TOT 9
00075 
00076 #ifdef __cplusplus
00077 }
00078 #endif
00079 
00080 #endif /* BKE_UNIT_H */