2011-11-09 13:25:49 +00:00
|
|
|
/**
|
|
|
|
* @file lengthpcb.h
|
|
|
|
* @brief Length definitions for PCBNEW.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LENGTHPCB_H_INCLUDED
|
|
|
|
#define LENGTHPCB_H_INCLUDED 1
|
|
|
|
|
|
|
|
#ifdef KICAD_NANOMETRE
|
|
|
|
#include "length.h"
|
|
|
|
|
|
|
|
/* switched type! */
|
|
|
|
typedef LENGTH< LIMITED_INT< int >, 1 > LENGTH_PCB;
|
|
|
|
typedef LENGTH< double, 1 > LENGTH_PCB_DBL;
|
|
|
|
|
|
|
|
/* Transition macros. they are used for unit conversion between
|
|
|
|
* nanometre scale and old (0.1 mil) scale */
|
|
|
|
|
|
|
|
#define PCB_LEGACY_INCH_SCALE 10000
|
|
|
|
#define PCB_LEGACY_UNIT( T ) ( LENGTH_UNITS< T >::inch() / PCB_LEGACY_INCH_SCALE )
|
|
|
|
|
|
|
|
#define TO_LEGACY_LU( x ) \
|
|
|
|
( LENGTH_PCB( x ) / PCB_LEGACY_UNIT( LENGTH_PCB ) )
|
|
|
|
#define TO_LEGACY_LU_DBL( x ) \
|
|
|
|
( LENGTH_PCB_DBL( x ) / PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) )
|
|
|
|
|
|
|
|
static LENGTH_PCB from_legacy_lu( int x ) {
|
|
|
|
return x * PCB_LEGACY_UNIT( LENGTH_PCB );
|
|
|
|
}
|
|
|
|
static LENGTH_PCB from_legacy_lu( double x ) {
|
|
|
|
return LENGTH_PCB( x * PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static LENGTH_PCB_DBL from_legacy_lu_dbl( double x ) {
|
|
|
|
return x * LENGTH_UNITS< LENGTH_PCB_DBL >::inch() / PCB_LEGACY_INCH_SCALE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FROM_LEGACY_LU( x ) ( from_legacy_lu( x ) )
|
|
|
|
#define FROM_LEGACY_LU_DBL( x ) ( from_legacy_lu_dbl( x ) )
|
|
|
|
|
2011-11-09 17:35:16 +00:00
|
|
|
#define ZERO_LENGTH ( LENGTH_PCB::zero() )
|
|
|
|
|
2011-11-09 13:25:49 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
typedef int LENGTH_PCB;
|
|
|
|
typedef double LENGTH_PCB_DBL;
|
|
|
|
|
|
|
|
/* transition macro stubs */
|
|
|
|
|
|
|
|
#define TO_LEGACY_LU( x ) ( x )
|
|
|
|
#define TO_LEGACY_LU_DBL( x ) ( double( x ) )
|
|
|
|
|
|
|
|
#define FROM_LEGACY_LU( x ) ( x )
|
|
|
|
#define FROM_LEGACY_LU_DBL( x ) ( double( x ) )
|
|
|
|
|
2011-11-09 17:35:16 +00:00
|
|
|
#define ZERO_LENGTH 0
|
|
|
|
|
2011-11-09 13:25:49 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* def LENGTHPCB_H_INCLUDED */
|