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