69 constexpr
double GERB_IU_PER_MM = 1e5;
70 constexpr
double PCB_IU_PER_MM = 1e6;
71 constexpr
double PL_IU_PER_MM = 1e3;
72 constexpr
double SCH_IU_PER_MM = 1e4;
75 #if defined(PCBNEW) || defined(CVPCB)
76 constexpr
double IU_PER_MM = PCB_IU_PER_MM;
77 #elif defined(GERBVIEW)
78 constexpr
double IU_PER_MM = GERB_IU_PER_MM;
79 #elif defined(PL_EDITOR)
80 constexpr
double IU_PER_MM = PL_IU_PER_MM;
81 #elif defined(EESCHEMA)
82 constexpr
double IU_PER_MM = SCH_IU_PER_MM;
88 constexpr
double IU_PER_MILS = (IU_PER_MM * 0.0254);
90 constexpr
inline int Mils2iu(
int mils )
92 double x = mils * IU_PER_MILS;
93 return int( x < 0 ? x - 0.5 : x + 0.5 );
97 constexpr
inline int Iu2Mils(
int iu )
99 double mils = iu / IU_PER_MILS;
101 return static_cast< int >( mils < 0 ? mils - 0.5 : mils + 0.5 );
104 constexpr
inline double Iu2Mils(
int iu )
106 double mils = iu / IU_PER_MILS;
108 return static_cast< int >( mils < 0 ? mils - 0.5 : mils + 0.5 );
113 constexpr
double MM_PER_IU = ( 1 / IU_PER_MM );
116 constexpr
inline int Millimeter2iu(
double mm )
118 return (
int) ( mm < 0 ? mm * IU_PER_MM - 0.5 : mm * IU_PER_MM + 0.5 );
122 constexpr
inline double Iu2Millimeter(
int iu )
124 return iu / IU_PER_MM;
138 constexpr
int ARC_LOW_DEF = Millimeter2iu( 0.02 );
139 constexpr
int ARC_HIGH_DEF = Millimeter2iu( 0.005 );
142 constexpr
double PCB_IU_PER_MILS = (PCB_IU_PER_MM * 0.0254);
143 constexpr
double SCH_IU_PER_MILS = (SCH_IU_PER_MM * 0.0254);
145 constexpr
inline int SchMils2iu(
double mils )
147 double x = mils * SCH_IU_PER_MILS;
148 return int( x < 0 ? x - 0.5 : x + 0.5 );
150 constexpr
inline double SchIu2Mils(
int iu )
152 return iu / SCH_IU_PER_MILS;
155 constexpr
inline int PcbMm2iu(
double mm )
157 return (
int) ( mm < 0 ? mm * PCB_IU_PER_MM - 0.5 : mm * PCB_IU_PER_MM + 0.5 );
159 constexpr
inline double PcbIu2mm(
int iu )
161 return iu / PCB_IU_PER_MM;