Commit 4b9b2f4e authored by Vladimir Ur's avatar Vladimir Ur

Nanometric work. Design rules, D_PAD (except m_Pos) is now in new units....

Nanometric work. Design rules, D_PAD (except m_Pos) is now in new units. Metric files can be loaded w/o KICAD_NANOMETRE flag set but saved only with this flag, this could help to gain some compatibility during transition process. ifdef'd code is somewhat minimized by using transition macros. Some potential code bugs are commented.
parents 6f3aa6ac 6ebb044d
......@@ -903,8 +903,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
int color;
scale = g_Parm_3D_Visu.m_BoardScale;
holeX = (double) m_Drill.x * scale / 2;
holeY = (double) m_Drill.y * scale / 2;
holeX = (double) TO_LEGACY_LU_DBL( m_Drill.x ) * scale / 2;
holeY = (double) TO_LEGACY_LU_DBL( m_Drill.y ) * scale / 2;
hole = MIN( holeX, holeY );
/* Calculate the center of the pad. */
......@@ -914,8 +914,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
xc = ux0;
yc = uy0;
dx = dx0 = m_Size.x >> 1;
dy = dy0 = m_Size.y >> 1;
dx = dx0 = TO_LEGACY_LU( m_Size.x ) >> 1;
dy = dy0 = TO_LEGACY_LU( m_Size.y ) >> 1;
angle = m_Orient;
drillx = m_Pos.x * scale;
......@@ -980,13 +980,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
{
delta_cx = dx - dy;
delta_cy = 0;
w = m_Size.y * scale;
w = TO_LEGACY_LU( m_Size.y ) * scale;
}
else /* Vertical ellipse */
{
delta_cx = 0;
delta_cy = dy - dx;
w = m_Size.x * scale;
w = TO_LEGACY_LU( m_Size.x ) * scale;
}
RotatePoint( &delta_cx, &delta_cy, angle );
......
......@@ -518,6 +518,20 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
tmp << wxT( "OFF\n" );
#endif
tmp << wxT( " KICAD_NANOMETRE=" );
#ifdef KICAD_NANOMETRE
tmp << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
#endif
tmp << wxT( " KICAD_KEEPCASE=" );
#ifdef KICAD_KEEPCASE
tmp << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
#endif
tmp << wxT( " USE_WX_GRAPHICS_CONTEXT=" );
#ifdef USE_WX_GRAPHICS_CONTEXT
tmp << wxT( "ON\n" );
......
......@@ -416,7 +416,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int
*New common length functions
*/
const LENGTH_UNIT_DESC g_MillimetreDesc =
const LENGTH_UNIT_DESC MillimetreDesc =
{
LENGTH_UNITS<LENGTH_DEF>::millimetre(),
wxT( "mm" ),
......@@ -424,7 +424,7 @@ const LENGTH_UNIT_DESC g_MillimetreDesc =
};
const LENGTH_UNIT_DESC g_InchDesc =
const LENGTH_UNIT_DESC InchDesc =
{
LENGTH_UNITS<LENGTH_DEF>::inch(),
wxT( "\"" ),
......@@ -432,7 +432,7 @@ const LENGTH_UNIT_DESC g_InchDesc =
};
const LENGTH_UNIT_DESC g_MilDesc =
const LENGTH_UNIT_DESC MilDesc =
{
LENGTH_UNITS<LENGTH_DEF>::mil(),
wxT( "mil" ),
......@@ -440,7 +440,7 @@ const LENGTH_UNIT_DESC g_MilDesc =
};
const LENGTH_UNIT_DESC g_UnscaledDesc = /* stub */
const LENGTH_UNIT_DESC UnscaledDesc = /* stub */
{
LENGTH_DEF::quantum(),
wxT( "" ),
......@@ -451,11 +451,11 @@ const LENGTH_UNIT_DESC g_UnscaledDesc = /* stub */
const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ) {
switch(aUnit) {
case INCHES:
return &g_InchDesc;
return &InchDesc;
case MILLIMETRES:
return &g_MillimetreDesc;
return &MillimetreDesc;
default:
return &g_UnscaledDesc; /* should not be reached */
return &UnscaledDesc; /* should not be reached */
}
}
......@@ -533,15 +533,15 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
{
aUnit = &g_InchDesc;
aUnit = &InchDesc;
}
else if( unit == wxT( "mm" ) )
{
aUnit = &g_MillimetreDesc;
aUnit = &MillimetreDesc;
}
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) /* Mils or thous */
{
aUnit = &g_MilDesc;
aUnit = &MilDesc;
}
Value = LENGTH_DEF( dtmp * LENGTH< double, 1 >( aUnit->m_Value ) );
......
......@@ -9,6 +9,8 @@
#include "lengthpcb.h"
#include "class_via_dimension.h"
// Class for handle current printed board design settings
class BOARD_DESIGN_SETTINGS
{
......@@ -25,10 +27,13 @@ public:
int m_PcbTextWidth; // current Pcb (not module) Text width
wxSize m_PcbTextSize; // current Pcb (not module) Text size
LENGTH_PCB m_TrackMinWidth; // track min value for width ((min copper size value
LENGTH_PCB m_ViasMinSize; // vias (not micro vias) min diameter
LENGTH_PCB m_ViasMinDrill; // vias (not micro vias) min drill diameter
LENGTH_PCB m_MicroViasMinSize; // micro vias (not vias) min diameter
LENGTH_PCB m_MicroViasMinDrill; // micro vias (not vias) min drill diameter
VIA_DIMENSION m_MinVia;
VIA_DIMENSION m_MinMicroVia;
//LENGTH_PCB m_ViasMinSize; // vias (not micro vias) min diameter
//LENGTH_PCB m_ViasMinDrill; // vias (not micro vias) min drill diameter
//LENGTH_PCB m_MicroViasMinSize; // micro vias (not vias) min diameter
//LENGTH_PCB m_MicroViasMinDrill; // micro vias (not vias) min drill diameter
// Global mask margins:
int m_SolderMaskMargin; // Solder mask margin
......
......@@ -22,6 +22,11 @@ public:
m_Drill = FROM_LEGACY_LU( 0 );
}
VIA_DIMENSION( LENGTH_PCB diam, LENGTH_PCB drill )
{
m_Diameter = diam;
m_Drill = drill;
}
bool operator ==( const VIA_DIMENSION& other ) const
{
......
......@@ -390,7 +390,7 @@ struct LENGTH_UNIT_DESC
int m_Precision;
};
extern const LENGTH_UNIT_DESC g_MillimetreDesc, g_InchDesc, g_MilDesc;
extern const LENGTH_UNIT_DESC MillimetreDesc, InchDesc, MilDesc;
const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit );
......@@ -401,6 +401,37 @@ wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValu
void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_DEF Value );
LENGTH_DEF LengthFromTextCtrl( const wxTextCtrl& TextCtr );
/* transition macros */
#define STR_TO_LENGTH( unit, str, iu ) \
( StringToLength( UnitDescription( ( unit ) ), ( str ) ) )
#define LENGTH_TO_STR( unit, l, iu ) \
( LengthToString( UnitDescription( ( unit ) ), ( l ) ) )
#define LENGTH_TO_STR_SYM( unit, l, iu ) \
( LengthToString( UnitDescription( ( unit ) ), ( l ), true ) )
#define CTR_GET_LENGTH( ctr, iu ) \
( StringToLength( UnitDescription( g_UserUnit ), ( ctr ).GetValue() ) )
#define CTR_PUT_LENGTH( ctr, l, iu ) \
( ( ctr ).SetValue( LengthToString( UnitDescription( g_UserUnit ), ( l ) ) ) )
#else
#define STR_TO_LENGTH( unit, str, iu ) \
ReturnValueFromString( ( unit ), ( str ), ( iu ) )
#define LENGTH_TO_STR( unit, l, iu ) \
( ReturnStringFromValue( ( unit ), ( l ), ( iu ) ) )
#define LENGTH_TO_STR_SYM( unit, l, iu ) \
( ReturnStringFromValue( ( unit ), ( l ), ( iu ), true ) )
#define CTR_GET_LENGTH( ctr, iu ) \
ReturnValueFromString( g_UserUnit, ( ctr ).GetValue(), ( iu ) )
#define CTR_PUT_LENGTH( ctr, l, iu ) \
( ( ctr ).SetValue( ReturnStringFromValue( g_UserUnit, ( l ), ( iu ) ) ) )
#endif
/**
......
......@@ -230,36 +230,50 @@ public:
return y / x.m_U;
}
friend LENGTH< T, P > sqrt( LENGTH< T, P*2 > y )
{
return sqrt( y.m_U );
}
friend LENGTH< T, P > cbrt( LENGTH< T, P*3 > y )
{
return cbrt( y.m_U );
}
/*************************/
/* assignment arithmetic */
/*************************/
LENGTH< T, P >& operator -= ( const LENGTH< T, P > y )
{
return m_U -= y.m_U;
m_U -= y.m_U;
return *this;
}
LENGTH< T, P >& operator += ( const LENGTH< T, P > y )
{
return m_U += y.m_U;
m_U += y.m_U;
return *this;
}
LENGTH< T, P >& operator *= ( const T y )
{
return m_U *= y;
m_U *= y;
return *this;
}
LENGTH< T, P >& operator /= ( const T y )
{
return m_U /= y;
m_U /= y;
return *this;
}
/*************************/
/* more arithmetic */
/* more functions */
/*************************/
friend LENGTH< T, P > sqrt( LENGTH< T, P*2 > y )
{
return sqrt( y.m_U );
}
friend LENGTH< T, P > cbrt( LENGTH< T, P*3 > y )
{
return cbrt( y.m_U );
}
friend LENGTH< T, P > hypot( LENGTH< T, P > x, LENGTH< T, P > y )
{
return hypot( x.m_U, y.m_U );
}
friend double atan2( LENGTH< T, P > x, LENGTH< T, P > y )
{
return atan2( double ( x.m_U ), double( y.m_U ) );
}
};
/**
......
......@@ -20,13 +20,16 @@ typedef LENGTH< double, 1 > LENGTH_PCB_DBL;
#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 ) )
( (int) ( LENGTH_PCB( x ) / PCB_LEGACY_UNIT( LENGTH_PCB ) ) )
#define TO_LEGACY_LU_DBL( x ) \
( LENGTH_PCB_DBL( x ) / PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) )
( (double) ( 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( long 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 ) );
}
......@@ -41,6 +44,10 @@ static LENGTH_PCB_DBL from_legacy_lu_dbl( double x ) {
#define ZERO_LENGTH ( LENGTH_PCB::zero() )
/* SAVE FILE macros */
#define FM_LENSV "%lf" ///< format specifier for saving
#define ARG_LENSV( x ) TO_LEGACY_LU_DBL( x ) ///< argument for saving
#else
typedef int LENGTH_PCB;
......@@ -56,7 +63,72 @@ typedef double LENGTH_PCB_DBL;
#define ZERO_LENGTH 0
/* SAVE FILE macros */
/** @TODO: after transition process this could be wrapped in some class */
#define FM_LENSV "%d"
#define ARG_LENSV( x ) ( (int)( x ) )
#endif
/* LOAD FILE macros */
#define FM_LENLD "%lf" ///< scanf format macro for loading
#define ARG_LENLD_TYPE double ///< tmp variable for length read
// they're set to flat type to help the transition process
// there would be some period while program gain ability to
// load float data but not acually save it
#define LENGTH_LOAD_TMP( x ) ( FROM_LEGACY_LU( x ) ) ///< reads tmp value from above
#define LENGTH_LOAD_STR( s ) ( FROM_LEGACY_LU( atof( s ) ) ) ///< reads string
/// @TODO: nice template and refiling for it
struct VECTOR_PCB
{
LENGTH_PCB x, y;
VECTOR_PCB()
{
}
VECTOR_PCB( LENGTH_PCB ax, LENGTH_PCB ay ): x( ax ), y( ay )
{
}
bool operator == ( const VECTOR_PCB &a ) const {
return x == a.x && y == a.y;
}
bool operator != ( const VECTOR_PCB &a ) const {
return x != a.x || y != a.y;
}
VECTOR_PCB & operator = (const VECTOR_PCB &a ) {
x = a.x;
y = a.y;
return *this;
}
VECTOR_PCB & operator += (const VECTOR_PCB &a ) {
x += a.x;
y += a.y;
return *this;
}
VECTOR_PCB & operator -= (const VECTOR_PCB &a ) {
x -= a.x;
y -= a.y;
return *this;
}
VECTOR_PCB operator + (VECTOR_PCB add) const {
return VECTOR_PCB(x + add.x, y + add.y);
}
VECTOR_PCB operator - (VECTOR_PCB add) const {
return VECTOR_PCB(x - add.x, y - add.y);
}
VECTOR_PCB operator * (int factor) const {
return VECTOR_PCB(x * factor, y * factor);
}
VECTOR_PCB operator / (int factor) const {
return VECTOR_PCB(x / factor, y / factor);
}
};
#define TO_LEGACY_LU_WXP( p ) ( wxPoint( TO_LEGACY_LU( ( p ).x ), TO_LEGACY_LU( ( p ).y ) ) )
#define TO_LEGACY_LU_WXS( p ) ( wxSize( TO_LEGACY_LU( ( p ).x ), TO_LEGACY_LU( ( p ).y ) ) )
#define FROM_LEGACY_LU_VEC( p ) ( VECTOR_PCB( FROM_LEGACY_LU( ( p ).x ), FROM_LEGACY_LU( ( p ).y ) ) )
#endif /* def LENGTHPCB_H_INCLUDED */
......@@ -164,6 +164,11 @@ public:
return x + double( y.m_Value );
}
LIMITED_INT< T > operator - ( void ) const
{
assert( -std::numeric_limits< T >::max() <= m_Value );
return -m_Value;
}
LIMITED_INT< T > operator - ( const LIMITED_INT< T > &y ) const
{
assert( !( 0 < m_Value ) || m_Value - std::numeric_limits< T >::max() <= y.m_Value );
......
......@@ -65,7 +65,8 @@ static inline const wxChar* GetChars( const wxString& s )
#endif
#ifndef ABS
#define ABS( y ) ( (y) >= 0 ? (y) : ( -(y) ) )
#define ABS( y ) ( MAX( ( y ), ( -y ) ) )
// dirty trick: now this should work with LENGTH<> too
#endif
#define NEGATE( x ) (x = -x)
......
......@@ -460,7 +460,7 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
continue;
pad->SetPosition( pad->GetPosition() + offset );
pad->m_Pos0 += offset;
pad->m_Pos0 += FROM_LEGACY_LU_VEC( offset );
}
item = module->m_Drawings;
......@@ -550,7 +550,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
continue;
SETMIRROR( pad->GetPosition().x );
pad->m_Pos0.x = pad->GetPosition().x;
pad->m_Pos0.x = FROM_LEGACY_LU( pad->GetPosition().x );
NEGATE( pad->m_Offset.x );
NEGATE( pad->m_DeltaSize.x );
pad->m_Orient = 1800 - pad->m_Orient;
......@@ -610,7 +610,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
continue;
ROTATE( pad->GetPosition() );
pad->m_Pos0 = pad->GetPosition();
pad->m_Pos0 = FROM_LEGACY_LU_VEC( pad->GetPosition() );
pad->m_Orient += 900;
NORMALIZE_ANGLE_POS( pad->m_Orient );
}
......
......@@ -328,13 +328,13 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
{
wxPoint corner_position;
int ii, angle;
int dx = (m_Size.x / 2) + aClearanceValue;
int dy = (m_Size.y / 2) + aClearanceValue;
int dx = TO_LEGACY_LU( m_Size.x / 2 ) + aClearanceValue;
int dy = TO_LEGACY_LU( m_Size.y / 2 ) + aClearanceValue;
int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree
wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset,
* the pad position is NOT the shape position */
wxSize psize = m_Size; /* pad size unsed in RECT and TRAPEZOIDAL pads
wxSize psize = TO_LEGACY_LU_WXS( m_Size ); /* pad size unsed in RECT and TRAPEZOIDAL pads
* trapezoidal pads are considered as rect
* pad shape having they boudary box size */
......@@ -437,8 +437,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
default:
case PAD_TRAPEZOID:
psize.x += ABS( m_DeltaSize.y );
psize.y += ABS( m_DeltaSize.x );
psize.x += TO_LEGACY_LU( ABS( m_DeltaSize.y ) );
psize.y += TO_LEGACY_LU( ABS( m_DeltaSize.x ) );
// fall through
case PAD_RECT:
......@@ -572,8 +572,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
wxPoint PadShapePos = aPad.ReturnShapePos(); /* Note: for pad having a shape offset,
* the pad position is NOT the shape position */
wxSize copper_thickness;
int dx = aPad.m_Size.x / 2;
int dy = aPad.m_Size.y / 2;
int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 );
int dy = TO_LEGACY_LU( aPad.m_Size.y / 2 );
int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree
......@@ -684,8 +684,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
// Oval pad support along the lines of round and rectangular pads
std::vector <wxPoint> corners_buffer; // Polygon buffer as vector
int dx = (aPad.m_Size.x / 2) + aThermalGap; // Cutout radius x
int dy = (aPad.m_Size.y / 2) + aThermalGap; // Cutout radius y
int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ) + aThermalGap; // Cutout radius x
int dy = TO_LEGACY_LU( aPad.m_Size.y / 2 ) + aThermalGap; // Cutout radius y
wxPoint shape_offset;
......@@ -839,8 +839,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
std::vector <wxPoint> corners_buffer; // Polygon buffer as vector
int dx = (aPad.m_Size.x / 2) + aThermalGap; // Cutout radius x
int dy = (aPad.m_Size.y / 2) + aThermalGap; // Cutout radius y
int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ) + aThermalGap; // Cutout radius x
int dy = TO_LEGACY_LU( aPad.m_Size.y / 2 ) + aThermalGap; // Cutout radius y
// The first point of polygon buffer is left lower corner, second the crosspoint of
// thermal spoke sides, the third is upper right corner and the rest are rounding
......@@ -861,7 +861,7 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
RotatePoint( &corner_position, 1800 / aCircleToSegmentsCount ); // Start at half increment offset
angle_pg = i * delta;
RotatePoint( &corner_position, angle_pg ); // Rounding vector rotation
corner_position -= aPad.m_Size / 2; // Rounding vector + Pad corner offset
corner_position -= TO_LEGACY_LU_WXS( aPad.m_Size / 2 ); // Rounding vector + Pad corner offset
corners_buffer.push_back( wxPoint( corner_position.x, corner_position.y ) );
}
......
......@@ -2003,13 +2003,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace,
if( track->GetState( BEGIN_ONPAD ) )
{
D_PAD * pad = (D_PAD *) track->start;
lenDie += (double) pad->m_LengthDie;
lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie );
}
if( track->GetState( END_ONPAD ) )
{
D_PAD * pad = (D_PAD *) track->end;
lenDie += (double) pad->m_LengthDie;
lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie );
}
}
}
......@@ -2033,13 +2033,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace,
if( track->GetState( BEGIN_ONPAD ) )
{
D_PAD * pad = (D_PAD *) track->start;
lenDie += (double) pad->m_LengthDie;
lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie );
}
if( track->GetState( END_ONPAD ) )
{
D_PAD * pad = (D_PAD *) track->end;
lenDie += (double) pad->m_LengthDie;
lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie );
}
}
}
......
......@@ -33,10 +33,12 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS()
m_PcbTextWidth = 100; // current Pcb (not module) Text width
m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size
m_TrackMinWidth = FROM_LEGACY_LU( 80 ); // track min value for width ((min copper size value
m_ViasMinSize = FROM_LEGACY_LU( 350 ); // vias (not micro vias) min diameter
m_ViasMinDrill = FROM_LEGACY_LU( 200 ); // vias (not micro vias) min drill diameter
m_MicroViasMinSize = FROM_LEGACY_LU( 200 ); // micro vias (not vias) min diameter
m_MicroViasMinDrill = FROM_LEGACY_LU( 50 ); // micro vias (not vias) min drill diameter
m_MinVia = VIA_DIMENSION( FROM_LEGACY_LU( 350 ), FROM_LEGACY_LU( 200 ) );
m_MinMicroVia = VIA_DIMENSION( FROM_LEGACY_LU( 200 ), FROM_LEGACY_LU( 50 ) );
//m_ViasMinSize = FROM_LEGACY_LU( 350 ); // vias (not micro vias) min diameter
//m_ViasMinDrill = FROM_LEGACY_LU( 200 ); // vias (not micro vias) min drill diameter
//m_MicroViasMinSize = FROM_LEGACY_LU( 200 ); // micro vias (not vias) min diameter
//m_MicroViasMinDrill = FROM_LEGACY_LU( 50 ); // micro vias (not vias) min drill diameter
// Global mask margins:
m_SolderMaskMargin = 150; // Solder mask margin
......
......@@ -352,8 +352,8 @@ void MODULE::SetOrientation( int newangle )
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{
px = pad->m_Pos0.x;
py = pad->m_Pos0.y;
px = TO_LEGACY_LU( pad->m_Pos0.x );
py = TO_LEGACY_LU( pad->m_Pos0.y );
pad->m_Orient += newangle; /* change m_Orientation */
NORMALIZE_ANGLE_POS( pad->m_Orient );
......
......@@ -42,8 +42,8 @@ extern BOARD_DESIGN_SETTINGS boardDesignSettings;
const wxString NETCLASS::Default = wxT("Default");
// Initial values for netclass initialization
int NETCLASS::DEFAULT_CLEARANCE = 100; // track to track and track to pads clearance
int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill
int NETCLASS::DEFAULT_UVIA_DRILL = 50; // micro via drill
int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill (TODO: should be gone on refactoring)
int NETCLASS::DEFAULT_UVIA_DRILL = 50; // micro via drill (TODO: --"--)
NETCLASS::NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initialParameters ) :
......@@ -55,37 +55,40 @@ NETCLASS::NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initi
SetParams( initialParameters );
}
void NETCLASS::SetParams( const NETCLASS* defaults )
{
if( defaults )
{
SetClearance( defaults->GetClearance() );
SetTrackWidth( defaults->GetTrackWidth() );
SetViaDiameter( defaults->GetViaDiameter() );
SetViaDrill( defaults->GetViaDrill() );
SetuViaDiameter( defaults->GetuViaDiameter() );
SetuViaDrill( defaults->GetuViaDrill() );
Via( defaults->Via() );
MicroVia( defaults->MicroVia() );
}
else
{ // We should use m_Parent->GetBoardDesignSettings()
{
SetToDefault();
}
}
void NETCLASS::SetToDefault()
{
// We should use m_Parent->GetBoardDesignSettings()
// But when the NETCLASSES constructor is called
// (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD)
// is not run, and GetBoardDesignSettings() return a bad value
// TODO: see how change that.
const BOARD_DESIGN_SETTINGS& g = boardDesignSettings;
SetTrackWidth( TO_LEGACY_LU( g.m_TrackMinWidth ) );
SetViaDiameter( TO_LEGACY_LU( g.m_ViasMinSize ) );
SetuViaDiameter( TO_LEGACY_LU( g.m_MicroViasMinSize ) );
TrackWidth( g.m_TrackMinWidth );
//SetViaDrill( TO_LEGACY_LU( g.m_ViasMinDrill ) ); // was DEFAULT_VIA_DRILL
//SetuViaDrill( TO_LEGACY_LU( g.m_MicroViasMinDrill ) ); // DEFAULT_UVIA_DRILL
Via( g.m_MinVia );
MicroVia( g.m_MinMicroVia );
// Use default values for next parameters:
SetClearance( DEFAULT_CLEARANCE );
SetViaDrill( DEFAULT_VIA_DRILL );
SetuViaDrill( DEFAULT_UVIA_DRILL );
}
Clearance( FROM_LEGACY_LU( DEFAULT_CLEARANCE ) );
}
NETCLASS::~NETCLASS()
{
}
......@@ -294,14 +297,14 @@ bool NETCLASS::Save( FILE* aFile ) const
// Write parameters
fprintf( aFile, "Clearance %d\n", GetClearance() );
fprintf( aFile, "TrackWidth %d\n", GetTrackWidth() );
fprintf( aFile, "Clearance %f\n", TO_LEGACY_LU_DBL( Clearance() ) );
fprintf( aFile, "TrackWidth %f\n", TO_LEGACY_LU_DBL( TrackWidth() ) );
fprintf( aFile, "ViaDia %d\n", GetViaDiameter() );
fprintf( aFile, "ViaDrill %d\n", GetViaDrill() );
fprintf( aFile, "ViaDia %f\n", TO_LEGACY_LU_DBL( Via().m_Diameter ) );
fprintf( aFile, "ViaDrill %f\n", TO_LEGACY_LU_DBL( Via().m_Drill ) );
fprintf( aFile, "uViaDia %d\n", GetuViaDiameter() );
fprintf( aFile, "uViaDrill %d\n", GetuViaDrill() );
fprintf( aFile, "uViaDia %f\n", TO_LEGACY_LU_DBL( MicroVia().m_Diameter ) );
fprintf( aFile, "uViaDrill %f\n", TO_LEGACY_LU_DBL( MicroVia().m_Drill ) );
// Write members:
for( const_iterator i = begin(); i!=end(); ++i )
......@@ -342,6 +345,8 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader )
char* Line;
char Buffer[1024];
wxString netname;
VIA_DIMENSION via = Via();
VIA_DIMENSION uvia = MicroVia();
while( aReader->ReadLine() )
{
......@@ -362,33 +367,37 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader )
if( strnicmp( Line, "Clearance", 9 ) == 0 )
{
SetClearance( atoi( Line + 9 ) );
Clearance( FROM_LEGACY_LU( atof( Line + 9 ) ) );
continue;
}
if( strnicmp( Line, "TrackWidth", 10 ) == 0 )
{
SetTrackWidth( atoi( Line + 10 ) );
TrackWidth( FROM_LEGACY_LU( atof( Line + 10 ) ) );
continue;
}
if( strnicmp( Line, "ViaDia", 6 ) == 0 )
{
SetViaDiameter( atoi( Line + 6 ) );
via.m_Diameter = FROM_LEGACY_LU( atof( Line + 6 ) );
Via(via);
continue;
}
if( strnicmp( Line, "ViaDrill", 8 ) == 0 )
{
SetViaDrill( atoi( Line + 8 ) );
via.m_Drill = FROM_LEGACY_LU( atof( Line + 8 ) );
Via(via);
continue;
}
if( strnicmp( Line, "uViaDia", 7 ) == 0 )
{
SetuViaDiameter( atoi( Line + 7 ) );
uvia.m_Diameter = FROM_LEGACY_LU( atof( Line + 7 ) );
MicroVia(uvia);
continue;
}
if( strnicmp( Line, "uViaDrill", 9 ) == 0 )
{
SetuViaDrill( atoi( Line + 9 ) );
uvia.m_Drill = FROM_LEGACY_LU( atof( Line + 9 ) );
MicroVia(uvia);
continue;
}
......@@ -417,22 +426,22 @@ int NETCLASS::GetTrackMinWidth() const
int NETCLASS::GetViaMinDiameter() const
{
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_ViasMinSize );
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinVia.m_Diameter );
}
int NETCLASS::GetViaMinDrill() const
{
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_ViasMinDrill );
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinVia.m_Drill );
}
int NETCLASS::GetuViaMinDiameter() const
{
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MicroViasMinSize );
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter );
}
int NETCLASS::GetuViaMinDrill() const
{
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MicroViasMinDrill );
return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinMicroVia.m_Drill );
}
......@@ -195,6 +195,17 @@ public:
int GetuViaMinDrill() const;
void SetuViaDrill( int aSize ) { m_uVia.m_Drill = FROM_LEGACY_LU( aSize ); }
LENGTH_PCB Clearance() const { return m_Clearance; }
LENGTH_PCB Clearance( const LENGTH_PCB a ) { return m_Clearance = a; }
LENGTH_PCB TrackWidth() const { return m_TrackWidth; }
LENGTH_PCB TrackWidth( const LENGTH_PCB a ) { return m_TrackWidth = a; }
VIA_DIMENSION Via() const { return m_Via; }
VIA_DIMENSION Via( const VIA_DIMENSION a ) { return m_Via = a; }
VIA_DIMENSION MicroVia() const { return m_uVia; }
VIA_DIMENSION MicroVia( const VIA_DIMENSION a ) { return m_uVia = a; }
/**
* Function SetParams
......@@ -205,6 +216,11 @@ public:
*/
void SetParams( const NETCLASS* defaults = NULL );
/**
* Sets Parameters to their default state.
*/
void SetToDefault();
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
......
......@@ -153,7 +153,7 @@ void NETINFO_ITEM::DisplayInfo( EDA_DRAW_FRAME* frame )
if( pad->GetNet() == GetNet() )
{
count++;
lengthdie += pad->m_LengthDie;
lengthdie += TO_LEGACY_LU_DBL( pad->m_LengthDie );
}
}
}
......
This diff is collapsed.
......@@ -11,6 +11,8 @@
#include "pad_shapes.h"
#include "PolyLine.h"
#include "lengthpcb.h"
class LINE_READER;
class EDA_3D_CANVAS;
......@@ -85,14 +87,17 @@ public:
// 2..14 = internal layers
// 16 .. 31 = technical layers
int m_PadShape; // Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID
int m_DrillShape; // Shape PAD_CIRCLE, PAD_OVAL
int m_PadShape; ///< Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID
int m_DrillShape; ///< Shape PAD_CIRCLE, PAD_OVAL
/// @TODO: as m_DrillShape is eqv. to m_Drill.x==.y
/// it would be relatively easy to remove
/// this redundant flag.
wxSize m_Drill; // Drill diam (drill shape = PAD_CIRCLE) or drill size
// (shape = OVAL) for drill shape = PAD_CIRCLE, drill
// diam = m_Drill.x
VECTOR_PCB m_Drill; ///< Drill diam (drill shape = PAD_CIRCLE) or drill size
/// (shape = OVAL) for drill shape = PAD_CIRCLE, drill
/// diam = m_Drill.x
wxSize m_Offset; /* This parameter is useful only for oblong pads (it can be used for other
VECTOR_PCB m_Offset; /* This parameter is useful only for oblong pads (it can be used for other
* shapes, but without any interest).
* this is the offset between the pad hole and the pad shape (you must
* understand here pad shape = copper area around the hole)
......@@ -105,11 +110,11 @@ public:
* D_PAD::ReturnShapePos() returns the physical shape position according to
* the offset and the pad rotation.*/
wxSize m_Size; // X and Y size ( relative to orient 0)
VECTOR_PCB m_Size; // X and Y size ( relative to orient 0)
wxSize m_DeltaSize; // delta on rectangular shapes
VECTOR_PCB m_DeltaSize; // delta on rectangular shapes
wxPoint m_Pos0; // Initial Pad position (i.e. pas position relative to the
VECTOR_PCB m_Pos0; // Initial Pad position (i.e. pas position relative to the
// module anchor, orientation 0
int m_ShapeMaxRadius; // radius of the circle containing the pad shape
......@@ -118,16 +123,16 @@ public:
static int m_PadSketchModePenSize; // Pen size used to draw pads in sketch mode
// (mode used to print pads on silkscreen layer)
int m_LengthDie; // Length net from pad to die on chip
LENGTH_PCB m_LengthDie; // Length net from pad to die on chip
// Local clearance. When null, the module default value is used.
// when the module default value is null, the netclass value is used
// Usually the local clearance is null
int m_LocalClearance;
LENGTH_PCB m_LocalClearance;
// Local mask margins: when NULL, the parent footprint design values are used
int m_LocalSolderMaskMargin; // Local solder mask margin
int m_LocalSolderPasteMargin; // Local solder paste margin absolute value
LENGTH_PCB m_LocalSolderMaskMargin; // Local solder mask margin
LENGTH_PCB m_LocalSolderPasteMargin; // Local solder paste margin absolute value
double m_LocalSolderPasteMarginRatio; // Local solder mask margin ratio value of pad size
// The final margin is the sum of these 2 values
......
......@@ -392,9 +392,9 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
// calculate pad shape position :
wxPoint shape_pos = ReturnShapePos() - aDrawInfo.m_Offset;
wxSize halfsize = m_Size;
halfsize.x >>= 1;
halfsize.y >>= 1;
wxSize halfsize = TO_LEGACY_LU_WXS( m_Size );
halfsize.x /= 2;
halfsize.y /= 2;
switch( GetShape() )
{
......@@ -476,7 +476,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
/* Draw the pad hole */
wxPoint holepos = m_Pos - aDrawInfo.m_Offset;
int hole = m_Drill.x >> 1;
int hole = TO_LEGACY_LU( m_Drill.x ) / 2;
bool drawhole = hole > 0;
......@@ -513,20 +513,20 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
break;
case PAD_OVAL:
halfsize.x = m_Drill.x >> 1;
halfsize.y = m_Drill.y >> 1;
halfsize.x = TO_LEGACY_LU( m_Drill.x ) / 2;
halfsize.y = TO_LEGACY_LU( m_Drill.y ) / 2;
if( m_Drill.x > m_Drill.y ) /* horizontal */
{
delta_cx = halfsize.x - halfsize.y;
delta_cy = 0;
seg_width = m_Drill.y;
seg_width = TO_LEGACY_LU( m_Drill.y );
}
else /* vertical */
{
delta_cx = 0;
delta_cy = halfsize.y - halfsize.x;
seg_width = m_Drill.x;
seg_width = TO_LEGACY_LU( m_Drill.x );
}
RotatePoint( &delta_cx, &delta_cy, angle );
......@@ -576,13 +576,13 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
if( GetShape() == PAD_CIRCLE )
angle = 0;
AreaSize = m_Size;
AreaSize = TO_LEGACY_LU_WXS( m_Size );
if( m_Size.y > m_Size.x )
{
angle += 900;
AreaSize.x = m_Size.y;
AreaSize.y = m_Size.x;
AreaSize.x = TO_LEGACY_LU( m_Size.y );
AreaSize.y = TO_LEGACY_LU( m_Size.x );
}
if( shortname_len > 0 ) // if there is a netname, provides room to display this netname
......@@ -666,21 +666,21 @@ int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, int a
if( m_Size.y < m_Size.x ) // Build an horizontal equiv segment
{
int delta = ( m_Size.x - m_Size.y ) / 2;
int delta = TO_LEGACY_LU( ( m_Size.x - m_Size.y ) / 2 );
aSegStart.x = -delta;
aSegStart.y = 0;
aSegEnd.x = delta;
aSegEnd.y = 0;
width = m_Size.y;
width = TO_LEGACY_LU( m_Size.y );
}
else // Vertical oval: build a vertical equiv segment
{
int delta = ( m_Size.y -m_Size.x ) / 2;
int delta = TO_LEGACY_LU( ( m_Size.y -m_Size.x ) / 2 );
aSegStart.x = 0;
aSegStart.y = -delta;
aSegEnd.x = 0;
aSegEnd.y = delta;
width = m_Size.x;
width = TO_LEGACY_LU( m_Size.x );
}
if( aRotation )
......@@ -701,8 +701,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
wxSize delta;
wxSize halfsize;
halfsize.x = m_Size.x >> 1;
halfsize.y = m_Size.y >> 1;
halfsize.x = TO_LEGACY_LU( m_Size.x / 2 );
halfsize.y = TO_LEGACY_LU( m_Size.y / 2 );
/* For rectangular shapes, inflate is easy
*/
......@@ -721,8 +721,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
else
{
// Trapezoidal pad: verify delta values
delta.x = ( m_DeltaSize.x >> 1 );
delta.y = ( m_DeltaSize.y >> 1 );
delta.x = TO_LEGACY_LU( m_DeltaSize.x / 2 );
delta.y = TO_LEGACY_LU( m_DeltaSize.y / 2 );
// be sure delta values are not to large
if( (delta.x < 0) && (delta.x <= -halfsize.y) )
......@@ -762,7 +762,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
if( delta.y ) // lower and upper segment is horizontal
{
// Calculate angle of left (or right) segment with vertical axis
angle = atan2( double( m_DeltaSize.y ), double( m_Size.y ) );
angle = atan2( m_DeltaSize.y, m_Size.y ); /// TODO: make atan2 available to LENGTH
// left and right sides are moved by aInflateValue.x in their perpendicular direction
// We must calculate the corresponding displacement on the horizontal axis
......@@ -778,7 +778,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
else if( delta.x ) // left and right segment is vertical
{
// Calculate angle of lower (or upper) segment with horizontal axis
angle = atan2( double( m_DeltaSize.x ), double( m_Size.x ) );
angle = atan2( m_DeltaSize.x, m_Size.x );
// lower and upper sides are moved by aInflateValue.x in their perpendicular direction
// We must calculate the corresponding displacement on the vertical axis
......
This diff is collapsed.
......@@ -133,16 +133,16 @@ void DIALOG_DRC_CONTROL::SetDrcParmeters( )
#ifdef KICAD_NANOMETRE
m_BrdSettings->m_TrackMinWidth =
LengthFromTextCtrl( *m_SetTrackMinWidthCtrl );
m_BrdSettings->m_ViasMinSize =
m_BrdSettings->m_MinVia.m_Diameter =
LengthFromTextCtrl( *m_SetViaMinSizeCtrl );
m_BrdSettings->m_MicroViasMinSize =
m_BrdSettings->m_MinMicroVia.m_Diameter =
LengthFromTextCtrl( *m_SetMicroViakMinSizeCtrl );
#else
m_BrdSettings->m_TrackMinWidth =
ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_ViasMinSize =
m_BrdSettings->m_MinVia.m_Diameter =
ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->m_InternalUnits );
m_BrdSettings->m_MicroViasMinSize =
m_BrdSettings->m_MinMicroVia.m_Diameter =
ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->m_InternalUnits );
#endif
}
......
......@@ -185,7 +185,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void )
{
if( pad->m_DrillShape == PAD_CIRCLE )
{
if( pad->m_Drill.x != 0 )
if( pad->m_Drill.x != ZERO_LENGTH )
{
if( pad->m_Attribut == PAD_HOLE_NOT_PLATED )
m_notplatedPadsHoleCount++;
......@@ -195,7 +195,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void )
}
else
{
if( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 )
if( MIN( TO_LEGACY_LU( pad->m_Drill.x ), TO_LEGACY_LU( pad->m_Drill.y ) ) != 0 )
{
if( pad->m_Attribut == PAD_HOLE_NOT_PLATED )
m_notplatedPadsHoleCount++;
......
This diff is collapsed.
......@@ -58,18 +58,18 @@ void DRC::ShowDialog()
LengthToTextCtrl( *m_ui->m_SetTrackMinWidthCtrl,
m_pcb->GetBoardDesignSettings()->m_TrackMinWidth );
LengthToTextCtrl( *m_ui->m_SetViaMinSizeCtrl,
m_pcb->GetBoardDesignSettings()->m_ViasMinSize );
m_pcb->GetBoardDesignSettings()->m_MinVia.m_Diameter );
LengthToTextCtrl( *m_ui->m_SetMicroViakMinSizeCtrl,
m_pcb->GetBoardDesignSettings()->m_MicroViasMinSize );
m_pcb->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter );
#else
PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl,
TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_TrackMinWidth ),
m_mainWindow->m_InternalUnits );
PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl,
TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_ViasMinSize ),
TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MinVia.m_Diameter ),
m_mainWindow->m_InternalUnits );
PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl,
TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MicroViasMinSize ),
TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ),
m_mainWindow->m_InternalUnits );
#endif
......@@ -335,12 +335,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
ret = false;
}
if( nc->GetViaDiameter() < TO_LEGACY_LU( g.m_ViasMinSize ) )
if( nc->GetViaDiameter() < TO_LEGACY_LU( g.m_MinVia.m_Diameter ) )
{
msg.Printf( _( "NETCLASS: '%s' has Via Dia:%s which is less than global:%s" ),
GetChars( nc->GetName() ),
FmtVal( nc->GetViaDiameter() ),
FmtVal( TO_LEGACY_LU( g.m_ViasMinSize ) )
FmtVal( TO_LEGACY_LU( g.m_MinVia.m_Diameter ) )
);
m_currentMarker = fillMarker( DRCE_NETCLASS_VIASIZE, msg, m_currentMarker );
......@@ -349,12 +349,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
ret = false;
}
if( nc->GetViaDrill() < TO_LEGACY_LU( g.m_ViasMinDrill ) )
if( nc->GetViaDrill() < TO_LEGACY_LU( g.m_MinVia.m_Drill ) )
{
msg.Printf( _( "NETCLASS: '%s' has Via Drill:%s which is less than global:%s" ),
GetChars( nc->GetName() ),
FmtVal( nc->GetViaDrill() ),
FmtVal( TO_LEGACY_LU( g.m_ViasMinDrill ) )
FmtVal( TO_LEGACY_LU( g.m_MinVia.m_Drill ) )
);
m_currentMarker = fillMarker( DRCE_NETCLASS_VIADRILLSIZE, msg, m_currentMarker );
......@@ -363,12 +363,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
ret = false;
}
if( nc->GetuViaDiameter() < TO_LEGACY_LU( g.m_MicroViasMinSize ) )
if( nc->GetuViaDiameter() < TO_LEGACY_LU( g.m_MinMicroVia.m_Diameter ) )
{
msg.Printf( _( "NETCLASS: '%s' has uVia Dia:%s which is less than global:%s" ),
GetChars( nc->GetName() ),
FmtVal( nc->GetuViaDiameter() ),
FmtVal( TO_LEGACY_LU( g.m_MicroViasMinSize ) )
FmtVal( TO_LEGACY_LU( g.m_MinMicroVia.m_Diameter ) )
);
m_currentMarker = fillMarker( DRCE_NETCLASS_uVIASIZE, msg, m_currentMarker );
......@@ -377,12 +377,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
ret = false;
}
if( nc->GetuViaDrill() < TO_LEGACY_LU( g.m_MicroViasMinDrill ) )
if( nc->GetuViaDrill() < TO_LEGACY_LU( g.m_MinMicroVia.m_Drill ) )
{
msg.Printf( _( "NETCLASS: '%s' has uVia Drill:%s which is less than global:%s" ),
GetChars( nc->GetName() ),
FmtVal( nc->GetuViaDrill() ),
FmtVal( TO_LEGACY_LU( g.m_MicroViasMinDrill ) )
FmtVal( TO_LEGACY_LU( g.m_MinMicroVia.m_Drill ) )
);
m_currentMarker = fillMarker( DRCE_NETCLASS_uVIADRILLSIZE, msg, m_currentMarker );
......@@ -577,7 +577,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li
MODULE dummymodule( m_pcb ); // Creates a dummy parent
D_PAD dummypad( &dummymodule );
dummypad.m_layerMask |= ALL_CU_LAYERS; // Ensure the hole is on all copper layers
dummypad.m_LocalClearance = 1; /* Use the minimal local clearance value for the dummy pad
dummypad.m_LocalClearance = FROM_LEGACY_LU( 1 ); /* Use the minimal local clearance value for the dummy pad
* the clearance of the active pad will be used
* as minimum distance to a hole
* (a value = 0 means use netclass value)
......@@ -617,7 +617,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li
/* Here, we must test clearance between holes and pads
* dummy pad size and shape is adjusted to pad drill size and shape
*/
if( pad->m_Drill.x )
if( pad->m_Drill.x != ZERO_LENGTH )
{
// pad under testing has a hole, test this hole against pad reference
dummypad.SetPosition( pad->GetPosition() );
......@@ -637,7 +637,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li
}
}
if( aRefPad->m_Drill.x ) // pad reference has a hole
if( aRefPad->m_Drill.x != ZERO_LENGTH ) // pad reference has a hole
{
dummypad.SetPosition( aRefPad->GetPosition() );
dummypad.m_Size = aRefPad->m_Drill;
......
......@@ -290,7 +290,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
* checkClearanceSegmToPad(),a pseudo pad is used, with a shape and a
* size like the hole
*/
if( pad->m_Drill.x == 0 )
if( pad->m_Drill.x == ZERO_LENGTH )
continue;
dummypad.m_Size = pad->m_Drill;
......@@ -633,7 +633,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
m_segmEnd.x = m_segmEnd.y = 0;
m_padToTestPos = relativePadPos;
diag = checkClearanceSegmToPad( aPad, aRefPad->m_Size.x, dist_min );
diag = checkClearanceSegmToPad( aPad, TO_LEGACY_LU( aRefPad->m_Size.x ), dist_min );
break;
case PAD_RECT:
......@@ -644,7 +644,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
if( aPad->m_PadShape == PAD_RECT )
{
wxSize size = aPad->m_Size;
wxSize size = TO_LEGACY_LU_WXS( aPad->m_Size );
// The trivial case is if both rects are rotated by multiple of 90 deg
// Most of time this is the case, and the test is fast
......@@ -664,10 +664,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
relativePadPos.x = ABS( relativePadPos.x );
relativePadPos.y = ABS( relativePadPos.y );
if( ( relativePadPos.x - ( (size.x + aRefPad->m_Size.x) / 2 ) ) >= dist_min )
if( ( relativePadPos.x - ( (size.x + TO_LEGACY_LU( aRefPad->m_Size.x ) ) / 2 ) ) >= dist_min )
diag = true;
if( ( relativePadPos.y - ( (size.y + aRefPad->m_Size.y) / 2 ) ) >= dist_min )
if( ( relativePadPos.y - ( (size.y + TO_LEGACY_LU( aRefPad->m_Size.y) ) / 2 ) ) >= dist_min )
diag = true;
}
else // at least one pad has any other orient. Test is more tricky
......@@ -718,13 +718,13 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
if( aRefPad->m_Size.y < aRefPad->m_Size.x ) // Build an horizontal equiv segment
{
segm_width = aRefPad->m_Size.y;
m_segmLength = aRefPad->m_Size.x - aRefPad->m_Size.y;
segm_width = TO_LEGACY_LU( aRefPad->m_Size.y );
m_segmLength = TO_LEGACY_LU( aRefPad->m_Size.x - aRefPad->m_Size.y );
}
else // Vertical oval: build an horizontal equiv segment and rotate 90.0 deg
{
segm_width = aRefPad->m_Size.x;
m_segmLength = aRefPad->m_Size.y - aRefPad->m_Size.x;
segm_width = TO_LEGACY_LU( aRefPad->m_Size.x );
m_segmLength = TO_LEGACY_LU( aRefPad->m_Size.y - aRefPad->m_Size.x );
m_segmAngle += 900;
}
......@@ -796,13 +796,13 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi
int segmHalfWidth = aSegmentWidth / 2;
seuil = segmHalfWidth + aMinDist;
padHalfsize.x = aPad->m_Size.x >> 1;
padHalfsize.y = aPad->m_Size.y >> 1;
padHalfsize.x = TO_LEGACY_LU( aPad->m_Size.x / 2 );
padHalfsize.y = TO_LEGACY_LU( aPad->m_Size.y / 2 );
if( aPad->m_PadShape == PAD_TRAPEZOID ) // The size is bigger, due to m_DeltaSize extra size
{
padHalfsize.x += ABS(aPad->m_DeltaSize.y) / 2; // Remember: m_DeltaSize.y is the m_Size.x change
padHalfsize.y += ABS(aPad->m_DeltaSize.x) / 2; // Remember: m_DeltaSize.x is the m_Size.y change
padHalfsize.x += TO_LEGACY_LU( ABS(aPad->m_DeltaSize.y) / 2 ); // Remember: m_DeltaSize.y is the m_Size.x change
padHalfsize.y += TO_LEGACY_LU( ABS(aPad->m_DeltaSize.x) / 2 ); // Remember: m_DeltaSize.x is the m_Size.y change
}
if( aPad->m_PadShape == PAD_CIRCLE )
......
......@@ -69,10 +69,10 @@
#define DRCE_TOO_SMALL_MICROVIA 29 ///< Too small micro via size
#define DRCE_NETCLASS_TRACKWIDTH 30 ///< netclass has TrackWidth < board.m_designSettings->m_TrackMinWidth
#define DRCE_NETCLASS_CLEARANCE 31 ///< netclass has Clearance < board.m_designSettings->m_TrackClearance
#define DRCE_NETCLASS_VIASIZE 32 ///< netclass has ViaSize < board.m_designSettings->m_ViasMinSize
#define DRCE_NETCLASS_VIADRILLSIZE 33 ///< netclass has ViaDrillSize < board.m_designSettings->m_ViasMinDrill
#define DRCE_NETCLASS_uVIASIZE 34 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinSize
#define DRCE_NETCLASS_uVIADRILLSIZE 35 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinDrill
#define DRCE_NETCLASS_VIASIZE 32 ///< netclass has ViaSize < board.m_designSettings->m_MinVia.m_Diameter
#define DRCE_NETCLASS_VIADRILLSIZE 33 ///< netclass has ViaDrillSize < board.m_designSettings->m_MinVia.m_Drill
#define DRCE_NETCLASS_uVIASIZE 34 ///< netclass has ViaSize < board.m_designSettings->m_MinMicroVia.m_Diameter
#define DRCE_NETCLASS_uVIADRILLSIZE 35 ///< netclass has ViaSize < board.m_designSettings->m_MinMicroVia.m_Drill
class EDA_DRAW_PANEL;
......
......@@ -82,7 +82,7 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod )
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{
pt_pad->m_Pos0 += moveVector;
pt_pad->m_Pos0 += VECTOR_PCB( FROM_LEGACY_LU( moveVector.x ), FROM_LEGACY_LU( moveVector.y ) );
}
/* Update the draw element coordinates. */
......@@ -93,7 +93,7 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod )
switch( PtStruct->Type() )
{
case PCB_MODULE_EDGE_T:
#undef STRUCT
#undef STRUCT /// @BUG: unsafe type cast
#define STRUCT ( (EDGE_MODULE*) PtStruct )
STRUCT->m_Start0 += moveVector;
STRUCT->m_End0 += moveVector;
......
......@@ -783,7 +783,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
if( g_FirstTrackSegment->GetState( BEGIN_ONPAD ) )
{
D_PAD * pad = (D_PAD *) g_FirstTrackSegment->start;
lenDie = (double) pad->m_LengthDie;
lenDie = TO_LEGACY_LU_DBL( pad->m_LengthDie );
}
// calculate track len on board:
......
......@@ -252,70 +252,70 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
fprintf( file, "PAD PAD%d", pad->GetSubRatsnest() );
int dx = pad->m_Size.x / 2;
int dy = pad->m_Size.y / 2;
int dx = TO_LEGACY_LU( pad->m_Size.x / 2 );
int dy = TO_LEGACY_LU( pad->m_Size.y / 2 );
switch( pad->m_PadShape )
{
default:
case PAD_CIRCLE:
pad_type = "ROUND";
fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x );
pad_type = "ROUND"; // how about oval holes?
fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) );
fprintf( file, "CIRCLE %d %d %d\n",
pad->m_Offset.x, -pad->m_Offset.y, dx );
TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ), dx );
break;
case PAD_RECT:
pad_type = "RECTANGULAR";
fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x );
fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) );
fprintf( file, "RECTANGLE %d %d %d %d\n",
pad->m_Offset.x - dx, -pad->m_Offset.y - dy,
pad->m_Size.x, pad->m_Size.y );
TO_LEGACY_LU( pad->m_Offset.x ) - dx, -TO_LEGACY_LU( pad->m_Offset.y ) - dy,
TO_LEGACY_LU( pad->m_Size.x ), TO_LEGACY_LU( pad->m_Size.y ) );
break;
case PAD_OVAL: /* Create outline by 2 lines and 2 arcs */
{
pad_type = "FINGER";
fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x );
fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) );
int dr = dx - dy;
if( dr >= 0 ) // Horizontal oval
{
int radius = dy;
fprintf( file, "LINE %d %d %d %d\n",
-dr + pad->m_Offset.x, -pad->m_Offset.y - radius,
dr + pad->m_Offset.x, -pad->m_Offset.y - radius );
-dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius,
dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius );
fprintf( file, "ARC %d %d %d %d %d %d\n",
dr + pad->m_Offset.x, -pad->m_Offset.y - radius,
dr + pad->m_Offset.x, -pad->m_Offset.y + radius,
dr + pad->m_Offset.x, -pad->m_Offset.y );
dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius,
dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius,
dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) );
fprintf( file, "LINE %d %d %d %d\n",
dr + pad->m_Offset.x, -pad->m_Offset.y + radius,
-dr + pad->m_Offset.x, -pad->m_Offset.y + radius );
dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius,
-dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius );
fprintf( file, "ARC %d %d %d %d %d %d\n",
-dr + pad->m_Offset.x, -pad->m_Offset.y + radius,
-dr + pad->m_Offset.x, -pad->m_Offset.y - radius,
-dr + pad->m_Offset.x, -pad->m_Offset.y );
-dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius,
-dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius,
-dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) );
}
else // Vertical oval
{
dr = -dr;
int radius = dx;
fprintf( file, "LINE %d %d %d %d\n",
-radius + pad->m_Offset.x, -pad->m_Offset.y - dr,
-radius + pad->m_Offset.x, -pad->m_Offset.y + dr );
-radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr,
-radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr );
fprintf( file, "ARC %d %d %d %d %d %d\n",
-radius + pad->m_Offset.x, -pad->m_Offset.y + dr,
radius + pad->m_Offset.x, -pad->m_Offset.y + dr,
pad->m_Offset.x, -pad->m_Offset.y + dr );
-radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr,
radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr,
TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr );
fprintf( file, "LINE %d %d %d %d\n",
radius + pad->m_Offset.x, -pad->m_Offset.y + dr,
radius + pad->m_Offset.x, -pad->m_Offset.y - dr );
radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr,
radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr );
fprintf( file, "ARC %d %d %d %d %d %d\n",
radius + pad->m_Offset.x, -pad->m_Offset.y - dr,
-radius + pad->m_Offset.x, -pad->m_Offset.y - dr,
pad->m_Offset.x, -pad->m_Offset.y - dr );
radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr,
-radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr,
TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr );
}
break;
}
......@@ -410,7 +410,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
NORMALIZE_ANGLE_POS( orient );
fprintf( file, "PIN %s PAD%d %d %d %s %d %s",
TO_UTF8( pinname ), pad->GetSubRatsnest(),
pad->m_Pos0.x, -pad->m_Pos0.y,
TO_LEGACY_LU( pad->m_Pos0.x ), TO_LEGACY_LU( -pad->m_Pos0.y ),
layer, orient / 10, mirror );
if( orient % 10 )
......
......@@ -881,8 +881,8 @@ static void export_vrml_edge_module( EDGE_MODULE* module ) /*{{{*/
static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/
{
double hole_drill_w = (double) pad->m_Drill.x / 2;
double hole_drill_h = (double) pad->m_Drill.y / 2;
double hole_drill_w = (double) TO_LEGACY_LU_DBL( pad->m_Drill.x / 2 );
double hole_drill_h = (double) TO_LEGACY_LU_DBL( pad->m_Drill.y / 2 );
double hole_drill = MIN( hole_drill_w, hole_drill_h );
double hole_x = pad->m_Pos.x;
double hole_y = pad->m_Pos.y;
......@@ -913,11 +913,11 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/
wxPoint pad_pos = pad->ReturnShapePos();
double pad_x = pad_pos.x;
double pad_y = pad_pos.y;
wxSize pad_delta = pad->m_DeltaSize;
wxSize pad_delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize );
double pad_dx = pad_delta.x / 2;
double pad_dy = pad_delta.y / 2;
double pad_w = pad->m_Size.x / 2;
double pad_h = pad->m_Size.y / 2;
double pad_w = TO_LEGACY_LU_DBL( pad->m_Size.x / 2 );
double pad_h = TO_LEGACY_LU_DBL( pad->m_Size.y / 2 );
for( int layer = FIRST_COPPER_LAYER; layer < copper_layers; layer++ )
{
......
......@@ -127,20 +127,21 @@ void Build_Holes_List( BOARD* aPcb,
if( aGenerateNPTH_list && pad->m_Attribut != PAD_HOLE_NOT_PLATED )
continue;
if( pad->m_Drill.x == 0 )
if( pad->m_Drill.x == ZERO_LENGTH )
continue;
new_hole.m_Hole_NotPlated = (pad->m_Attribut == PAD_HOLE_NOT_PLATED);
new_hole.m_Tool_Reference = -1; // Flag is: Not initialized
new_hole.m_Hole_Orient = pad->m_Orient;
new_hole.m_Hole_Shape = 0; // hole shape: round
new_hole.m_Hole_Diameter = min( pad->m_Drill.x, pad->m_Drill.y );
new_hole.m_Hole_Diameter = min( TO_LEGACY_LU( pad->m_Drill.x ), TO_LEGACY_LU( pad->m_Drill.y ) );
new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
if( pad->m_DrillShape != PAD_CIRCLE )
new_hole.m_Hole_Shape = 1; // oval flag set
new_hole.m_Hole_Size = pad->m_Drill;
new_hole.m_Hole_Size.x = TO_LEGACY_LU( pad->m_Drill.x );
new_hole.m_Hole_Size.y = TO_LEGACY_LU( pad->m_Drill.y );
new_hole.m_Hole_Pos = pad->m_Pos; // hole position
new_hole.m_Hole_Bottom_Layer = LAYER_N_BACK;
new_hole.m_Hole_Top_Layer = LAYER_N_FRONT;// pad holes are through holes
......
......@@ -438,19 +438,19 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
{
fprintf( rptfile, "$PAD \"%.4s\"\n", pad->m_Padname );
sprintf( line, "position %9.6f %9.6f\n",
pad->m_Pos0.x * conv_unit,
pad->m_Pos0.y * conv_unit );
TO_LEGACY_LU_DBL( pad->m_Pos0.x ) * conv_unit,
TO_LEGACY_LU_DBL( pad->m_Pos0.y ) * conv_unit );
fputs( line, rptfile );
sprintf( line, "size %9.6f %9.6f\n",
pad->m_Size.x * conv_unit,
pad->m_Size.y * conv_unit );
TO_LEGACY_LU_DBL( pad->m_Size.x ) * conv_unit,
TO_LEGACY_LU_DBL( pad->m_Size.y ) * conv_unit );
fputs( line, rptfile );
sprintf( line, "drill %9.6f\n", pad->m_Drill.x * conv_unit );
sprintf( line, "drill %9.6f\n", TO_LEGACY_LU_DBL( pad->m_Drill.x ) * conv_unit );
fputs( line, rptfile );
sprintf( line, "shape_offset %9.6f %9.6f\n",
pad->m_Offset.x * conv_unit,
pad->m_Offset.y * conv_unit );
TO_LEGACY_LU_DBL( pad->m_Offset.x ) * conv_unit,
TO_LEGACY_LU_DBL( pad->m_Offset.y ) * conv_unit );
fputs( line, rptfile );
sprintf( line, "orientation %.2f\n",
......
......@@ -254,8 +254,8 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( pt_pad->m_PadShape != PAD_TRAPEZOID )
{
pt_pad->m_DeltaSize.x = 0;
pt_pad->m_DeltaSize.y = 0;
pt_pad->m_DeltaSize.x = ZERO_LENGTH;
pt_pad->m_DeltaSize.y = ZERO_LENGTH;
}
if( pt_pad->m_PadShape == PAD_CIRCLE )
pt_pad->m_Size.y = pt_pad->m_Size.x;
......@@ -264,9 +264,9 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
{
case PAD_SMD:
case PAD_CONN:
pt_pad->m_Drill = wxSize( 0, 0 );
pt_pad->m_Offset.x = 0;
pt_pad->m_Offset.y = 0;
pt_pad->m_Drill = VECTOR_PCB(ZERO_LENGTH, ZERO_LENGTH);//wxSize( 0, 0 );
pt_pad->m_Offset.x = ZERO_LENGTH;
pt_pad->m_Offset.y = ZERO_LENGTH;
break;
default:
......
......@@ -371,8 +371,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
}
Pad->m_Pos.x = (ibuf[0] + ibuf[2]) / 2;
Pad->m_Pos.y = (ibuf[1] + ibuf[3]) / 2;
Pad->m_Size.x = ibuf[4] + abs( ibuf[0] - ibuf[2] );
Pad->m_Size.y = ibuf[4] + abs( ibuf[1] - ibuf[3] );
Pad->m_Size.x = FROM_LEGACY_LU( ibuf[4] + abs( ibuf[0] - ibuf[2] ) );
Pad->m_Size.y = FROM_LEGACY_LU( ibuf[4] + abs( ibuf[1] - ibuf[3] ) );
Pad->m_Pos.x += m_Pos.x;
Pad->m_Pos.y += m_Pos.y;
......@@ -430,8 +430,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
Pad->m_Pos.x = ibuf[0];
Pad->m_Pos.y = ibuf[1];
Pad->m_Drill.x = Pad->m_Drill.y = ibuf[5];
Pad->m_Size.x = Pad->m_Size.y = ibuf[3] + Pad->m_Drill.x;
Pad->m_Drill.x = Pad->m_Drill.y = FROM_LEGACY_LU( (int) ibuf[5] );
Pad->m_Size.x = Pad->m_Size.y = FROM_LEGACY_LU( ibuf[3] ) + Pad->m_Drill.x;
Pad->m_Pos.x += m_Pos.x;
Pad->m_Pos.y += m_Pos.y;
......
......@@ -89,7 +89,7 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic )
int dx, dy;
wxPoint shape_pos = pt_pad->ReturnShapePos();
dx = pt_pad->m_Size.x / 2;
dx = TO_LEGACY_LU( pt_pad->m_Size.x / 2 );
dx += marge;
if( pt_pad->m_PadShape == PAD_CIRCLE )
......@@ -100,13 +100,13 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic )
}
dy = pt_pad->m_Size.y / 2;
dy = TO_LEGACY_LU( pt_pad->m_Size.y / 2 );
dy += marge;
if( pt_pad->m_PadShape == PAD_TRAPEZOID )
{
dx += abs( pt_pad->m_DeltaSize.y ) / 2;
dy += abs( pt_pad->m_DeltaSize.x ) / 2;
dx += TO_LEGACY_LU( ABS( pt_pad->m_DeltaSize.y ) / 2 );
dy += TO_LEGACY_LU( ABS( pt_pad->m_DeltaSize.x ) / 2 );
}
if( ( pt_pad->m_Orient % 900 ) == 0 ) /* The pad is a rectangle
......
......@@ -436,21 +436,21 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "TrackWidthList" ) == 0 )
{
double tmp = atof( data );
GetBoard()->m_TrackWidthList.push_back( FROM_LEGACY_LU( tmp ) );
//double tmp = atof( data );
GetBoard()->m_TrackWidthList.push_back( LENGTH_LOAD_STR( data ) );
continue;
}
if( stricmp( line, "TrackClearence" ) == 0 )
{
netclass_default->SetClearance( atoi( data ) );
netclass_default->Clearance( LENGTH_LOAD_STR( data ) );
continue;
}
if( stricmp( line, "TrackMinWidth" ) == 0 )
{
double width = atof( data );
GetBoard()->GetBoardDesignSettings()->m_TrackMinWidth = FROM_LEGACY_LU( width );
//double width = atof( data );
GetBoard()->GetBoardDesignSettings()->m_TrackMinWidth = LENGTH_LOAD_STR( data );
continue;
}
......@@ -479,8 +479,8 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "ViaMinSize" ) == 0 )
{
double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_ViasMinSize = FROM_LEGACY_LU( diameter );
//double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_MinVia.m_Diameter = LENGTH_LOAD_STR( data );
continue;
}
......@@ -491,22 +491,23 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "MicroViaMinSize" ) == 0 )
{
double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_MicroViasMinSize = FROM_LEGACY_LU( diameter );
//double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter = LENGTH_LOAD_STR( data );
continue;
}
if( stricmp( line, "ViaSizeList" ) == 0 )
{
double tmp = atof( data );
//double tmp = atof( data );
VIA_DIMENSION via_dim;
via_dim.m_Diameter = FROM_LEGACY_LU( tmp );
via_dim.m_Diameter = LENGTH_LOAD_STR( data );
data = strtok( NULL, " \n\r" );
if( data )
{
tmp = atof( data );
via_dim.m_Drill = FROM_LEGACY_LU( tmp > 0 ? tmp : 0 );
//tmp = atof( data );
LENGTH_PCB tmp = LENGTH_LOAD_STR( data );
via_dim.m_Drill = tmp > ZERO_LENGTH ? tmp : ZERO_LENGTH;
}
GetBoard()->m_ViasDimensionsList.push_back( via_dim );
......@@ -515,29 +516,31 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "ViaDrill" ) == 0 )
{
int diameter = atoi( data );
netclass_default->SetViaDrill( diameter );
VIA_DIMENSION via = netclass_default->Via();
via.m_Drill = LENGTH_LOAD_STR( data );
netclass_default->Via( via );
continue;
}
if( stricmp( line, "ViaMinDrill" ) == 0 )
{
double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_ViasMinDrill = FROM_LEGACY_LU( diameter );
//double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_MinVia.m_Drill = LENGTH_LOAD_STR( data );
continue;
}
if( stricmp( line, "MicroViaDrill" ) == 0 )
{
int diameter = atoi( data );
netclass_default->SetuViaDrill( diameter );
VIA_DIMENSION via = netclass_default->MicroVia();
via.m_Drill = LENGTH_LOAD_STR( data );
netclass_default->MicroVia( via );
continue;
}
if( stricmp( line, "MicroViaMinDrill" ) == 0 )
{
double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_MicroViasMinDrill = FROM_LEGACY_LU( diameter );
//double diameter = atof( data );
GetBoard()->GetBoardDesignSettings()->m_MinMicroVia.m_Drill = LENGTH_LOAD_STR( data );
continue;
}
......@@ -583,15 +586,15 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "PadSize" ) == 0 )
{
g_Pad_Master.m_Size.x = atoi( data );
g_Pad_Master.m_Size.x = LENGTH_LOAD_STR( data );
data = strtok( NULL, delims );
g_Pad_Master.m_Size.y = atoi( data );
g_Pad_Master.m_Size.y = LENGTH_LOAD_STR( data );
continue;
}
if( stricmp( line, "PadDrill" ) == 0 )
{
g_Pad_Master.m_Drill.x = atoi( data );
g_Pad_Master.m_Drill.x = LENGTH_LOAD_STR( data );
g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x;
continue;
}
......@@ -693,47 +696,57 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
// Save custom tracks width list (the first is not saved here: this is the netclass value
for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ )
fprintf( aFile, "TrackWidthList %f\n", TO_LEGACY_LU_DBL( aBoard->m_TrackWidthList[ii] ) );
fprintf( aFile, "TrackWidthList "FM_LENSV"\n", ARG_LENSV( aBoard->m_TrackWidthList[ii] ) );
fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() );
fprintf( aFile,
"TrackClearence "FM_LENSV"\n",
ARG_LENSV( netclass_default->Clearance() ) );
fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance );
fprintf( aFile,
"TrackMinWidth %f\n",
TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_TrackMinWidth ) );
"TrackMinWidth "FM_LENSV"\n",
ARG_LENSV( aBoard->GetBoardDesignSettings()->m_TrackMinWidth ) );
fprintf( aFile, "DrawSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_DrawSegmentWidth );
fprintf( aFile, "EdgeSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_EdgeSegmentWidth );
// Save current default via size, for compatibility with older Pcbnew version;
fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() );
fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() );
fprintf( aFile,
"ViaMinSize %f\n",
TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_ViasMinSize ) );
"ViaSize "FM_LENSV"\n",
ARG_LENSV( netclass_default->Via().m_Diameter ) );
fprintf( aFile,
"ViaDrill "FM_LENSV"\n",
ARG_LENSV( netclass_default->Via().m_Drill ) );
fprintf( aFile,
"ViaMinSize "FM_LENSV"\n",
ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinVia.m_Diameter ) );
fprintf( aFile,
"ViaMinDrill %f\n",
TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_ViasMinDrill ) );
"ViaMinDrill "FM_LENSV"\n",
ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinVia.m_Drill ) );
// Save custom vias diameters list (the first is not saved here: this is
// the netclass value
for( unsigned ii = 1; ii < aBoard->m_ViasDimensionsList.size(); ii++ )
fprintf( aFile, "ViaSizeList %f %f\n",
TO_LEGACY_LU_DBL( aBoard->m_ViasDimensionsList[ii].m_Diameter ),
TO_LEGACY_LU_DBL( aBoard->m_ViasDimensionsList[ii].m_Drill ) );
fprintf( aFile, "ViaSizeList "FM_LENSV" "FM_LENSV"\n",
ARG_LENSV( aBoard->m_ViasDimensionsList[ii].m_Diameter ),
ARG_LENSV( aBoard->m_ViasDimensionsList[ii].m_Drill ) );
// for old versions compatibility:
fprintf( aFile, "MicroViaSize %d\n", netclass_default->GetuViaDiameter() );
fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() );
fprintf( aFile,
"MicroViaSize "FM_LENSV"\n",
ARG_LENSV( netclass_default->MicroVia().m_Diameter ) );
fprintf( aFile,
"MicroViaDrill "FM_LENSV"\n",
ARG_LENSV( netclass_default->MicroVia().m_Drill ) );
fprintf( aFile,
"MicroViasAllowed %d\n",
aBoard->GetBoardDesignSettings()->m_MicroViasAllowed );
fprintf( aFile,
"MicroViaMinSize %f\n",
TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MicroViasMinSize ) );
"MicroViaMinSize "FM_LENSV"\n",
ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ) );
fprintf( aFile,
"MicroViaMinDrill %f\n",
TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MicroViasMinDrill ) );
"MicroViaMinDrill "FM_LENSV"\n",
ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinMicroVia.m_Drill ) );
fprintf( aFile, "TextPcbWidth %d\n", aBoard->GetBoardDesignSettings()->m_PcbTextWidth );
fprintf( aFile,
......@@ -744,8 +757,8 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y );
fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth );
fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y );
fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x );
fprintf( aFile, "PadSize "FM_LENSV" "FM_LENSV"\n", ARG_LENSV( g_Pad_Master.m_Size.x ), ARG_LENSV( g_Pad_Master.m_Size.y ) );
fprintf( aFile, "PadDrill "FM_LENSV"\n", ARG_LENSV( g_Pad_Master.m_Drill.x ) );
fprintf( aFile,
"Pad2MaskClearance %d\n",
aBoard->GetBoardDesignSettings()->m_SolderMaskMargin );
......
......@@ -692,7 +692,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DrawPanel->Refresh();
}
// TODO: this should be refactored in the name of good programming style
void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
{
D_PAD* pad = module->m_Pads;
......@@ -708,11 +708,18 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
for( ; pad != NULL; pad = (D_PAD*) pad->Next() )
{
pad->m_Pos0 = pad->m_Pos;
pad->m_Pos0 = FROM_LEGACY_LU_VEC( pad->m_Pos );
pad->m_Orient -= angle;
RotatePoint( &pad->m_Offset.x, &pad->m_Offset.y, angle );
wxPoint of;
of.x = TO_LEGACY_LU( pad->m_Offset.x );
of.y = TO_LEGACY_LU( pad->m_Offset.y );
RotatePoint( &of.x, &of.y, angle );
pad->m_Offset.x = FROM_LEGACY_LU( of.x );
pad->m_Offset.y = FROM_LEGACY_LU( of.y );
EXCHG( pad->m_Size.x, pad->m_Size.y );
RotatePoint( &pad->m_DeltaSize.x, &pad->m_DeltaSize.y, -angle );
wxSize delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize );
RotatePoint( &delta.x, &delta.y, -angle );
pad->m_DeltaSize = VECTOR_PCB( FROM_LEGACY_LU( delta.x ), FROM_LEGACY_LU( delta.y ) );
}
module->m_Reference->m_Pos0 = module->m_Reference->m_Pos;
......
......@@ -148,7 +148,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
aPad->m_Orient = g_Pad_Master.m_Orient +
( (MODULE*) aPad->GetParent() )->m_Orient;
aPad->m_Size = g_Pad_Master.m_Size;
aPad->m_DeltaSize = wxSize( 0, 0 );
aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH );//wxSize( 0, 0 );
aPad->m_Offset = g_Pad_Master.m_Offset;
aPad->m_Drill = g_Pad_Master.m_Drill;
aPad->m_DrillShape = g_Pad_Master.m_DrillShape;
......@@ -168,9 +168,8 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
{
case PAD_SMD:
case PAD_CONN:
aPad->m_Drill = wxSize( 0, 0 );
aPad->m_Offset.x = 0;
aPad->m_Offset.y = 0;
aPad->m_Drill = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 );
aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH );
}
aPad->ComputeShapeMaxRadius();
......@@ -205,8 +204,10 @@ void PCB_BASE_FRAME::AddPad( MODULE* Module, bool draw )
// Set the relative pad position
// ( pad position for module orient, 0, and relative to the module position)
Pad->m_Pos0 = Pad->m_Pos - Module->m_Pos;
RotatePoint( &Pad->m_Pos0, -Module->m_Orient );
Pad->m_Pos0 = FROM_LEGACY_LU_VEC( Pad->m_Pos - Module->m_Pos );
wxPoint p = TO_LEGACY_LU_WXP( Pad->m_Pos0 );
RotatePoint( &p, -Module->m_Orient );
Pad->m_Pos0 = FROM_LEGACY_LU_VEC( p );
/* Automatically increment the current pad number. */
long num = 0;
......@@ -365,8 +366,8 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC )
dY = Pad->m_Pos.y - Pad_OldPos.y;
RotatePoint( &dX, &dY, -Module->m_Orient );
Pad->m_Pos0.x += dX;
s_CurrentSelectedPad->m_Pos0.y += dY;
Pad->m_Pos0.x += FROM_LEGACY_LU( dX );
s_CurrentSelectedPad->m_Pos0.y += FROM_LEGACY_LU( dY ); /// @BUG???
Pad->m_Flags = 0;
......
......@@ -261,8 +261,8 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
PtPad->SetPadName( wxT( "1" ) );
PtPad->m_Pos = Mself.m_End;
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
PtPad->m_Size.x = PtPad->m_Size.y = Mself.m_Width;
PtPad->m_Pos0 = FROM_LEGACY_LU_VEC( PtPad->m_Pos - Module->m_Pos );
PtPad->m_Size.x = PtPad->m_Size.y = FROM_LEGACY_LU( Mself.m_Width );
PtPad->m_layerMask = g_TabOneLayerMask[Module->GetLayer()];
PtPad->m_Attribut = PAD_SMD;
PtPad->m_PadShape = PAD_CIRCLE;
......@@ -276,7 +276,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
PtPad = newpad;
PtPad->SetPadName( wxT( "2" ) );
PtPad->m_Pos = Mself.m_Start;
PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos;
PtPad->m_Pos0 = FROM_LEGACY_LU_VEC( PtPad->m_Pos - Module->m_Pos );
/* Modify text positions. */
Module->DisplayInfo( this );
......@@ -552,7 +552,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c
Module->m_Pads.PushFront( pad );
pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
pad->m_Size.x = pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() );
pad->m_Pos = Module->m_Pos;
pad->m_PadShape = PAD_RECT;
pad->m_Attribut = PAD_SMD;
......@@ -656,19 +656,19 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
switch( shape_type )
{
case 0: //Gap :
oX = pad->m_Pos0.x = -( gap_size + pad->m_Size.x ) / 2;
pad->m_Pos.x += pad->m_Pos0.x;
pad->m_Pos0.x = FROM_LEGACY_LU( oX = -( gap_size + TO_LEGACY_LU( pad->m_Size.x ) ) / 2 );
pad->m_Pos.x += TO_LEGACY_LU( pad->m_Pos0.x );
pad = pad->Next();
pad->m_Pos0.x = oX + gap_size + pad->m_Size.x;
pad->m_Pos.x += pad->m_Pos0.x;
pad->m_Pos0.x = FROM_LEGACY_LU( oX + gap_size + TO_LEGACY_LU( pad->m_Size.x ) );
pad->m_Pos.x += TO_LEGACY_LU( pad->m_Pos0.x );
break;
case 1: //Stub :
pad->SetPadName( wxT( "1" ) );
pad = pad->Next();
pad->m_Pos0.y = -( gap_size + pad->m_Size.y ) / 2;
pad->m_Size.y = gap_size;
pad->m_Pos.y += pad->m_Pos0.y;
pad->m_Pos0.y = FROM_LEGACY_LU( -( gap_size + TO_LEGACY_LU( pad->m_Size.y ) ) / 2 );
pad->m_Size.y = FROM_LEGACY_LU( gap_size );
pad->m_Pos.y += TO_LEGACY_LU( pad->m_Pos0.y );
break;
case 2: // Arc Stub created by a polygonal approach:
......@@ -683,7 +683,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
std::vector<wxPoint> polyPoints = edge->GetPolyPoints();
polyPoints.reserve( numPoints );
edge->m_Start0.y = -pad->m_Size.y / 2;
edge->m_Start0.y = TO_LEGACY_LU( -pad->m_Size.y / 2 );
polyPoints.push_back( wxPoint( 0, 0 ) );
......@@ -968,12 +968,12 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
Module = Create_MuWaveBasicShape( cmp_name, pad_count );
pad1 = Module->m_Pads;
pad1->m_Pos0.x = -ShapeSize.x / 2;
pad1->m_Pos.x += pad1->m_Pos0.x;
pad1->m_Pos0.x = FROM_LEGACY_LU( -ShapeSize.x / 2 );
pad1->m_Pos.x += TO_LEGACY_LU( pad1->m_Pos0.x );
pad2 = (D_PAD*) pad1->Next();
pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x;
pad2->m_Pos.x += pad2->m_Pos0.x;
pad2->m_Pos0.x = pad1->m_Pos0.x + FROM_LEGACY_LU( ShapeSize.x );
pad2->m_Pos.x += TO_LEGACY_LU( pad2->m_Pos0.x );
edge = new EDGE_MODULE( Module );
......@@ -987,13 +987,13 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
polyPoints.reserve( 2 * PolyEdges.size() + 2 );
// Init start point coord:
polyPoints.push_back( wxPoint( pad1->m_Pos0.x, 0 ) );
polyPoints.push_back( wxPoint( TO_LEGACY_LU( pad1->m_Pos0.x ), 0 ) );
wxPoint first_coordinate, last_coordinate;
for( ii = 0; ii < PolyEdges.size(); ii++ ) // Copy points
{
last_coordinate.x = wxRound( PolyEdges[ii] * ShapeScaleX ) + pad1->m_Pos0.x;
last_coordinate.x = wxRound( PolyEdges[ii] * ShapeScaleX ) + TO_LEGACY_LU( pad1->m_Pos0.x );
last_coordinate.y = -wxRound( PolyEdges[ii] * ShapeScaleY );
polyPoints.push_back( last_coordinate );
}
......@@ -1005,15 +1005,15 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
case 0: // Single
case 2: // Single mirrored
// Init end point coord:
pad2->m_Pos0.x = last_coordinate.x;
pad2->m_Pos0.x = FROM_LEGACY_LU( last_coordinate.x );
polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) );
pad1->m_Size.x = pad1->m_Size.y = ABS( first_coordinate.y );
pad2->m_Size.x = pad2->m_Size.y = ABS( last_coordinate.y );
pad1->m_Pos0.y = first_coordinate.y / 2;
pad2->m_Pos0.y = last_coordinate.y / 2;
pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y;
pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y;
pad1->m_Size.x = pad1->m_Size.y = FROM_LEGACY_LU( ABS( first_coordinate.y ) );
pad2->m_Size.x = pad2->m_Size.y = FROM_LEGACY_LU( ABS( last_coordinate.y ) );
pad1->m_Pos0.y = FROM_LEGACY_LU( first_coordinate.y / 2 );
pad2->m_Pos0.y = FROM_LEGACY_LU( last_coordinate.y / 2 );
pad1->m_Pos.y = TO_LEGACY_LU( pad1->m_Pos0.y ) + Module->m_Pos.y;
pad2->m_Pos.y = TO_LEGACY_LU( pad2->m_Pos0.y ) + Module->m_Pos.y;
break;
case 1: // Symmetric
......@@ -1026,8 +1026,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
polyPoints.push_back( pt );
}
pad1->m_Size.x = pad1->m_Size.y = 2 * ABS( first_coordinate.y );
pad2->m_Size.x = pad2->m_Size.y = 2 * ABS( last_coordinate.y );
pad1->m_Size.x = pad1->m_Size.y = FROM_LEGACY_LU( 2 * ABS( first_coordinate.y ) );
pad2->m_Size.x = pad2->m_Size.y = FROM_LEGACY_LU( 2 * ABS( last_coordinate.y ) );
break;
}
......@@ -1073,7 +1073,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module )
Module->Draw( DrawPanel, DC, GR_XOR );
/* Calculate the current dimension. */
gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x;
gap_size = TO_LEGACY_LU( next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x );
/* Entrer the desired length of the gap. */
msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() );
......@@ -1086,19 +1086,19 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module )
gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
/* Updating sizes of pads forming the gap. */
pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
pad->m_Pos0.y = 0;
oX = pad->m_Pos0.x = -( (gap_size + pad->m_Size.x) / 2 );
pad->m_Pos.x = pad->m_Pos0.x + Module->m_Pos.x;
pad->m_Pos.y = pad->m_Pos0.y + Module->m_Pos.y;
pad->m_Size.x = pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() );
pad->m_Pos0.y = ZERO_LENGTH;
pad->m_Pos0.x = FROM_LEGACY_LU( oX = -( ( gap_size + TO_LEGACY_LU( pad->m_Size.x ) ) / 2 ) );
pad->m_Pos.x = TO_LEGACY_LU( pad->m_Pos0.x ) + Module->m_Pos.x;
pad->m_Pos.y = TO_LEGACY_LU( pad->m_Pos0.y ) + Module->m_Pos.y;
RotatePoint( &pad->m_Pos.x, &pad->m_Pos.y,
Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
next_pad->m_Size.x = next_pad->m_Size.y = GetBoard()->GetCurrentTrackWidth();
next_pad->m_Pos0.y = 0;
next_pad->m_Pos0.x = oX + gap_size + next_pad->m_Size.x;
next_pad->m_Pos.x = next_pad->m_Pos0.x + Module->m_Pos.x;
next_pad->m_Pos.y = next_pad->m_Pos0.y + Module->m_Pos.y;
next_pad->m_Size.x = next_pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() );
next_pad->m_Pos0.y = ZERO_LENGTH;
next_pad->m_Pos0.x = FROM_LEGACY_LU( oX + gap_size + TO_LEGACY_LU( next_pad->m_Size.x ) );
next_pad->m_Pos.x = TO_LEGACY_LU( next_pad->m_Pos0.x ) + Module->m_Pos.x;
next_pad->m_Pos.y = TO_LEGACY_LU( next_pad->m_Pos0.y ) + Module->m_Pos.y;
RotatePoint( &next_pad->m_Pos.x, &next_pad->m_Pos.y,
Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
......
......@@ -217,12 +217,16 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&g_LibraryNames,
GROUPLIB ) );
#ifdef KICAD_NANOMETRE
/* TODO: something should be done here!!! */
#else
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDrlX" ), &g_Pad_Master.m_Drill.x,
320, 0, 0x7FFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimH" ), &g_Pad_Master.m_Size.x,
550, 0, 0x7FFF ) );
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimV" ), &g_Pad_Master.m_Size.y,
550, 0, 0x7FFF ) );
#endif
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ),
&boardDesignSettings.m_BoardThickness,
630, 0, 0xFFFF ) );
......
......@@ -97,11 +97,11 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* plotter, int aLayerMask, GRTraceMo
switch( pad->m_PadShape & 0x7F )
{
case PAD_CIRCLE:
plotter->flash_pad_circle( shape_pos, pad->m_Size.x, FILAIRE );
plotter->flash_pad_circle( shape_pos, TO_LEGACY_LU( pad->m_Size.x ), FILAIRE );
break;
case PAD_OVAL:
plotter->flash_pad_oval( shape_pos, pad->m_Size, pad->m_Orient, FILAIRE );
plotter->flash_pad_oval( shape_pos, TO_LEGACY_LU_WXS( pad->m_Size ), pad->m_Orient, FILAIRE );
break;
case PAD_TRAPEZOID:
......@@ -114,7 +114,7 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* plotter, int aLayerMask, GRTraceMo
case PAD_RECT:
default:
plotter->flash_pad_rect( shape_pos, pad->m_Size, pad->m_Orient, FILAIRE );
plotter->flash_pad_rect( shape_pos, TO_LEGACY_LU_WXS( pad->m_Size ), pad->m_Orient, FILAIRE );
break;
}
}
......@@ -840,8 +840,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
break;
}
size.x = pad->m_Size.x + ( 2 * margin.x );
size.y = pad->m_Size.y + ( 2 * margin.y );
size.x = TO_LEGACY_LU( pad->m_Size.x ) + ( 2 * margin.x );
size.y = TO_LEGACY_LU( pad->m_Size.y ) + ( 2 * margin.y );
/* Don't draw a null size item : */
if( size.x <= 0 || size.y <= 0 )
......@@ -851,7 +851,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
{
case PAD_CIRCLE:
if( aSkipNPTH_Pads &&
(pad->m_Size == pad->m_Drill) &&
( pad->m_Size.x == pad->m_Drill.x ) &&
( pad->m_Size.y == pad->m_Drill.y ) &&
(pad->m_Attribut == PAD_HOLE_NOT_PLATED) )
break;
......@@ -860,7 +861,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
case PAD_OVAL:
if( aSkipNPTH_Pads &&
(pad->m_Size == pad->m_Drill) &&
(pad->m_Size.x == pad->m_Drill.x ) &&
(pad->m_Size.y == pad->m_Drill.y ) &&
(pad->m_Attribut == PAD_HOLE_NOT_PLATED) )
break;
......@@ -1016,7 +1018,7 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter,
{
for( PtPad = Module->m_Pads; PtPad != NULL; PtPad = PtPad->Next() )
{
if( PtPad->m_Drill.x == 0 )
if( PtPad->m_Drill.x == ZERO_LENGTH )
continue;
// Output hole shapes:
......@@ -1024,12 +1026,13 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter,
if( PtPad->m_DrillShape == PAD_OVAL )
{
diam = PtPad->m_Drill;
diam.x = TO_LEGACY_LU( PtPad->m_Drill.x );
diam.y = TO_LEGACY_LU( PtPad->m_Drill.y );
aPlotter->flash_pad_oval( pos, diam, PtPad->m_Orient, aTraceMode );
}
else
{
diam.x = aSmallDrillShape ? SMALL_DRILL : PtPad->m_Drill.x;
diam.x = aSmallDrillShape ? SMALL_DRILL : TO_LEGACY_LU( PtPad->m_Drill.x );
aPlotter->flash_pad_circle( pos, diam.x, aTraceMode );
}
}
......
......@@ -351,16 +351,18 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
continue;
// Manage hole according to the print drill option
wxSize drill_tmp = pt_pad->m_Drill;
wxSize drill_tmp;
drill_tmp.x = TO_LEGACY_LU( pt_pad->m_Drill.x );
drill_tmp.y = TO_LEGACY_LU( pt_pad->m_Drill.y );
switch ( aDrillShapeOpt )
{
case PRINT_PARAMETERS::NO_DRILL_SHAPE:
pt_pad->m_Drill = wxSize(0,0);
pt_pad->m_Drill = VECTOR_PCB(ZERO_LENGTH, ZERO_LENGTH); //wxSize(0,0);
break;
case PRINT_PARAMETERS::SMALL_DRILL_SHAPE:
pt_pad->m_Drill.x = MIN(SMALL_DRILL,pt_pad->m_Drill.x);
pt_pad->m_Drill.y = MIN(SMALL_DRILL,pt_pad->m_Drill.y);
pt_pad->m_Drill.x = MIN(FROM_LEGACY_LU( SMALL_DRILL ),pt_pad->m_Drill.x );
pt_pad->m_Drill.y = MIN(FROM_LEGACY_LU( SMALL_DRILL ),pt_pad->m_Drill.y );
break;
case PRINT_PARAMETERS::FULL_DRILL_SHAPE:
// Do nothing
......@@ -368,7 +370,8 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
}
pt_pad->Draw( aPanel, aDC, aDraw_mode );
pt_pad->m_Drill = drill_tmp;
pt_pad->m_Drill.x = FROM_LEGACY_LU( drill_tmp.x );
pt_pad->m_Drill.y = FROM_LEGACY_LU( drill_tmp.y );
}
/* Print footprint graphic shapes */
......
......@@ -464,8 +464,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
int cY = ( Board.m_GridRouting * row_source )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
int dx = pt_cur_ch->m_PadStart->m_Size.x / 2;
int dy = pt_cur_ch->m_PadStart->m_Size.y / 2;
int dx = TO_LEGACY_LU( pt_cur_ch->m_PadStart->m_Size.x / 2 );
int dy = TO_LEGACY_LU( pt_cur_ch->m_PadStart->m_Size.y / 2 );
int px = pt_cur_ch->m_PadStart->GetPosition().x;
int py = pt_cur_ch->m_PadStart->GetPosition().y;
......@@ -479,8 +479,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
cY = ( Board.m_GridRouting * row_target )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
dx = pt_cur_ch->m_PadEnd->m_Size.x / 2;
dy = pt_cur_ch->m_PadEnd->m_Size.y / 2;
dx = TO_LEGACY_LU( pt_cur_ch->m_PadEnd->m_Size.x / 2 );
dy = TO_LEGACY_LU( pt_cur_ch->m_PadEnd->m_Size.y / 2 );
px = pt_cur_ch->m_PadEnd->GetPosition().x;
py = pt_cur_ch->m_PadEnd->GetPosition().y;
......
......@@ -321,11 +321,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
POINT dsnOffset;
if( aPad->m_Offset.x || aPad->m_Offset.y )
if( aPad->m_Offset.x != ZERO_LENGTH || aPad->m_Offset.y != ZERO_LENGTH )
{
char offsetTxt[64];
char offsetTxt[64]; /// @BUG !!!Unsafe
wxPoint offset( aPad->m_Offset.x, aPad->m_Offset.y );
wxPoint offset( TO_LEGACY_LU( aPad->m_Offset.x ), TO_LEGACY_LU( aPad->m_Offset.y ) );
dsnOffset = mapPt( offset );
......@@ -341,7 +341,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
default:
case PAD_CIRCLE:
{
double diameter = scale(aPad->m_Size.x);
double diameter = scale( TO_LEGACY_LU( aPad->m_Size.x ) );
for( int ndx=0; ndx<reportedLayers; ++ndx )
{
......@@ -357,7 +357,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
}
snprintf( name, sizeof(name), "Round%sPad_%.6g_mil",
uniqifier.c_str(), scale(aPad->m_Size.x) );
uniqifier.c_str(), scale(TO_LEGACY_LU( aPad->m_Size.x ) ) );
name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name );
......@@ -366,8 +366,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
case PAD_RECT:
{
double dx = scale( aPad->m_Size.x ) / 2.0;
double dy = scale( aPad->m_Size.y ) / 2.0;
double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 2.0;
double dy = scale( TO_LEGACY_LU( aPad->m_Size.y ) ) / 2.0;
POINT lowerLeft( -dx, -dy );
POINT upperRight( dx, dy );
......@@ -388,7 +388,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
}
snprintf( name, sizeof(name), "Rect%sPad_%.6gx%.6g_mil",
uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y) );
uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( aPad->m_Size.y ) ) );
name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name );
......@@ -397,8 +397,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
case PAD_OVAL:
{
double dx = scale( aPad->m_Size.x ) / 2.0;
double dy = scale( aPad->m_Size.y ) / 2.0;
double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 2.0;
double dy = scale( TO_LEGACY_LU( aPad->m_Size.y ) ) / 2.0;
double dr = dx - dy;
double radius;
POINT start;
......@@ -436,7 +436,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
}
snprintf( name, sizeof(name), "Oval%sPad_%.6gx%.6g_mil",
uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y) );
uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( aPad->m_Size.y ) ) );
name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name );
......@@ -445,11 +445,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
case PAD_TRAPEZOID:
{
double dx = scale( aPad->m_Size.x ) / 2.0;
double dy = scale( aPad->m_Size.y ) / 2.0;
double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 2.0;
double dy = scale( TO_LEGACY_LU( aPad->m_Size.y ) ) / 2.0;
double ddx = scale( aPad->m_DeltaSize.x ) / 2.0;
double ddy = scale( aPad->m_DeltaSize.y ) / 2.0;
double ddx = scale( TO_LEGACY_LU( aPad->m_DeltaSize.x ) ) / 2.0;
double ddy = scale( TO_LEGACY_LU( aPad->m_DeltaSize.y ) ) / 2.0;
// see class_pad_draw_functions.cpp which draws the trapezoid pad
POINT lowerLeft( -dx - ddy, -dy - ddx );
......@@ -479,15 +479,15 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
polygon->AppendPoint( lowerRight );
}
D(printf( "m_DeltaSize: %d,%d\n", aPad->m_DeltaSize.x, aPad->m_DeltaSize.y );)
D(printf( "m_DeltaSize: %d,%d\n", TO_LEGACY_LU( aPad->m_DeltaSize.x ), TO_LEGACY_LU( aPad->m_DeltaSize.y ) );)
// this string _must_ be unique for a given physical shape
snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_mil",
uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y),
aPad->m_DeltaSize.x < 0 ? 'n' : 'p',
abs( scale( aPad->m_DeltaSize.x )),
aPad->m_DeltaSize.y < 0 ? 'n' : 'p',
abs( scale( aPad->m_DeltaSize.y ))
uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( aPad->m_Size.y ) ),
aPad->m_DeltaSize.x < ZERO_LENGTH ? 'n' : 'p',
abs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.x ) )),
aPad->m_DeltaSize.y < ZERO_LENGTH ? 'n' : 'p',
abs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.y ) ))
);
name[ sizeof(name)-1 ] = 0;
......@@ -527,8 +527,8 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
// see if this pad is a through hole with no copper on its perimeter
if( isRoundKeepout( pad ) )
{
double diameter = scale( pad->m_Drill.x );
POINT vertex = mapPt( pad->m_Pos0 );
double diameter = scale( TO_LEGACY_LU( pad->m_Drill.x ) );
POINT vertex = mapPt( TO_LEGACY_LU_WXP( pad->m_Pos0 ) );
int layerCount = aBoard->GetCopperLayerCount();
for( int layer=0; layer<layerCount; ++layer )
......@@ -596,7 +596,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
pin->SetRotation( angle / 10.0 );
}
wxPoint pos( pad->m_Pos0 );
wxPoint pos( TO_LEGACY_LU_WXP( pad->m_Pos0 ) );
pin->SetVertex( mapPt( pos ) );
}
......
......@@ -201,7 +201,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
* inside the board (in fact inside the hole. Some photo diodes and Leds are
* like this)
*/
if( (pad->m_Drill.x == 0) && (pad->m_Drill.y == 0) )
if( (pad->m_Drill.x == ZERO_LENGTH) && (pad->m_Drill.y == ZERO_LENGTH) )
continue;
// Use a dummy pad to calculate a hole shape that have the same dimension as
......
......@@ -68,15 +68,15 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffe
// Thermal bridges are like a segment from a starting point inside the pad
// to an ending point outside the pad
wxPoint startpoint, endpoint;
endpoint.x = ( pad->m_Size.x / 2 ) + aZone->m_ThermalReliefGapValue;
endpoint.y = ( pad->m_Size.y / 2 ) + aZone->m_ThermalReliefGapValue;
endpoint.x = ( TO_LEGACY_LU( pad->m_Size.x / 2 ) ) + aZone->m_ThermalReliefGapValue;
endpoint.y = ( TO_LEGACY_LU( pad->m_Size.y / 2 ) ) + aZone->m_ThermalReliefGapValue;
int copperThickness = aZone->m_ThermalReliefCopperBridgeValue - aZone->m_ZoneMinThickness;
if( copperThickness < 0 )
copperThickness = 0;
startpoint.x = min( pad->m_Size.x, copperThickness );
startpoint.y = min( pad->m_Size.y, copperThickness );
startpoint.x = min( TO_LEGACY_LU( pad->m_Size.x ), copperThickness );
startpoint.y = min( TO_LEGACY_LU( pad->m_Size.y ), copperThickness );
startpoint.x /= 2;
startpoint.y /= 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment