Commit 2a69ffb4 authored by Vladimir Ur's avatar Vladimir Ur

Nanometric work

- D_PAD members converted;
- style improved;
- GetPosition made returning value, added SetPosition;
- highly experimental, test it please!
parents 69f8b30b 959e3386
...@@ -884,7 +884,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) ...@@ -884,7 +884,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
} }
} }
/** @TODO: move D_PAD method to appropriate file */
/* Draw 3D pads. */ /* Draw 3D pads. */
void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
{ {
...@@ -903,8 +903,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) ...@@ -903,8 +903,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
int color; int color;
scale = g_Parm_3D_Visu.m_BoardScale; scale = g_Parm_3D_Visu.m_BoardScale;
holeX = (double) TO_LEGACY_LU_DBL( m_Drill.x ) * scale / 2; holeX = (double) TO_LEGACY_LU_DBL( m_Drill.x() ) * scale / 2;
holeY = (double) TO_LEGACY_LU_DBL( m_Drill.y ) * scale / 2; holeY = (double) TO_LEGACY_LU_DBL( m_Drill.y() ) * scale / 2;
hole = MIN( holeX, holeY ); hole = MIN( holeX, holeY );
/* Calculate the center of the pad. */ /* Calculate the center of the pad. */
...@@ -914,12 +914,12 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) ...@@ -914,12 +914,12 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
xc = ux0; xc = ux0;
yc = uy0; yc = uy0;
dx = dx0 = TO_LEGACY_LU( m_Size.x ) >> 1; dx = dx0 = TO_LEGACY_LU( m_Size.x() ) >> 1;
dy = dy0 = TO_LEGACY_LU( m_Size.y ) >> 1; dy = dy0 = TO_LEGACY_LU( m_Size.y() ) >> 1;
angle = m_Orient; angle = m_Orient;
drillx = m_Pos.x * scale; drillx = TO_LEGACY_LU( m_Pos.x() ) * scale;
drilly = m_Pos.y * scale; drilly = TO_LEGACY_LU( m_Pos.y() ) * scale;
/* Draw the pad hole (TODO: draw OBLONG hole) */ /* Draw the pad hole (TODO: draw OBLONG hole) */
if( holeX && holeY ) if( holeX && holeY )
...@@ -980,13 +980,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) ...@@ -980,13 +980,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
{ {
delta_cx = dx - dy; delta_cx = dx - dy;
delta_cy = 0; delta_cy = 0;
w = TO_LEGACY_LU( m_Size.y ) * scale; w = TO_LEGACY_LU( m_Size.y() ) * scale;
} }
else /* Vertical ellipse */ else /* Vertical ellipse */
{ {
delta_cx = 0; delta_cx = 0;
delta_cy = dy - dx; delta_cy = dy - dx;
w = TO_LEGACY_LU( m_Size.x ) * scale; w = TO_LEGACY_LU( m_Size.x() ) * scale;
} }
RotatePoint( &delta_cx, &delta_cy, angle ); RotatePoint( &delta_cx, &delta_cy, angle );
......
...@@ -37,13 +37,6 @@ ...@@ -37,13 +37,6 @@
#include "auxiliary.h" #include "auxiliary.h"
#ifndef max
#define max( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
#endif
#ifndef min
#define min( a, b ) ( ( (a) < (b) ) ? (a) : (b) )
#endif
// Define some types used here from boost::polygon // Define some types used here from boost::polygon
namespace bpl = boost::polygon; // bpl = boost polygon library namespace bpl = boost::polygon; // bpl = boost polygon library
using namespace bpl::operators; // +, -, =, ... using namespace bpl::operators; // +, -, =, ...
...@@ -476,7 +469,7 @@ void BezierToPolyline( std::vector <potrace_dpoint_t>& aCornersBuffer, ...@@ -476,7 +469,7 @@ void BezierToPolyline( std::vector <potrace_dpoint_t>& aCornersBuffer,
* occur at an endpoint. */ * occur at an endpoint. */
dd0 = sq( p1.x - 2 * p2.x + p3.x ) + sq( p1.y - 2 * p2.y + p3.y ); dd0 = sq( p1.x - 2 * p2.x + p3.x ) + sq( p1.y - 2 * p2.y + p3.y );
dd1 = sq( p2.x - 2 * p3.x + p4.x ) + sq( p2.y - 2 * p3.y + p4.y ); dd1 = sq( p2.x - 2 * p3.x + p4.x ) + sq( p2.y - 2 * p3.y + p4.y );
dd = 6 * sqrt( max( dd0, dd1 ) ); dd = 6 * sqrt( fmax( dd0, dd1 ) );
e2 = 8 * delta <= dd ? 8 * delta / dd : 1; e2 = 8 * delta <= dd ? 8 * delta / dd : 1;
epsilon = sqrt( e2 ); /* necessary interval size */ epsilon = sqrt( e2 ); /* necessary interval size */
......
...@@ -418,7 +418,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int ...@@ -418,7 +418,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int
const LENGTH_UNIT_DESC MillimetreDesc = const LENGTH_UNIT_DESC MillimetreDesc =
{ {
LENGTH_UNITS<LENGTH_DEF>::millimetre(), LENGTH_UNITS<LENGTH_PCB>::millimetre(),
wxT( "mm" ), wxT( "mm" ),
6 6
}; };
...@@ -426,7 +426,7 @@ const LENGTH_UNIT_DESC MillimetreDesc = ...@@ -426,7 +426,7 @@ const LENGTH_UNIT_DESC MillimetreDesc =
const LENGTH_UNIT_DESC InchDesc = const LENGTH_UNIT_DESC InchDesc =
{ {
LENGTH_UNITS<LENGTH_DEF>::inch(), LENGTH_UNITS<LENGTH_PCB>::inch(),
wxT( "\"" ), wxT( "\"" ),
7 7
}; };
...@@ -434,7 +434,7 @@ const LENGTH_UNIT_DESC InchDesc = ...@@ -434,7 +434,7 @@ const LENGTH_UNIT_DESC InchDesc =
const LENGTH_UNIT_DESC MilDesc = const LENGTH_UNIT_DESC MilDesc =
{ {
LENGTH_UNITS<LENGTH_DEF>::mil(), LENGTH_UNITS<LENGTH_PCB>::mil(),
wxT( "mil" ), wxT( "mil" ),
5 5
}; };
...@@ -442,7 +442,7 @@ const LENGTH_UNIT_DESC MilDesc = ...@@ -442,7 +442,7 @@ const LENGTH_UNIT_DESC MilDesc =
const LENGTH_UNIT_DESC UnscaledDesc = /* stub */ const LENGTH_UNIT_DESC UnscaledDesc = /* stub */
{ {
LENGTH_DEF::quantum(), LENGTH_PCB::quantum(),
wxT( "" ), wxT( "" ),
4 4
}; };
...@@ -461,7 +461,7 @@ const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ) { ...@@ -461,7 +461,7 @@ const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ) {
/* TODO: localisation */ /* TODO: localisation */
wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue, wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_PCB aValue,
bool aAdd_unit_symbol ) { bool aAdd_unit_symbol ) {
wxString StringValue; wxString StringValue;
double value_to_print; double value_to_print;
...@@ -490,11 +490,11 @@ wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue, ...@@ -490,11 +490,11 @@ wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue,
return StringValue; return StringValue;
} }
LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue ) LENGTH_PCB StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue )
{ {
LENGTH_DEF Value; LENGTH_PCB Value;
double dtmp = 0; double dtmp = 0;
/* Acquire the 'right' decimal point separator */ /* Acquire the 'right' decimal point separator */
const struct lconv* lc = localeconv(); const struct lconv* lc = localeconv();
...@@ -544,21 +544,21 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa ...@@ -544,21 +544,21 @@ LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextVa
aUnit = &MilDesc; aUnit = &MilDesc;
} }
Value = LENGTH_DEF( dtmp * LENGTH< double, 1 >( aUnit->m_Value ) ); Value = LENGTH_PCB( dtmp * LENGTH< double, 1 >( aUnit->m_Value ) );
return Value; return Value;
} }
void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_DEF Value ) void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_PCB Value )
{ {
wxString msg = LengthToString( UnitDescription( g_UserUnit ), Value ); wxString msg = LengthToString( UnitDescription( g_UserUnit ), Value );
TextCtr.SetValue( msg ); TextCtr.SetValue( msg );
} }
LENGTH_DEF LengthFromTextCtrl( const wxTextCtrl& TextCtr ) LENGTH_PCB LengthFromTextCtrl( const wxTextCtrl& TextCtr )
{ {
LENGTH_DEF value; LENGTH_PCB value;
wxString msg = TextCtr.GetValue(); wxString msg = TextCtr.GetValue();
value = StringToLength( UnitDescription( g_UserUnit ), msg ); value = StringToLength( UnitDescription( g_UserUnit ), msg );
......
...@@ -802,3 +802,85 @@ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) ...@@ -802,3 +802,85 @@ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig )
aConfig->Write( configkey, libname ); aConfig->Write( configkey, libname );
} }
} }
/*
* LENGTH_PCB
*/
PARAM_CFG_LENGTH_PCB::PARAM_CFG_LENGTH_PCB( const wxChar* ident,
LENGTH_PCB* ptparam,
LENGTH_PCB default_val,
LENGTH_PCB min,
LENGTH_PCB max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
{
m_Pt_param = ptparam;
m_Default = default_val;
m_Min = min;
m_Max = max;
}
PARAM_CFG_LENGTH_PCB::PARAM_CFG_LENGTH_PCB( bool Insetup,
const wxChar* ident,
LENGTH_PCB* ptparam,
LENGTH_PCB default_val,
LENGTH_PCB min,
LENGTH_PCB max,
const wxChar* group ) :
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
{
m_Pt_param = ptparam;
m_Default = default_val;
m_Min = min;
m_Max = max;
m_Setup = Insetup;
}
/** ReadParam
* read the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that store the parameter
*/
void PARAM_CFG_LENGTH_PCB::ReadParam( wxConfigBase* aConfig )
{
if( m_Pt_param == NULL || aConfig == NULL )
return;
LENGTH_PCB ftmp;
wxString msg;
msg = aConfig->Read( m_Ident, wxT( "" ) );
if( msg.IsEmpty() )
{
ftmp = m_Default;
}
else
{
double t;
msg.ToDouble( &t );
ftmp = FROM_LEGACY_LU( t );
if( (ftmp < m_Min) || (ftmp > m_Max) )
ftmp = m_Default;
}
*m_Pt_param = ftmp;
}
/** SaveParam
* save the the value of parameter this stored in aConfig
* @param aConfig = the wxConfigBase that can store the parameter
*/
void PARAM_CFG_LENGTH_PCB::SaveParam( wxConfigBase* aConfig )
{
if( m_Pt_param == NULL || aConfig == NULL )
return;
#ifdef KICAD_NANOMETRE
aConfig->Write( m_Ident, TO_LEGACY_LU_DBL( *m_Pt_param ) );
#else // save it as int to mantain compatibility while in transition to nanoscale
aConfig->Write( m_Ident, TO_LEGACY_LU( *m_Pt_param ) );
#endif
}
...@@ -167,11 +167,15 @@ public: ...@@ -167,11 +167,15 @@ public:
* @return const wxPoint& - The position of this object. * @return const wxPoint& - The position of this object.
* This function exists mainly to satisfy the virtual GetPosition() in parent class * This function exists mainly to satisfy the virtual GetPosition() in parent class
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Start; // it had to be start or end. return m_Start; // it had to be start or end.
} }
void SetPosition( const wxPoint& pos ) {
m_Start = pos;
}
/** /**
* Function GetABPosition * Function GetABPosition
* returns the image position of aPosition for this object. * returns the image position of aPosition for this object.
......
...@@ -76,9 +76,19 @@ public: ...@@ -76,9 +76,19 @@ public:
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
* @return wxPoint& - The position of this object, non-const so it can be changed * @return wxPoint - The position of this object
* It seems this function could not return modifiable reference as this
* contradict good design practice: as the class could be able
* doing internal recalculations on reposition.
* @TODO: Check all the GetPosition calls for position assignments.
*/ */
virtual wxPoint& GetPosition() = 0; virtual const wxPoint GetPosition() const = 0;
/**
* Sets the position of this object.
* @param pos The position of this object
*/
virtual void SetPosition( const wxPoint& pos ) = 0;
/** /**
* Function GetLayer * Function GetLayer
...@@ -313,10 +323,9 @@ public: ...@@ -313,10 +323,9 @@ public:
{} {}
//-----< satisfy some virtual functions >------------------------------ //-----< satisfy some virtual functions >------------------------------
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
static wxPoint dummy; return wxPoint(0, 0);
return dummy;
} }
void Draw( EDA_DRAW_PANEL* DrawPanel, wxDC* DC, void Draw( EDA_DRAW_PANEL* DrawPanel, wxDC* DC,
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#ifdef KICAD_NANOMETRE #ifdef KICAD_NANOMETRE
#include "length.h" #include "lengthpcb.h"
#endif #endif
class wxAboutDialogInfo; class wxAboutDialogInfo;
...@@ -385,21 +385,21 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ); ...@@ -385,21 +385,21 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit );
struct LENGTH_UNIT_DESC struct LENGTH_UNIT_DESC
{ {
LENGTH_DEF m_Value; LENGTH_PCB m_Value;
const wxString m_Symbol; const wxString m_Symbol;
int m_Precision; int m_Precision;
}; };
extern const LENGTH_UNIT_DESC MillimetreDesc, InchDesc, MilDesc; extern const LENGTH_UNIT_DESC MillimetreDesc, InchDesc, MilDesc;
const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ); const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit );
LENGTH_DEF StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue ); LENGTH_PCB StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue );
wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_DEF aValue, wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_PCB aValue,
bool aAdd_unit_symbol = false ); bool aAdd_unit_symbol = false );
void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_DEF Value ); void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_PCB Value );
LENGTH_DEF LengthFromTextCtrl( const wxTextCtrl& TextCtr ); LENGTH_PCB LengthFromTextCtrl( const wxTextCtrl& TextCtr );
/* transition macros */ /* transition macros */
#define STR_TO_LENGTH( unit, str, iu ) \ #define STR_TO_LENGTH( unit, str, iu ) \
......
...@@ -8,66 +8,33 @@ ...@@ -8,66 +8,33 @@
#ifndef LENGTH_H_INCLUDED #ifndef LENGTH_H_INCLUDED
#define LENGTH_H_INCLUDED 1 #define LENGTH_H_INCLUDED 1
#include "limited_int.h" #include <math.h>
/* type to be used by length units by default */ template < typename T = double, int P = 1 > class LENGTH;
typedef LIMITED_INT< int > DEF_LENGTH_VALUE;
/**
* Length template class.
* @param T actual type holding a value (be aware of precision and range!)
* @param P power of length unit: 1 - length, 2 - area, 3 - volume, -1 - lin. density etc...
* This class check length dimension in compile time. In runtime it behaves
* exactly like contained type t (which should be numeric type, like int or double)
* This class can be replaced with its contained type or simple stub.
* Check rules:
* - comparisons (< = etc.), addition, subtraction require values of same dimension
* e. g. length with length, area with area etc.
* - multiplication and division result have appropriate dimension (powers
* added and subtracted respectively)
* - sqrt and cbrt have appropriate dimensions (P/2 and P/3).
* Limitations:
* - functions which should not be applied to dimensioned values are not implemeted:
* they include algebraic (exp, log...), trigo (sin, cos...), hyperbolic (sinh, cosh..)
* - pow function is not implemented as it is require dimension check in runtime
* you should use multiplication, division, sqrt and cbrt functions instead.
* - sqrt and cbrt result type should be instantiated before they used
* Be aware when using them in complex formulae, e. g.
* LENGTH< double, 1 > len = cbrt(vol) - is ok, but
* LENGTH< double, 2 > vol = sqrt(area*area*area*area)/length - will fail
* if LENGTH<..., 4> is not instantiated
* - non-integer power values do not supported
* they should be implemented carefully using natural fractions, not floats, to be exact
* but they are very rare so you should not worry about.
* e. g. linear electric noise density should be in mV/sqrt(m)
* - automatic numeric type casts are not performed. You even have to manually
* cast LENGTH< short > to LENGTH< int > or LENGTH< float >
* to LENGTH< double >. Anyway it is not such trouble as progremmer should be
* very careful when mixing numeric types and avoid automatic casts.
*
*/
template < typename T = DEF_LENGTH_VALUE, int P = 1 > class LENGTH;
typedef LENGTH<DEF_LENGTH_VALUE, 1> LENGTH_DEF;
/**
* Length units contained in this class
*/
template <typename T> class LENGTH_UNITS; template <typename T> class LENGTH_UNITS;
/** /*!
* For internal needs * The template that "inflate" LENGTH< T, 0 > class to T. Used with (*) and (/).
*/ */
template < typename T, int P > struct LENGTH_TRAITS template < typename T, int P > struct LENGTH_TRAITS
{ {
typedef LENGTH<T, P> flat; typedef LENGTH<T, P> flat;
}; };
template < typename T > struct LENGTH_TRAITS< T, 0 >
{
/* length dimension to power 0 is just a number, so LENGTH<T, 0> should be automatically converted to T */
typedef T flat;
};
/*!
* The template for value type conversions
*/
template < typename T > struct LENGTH_CASTS template < typename T > struct LENGTH_CASTS
{ {
template< typename X > static T cast( const X x ) /*! This function to convert length value to given type T. */
template< typename X > static T nearest( const X x )
{ {
return T( x ); return T( x );
} }
...@@ -75,7 +42,7 @@ template < typename T > struct LENGTH_CASTS ...@@ -75,7 +42,7 @@ template < typename T > struct LENGTH_CASTS
template <> struct LENGTH_CASTS < int > template <> struct LENGTH_CASTS < int >
{ {
static int cast( const double x ) static int nearest( const double x )
{ {
return floor( x + 0.5 ); return floor( x + 0.5 );
} }
...@@ -83,25 +50,56 @@ template <> struct LENGTH_CASTS < int > ...@@ -83,25 +50,56 @@ template <> struct LENGTH_CASTS < int >
template <> struct LENGTH_CASTS < long > template <> struct LENGTH_CASTS < long >
{ {
static long cast( const double x ) static long nearest( const double x )
{ {
return floor( x + 0.5 ); return floor( x + 0.5 );
} }
}; };
/** Forward declaration for LIMITED_INT to use with casts. */
template < typename T > class LIMITED_INT;
template < typename T > struct LENGTH_CASTS < LIMITED_INT< T > > template < typename T > struct LENGTH_CASTS < LIMITED_INT< T > >
{ {
static LIMITED_INT< T > cast( const double x ) static LIMITED_INT< T > nearest( const double x )
{ {
return LIMITED_INT< T > ( floor( x + 0.5 ) ); return LIMITED_INT< T > ( floor( x + 0.5 ) );
} }
}; };
template < typename T > struct LENGTH_TRAITS< T, 0 > /**
{ * Length template class.
/* length dimension to power 0 is just a number, so LENGTH<T, 0> should be automatically converted to T */ * @param T actual type holding a value (be aware of precision and range!)
typedef T flat; * @param P power of length unit: 1 - length, 2 - area, 3 - volume, -1 - lin. density etc...
}; * This class check length dimension in compile time. In runtime it behaves
* exactly like contained type t (which should be numeric type, like int or double)
* This class can be replaced with its contained type or simple stub.
* Check rules:
* - comparisons (< = etc.), addition, subtraction require values of same dimension
* e. g. length with length, area with area etc.
* - multiplication and division result have appropriate dimension (powers
* added and subtracted respectively)
* - sqrt and cbrt have appropriate dimensions (P/2 and P/3).
* Limitations:
* - functions which should not be applied to dimensioned values are not implemeted:
* they include algebraic (exp, log...), trigo (sin, cos...), hyperbolic (sinh, cosh..)
* - pow function is not implemented as it is require dimension check in runtime
* you should use multiplication, division, sqrt and cbrt functions instead.
* - sqrt and cbrt result type should be instantiated before they used
* Be aware when using them in complex formulae, e. g.
* LENGTH< double, 1 > len = cbrt(vol) - is ok, but
* LENGTH< double, 3 > vol = sqrt(area*area*area*area)/length - will fail
* if LENGTH<..., 4> is not instantiated
* - non-integer power values do not supported
* they should be implemented carefully using natural fractions, not floats, to be exact
* but they are very rare so you should not worry about.
* e. g. linear electric noise density should be in mV/sqrt(m)
* - automatic numeric type casts are not performed. You even have to manually
* cast LENGTH< short > to LENGTH< int > or LENGTH< float >
* to LENGTH< double >. Anyway it is not such trouble as progremmer should be
* very careful when mixing numeric types and avoid automatic casts.
*
*/
template< typename T, int P > class LENGTH template< typename T, int P > class LENGTH
{ {
...@@ -110,38 +108,45 @@ template< typename T, int P > class LENGTH ...@@ -110,38 +108,45 @@ template< typename T, int P > class LENGTH
template < typename Y, int R > friend class LENGTH; template < typename Y, int R > friend class LENGTH;
protected: protected:
T m_U; T u;
LENGTH( T units ) : m_U( units )
{ /**
} * The 'direct' constructor which should not be accessed from outside
static T RawValue( const LENGTH<T, P> &x ) */
{ LENGTH( T units ) : u( units )
return x.m_U;
}
static T RawValue( const T& x )
{ {
return x;
} }
public: public:
typedef T value_type; typedef T value_type;
enum enum
{ {
dimension = P dimension = P
}; };
template< typename U > LENGTH( const LENGTH< U, P > &orig ) template< typename U > LENGTH( const LENGTH< U, P > &orig )
: m_U( LENGTH_CASTS < T >::cast( orig.m_U ) ) : u( LENGTH_CASTS < T >::nearest( orig.u ) )
{ {
} }
LENGTH( void ) : m_U()
LENGTH( void ) : u()
{ {
} }
/**
* Zero length of given type
* @return A zero
*/
static LENGTH<T, P> zero ( void ) static LENGTH<T, P> zero ( void )
{ {
return T(0); return T(0);
} }
/* Do not use this, please */ /**
* Internal unit. Service function. Do not use this, please!
* @return An internal unit
*/
static LENGTH<T, P> quantum ( void ) static LENGTH<T, P> quantum ( void )
{ {
return T(1); return T(1);
...@@ -149,134 +154,196 @@ public: ...@@ -149,134 +154,196 @@ public:
LENGTH<T, P> & operator = ( const LENGTH<T, P> & y ) LENGTH<T, P> & operator = ( const LENGTH<T, P> & y )
{ {
this->m_U = y.m_U; this->u = y.u;
return *this; return *this;
} }
template< typename Y > operator LENGTH< Y, P > ( void ) /** @} */
{
return LENGTH< Y, P >( this->m_U ); /**
} * @defgroup length-comparisons Comparisons and tests
/*************************/ * @{
/* comparisons and tests */ */
/*************************/
bool operator ==( const LENGTH < T, P > y ) const bool operator ==( const LENGTH < T, P > y ) const
{ {
return m_U == y.m_U; return u == y.u;
} }
bool operator !=( const LENGTH < T, P > y ) const bool operator !=( const LENGTH < T, P > y ) const
{ {
return m_U != y.m_U; return u != y.u;
} }
bool operator <( const LENGTH < T, P > y ) const bool operator <( const LENGTH < T, P > y ) const
{ {
return m_U < y.m_U; return u < y.u;
} }
bool operator >=( const LENGTH < T, P > y ) const bool operator >=( const LENGTH < T, P > y ) const
{ {
return m_U >= y.m_U; return u >= y.u;
} }
bool operator >( const LENGTH < T, P > y ) const bool operator >( const LENGTH < T, P > y ) const
{ {
return m_U > y.m_U; return u > y.u;
} }
bool operator <=( const LENGTH < T, P > y ) const bool operator <=( const LENGTH < T, P > y ) const
{ {
return m_U <= y.m_U; return u <= y.u;
} }
bool operator !( void ) const bool operator !( void ) const
{ {
return !m_U; return !u;
} }
/*************************/ /** @} */
/* basic arithmetic */
/*************************/ /**
* @defgroup length-arithmetic Basic arithmetic
* @{
*/
LENGTH< T, P > operator - ( void ) const LENGTH< T, P > operator - ( void ) const
{ {
return LENGTH<T, P>(-this->m_U); LENGTH< T, P > z;
z.u = -u;
return z;
} }
LENGTH< T, P > operator - ( const LENGTH< T, P > y ) const
LENGTH< T, P >& operator -= ( const LENGTH< T, P > y )
{ {
return m_U - y.m_U; u -= y.u;
return *this;
} }
LENGTH< T, P > operator + ( const LENGTH< T, P > y ) const
friend LENGTH< T, P > operator - ( const LENGTH< T, P > x, const LENGTH< T, P > y )
{ {
return m_U + y.m_U; LENGTH< T, P > z = x;
z -= y;
return z;
} }
template < int R >
typename LENGTH_TRAITS< T, P + R >::flat operator * ( const LENGTH<T, R> &y ) const LENGTH< T, P >& operator += ( const LENGTH< T, P > y )
{ {
return m_U * y.m_U; u += y.u;
return *this;
} }
friend LENGTH< T, P > operator + ( const LENGTH< T, P > x, const LENGTH< T, P > y )
{
LENGTH< T, P > z = x;
z += y;
return z;
}
LENGTH< T, P >& operator *= ( const T y )
{
u *= y;
return *this;
}
LENGTH< T, P > operator * ( const T & y) const LENGTH< T, P > operator * ( const T & y) const
{ {
return m_U * y; LENGTH< T, P > z = *this;
z *= y;
return z;
}
template < int R >
typename LENGTH_TRAITS< T, P + R >::flat operator * ( const LENGTH<T, R> &y ) const
{
LENGTH< T, P + R > z;
z.u = u * y.u;
return z;
} }
LENGTH< T, P > friend operator * ( const T &y, const LENGTH<T, P> &x ) LENGTH< T, P > friend operator * ( const T &y, const LENGTH<T, P> &x )
{ {
return x.m_U * y; return x.u * y;
} }
template < int R > LENGTH< T, P >& operator /= ( const T y )
typename LENGTH_TRAITS< T, P - R >::flat operator / ( const LENGTH<T, R> &y ) const
{ {
return m_U / y.m_U; u /= y;
return *this;
} }
LENGTH< T, P > operator / ( const T &y ) const LENGTH< T, P > operator / ( const T &y ) const
{ {
return m_U / y; return u / y;
} }
LENGTH< T, -P > friend operator / ( const T &y, const LENGTH< T, P > &x )
template < int R >
typename LENGTH_TRAITS< T, P - R >::flat operator / ( const LENGTH< T, R > &y ) const
{ {
return y / x.m_U; return u / y.u;
} }
/*************************/ LENGTH< T, -P > friend operator / ( const T &y, const LENGTH< T, P > &x )
/* assignment arithmetic */
/*************************/
LENGTH< T, P >& operator -= ( const LENGTH< T, P > y )
{ {
m_U -= y.m_U; return y / x.u;
return *this;
} }
LENGTH< T, P >& operator += ( const LENGTH< T, P > y ) /** @} */
/**
* @defgroup length-algebra Algebraic functions
* @{
*/
/** Absolute value. */
friend LENGTH< T, P > abs( LENGTH< T, P > y )
{ {
m_U += y.m_U; return 0 < y.u? y : -y;
return *this;
} }
LENGTH< T, P >& operator *= ( const T y )
/** Maximum of two values. */
friend LENGTH< T, P > max( LENGTH< T, P > x, LENGTH< T, P > y )
{ {
m_U *= y; LENGTH< T, P > z;
return *this; z.u = max( x.u, y.u );
return z;
} }
LENGTH< T, P >& operator /= ( const T y )
/** Minimum of two values. */
friend LENGTH< T, P > min( LENGTH< T, P > x, LENGTH< T, P > y )
{ {
m_U /= y; LENGTH< T, P > z;
return *this; z.u = min( x.u, y.u );
return z;
} }
/*************************/ /** Square root. */
/* more functions */
/*************************/
friend LENGTH< T, P > sqrt( LENGTH< T, P*2 > y ) friend LENGTH< T, P > sqrt( LENGTH< T, P*2 > y )
{ {
return sqrt( y.m_U ); LENGTH< T, P > z;
z.u = sqrt( y.u );
return z;
} }
/** Cubic root. */
friend LENGTH< T, P > cbrt( LENGTH< T, P*3 > y ) friend LENGTH< T, P > cbrt( LENGTH< T, P*3 > y )
{ {
return cbrt( y.m_U ); LENGTH< T, P > z;
z.u = cbrt( y.u );
return z;
} }
/** Hypothenuse of a triangle given katheti. */
friend LENGTH< T, P > hypot( LENGTH< T, P > x, LENGTH< T, P > y ) friend LENGTH< T, P > hypot( LENGTH< T, P > x, LENGTH< T, P > y )
{ {
return hypot( x.m_U, y.m_U ); LENGTH< T, P > z;
z.u = hypot( x.u, y.u );
return z;
} }
/** Direction of vector given cartesian coords. */
friend double atan2( LENGTH< T, P > x, LENGTH< T, P > y ) friend double atan2( LENGTH< T, P > x, LENGTH< T, P > y )
{ {
return atan2( double ( x.m_U ), double( y.m_U ) ); return atan2( double ( x.u ), double( y.u ) );
} }
/** @} */
}; };
/** /*!
* Units of length * Units of length
* *
* How to use them: * How to use them:
...@@ -293,43 +360,66 @@ public: ...@@ -293,43 +360,66 @@ public:
* is going to use relative units. * is going to use relative units.
*/ */
template < typename T = DEF_LENGTH_VALUE > class LENGTH_UNITS { template < typename T > class LENGTH_UNITS {
protected: protected:
enum enum
{ {
METRE = 1000000000, /* The ONLY constant connecting length to the real world */ METRE = 1000000000, /*!< The ONLY constant connecting length to the real world */
INCH = METRE / 10000 * 254 INCH = METRE / 10000 * 254
}; };
public:
static LENGTH< T, 1 > metre( void ) { public:
/** One metre. */
static LENGTH< T, 1 > metre( void )
{
return T( METRE ); return T( METRE );
} }
static LENGTH< T, 1 > decimetre( void ) {
/** One decimetre, 0.1 m. */
static LENGTH< T, 1 > decimetre( void )
{
return T( METRE / 10 ); return T( METRE / 10 );
} }
static LENGTH< T, 1 > centimetre( void ) {
/** One centimetre, 0.01 m. */
static LENGTH< T, 1 > centimetre( void )
{
return T( METRE / 100 ); return T( METRE / 100 );
} }
static LENGTH< T, 1 > millimetre( void ) {
/** One millimetre, 0.001 m. */
static LENGTH< T, 1 > millimetre( void )
{
return T( METRE / 1000 ); return T( METRE / 1000 );
} }
static LENGTH< T, 1 > micrometre( void ) {
/** One micrometre, 1E-6 m. */
static LENGTH< T, 1 > micrometre( void )
{
return T( METRE / 1000000 ); return T( METRE / 1000000 );
} }
static LENGTH< T, 1 > foot( void ) { /* do not think this will ever need */
/** One foot, 304.8 mm, 12 inch. */
static LENGTH< T, 1 > foot( void )
{
return T( INCH * 12 ); return T( INCH * 12 );
} }
static LENGTH< T, 1 > inch( void ) {
/** One inch, 25.4 mm, 1/12 feet. */
static LENGTH< T, 1 > inch( void )
{
return T( INCH ); return T( INCH );
} }
static LENGTH< T, 1 > mil( void ) {
/** One mil (or thou), 0.001 inch . */
static LENGTH< T, 1 > mil( void )
{
return T( INCH / 1000 ); return T( INCH / 1000 );
} }
}; };
/** /**
* shortcut to get units of given length type * Shortcut to get units of given length type
*/ */
template < typename T, int D > class LENGTH_UNITS< LENGTH< T, D > >: public LENGTH_UNITS< T > template < typename T, int D > class LENGTH_UNITS< LENGTH< T, D > >: public LENGTH_UNITS< T >
{ {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#ifdef KICAD_NANOMETRE #ifdef KICAD_NANOMETRE
#include "length.h" #include "length.h"
#include "limited_int.h"
/* switched type! */ /* switched type! */
typedef LENGTH< LIMITED_INT< int >, 1 > LENGTH_PCB; typedef LENGTH< LIMITED_INT< int >, 1 > LENGTH_PCB;
...@@ -24,18 +25,24 @@ typedef LENGTH< double, 1 > LENGTH_PCB_DBL; ...@@ -24,18 +25,24 @@ typedef LENGTH< double, 1 > LENGTH_PCB_DBL;
#define TO_LEGACY_LU_DBL( x ) \ #define TO_LEGACY_LU_DBL( x ) \
( (double) ( 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 ) { static LENGTH_PCB from_legacy_lu( int x )
return x * PCB_LEGACY_UNIT( LENGTH_PCB ); {
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( 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 ) ); 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 ) { static LENGTH_PCB_DBL from_legacy_lu_dbl( double x )
return x * LENGTH_UNITS< LENGTH_PCB_DBL >::inch() / PCB_LEGACY_INCH_SCALE; {
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( x ) ( from_legacy_lu( x ) )
...@@ -43,7 +50,6 @@ static LENGTH_PCB_DBL from_legacy_lu_dbl( double x ) { ...@@ -43,7 +50,6 @@ static LENGTH_PCB_DBL from_legacy_lu_dbl( double x ) {
#define ZERO_LENGTH ( LENGTH_PCB::zero() ) #define ZERO_LENGTH ( LENGTH_PCB::zero() )
/* SAVE FILE macros */ /* SAVE FILE macros */
#define FM_LENSV "%lf" ///< format specifier for saving #define FM_LENSV "%lf" ///< format specifier for saving
#define ARG_LENSV( x ) TO_LEGACY_LU_DBL( x ) ///< argument for saving #define ARG_LENSV( x ) TO_LEGACY_LU_DBL( x ) ///< argument for saving
...@@ -63,6 +69,7 @@ typedef double LENGTH_PCB_DBL; ...@@ -63,6 +69,7 @@ typedef double LENGTH_PCB_DBL;
#define ZERO_LENGTH 0 #define ZERO_LENGTH 0
/* SAVE FILE macros */ /* SAVE FILE macros */
/** @TODO: after transition process this could be wrapped in some class */ /** @TODO: after transition process this could be wrapped in some class */
#define FM_LENSV "%d" #define FM_LENSV "%d"
...@@ -70,6 +77,7 @@ typedef double LENGTH_PCB_DBL; ...@@ -70,6 +77,7 @@ typedef double LENGTH_PCB_DBL;
#endif #endif
/* LOAD FILE macros */ /* LOAD FILE macros */
#define FM_LENLD "%lf" ///< scanf format macro for loading #define FM_LENLD "%lf" ///< scanf format macro for loading
#define ARG_LENLD_TYPE double ///< tmp variable for length read #define ARG_LENLD_TYPE double ///< tmp variable for length read
...@@ -80,55 +88,7 @@ typedef double LENGTH_PCB_DBL; ...@@ -80,55 +88,7 @@ typedef double LENGTH_PCB_DBL;
#define LENGTH_LOAD_TMP( x ) ( FROM_LEGACY_LU( x ) ) ///< reads tmp value from above #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 #define LENGTH_LOAD_STR( s ) ( FROM_LEGACY_LU( atof( s ) ) ) ///< reads string
/* used fo loading/saving config */
/// @TODO: nice template and refiling for it #define LENGTH_MAX_CONFIG ( FROM_LEGACY_LU( 393700 ) )
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 */ #endif /* def LENGTHPCB_H_INCLUDED */
...@@ -15,21 +15,25 @@ ...@@ -15,21 +15,25 @@
template < typename T = int > class LIMITED_INT { template < typename T = int > class LIMITED_INT {
private: private:
T m_Value; T m_Value;
public: public:
LIMITED_INT( void ) : m_Value() { LIMITED_INT( void ) : m_Value() {
} }
template<typename V> LIMITED_INT( const LIMITED_INT< V >& orig ) template<typename V> LIMITED_INT( const LIMITED_INT< V >& orig )
: m_Value( orig.m_Value ) : m_Value( orig.m_Value )
{ {
assert(std::numeric_limits<T>::min() <= orig.m_Value); assert(std::numeric_limits<T>::min() <= orig.m_Value);
assert(orig.m_Value <= std::numeric_limits<T>::max()); assert(orig.m_Value <= std::numeric_limits<T>::max());
} }
template<typename V> LIMITED_INT( const double v ) template<typename V> LIMITED_INT( const double v )
: m_Value( floor(v+0.5) ) : m_Value( floor(v+0.5) )
{ {
assert(std::numeric_limits<T>::min() <= v); assert(std::numeric_limits<T>::min() <= v);
assert(v <= std::numeric_limits<T>::max()); assert(v <= std::numeric_limits<T>::max());
} }
LIMITED_INT( T v ): m_Value( v ) LIMITED_INT( T v ): m_Value( v )
{ {
} }
...@@ -38,6 +42,7 @@ public: ...@@ -38,6 +42,7 @@ public:
{ {
return m_Value; return m_Value;
} }
operator double( void ) const operator double( void ) const
{ {
return ( double )m_Value; return ( double )m_Value;
...@@ -48,11 +53,13 @@ public: ...@@ -48,11 +53,13 @@ public:
m_Value = src.m_Value; m_Value = src.m_Value;
return *this; return *this;
} }
LIMITED_INT<T> & operator = ( T src ) LIMITED_INT<T> & operator = ( T src )
{ {
m_Value = src; m_Value = src;
return *this; return *this;
} }
/*************************/ /*************************/
/* comparisons and tests */ /* comparisons and tests */
/*************************/ /*************************/
...@@ -64,10 +71,12 @@ public: ...@@ -64,10 +71,12 @@ public:
{ {
return m_Value == y.m_Value; return m_Value == y.m_Value;
} }
bool operator == ( const T y ) const bool operator == ( const T y ) const
{ {
return m_Value == y; return m_Value == y;
} }
friend bool operator == ( const T x, const LIMITED_INT< T > &y ) friend bool operator == ( const T x, const LIMITED_INT< T > &y )
{ {
return x == y.m_Value; return x == y.m_Value;
...@@ -77,10 +86,12 @@ public: ...@@ -77,10 +86,12 @@ public:
{ {
return m_Value != y.m_Value; return m_Value != y.m_Value;
} }
bool operator != ( const T y ) const bool operator != ( const T y ) const
{ {
return m_Value != y; return m_Value != y;
} }
friend bool operator != ( const T x, const LIMITED_INT< T > &y ) friend bool operator != ( const T x, const LIMITED_INT< T > &y )
{ {
return x != y.m_Value; return x != y.m_Value;
...@@ -90,10 +101,12 @@ public: ...@@ -90,10 +101,12 @@ public:
{ {
return m_Value < y.m_Value; return m_Value < y.m_Value;
} }
bool operator < ( const T y ) const bool operator < ( const T y ) const
{ {
return m_Value < y; return m_Value < y;
} }
friend bool operator < ( const T x, const LIMITED_INT< T > &y ) friend bool operator < ( const T x, const LIMITED_INT< T > &y )
{ {
return x < y.m_Value; return x < y.m_Value;
...@@ -103,10 +116,12 @@ public: ...@@ -103,10 +116,12 @@ public:
{ {
return m_Value >= y.m_Value; return m_Value >= y.m_Value;
} }
bool operator >= ( const T y ) const bool operator >= ( const T y ) const
{ {
return m_Value >= y; return m_Value >= y;
} }
friend bool operator >= ( const T x, const LIMITED_INT<T> &y ) friend bool operator >= ( const T x, const LIMITED_INT<T> &y )
{ {
return x >= y.m_Value; return x >= y.m_Value;
...@@ -116,10 +131,12 @@ public: ...@@ -116,10 +131,12 @@ public:
{ {
return m_Value > y.m_Value; return m_Value > y.m_Value;
} }
bool operator > ( const T y ) const bool operator > ( const T y ) const
{ {
return m_Value > y; return m_Value > y;
} }
friend bool operator > ( const T x, const LIMITED_INT< T > &y ) friend bool operator > ( const T x, const LIMITED_INT< T > &y )
{ {
return x > y.m_Value; return x > y.m_Value;
...@@ -129,10 +146,12 @@ public: ...@@ -129,10 +146,12 @@ public:
{ {
return m_Value <= y.m_Value; return m_Value <= y.m_Value;
} }
bool operator <= ( const T y ) const bool operator <= ( const T y ) const
{ {
return m_Value <= y; return m_Value <= y;
} }
friend bool operator <= ( const T x, const LIMITED_INT< T > &y ) friend bool operator <= ( const T x, const LIMITED_INT< T > &y )
{ {
return x <= y.m_Value; return x <= y.m_Value;
...@@ -147,18 +166,22 @@ public: ...@@ -147,18 +166,22 @@ public:
assert( !( m_Value < 0 ) || std::numeric_limits< T >::min() - m_Value <= y.m_Value ); assert( !( m_Value < 0 ) || std::numeric_limits< T >::min() - m_Value <= y.m_Value );
return m_Value + y.m_Value; return m_Value + y.m_Value;
} }
LIMITED_INT< T > operator + ( const T y ) const LIMITED_INT< T > operator + ( const T y ) const
{ {
return *this + LIMITED_INT< T >( y ); return *this + LIMITED_INT< T >( y );
} }
friend LIMITED_INT< T > operator + ( const T x, const LIMITED_INT< T > &y ) friend LIMITED_INT< T > operator + ( const T x, const LIMITED_INT< T > &y )
{ {
return LIMITED_INT< T >( x ) + y; return LIMITED_INT< T >( x ) + y;
} }
double operator + ( const double y ) const double operator + ( const double y ) const
{ {
return double( m_Value ) + y; return double( m_Value ) + y;
} }
friend double operator + ( const double x, const LIMITED_INT< T > &y ) friend double operator + ( const double x, const LIMITED_INT< T > &y )
{ {
return x + double( y.m_Value ); return x + double( y.m_Value );
...@@ -169,24 +192,29 @@ public: ...@@ -169,24 +192,29 @@ public:
assert( -std::numeric_limits< T >::max() <= m_Value ); assert( -std::numeric_limits< T >::max() <= m_Value );
return -m_Value; return -m_Value;
} }
LIMITED_INT< T > operator - ( const LIMITED_INT< T > &y ) const LIMITED_INT< T > operator - ( const LIMITED_INT< T > &y ) const
{ {
assert( !( 0 < m_Value ) || m_Value - std::numeric_limits< T >::max() <= y.m_Value ); assert( !( 0 < m_Value ) || m_Value - std::numeric_limits< T >::max() <= y.m_Value );
assert( !( m_Value < 0 ) || y.m_Value <= m_Value - std::numeric_limits< T >::min() ); assert( !( m_Value < 0 ) || y.m_Value <= m_Value - std::numeric_limits< T >::min() );
return m_Value - y.m_Value; return m_Value - y.m_Value;
} }
LIMITED_INT< T > operator - ( const T y ) const LIMITED_INT< T > operator - ( const T y ) const
{ {
return *this - LIMITED_INT< T >( y ); return *this - LIMITED_INT< T >( y );
} }
friend LIMITED_INT< T > operator - ( const T x, const LIMITED_INT< T > &y ) friend LIMITED_INT< T > operator - ( const T x, const LIMITED_INT< T > &y )
{ {
return LIMITED_INT< T >( x ) - y; return LIMITED_INT< T >( x ) - y;
} }
double operator - ( const double y ) const double operator - ( const double y ) const
{ {
return double( m_Value ) - y; return double( m_Value ) - y;
} }
friend double operator - ( const double x, const LIMITED_INT< T > &y ) friend double operator - ( const double x, const LIMITED_INT< T > &y )
{ {
return x - double( y.m_Value ); return x - double( y.m_Value );
...@@ -204,18 +232,22 @@ public: ...@@ -204,18 +232,22 @@ public:
|| std::numeric_limits<T>::max() / m_Value <= y.m_Value ); || std::numeric_limits<T>::max() / m_Value <= y.m_Value );
return m_Value * y.m_Value; return m_Value * y.m_Value;
} }
LIMITED_INT<T> operator * ( const T y) const LIMITED_INT<T> operator * ( const T y) const
{ {
return *this * LIMITED_INT< T >( y ); return *this * LIMITED_INT< T >( y );
} }
friend LIMITED_INT< T > operator *( const T x, const LIMITED_INT< T > &y ) friend LIMITED_INT< T > operator *( const T x, const LIMITED_INT< T > &y )
{ {
return LIMITED_INT< T >( x ) * y; return LIMITED_INT< T >( x ) * y;
} }
double operator * ( const double y ) const double operator * ( const double y ) const
{ {
return double( m_Value ) * y; return double( m_Value ) * y;
} }
friend double operator * ( const double x, const LIMITED_INT< T > &y ) friend double operator * ( const double x, const LIMITED_INT< T > &y )
{ {
return x * double( y.m_Value ); return x * double( y.m_Value );
...@@ -227,18 +259,22 @@ public: ...@@ -227,18 +259,22 @@ public:
|| -std::numeric_limits< T >::max() <= m_Value ); || -std::numeric_limits< T >::max() <= m_Value );
return m_Value / y.m_Value; return m_Value / y.m_Value;
} }
LIMITED_INT<T> operator / ( const T y ) const LIMITED_INT<T> operator / ( const T y ) const
{ {
return *this / LIMITED_INT<T>(y); return *this / LIMITED_INT<T>(y);
} }
friend LIMITED_INT< T > operator / ( const T x, const LIMITED_INT< T > &y ) friend LIMITED_INT< T > operator / ( const T x, const LIMITED_INT< T > &y )
{ {
return LIMITED_INT< T >( x ) / y; return LIMITED_INT< T >( x ) / y;
} }
double operator / ( const double y ) const double operator / ( const double y ) const
{ {
return double( m_Value ) / y; return double( m_Value ) / y;
} }
friend double operator / ( const double x, const LIMITED_INT< T > &y ) friend double operator / ( const double x, const LIMITED_INT< T > &y )
{ {
return x / double( y.m_Value ); return x / double( y.m_Value );
...@@ -248,62 +284,71 @@ public: ...@@ -248,62 +284,71 @@ public:
{ {
return m_Value % y.m_Value; return m_Value % y.m_Value;
} }
LIMITED_INT<T> operator % ( const T y ) const LIMITED_INT<T> operator % ( const T y ) const
{ {
return *this % LIMITED_INT<T>(y); return *this % LIMITED_INT<T>(y);
} }
friend LIMITED_INT< T > operator % ( const T x, const LIMITED_INT< T > &y ) friend LIMITED_INT< T > operator % ( const T x, const LIMITED_INT< T > &y )
{ {
return LIMITED_INT< T >( x ) % y; return LIMITED_INT< T >( x ) % y;
} }
/*************************/
/* assignment arithmetic */
/*************************/
LIMITED_INT< T >& operator += ( const LIMITED_INT< T > &y ) LIMITED_INT< T >& operator += ( const LIMITED_INT< T > &y )
{ {
*this = *this + y; *this = *this + y;
return *this; return *this;
} }
LIMITED_INT< T >& operator += ( const T y ) LIMITED_INT< T >& operator += ( const T y )
{ {
*this = *this + y; *this = *this + y;
return *this; return *this;
} }
LIMITED_INT< T >& operator ++ ( void ) LIMITED_INT< T >& operator ++ ( void )
{ {
*this = *this + 1; *this = *this + 1;
return *this; return *this;
} }
LIMITED_INT< T >& operator -= ( const LIMITED_INT< T > &y ) LIMITED_INT< T >& operator -= ( const LIMITED_INT< T > &y )
{ {
*this = *this - y; *this = *this - y;
return *this; return *this;
} }
LIMITED_INT< T >& operator -= ( const T y ) LIMITED_INT< T >& operator -= ( const T y )
{ {
*this = *this - y; *this = *this - y;
return *this; return *this;
} }
LIMITED_INT< T >& operator -- ( void ) LIMITED_INT< T >& operator -- ( void )
{ {
*this = *this - 1; *this = *this - 1;
return *this; return *this;
} }
LIMITED_INT< T >& operator *= ( const LIMITED_INT< T > &y ) LIMITED_INT< T >& operator *= ( const LIMITED_INT< T > &y )
{ {
*this = *this * y; *this = *this * y;
return *this; return *this;
} }
LIMITED_INT< T >& operator *= ( const T y ) LIMITED_INT< T >& operator *= ( const T y )
{ {
*this = *this * y; *this = *this * y;
return *this; return *this;
} }
LIMITED_INT< T >& operator /= ( const LIMITED_INT< T > &y ) LIMITED_INT< T >& operator /= ( const LIMITED_INT< T > &y )
{ {
*this = *this / y; *this = *this / y;
return *this; return *this;
} }
LIMITED_INT< T >& operator /= ( const T y ) LIMITED_INT< T >& operator /= ( const T y )
{ {
*this = *this / y; *this = *this / y;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "wx/fileconf.h" #include "wx/fileconf.h"
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include "lengthpcb.h"
/** Type of parameter in the configuration file */ /** Type of parameter in the configuration file */
enum paramcfg_id { enum paramcfg_id {
...@@ -85,6 +86,35 @@ public: PARAM_CFG_INT( const wxChar* ident, int* ptparam, ...@@ -85,6 +86,35 @@ public: PARAM_CFG_INT( const wxChar* ident, int* ptparam,
virtual void SaveParam( wxConfigBase* aConfig ); virtual void SaveParam( wxConfigBase* aConfig );
}; };
/**
* Configuration parameter - Length PCB Class
*
*/
class PARAM_CFG_LENGTH_PCB : public PARAM_CFG_BASE
{
public:
LENGTH_PCB * m_Pt_param; ///< Pointer to the parameter value
LENGTH_PCB m_Min, m_Max; ///< Minimum and maximum values of the param type
LENGTH_PCB m_Default; ///< The default value of the parameter
public:
PARAM_CFG_LENGTH_PCB( const wxChar* ident, /// @TODO: remove hardcoded constants
LENGTH_PCB* ptparam,
LENGTH_PCB default_val = ZERO_LENGTH,
LENGTH_PCB min = -LENGTH_MAX_CONFIG,
LENGTH_PCB max = LENGTH_MAX_CONFIG,
const wxChar* group = NULL );
PARAM_CFG_LENGTH_PCB( bool Insetup,
const wxChar* ident,
LENGTH_PCB* ptparam,
LENGTH_PCB default_val = ZERO_LENGTH,
LENGTH_PCB min = -LENGTH_MAX_CONFIG,
LENGTH_PCB max = LENGTH_MAX_CONFIG,
const wxChar* group = NULL );
virtual void ReadParam( wxConfigBase* aConfig );
virtual void SaveParam( wxConfigBase* aConfig );
};
/** /**
* Configuration parameter - SetColor Class * Configuration parameter - SetColor Class
......
/**
* @file vectorpcb.h
* @brief Planar vector definitions for PCBNEW.
*/
#ifndef VECTORPCB_H_INCLUDED
#define VECTORPCB_H_INCLUDED 1
/// @TODO: nice template and refiling for it
class VECTOR_PCB
{
public:
LENGTH_PCB data[2];
/** A vector from pair of coords. Constructor is avoided in favor to POD-like object.
*/
static VECTOR_PCB fromXY( LENGTH_PCB x, LENGTH_PCB y )
{
VECTOR_PCB z = { { x, y } };
return z;
}
/** @defgroup vector-elements Access individual attributes
* @{
*/
LENGTH_PCB &operator[]( int i )
{
return data[i];
}
const LENGTH_PCB &operator[]( int i ) const
{
return data[i];
}
/** @} */
/** @defgroup vector-cartesian Access to cartesian coordinates
* Definitions follow the agreement:
* - methods are named exactly as attributes, thus setter and getter have same name;
* - all methods (setters and getterrs) return actual attribute value;
* - method without argument gets the attribute;
* - method with argument sets it to argument value.
* These methods different than operator[]
* because vector actually may have any storage layout,
* so cartesian coords may be calculated rahter than actually stored.
* E. g. homogeneous coordinates is likely to be used in perspective.
* @{
*/
const LENGTH_PCB x() const
{
return data[0];
}
const LENGTH_PCB x( LENGTH_PCB nx )
{
return data[0] = nx;
}
const LENGTH_PCB y() const
{
return data[1];
}
const LENGTH_PCB y( LENGTH_PCB ny )
{
return data[1] = ny;
}
/** @} */
/** @defgroup vector-comparisons Compare vectors
* @{
*/
bool operator == ( const VECTOR_PCB &b ) const
{
return data[0] == b.data[0] && data[1] == b.data[1];
}
bool operator != ( const VECTOR_PCB &b ) const
{
return !(*this == b);
}
/** @} */
/** @defgroup vector-arithmetic Arithmetic operations on vectors
* @{
*/
VECTOR_PCB & operator -= ( const VECTOR_PCB &b )
{
data[0] -= b.data[0];
data[1] -= b.data[1];
return *this;
}
VECTOR_PCB operator - ( const VECTOR_PCB &b ) const
{
VECTOR_PCB z = *this;
z -= b;
return z;
}
VECTOR_PCB & operator += ( const VECTOR_PCB &b )
{
data[0] += b.data[0];
data[1] += b.data[1];
return *this;
}
VECTOR_PCB operator + ( VECTOR_PCB b ) const
{
VECTOR_PCB z = *this;
z += b;
return z;
}
VECTOR_PCB & operator *= ( int b )
{
data[0] *= b;
data[1] *= b;
return *this;
}
VECTOR_PCB operator * ( int b ) const
{
VECTOR_PCB z = *this;
z *= b;
return z;
}
VECTOR_PCB & operator /= ( int b )
{
data[0] /= b;
data[1] /= b;
return *this;
}
VECTOR_PCB operator / ( int b ) const
{
VECTOR_PCB z = *this;
z /= b;
return z;
}
/** @} */
};
#define TO_LEGACY_LU_WXP( p ) ( wxPoint( \
TO_LEGACY_LU( ( p )[0] ), \
TO_LEGACY_LU( ( p )[1] ) ) )
#define TO_LEGACY_LU_WXS( p ) ( wxSize( \
TO_LEGACY_LU( ( p )[0] ), \
TO_LEGACY_LU( ( p )[1] ) ) )
#define FROM_LEGACY_LU_VEC( p ) ( VECTOR_PCB::fromXY( \
FROM_LEGACY_LU( ( p ).x ), \
FROM_LEGACY_LU( ( p ).y ) ) )
#endif /* def VECTORPCB_H_INCLUDED */
...@@ -538,7 +538,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) ...@@ -538,7 +538,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
{ {
#define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x; #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x;
EDA_ITEM* item; EDA_ITEM* item;
wxPoint tmp;
if( module == NULL ) if( module == NULL )
return; return;
...@@ -549,10 +549,12 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) ...@@ -549,10 +549,12 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
if( pad->m_Selected == 0 ) if( pad->m_Selected == 0 )
continue; continue;
SETMIRROR( pad->GetPosition().x ); tmp = pad->GetPosition();
pad->m_Pos0.x = FROM_LEGACY_LU( pad->GetPosition().x ); SETMIRROR( tmp.x );
NEGATE( pad->m_Offset.x ); pad->SetPosition( tmp );
NEGATE( pad->m_DeltaSize.x ); pad->m_Pos0.x( FROM_LEGACY_LU( pad->GetPosition().x ) );
pad->m_Offset.x( -pad->m_Offset.x() );
pad->m_DeltaSize.x( -pad->m_DeltaSize.x() );
pad->m_Orient = 1800 - pad->m_Orient; pad->m_Orient = 1800 - pad->m_Orient;
NORMALIZE_ANGLE_POS( pad->m_Orient ); NORMALIZE_ANGLE_POS( pad->m_Orient );
} }
...@@ -578,7 +580,9 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) ...@@ -578,7 +580,9 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x ); tmp = ( (TEXTE_MODULE*) item )->GetPosition();
SETMIRROR( tmp.x );
( (TEXTE_MODULE*) item )->SetPosition( tmp );
( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x; ( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x;
break; break;
...@@ -608,8 +612,9 @@ void RotateMarkedItems( MODULE* module, wxPoint offset ) ...@@ -608,8 +612,9 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
{ {
if( pad->m_Selected == 0 ) if( pad->m_Selected == 0 )
continue; continue;
wxPoint pos = pad->GetPosition();
ROTATE( pad->GetPosition() ); ROTATE( pos );
pad->SetPosition( pos );
pad->m_Pos0 = FROM_LEGACY_LU_VEC( pad->GetPosition() ); pad->m_Pos0 = FROM_LEGACY_LU_VEC( pad->GetPosition() );
pad->m_Orient += 900; pad->m_Orient += 900;
NORMALIZE_ANGLE_POS( pad->m_Orient ); NORMALIZE_ANGLE_POS( pad->m_Orient );
...@@ -632,7 +637,11 @@ void RotateMarkedItems( MODULE* module, wxPoint offset ) ...@@ -632,7 +637,11 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
break; break;
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() ); {
wxPoint pos = ( (TEXTE_MODULE*) item )->m_Pos;
ROTATE( pos );
( (TEXTE_MODULE*) item )->m_Pos = pos;
}
( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition(); ( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition();
( (TEXTE_MODULE*) item )->m_Orient += 900; ( (TEXTE_MODULE*) item )->m_Orient += 900;
break; break;
......
...@@ -328,8 +328,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor ...@@ -328,8 +328,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
{ {
wxPoint corner_position; wxPoint corner_position;
int ii, angle; int ii, angle;
int dx = TO_LEGACY_LU( m_Size.x / 2 ) + aClearanceValue; int dx = TO_LEGACY_LU( m_Size.x() / 2 ) + aClearanceValue;
int dy = TO_LEGACY_LU( m_Size.y / 2 ) + aClearanceValue; int dy = TO_LEGACY_LU( m_Size.y() / 2 ) + aClearanceValue;
int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree
wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset, wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset,
...@@ -437,8 +437,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor ...@@ -437,8 +437,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor
default: default:
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
psize.x += TO_LEGACY_LU( ABS( m_DeltaSize.y ) ); psize.x += TO_LEGACY_LU( abs( m_DeltaSize.y() ) );
psize.y += TO_LEGACY_LU( ABS( m_DeltaSize.x ) ); psize.y += TO_LEGACY_LU( abs( m_DeltaSize.x() ) );
// fall through // fall through
case PAD_RECT: case PAD_RECT:
...@@ -572,8 +572,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, ...@@ -572,8 +572,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
wxPoint PadShapePos = aPad.ReturnShapePos(); /* Note: for pad having a shape offset, wxPoint PadShapePos = aPad.ReturnShapePos(); /* Note: for pad having a shape offset,
* the pad position is NOT the shape position */ * the pad position is NOT the shape position */
wxSize copper_thickness; wxSize copper_thickness;
int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ); int dx = TO_LEGACY_LU( aPad.m_Size.x() / 2 );
int dy = TO_LEGACY_LU( aPad.m_Size.y / 2 ); int dy = TO_LEGACY_LU( aPad.m_Size.y() / 2 );
int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree
...@@ -684,8 +684,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, ...@@ -684,8 +684,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
// Oval pad support along the lines of round and rectangular pads // Oval pad support along the lines of round and rectangular pads
std::vector <wxPoint> corners_buffer; // Polygon buffer as vector std::vector <wxPoint> corners_buffer; // Polygon buffer as vector
int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ) + aThermalGap; // Cutout radius x 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 int dy = TO_LEGACY_LU( aPad.m_Size.y() / 2 ) + aThermalGap; // Cutout radius y
wxPoint shape_offset; wxPoint shape_offset;
...@@ -839,8 +839,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer, ...@@ -839,8 +839,8 @@ void CreateThermalReliefPadPolygon( std::vector<CPolyPt>& aCornerBuffer,
std::vector <wxPoint> corners_buffer; // Polygon buffer as vector std::vector <wxPoint> corners_buffer; // Polygon buffer as vector
int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ) + aThermalGap; // Cutout radius x 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 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 // 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 // thermal spoke sides, the third is upper right corner and the rest are rounding
......
...@@ -647,13 +647,13 @@ bool BOARD::IsModuleLayerVisible( int layer ) ...@@ -647,13 +647,13 @@ bool BOARD::IsModuleLayerVisible( int layer )
wxPoint& BOARD::GetPosition() const wxPoint BOARD::GetPosition() const
{ {
static wxPoint dummy( 0, 0 ); return wxPoint ( 0, 0 );
return dummy; // a reference
} }
void BOARD::SetPosition( const wxPoint& pos ) {
}
void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
{ {
...@@ -1668,7 +1668,7 @@ D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, int aLayerMask ) ...@@ -1668,7 +1668,7 @@ D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, int aLayerMask )
{ {
D_PAD* pad = m_NetInfo->GetPad(i); D_PAD* pad = m_NetInfo->GetPad(i);
if( pad->m_Pos != aPosition ) if( TO_LEGACY_LU_WXP( pad->m_Pos ) != aPosition )
continue; continue;
/* Pad found, it must be on the correct layer */ /* Pad found, it must be on the correct layer */
...@@ -1699,7 +1699,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i ...@@ -1699,7 +1699,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i
D_PAD* pad = aPadList[idx]; D_PAD* pad = aPadList[idx];
if( pad->m_Pos == aPosition ) // candidate found if( TO_LEGACY_LU_WXP( pad->m_Pos ) == aPosition ) // candidate found
{ {
// The pad must match the layer mask: // The pad must match the layer mask:
if( (aLayerMask & pad->m_layerMask) != 0 ) if( (aLayerMask & pad->m_layerMask) != 0 )
...@@ -1712,7 +1712,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i ...@@ -1712,7 +1712,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i
for( int ii = idx+1; ii <= idxmax; ii++ ) for( int ii = idx+1; ii <= idxmax; ii++ )
{ {
pad = aPadList[ii]; pad = aPadList[ii];
if( pad->m_Pos != aPosition ) if( TO_LEGACY_LU_WXP( pad->m_Pos ) != aPosition )
break; break;
if( (aLayerMask & pad->m_layerMask) != 0 ) if( (aLayerMask & pad->m_layerMask) != 0 )
return pad; return pad;
...@@ -1721,7 +1721,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i ...@@ -1721,7 +1721,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i
for( int ii = idx-1 ;ii >=0; ii-- ) for( int ii = idx-1 ;ii >=0; ii-- )
{ {
pad = aPadList[ii]; pad = aPadList[ii];
if( pad->m_Pos != aPosition ) if( TO_LEGACY_LU_WXP( pad->m_Pos ) != aPosition )
break; break;
if( (aLayerMask & pad->m_layerMask) != 0 ) if( (aLayerMask & pad->m_layerMask) != 0 )
return pad; return pad;
...@@ -1731,9 +1731,9 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i ...@@ -1731,9 +1731,9 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i
return 0; return 0;
} }
if( pad->m_Pos.x == aPosition.x ) // Must search considering Y coordinate if( TO_LEGACY_LU( pad->m_Pos.x() ) == aPosition.x ) // Must search considering Y coordinate
{ {
if(pad->m_Pos.y < aPosition.y) // Must search after this item if( TO_LEGACY_LU( pad->m_Pos.y() ) < aPosition.y ) // Must search after this item
{ {
idx += delta; idx += delta;
if( idx > idxmax ) if( idx > idxmax )
...@@ -1746,7 +1746,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i ...@@ -1746,7 +1746,7 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i
idx = 0; idx = 0;
} }
} }
else if( pad->m_Pos.x < aPosition.x ) // Must search after this item else if( TO_LEGACY_LU( pad->m_Pos.x() ) < aPosition.x ) // Must search after this item
{ {
idx += delta; idx += delta;
if( idx > idxmax ) if( idx > idxmax )
...@@ -1770,9 +1770,9 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i ...@@ -1770,9 +1770,9 @@ D_PAD* BOARD::GetPad( std::vector<D_PAD*>& aPadList, const wxPoint& aPosition, i
*/ */
static bool sortPadsByXthenYCoord( D_PAD* const & ref, D_PAD* const & comp ) static bool sortPadsByXthenYCoord( D_PAD* const & ref, D_PAD* const & comp )
{ {
if( ref->m_Pos.x == comp->m_Pos.x ) if( ref->m_Pos.x() == comp->m_Pos.x() )
return ref->m_Pos.y < comp->m_Pos.y; return ref->m_Pos.y() < comp->m_Pos.y();
return ref->m_Pos.x < comp->m_Pos.x; return ref->m_Pos.x() < comp->m_Pos.x();
} }
......
...@@ -226,7 +226,9 @@ public: ...@@ -226,7 +226,9 @@ public:
* is a dummy. * is a dummy.
* @return const wxPoint& of (0,0) * @return const wxPoint& of (0,0)
*/ */
wxPoint& GetPosition(); const wxPoint GetPosition() const;
void SetPosition( const wxPoint& pos );
/** /**
* Function Add * Function Add
......
...@@ -37,11 +37,15 @@ public: ...@@ -37,11 +37,15 @@ public:
DIMENSION( BOARD_ITEM* aParent ); DIMENSION( BOARD_ITEM* aParent );
~DIMENSION(); ~DIMENSION();
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Pos; return m_Pos;
} }
void SetPosition( const wxPoint& pos ) {
m_Pos = pos;
}
/** /**
* Function SetLayer * Function SetLayer
* sets the layer this item is on. * sets the layer this item is on.
......
...@@ -44,13 +44,17 @@ public: ...@@ -44,13 +44,17 @@ public:
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition() * Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object. * @return const wxPoint - The position of this object.
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Start; return m_Start;
} }
void SetPosition( const wxPoint& pos ) {
m_Start = pos;
}
/** /**
* Function GetStart * Function GetStart
* returns the starting point of the graphic * returns the starting point of the graphic
......
...@@ -81,11 +81,14 @@ public: ...@@ -81,11 +81,14 @@ public:
* Function GetPosition * Function GetPosition
* returns the position of this MARKER_PCB. * returns the position of this MARKER_PCB.
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return (wxPoint&) m_Pos; return m_Pos;
} }
void SetPosition( const wxPoint& pos ) {
m_Pos = pos;
}
/** /**
* Function HitTest * Function HitTest
......
...@@ -30,11 +30,14 @@ public: ...@@ -30,11 +30,14 @@ public:
PCB_TARGET* Next() const { return (PCB_TARGET*) Pnext; } PCB_TARGET* Next() const { return (PCB_TARGET*) Pnext; }
PCB_TARGET* Back() const { return (PCB_TARGET*) Pnext; } PCB_TARGET* Back() const { return (PCB_TARGET*) Pnext; }
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Pos; return m_Pos;
} }
void SetPosition( const wxPoint& pos ) {
m_Pos = pos;
}
/** /**
* Function Move * Function Move
......
...@@ -534,9 +534,10 @@ int MODULE::ReadDescr( LINE_READER* aReader ) ...@@ -534,9 +534,10 @@ int MODULE::ReadDescr( LINE_READER* aReader )
{ {
D_PAD* pad = new D_PAD( this ); D_PAD* pad = new D_PAD( this );
pad->ReadDescr( aReader ); pad->ReadDescr( aReader );
RotatePoint( &pad->m_Pos, m_Orient ); wxPoint pos = TO_LEGACY_LU_WXP( pad->m_Pos );
pad->m_Pos.x += m_Pos.x; RotatePoint( &pos, m_Orient );
pad->m_Pos.y += m_Pos.y; pad->m_Pos = FROM_LEGACY_LU_VEC( pos );
pad->m_Pos += FROM_LEGACY_LU_VEC( m_Pos );
m_Pads.PushBack( pad ); m_Pads.PushBack( pad );
continue; continue;
......
...@@ -135,9 +135,9 @@ public: ...@@ -135,9 +135,9 @@ public:
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
* Required by pure virtual BOARD_ITEM::GetPosition() * Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object. * @return const wxPoint - The position of this object.
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Pos; return m_Pos;
} }
......
...@@ -183,12 +183,24 @@ void MODULE::Flip(const wxPoint& aCentre ) ...@@ -183,12 +183,24 @@ void MODULE::Flip(const wxPoint& aCentre )
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{ {
pt_pad->m_Pos.y -= m_Pos.y; LENGTH_PCB tmpy = pt_pad->m_Pos.y();
pt_pad->m_Pos.y = -pt_pad->m_Pos.y; tmpy -= FROM_LEGACY_LU( m_Pos.y );
pt_pad->m_Pos.y += m_Pos.y; tmpy = -tmpy;
NEGATE( pt_pad->m_Pos0.y ); tmpy += FROM_LEGACY_LU( m_Pos.y );
NEGATE( pt_pad->m_Offset.y ); pt_pad->m_Pos.y( tmpy );
NEGATE( pt_pad->m_DeltaSize.y );
tmpy = pt_pad->m_Pos0.y();
NEGATE( tmpy );
pt_pad->m_Pos0.y( tmpy );
tmpy = pt_pad->m_Offset.y();
NEGATE( tmpy );
pt_pad->m_Offset.y( tmpy );
pt_pad->m_DeltaSize.y();
NEGATE( tmpy );
pt_pad->m_DeltaSize.y( tmpy );
NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient ); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient );
/* flip pads layers*/ /* flip pads layers*/
...@@ -308,7 +320,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) ...@@ -308,7 +320,7 @@ void MODULE::SetPosition( const wxPoint& newpos )
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{ {
pad->m_Pos += delta; pad->m_Pos += FROM_LEGACY_LU_VEC( delta );
} }
EDA_ITEM* PtStruct = m_Drawings; EDA_ITEM* PtStruct = m_Drawings;
...@@ -352,15 +364,15 @@ void MODULE::SetOrientation( int newangle ) ...@@ -352,15 +364,15 @@ void MODULE::SetOrientation( int newangle )
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
{ {
px = TO_LEGACY_LU( pad->m_Pos0.x ); px = TO_LEGACY_LU( pad->m_Pos0.x() );
py = TO_LEGACY_LU( pad->m_Pos0.y ); py = TO_LEGACY_LU( pad->m_Pos0.y() );
pad->m_Orient += newangle; /* change m_Orientation */ pad->m_Orient += newangle; /* change m_Orientation */
NORMALIZE_ANGLE_POS( pad->m_Orient ); NORMALIZE_ANGLE_POS( pad->m_Orient );
RotatePoint( &px, &py, m_Orient ); RotatePoint( &px, &py, m_Orient );
pad->m_Pos.x = m_Pos.x + px; pad->m_Pos.x( FROM_LEGACY_LU( m_Pos.x + px ) );
pad->m_Pos.y = m_Pos.y + py; pad->m_Pos.y( FROM_LEGACY_LU( m_Pos.y + py ) );
} }
/* Update of the reference and value. */ /* Update of the reference and value. */
......
...@@ -224,6 +224,6 @@ void RATSNEST_ITEM::Draw( EDA_DRAW_PANEL* panel, ...@@ -224,6 +224,6 @@ void RATSNEST_ITEM::Draw( EDA_DRAW_PANEL* panel,
{ {
GRSetDrawMode( DC, aDrawMode ); GRSetDrawMode( DC, aDrawMode );
int color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); int color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE);
GRLine( &panel->m_ClipBox, DC, m_PadStart->m_Pos - aOffset, GRLine( &panel->m_ClipBox, DC, TO_LEGACY_LU_WXP( m_PadStart->m_Pos ) - aOffset,
m_PadEnd->m_Pos - aOffset, 0, color ); TO_LEGACY_LU_WXP( m_PadEnd->m_Pos ) - aOffset, 0, color );
} }
...@@ -27,14 +27,14 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, PCB_PAD_T ) ...@@ -27,14 +27,14 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, PCB_PAD_T )
{ {
m_NumPadName = 0; m_NumPadName = 0;
m_Size.x = m_Size.y = FROM_LEGACY_LU( 500 ); // give it a reasonable size m_Size[0] = m_Size[1] = FROM_LEGACY_LU( 500 ); // give it a reasonable size
/// TODO: remove hardcoded constant /// TODO: remove hardcoded constant
m_Orient = 0; // Pad rotation in 1/10 degrees m_Orient = 0; // Pad rotation in 1/10 degrees
m_LengthDie = ZERO_LENGTH; m_LengthDie = ZERO_LENGTH;
if( m_Parent && (m_Parent->Type() == PCB_MODULE_T) ) if( m_Parent && (m_Parent->Type() == PCB_MODULE_T) )
{ {
m_Pos = ( (MODULE*) m_Parent )->GetPosition(); m_Pos = FROM_LEGACY_LU_VEC( ( (MODULE*) m_Parent )->GetPosition() );
} }
m_PadShape = PAD_CIRCLE; // Shape: PAD_CIRCLE, PAD_RECT PAD_OVAL m_PadShape = PAD_CIRCLE; // Shape: PAD_CIRCLE, PAD_RECT PAD_OVAL
...@@ -68,23 +68,23 @@ int D_PAD::GetMaxRadius() const ...@@ -68,23 +68,23 @@ int D_PAD::GetMaxRadius() const
switch( m_PadShape & 0x7F ) switch( m_PadShape & 0x7F )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
radius = TO_LEGACY_LU( m_Size.x / 2 ); radius = TO_LEGACY_LU( m_Size.x() / 2 );
break; break;
case PAD_OVAL: case PAD_OVAL:
radius = TO_LEGACY_LU( MAX( m_Size.x, m_Size.y ) / 2 ); radius = TO_LEGACY_LU( max( m_Size.x(), m_Size.y() ) / 2 );
break; break;
case PAD_RECT: case PAD_RECT:
x = TO_LEGACY_LU( m_Size.x ); x = TO_LEGACY_LU( m_Size.x() );
y = TO_LEGACY_LU( m_Size.y ); y = TO_LEGACY_LU( m_Size.y() );
radius = 1 + (int) ( sqrt( (double) y * y radius = 1 + (int) ( sqrt( (double) y * y
+ (double) x * x ) / 2 ); + (double) x * x ) / 2 );
break; break;
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
x = TO_LEGACY_LU( m_Size.x + ABS( m_DeltaSize.y ) ); // Remember: m_DeltaSize.y is the m_Size.x change x = TO_LEGACY_LU( m_Size.x() + abs( m_DeltaSize.y() ) ); // Remember: m_DeltaSize.y is the m_Size.x change
y = TO_LEGACY_LU( m_Size.y + ABS( m_DeltaSize.x ) ); // Remember: m_DeltaSize.x is the m_Size.y change y = TO_LEGACY_LU( m_Size.y() + abs( m_DeltaSize.x() ) ); // Remember: m_DeltaSize.x is the m_Size.y change
radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 ); radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 );
break; break;
...@@ -114,7 +114,7 @@ EDA_RECT D_PAD::GetBoundingBox() const ...@@ -114,7 +114,7 @@ EDA_RECT D_PAD::GetBoundingBox() const
EDA_RECT area; EDA_RECT area;
int radius = GetMaxRadius(); // Calculate the radius of the area, considered as a circle int radius = GetMaxRadius(); // Calculate the radius of the area, considered as a circle
area.SetOrigin( m_Pos ); area.SetOrigin( TO_LEGACY_LU_WXP( m_Pos ) );
area.Inflate( radius ); area.Inflate( radius );
return area; return area;
...@@ -124,19 +124,19 @@ EDA_RECT D_PAD::GetBoundingBox() const ...@@ -124,19 +124,19 @@ EDA_RECT D_PAD::GetBoundingBox() const
// Returns the position of the pad. // Returns the position of the pad.
const wxPoint D_PAD::ReturnShapePos() const wxPoint D_PAD::ReturnShapePos()
{ {
if( m_Offset.x == ZERO_LENGTH && m_Offset.y == ZERO_LENGTH ) if( m_Offset[0] == ZERO_LENGTH && m_Offset[0] == ZERO_LENGTH )
return m_Pos; return TO_LEGACY_LU_WXP( m_Pos );
wxPoint shape_pos; wxPoint shape_pos;
int dX, dY; int dX, dY;
dX = TO_LEGACY_LU( m_Offset.x ); dX = TO_LEGACY_LU( m_Offset[0] );
dY = TO_LEGACY_LU( m_Offset.y ); dY = TO_LEGACY_LU( m_Offset[1] );
RotatePoint( &dX, &dY, m_Orient ); RotatePoint( &dX, &dY, m_Orient );
shape_pos.x = m_Pos.x + dX; shape_pos.x = TO_LEGACY_LU( m_Pos.x() ) + dX;
shape_pos.y = m_Pos.y + dY; shape_pos.y = TO_LEGACY_LU( m_Pos.y() ) + dY;
return shape_pos; return shape_pos;
} }
...@@ -304,7 +304,7 @@ int D_PAD::GetSolderMaskMargin() ...@@ -304,7 +304,7 @@ int D_PAD::GetSolderMaskMargin()
// ensure mask have a size always >= 0 // ensure mask have a size always >= 0
if( margin < 0 ) if( margin < 0 )
{ {
int minsize = TO_LEGACY_LU( -MIN( m_Size.x, m_Size.y ) / 2 ); int minsize = TO_LEGACY_LU( -min( m_Size.x(), m_Size.y() ) / 2 );
if( margin < minsize ) if( margin < minsize )
minsize = minsize; minsize = minsize;
...@@ -349,15 +349,15 @@ wxSize D_PAD::GetSolderPasteMargin() ...@@ -349,15 +349,15 @@ wxSize D_PAD::GetSolderPasteMargin()
} }
wxSize pad_margin; wxSize pad_margin;
pad_margin.x = margin + wxRound( TO_LEGACY_LU_DBL( m_Size.x ) * mratio ); pad_margin.x = margin + wxRound( TO_LEGACY_LU_DBL( m_Size.x() ) * mratio );
pad_margin.y = margin + wxRound( TO_LEGACY_LU_DBL( m_Size.y ) * mratio ); pad_margin.y = margin + wxRound( TO_LEGACY_LU_DBL( m_Size.y() ) * mratio );
// ensure mask have a size always >= 0 // ensure mask have a size always >= 0
if( pad_margin.x < TO_LEGACY_LU( -m_Size.x / 2 ) ) if( pad_margin.x < TO_LEGACY_LU( -m_Size.x() / 2 ) )
pad_margin.x = TO_LEGACY_LU( -m_Size.x / 2 ); pad_margin.x = TO_LEGACY_LU( -m_Size.x() / 2 );
if( pad_margin.y < TO_LEGACY_LU( -m_Size.y / 2 ) ) if( pad_margin.y < TO_LEGACY_LU( -m_Size.y() / 2 ) )
pad_margin.y = TO_LEGACY_LU( -m_Size.y / 2 ); pad_margin.y = TO_LEGACY_LU( -m_Size.y() / 2 );
return pad_margin; return pad_margin;
} }
...@@ -426,10 +426,10 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) ...@@ -426,10 +426,10 @@ int D_PAD::ReadDescr( LINE_READER* aReader )
BufCar, &sx, &sy, BufCar, &sx, &sy,
&dx, &dy, &dx, &dy,
&m_Orient ); &m_Orient );
m_Size.x = LENGTH_LOAD_TMP( sx ); m_Size.x( LENGTH_LOAD_TMP( sx ) );
m_Size.y = LENGTH_LOAD_TMP( sy ); m_Size.y( LENGTH_LOAD_TMP( sy ) );
m_DeltaSize.x = LENGTH_LOAD_TMP( dx ); m_DeltaSize.x( LENGTH_LOAD_TMP( dx ) );
m_DeltaSize.y = LENGTH_LOAD_TMP( dy ); m_DeltaSize.y( LENGTH_LOAD_TMP( dy ) );
ll = 0xFF & BufCar[0]; ll = 0xFF & BufCar[0];
/* Read pad shape */ /* Read pad shape */
...@@ -457,17 +457,18 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) ...@@ -457,17 +457,18 @@ int D_PAD::ReadDescr( LINE_READER* aReader )
BufCar[0] = 0; BufCar[0] = 0;
nn = sscanf( PtLine, FM_LENLD" "FM_LENLD" "FM_LENLD" %s "FM_LENLD" "FM_LENLD, &dr, nn = sscanf( PtLine, FM_LENLD" "FM_LENLD" "FM_LENLD" %s "FM_LENLD" "FM_LENLD, &dr,
&ox, &oy, BufCar, &dx, &dy ); &ox, &oy, BufCar, &dx, &dy );
m_Offset.x = LENGTH_LOAD_TMP( ox ); m_Offset.x( LENGTH_LOAD_TMP( ox ) );
m_Offset.y = LENGTH_LOAD_TMP( oy ); m_Offset.y( LENGTH_LOAD_TMP( oy ) );
m_Drill.y = m_Drill.x = LENGTH_LOAD_TMP( dr ); m_Drill.x( LENGTH_LOAD_TMP( dr ) );
m_Drill.y( m_Drill.x() );
m_DrillShape = PAD_CIRCLE; m_DrillShape = PAD_CIRCLE;
if( nn >= 6 ) // Drill shape = OVAL ? if( nn >= 6 ) // Drill shape = OVAL ?
{ {
if( BufCar[0] == 'O' ) if( BufCar[0] == 'O' )
{ {
m_Drill.x = FROM_LEGACY_LU( dx ); m_Drill.x( FROM_LEGACY_LU( dx ) );
m_Drill.y = FROM_LEGACY_LU( dy ); m_Drill.y( FROM_LEGACY_LU( dy ) );
m_DrillShape = PAD_OVAL; m_DrillShape = PAD_OVAL;
} }
} }
...@@ -503,8 +504,8 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) ...@@ -503,8 +504,8 @@ int D_PAD::ReadDescr( LINE_READER* aReader )
case 'P': case 'P':
nn = sscanf( PtLine, FM_LENLD" "FM_LENLD, &ox, &oy ); nn = sscanf( PtLine, FM_LENLD" "FM_LENLD, &ox, &oy );
m_Pos0 = VECTOR_PCB( LENGTH_LOAD_TMP( ox ), LENGTH_LOAD_TMP( oy ) ); m_Pos0 = VECTOR_PCB::fromXY( LENGTH_LOAD_TMP( ox ), LENGTH_LOAD_TMP( oy ) );
m_Pos = TO_LEGACY_LU_WXP( m_Pos0 ); m_Pos = m_Pos0;
break; break;
case 'L': case 'L':
...@@ -563,14 +564,14 @@ bool D_PAD::Save( FILE* aFile ) const ...@@ -563,14 +564,14 @@ bool D_PAD::Save( FILE* aFile ) const
} }
fprintf( aFile, "Sh \"%.4s\" %c "FM_LENSV" "FM_LENSV" "FM_LENSV" "FM_LENSV" %d\n", // TODO: pad name length limit! fprintf( aFile, "Sh \"%.4s\" %c "FM_LENSV" "FM_LENSV" "FM_LENSV" "FM_LENSV" %d\n", // TODO: pad name length limit!
m_Padname, cshape, ARG_LENSV( m_Size.x ), ARG_LENSV( m_Size.y ), m_Padname, cshape, ARG_LENSV( m_Size.x() ), ARG_LENSV( m_Size.y() ),
ARG_LENSV( m_DeltaSize.x ), ARG_LENSV( m_DeltaSize.y ), m_Orient ); ARG_LENSV( m_DeltaSize.x() ), ARG_LENSV( m_DeltaSize.y() ), m_Orient );
fprintf( aFile, "Dr "FM_LENSV" "FM_LENSV" "FM_LENSV, ARG_LENSV( m_Drill.x ), ARG_LENSV( m_Offset.x ), ARG_LENSV( m_Offset.y ) ); fprintf( aFile, "Dr "FM_LENSV" "FM_LENSV" "FM_LENSV, ARG_LENSV( m_Drill.x() ), ARG_LENSV( m_Offset.x() ), ARG_LENSV( m_Offset.y() ) );
if( m_DrillShape == PAD_OVAL ) if( m_DrillShape == PAD_OVAL )
{ {
fprintf( aFile, " %c "FM_LENSV" "FM_LENSV, 'O', ARG_LENSV( m_Drill.x ), ARG_LENSV( m_Drill.y ) ); fprintf( aFile, " %c "FM_LENSV" "FM_LENSV, 'O', ARG_LENSV( m_Drill.x() ), ARG_LENSV( m_Drill.y() ) );
} }
fprintf( aFile, "\n" ); fprintf( aFile, "\n" );
...@@ -599,7 +600,7 @@ bool D_PAD::Save( FILE* aFile ) const ...@@ -599,7 +600,7 @@ bool D_PAD::Save( FILE* aFile ) const
fprintf( aFile, "Ne %d %s\n", GetNet(), EscapedUTF8( m_Netname ).c_str() ); fprintf( aFile, "Ne %d %s\n", GetNet(), EscapedUTF8( m_Netname ).c_str() );
fprintf( aFile, "Po "FM_LENSV" "FM_LENSV"\n", ARG_LENSV( m_Pos0.x ), ARG_LENSV( m_Pos0.y ) ); fprintf( aFile, "Po "FM_LENSV" "FM_LENSV"\n", ARG_LENSV( m_Pos0.x() ), ARG_LENSV( m_Pos0.y() ) );
if( m_LengthDie != ZERO_LENGTH ) if( m_LengthDie != ZERO_LENGTH )
fprintf( aFile, "Le "FM_LENSV"\n", ARG_LENSV( m_LengthDie ) ); fprintf( aFile, "Le "FM_LENSV"\n", ARG_LENSV( m_LengthDie ) );
...@@ -755,13 +756,13 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -755,13 +756,13 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( ShowPadShape(), ShowPadAttr(), DARKGREEN ); frame->AppendMsgPanel( ShowPadShape(), ShowPadAttr(), DARKGREEN );
valeur_param( TO_LEGACY_LU( m_Size.x ), Line ); valeur_param( TO_LEGACY_LU( m_Size.x() ), Line );
frame->AppendMsgPanel( _( "H Size" ), Line, RED ); frame->AppendMsgPanel( _( "H Size" ), Line, RED );
valeur_param( TO_LEGACY_LU( m_Size.y ), Line ); valeur_param( TO_LEGACY_LU( m_Size.y() ), Line );
frame->AppendMsgPanel( _( "V Size" ), Line, RED ); frame->AppendMsgPanel( _( "V Size" ), Line, RED );
valeur_param( (unsigned)(int) TO_LEGACY_LU( m_Drill.x ), Line ); valeur_param( (unsigned)(int) TO_LEGACY_LU( m_Drill.x() ), Line );
if( m_DrillShape == PAD_CIRCLE ) if( m_DrillShape == PAD_CIRCLE )
{ {
...@@ -769,9 +770,9 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -769,9 +770,9 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
} }
else else
{ {
valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.x ), Line ); valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.x() ), Line );
wxString msg; wxString msg;
valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.y ), msg ); valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.y() ), msg );
Line += wxT( " / " ) + msg; Line += wxT( " / " ) + msg;
frame->AppendMsgPanel( _( "Drill X / Y" ), Line, RED ); frame->AppendMsgPanel( _( "Drill X / Y" ), Line, RED );
} }
...@@ -787,10 +788,10 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -787,10 +788,10 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Orient" ), Line, LIGHTBLUE ); frame->AppendMsgPanel( _( "Orient" ), Line, LIGHTBLUE );
valeur_param( m_Pos.x, Line ); valeur_param( TO_LEGACY_LU( m_Pos.x() ), Line );
frame->AppendMsgPanel( _( "X Pos" ), Line, LIGHTBLUE ); frame->AppendMsgPanel( _( "X Pos" ), Line, LIGHTBLUE );
valeur_param( m_Pos.y, Line ); valeur_param( TO_LEGACY_LU( m_Pos.y() ), Line );
frame->AppendMsgPanel( _( "Y pos" ), Line, LIGHTBLUE ); frame->AppendMsgPanel( _( "Y pos" ), Line, LIGHTBLUE );
if( m_LengthDie != ZERO_LENGTH ) if( m_LengthDie != ZERO_LENGTH )
...@@ -827,8 +828,8 @@ bool D_PAD::HitTest( const wxPoint& refPos ) ...@@ -827,8 +828,8 @@ bool D_PAD::HitTest( const wxPoint& refPos )
if( ( abs( delta.x ) > m_ShapeMaxRadius ) || ( abs( delta.y ) > m_ShapeMaxRadius ) ) if( ( abs( delta.x ) > m_ShapeMaxRadius ) || ( abs( delta.y ) > m_ShapeMaxRadius ) )
return false; return false;
dx = TO_LEGACY_LU( m_Size.x / 2 ); // dx also is the radius for rounded pads dx = TO_LEGACY_LU( m_Size.x() / 2 ); // dx also is the radius for rounded pads
dy = TO_LEGACY_LU( m_Size.y / 2 ); dy = TO_LEGACY_LU( m_Size.y() / 2 );
switch( m_PadShape & 0x7F ) switch( m_PadShape & 0x7F )
{ {
...@@ -868,22 +869,22 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) ...@@ -868,22 +869,22 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
if( ( diff = padref->m_PadShape - padcmp->m_PadShape) ) if( ( diff = padref->m_PadShape - padcmp->m_PadShape) )
return diff; return diff;
if( ( diff = TO_LEGACY_LU( padref->m_Size.x - padcmp->m_Size.x ) ) ) if( ( diff = TO_LEGACY_LU( padref->m_Size.x() - padcmp->m_Size.x() ) ) )
return diff; return diff;
if( ( diff = TO_LEGACY_LU( padref->m_Size.y - padcmp->m_Size.y ) ) ) if( ( diff = TO_LEGACY_LU( padref->m_Size.y() - padcmp->m_Size.y() ) ) )
return diff; return diff;
if( ( diff = TO_LEGACY_LU( padref->m_Offset.x - padcmp->m_Offset.x ) ) ) if( ( diff = TO_LEGACY_LU( padref->m_Offset.x() - padcmp->m_Offset.x() ) ) )
return diff; return diff;
if( ( diff = TO_LEGACY_LU( padref->m_Offset.y - padcmp->m_Offset.y ) ) ) if( ( diff = TO_LEGACY_LU( padref->m_Offset.y() - padcmp->m_Offset.y() ) ) )
return diff; return diff;
if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.x - padcmp->m_DeltaSize.x ) ) ) if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.x() - padcmp->m_DeltaSize.x() ) ) )
return diff; return diff;
if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.y - padcmp->m_DeltaSize.y ) ) ) if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.y() - padcmp->m_DeltaSize.y() ) ) )
return diff; return diff;
// @todo check if export_gencad still works: // @todo check if export_gencad still works:
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "PolyLine.h" #include "PolyLine.h"
#include "lengthpcb.h" #include "lengthpcb.h"
#include "vectorpcb.h"
class LINE_READER; class LINE_READER;
class EDA_3D_CANVAS; class EDA_3D_CANVAS;
...@@ -72,8 +72,9 @@ private: ...@@ -72,8 +72,9 @@ private:
wxString m_ShortNetname; // short net name, like vout from /mysheet/mysubsheet/vout wxString m_ShortNetname; // short net name, like vout from /mysheet/mysubsheet/vout
public: public: /** TODO: that's not so good if parameters are easily modifiable outside
wxPoint m_Pos; // pad Position on board (e. g. m_Pos, which could be coherent with m_Pos and module orient/pos ) */
VECTOR_PCB m_Pos; // pad Position on board
union union
{ {
...@@ -114,7 +115,7 @@ public: ...@@ -114,7 +115,7 @@ public:
VECTOR_PCB m_DeltaSize; // delta on rectangular shapes VECTOR_PCB m_DeltaSize; // delta on rectangular shapes
VECTOR_PCB m_Pos0; // Initial Pad position (i.e. pas position relative to the VECTOR_PCB m_Pos0; // Initial Pad position (i.e. pad position relative to the
// module anchor, orientation 0 // module anchor, orientation 0
int m_ShapeMaxRadius; // radius of the circle containing the pad shape int m_ShapeMaxRadius; // radius of the circle containing the pad shape
...@@ -177,16 +178,17 @@ public: ...@@ -177,16 +178,17 @@ public:
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
* @return const wxPoint& - The position of this object. * @return const wxPoint& - The position of this object.
* @TODO: could move virtual method to .c file
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Pos; return TO_LEGACY_LU_WXP( m_Pos );
} }
void SetPosition( const wxPoint& aPos ) void SetPosition( const wxPoint& aPos )
{ {
m_Pos = aPos; m_Pos = FROM_LEGACY_LU_VEC( aPos );
} }
/** /**
...@@ -385,7 +387,7 @@ public: ...@@ -385,7 +387,7 @@ public:
*/ */
virtual void Move( const wxPoint& aMoveVector ) virtual void Move( const wxPoint& aMoveVector )
{ {
m_Pos += aMoveVector; m_Pos += FROM_LEGACY_LU_VEC( aMoveVector );
} }
......
...@@ -475,8 +475,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -475,8 +475,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
} }
/* Draw the pad hole */ /* Draw the pad hole */
wxPoint holepos = m_Pos - aDrawInfo.m_Offset; wxPoint holepos = TO_LEGACY_LU_WXP( m_Pos ) - aDrawInfo.m_Offset;
int hole = TO_LEGACY_LU( m_Drill.x ) / 2; int hole = TO_LEGACY_LU( m_Drill.x() ) / 2;
bool drawhole = hole > 0; bool drawhole = hole > 0;
...@@ -513,20 +513,20 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -513,20 +513,20 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
break; break;
case PAD_OVAL: case PAD_OVAL:
halfsize.x = TO_LEGACY_LU( m_Drill.x ) / 2; halfsize.x = TO_LEGACY_LU( m_Drill.x() ) / 2;
halfsize.y = TO_LEGACY_LU( m_Drill.y ) / 2; halfsize.y = TO_LEGACY_LU( m_Drill.y() ) / 2;
if( m_Drill.x > m_Drill.y ) /* horizontal */ if( m_Drill.x() > m_Drill.y() ) /* horizontal */
{ {
delta_cx = halfsize.x - halfsize.y; delta_cx = halfsize.x - halfsize.y;
delta_cy = 0; delta_cy = 0;
seg_width = TO_LEGACY_LU( m_Drill.y ); seg_width = TO_LEGACY_LU( m_Drill.y() );
} }
else /* vertical */ else /* vertical */
{ {
delta_cx = 0; delta_cx = 0;
delta_cy = halfsize.y - halfsize.x; delta_cy = halfsize.y - halfsize.x;
seg_width = TO_LEGACY_LU( m_Drill.x ); seg_width = TO_LEGACY_LU( m_Drill.x() );
} }
RotatePoint( &delta_cx, &delta_cy, angle ); RotatePoint( &delta_cx, &delta_cy, angle );
...@@ -578,11 +578,11 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -578,11 +578,11 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
AreaSize = TO_LEGACY_LU_WXS( m_Size ); AreaSize = TO_LEGACY_LU_WXS( m_Size );
if( m_Size.y > m_Size.x ) if( m_Size.y() > m_Size.x() )
{ {
angle += 900; angle += 900;
AreaSize.x = TO_LEGACY_LU( m_Size.y ); AreaSize.x = TO_LEGACY_LU( m_Size.y() );
AreaSize.y = TO_LEGACY_LU( m_Size.x ); AreaSize.y = TO_LEGACY_LU( m_Size.x() );
} }
if( shortname_len > 0 ) // if there is a netname, provides room to display this netname if( shortname_len > 0 ) // if there is a netname, provides room to display this netname
...@@ -664,23 +664,23 @@ int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, int a ...@@ -664,23 +664,23 @@ int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, int a
{ {
int width; int width;
if( m_Size.y < m_Size.x ) // Build an horizontal equiv segment if( m_Size.y() < m_Size.x() ) // Build an horizontal equiv segment
{ {
int delta = TO_LEGACY_LU( ( m_Size.x - m_Size.y ) / 2 ); int delta = TO_LEGACY_LU( ( m_Size.x() - m_Size.y() ) / 2 );
aSegStart.x = -delta; aSegStart.x = -delta;
aSegStart.y = 0; aSegStart.y = 0;
aSegEnd.x = delta; aSegEnd.x = delta;
aSegEnd.y = 0; aSegEnd.y = 0;
width = TO_LEGACY_LU( m_Size.y ); width = TO_LEGACY_LU( m_Size.y() );
} }
else // Vertical oval: build a vertical equiv segment else // Vertical oval: build a vertical equiv segment
{ {
int delta = TO_LEGACY_LU( ( m_Size.y -m_Size.x ) / 2 ); int delta = TO_LEGACY_LU( ( m_Size.y() -m_Size.x() ) / 2 );
aSegStart.x = 0; aSegStart.x = 0;
aSegStart.y = -delta; aSegStart.y = -delta;
aSegEnd.x = 0; aSegEnd.x = 0;
aSegEnd.y = delta; aSegEnd.y = delta;
width = TO_LEGACY_LU( m_Size.x ); width = TO_LEGACY_LU( m_Size.x() );
} }
if( aRotation ) if( aRotation )
...@@ -701,8 +701,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat ...@@ -701,8 +701,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
wxSize delta; wxSize delta;
wxSize halfsize; wxSize halfsize;
halfsize.x = TO_LEGACY_LU( m_Size.x / 2 ); halfsize.x = TO_LEGACY_LU( m_Size.x() / 2 );
halfsize.y = TO_LEGACY_LU( m_Size.y / 2 ); halfsize.y = TO_LEGACY_LU( m_Size.y() / 2 );
/* For rectangular shapes, inflate is easy /* For rectangular shapes, inflate is easy
*/ */
...@@ -721,8 +721,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat ...@@ -721,8 +721,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
else else
{ {
// Trapezoidal pad: verify delta values // Trapezoidal pad: verify delta values
delta.x = TO_LEGACY_LU( m_DeltaSize.x / 2 ); delta.x = TO_LEGACY_LU( m_DeltaSize.x() / 2 );
delta.y = TO_LEGACY_LU( m_DeltaSize.y / 2 ); delta.y = TO_LEGACY_LU( m_DeltaSize.y() / 2 );
// be sure delta values are not to large // be sure delta values are not to large
if( (delta.x < 0) && (delta.x <= -halfsize.y) ) if( (delta.x < 0) && (delta.x <= -halfsize.y) )
...@@ -762,7 +762,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat ...@@ -762,7 +762,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat
if( delta.y ) // lower and upper segment is horizontal if( delta.y ) // lower and upper segment is horizontal
{ {
// Calculate angle of left (or right) segment with vertical axis // Calculate angle of left (or right) segment with vertical axis
angle = atan2( m_DeltaSize.y, m_Size.y ); /// TODO: make atan2 available to LENGTH angle = atan2( m_DeltaSize.y(), m_Size.y() );
// left and right sides are moved by aInflateValue.x in their perpendicular direction // left and right sides are moved by aInflateValue.x in their perpendicular direction
// We must calculate the corresponding displacement on the horizontal axis // 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 ...@@ -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 else if( delta.x ) // left and right segment is vertical
{ {
// Calculate angle of lower (or upper) segment with horizontal axis // Calculate angle of lower (or upper) segment with horizontal axis
angle = atan2( m_DeltaSize.x, m_Size.x ); angle = atan2( m_DeltaSize.x(), m_Size.x() );
// lower and upper sides are moved by aInflateValue.x in their perpendicular direction // lower and upper sides are moved by aInflateValue.x in their perpendicular direction
// We must calculate the corresponding displacement on the vertical axis // We must calculate the corresponding displacement on the vertical axis
......
...@@ -26,11 +26,15 @@ public: ...@@ -26,11 +26,15 @@ public:
* returns the position of this object. * returns the position of this object.
* @return wxPoint& - The position of this object, non-const so it can be changed * @return wxPoint& - The position of this object, non-const so it can be changed
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Pos; // within EDA_TEXT return m_Pos; // within EDA_TEXT
} }
void SetPosition( const wxPoint& pos ) {
m_Pos = pos;
}
/** /**
* Function Move * Function Move
* move this object. * move this object.
......
...@@ -51,11 +51,14 @@ public: ...@@ -51,11 +51,14 @@ public:
* Required by pure virtual BOARD_ITEM::GetPosition() * Required by pure virtual BOARD_ITEM::GetPosition()
* @return const wxPoint& - The position of this object. * @return const wxPoint& - The position of this object.
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Pos; return m_Pos;
} }
void SetPosition( const wxPoint& pos ) {
m_Pos = pos;
}
void Copy( TEXTE_MODULE* source ); // copy structure void Copy( TEXTE_MODULE* source ); // copy structure
......
...@@ -120,13 +120,21 @@ public: ...@@ -120,13 +120,21 @@ public:
/** /**
* Function GetPosition * Function GetPosition
* returns the position of this object. * returns the position of this object.
* @return const wxPoint& - The position of this object. * @return const wxPoint - The position of this object.
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Start; // it had to be start or end. return m_Start; // it had to be start or end.
} }
/**
* Sets the position of this object. Virtual function, needed by BOARD_ITEM
* @param pos The position of this object
*/
void SetPosition( const wxPoint& pos ) {
m_Start = pos;
}
EDA_RECT GetBoundingBox() const; EDA_RECT GetBoundingBox() const;
/** /**
...@@ -470,12 +478,11 @@ public: ...@@ -470,12 +478,11 @@ public:
* returns the position of this object. * returns the position of this object.
* @return const wxPoint& - The position of this object. * @return const wxPoint& - The position of this object.
*/ */
wxPoint& GetPosition() const wxPoint GetPosition() const
{ {
return m_Start; return m_Start;
} }
void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; }
/** /**
......
...@@ -84,20 +84,13 @@ bool ZONE_CONTAINER::UnFill() ...@@ -84,20 +84,13 @@ bool ZONE_CONTAINER::UnFill()
} }
wxPoint& ZONE_CONTAINER::GetPosition() const wxPoint ZONE_CONTAINER::GetPosition() const
{ {
static wxPoint pos; return m_Poly? GetCornerPosition( 0 ) : wxPoint( 0, 0 );
if( m_Poly )
{
pos = GetCornerPosition( 0 );
}
else
pos = wxPoint( 0, 0 );
return pos;
} }
void ZONE_CONTAINER::SetPosition( const wxPoint& pos ) {
}
void ZONE_CONTAINER::SetNet( int aNetCode ) void ZONE_CONTAINER::SetNet( int aNetCode )
{ {
......
...@@ -118,8 +118,8 @@ public: ...@@ -118,8 +118,8 @@ public:
* Function GetPosition * Function GetPosition
* @return a wxPoint, position of the first point of the outline * @return a wxPoint, position of the first point of the outline
*/ */
wxPoint& GetPosition(); const wxPoint GetPosition() const;
void SetPosition( const wxPoint& pos );
/** /**
* Function copy * Function copy
* copy useful data from the source. * copy useful data from the source.
......
...@@ -850,7 +850,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) ...@@ -850,7 +850,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame )
if( pad ) if( pad )
{ {
// test if the track start point is not exactly starting on the pad // test if the track start point is not exactly starting on the pad
if( segment->m_Start != pad->m_Pos ) if( segment->m_Start != TO_LEGACY_LU_WXP( pad->m_Pos ) )
{ {
if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, START ) == NULL ) if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, START ) == NULL )
{ {
...@@ -858,7 +858,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) ...@@ -858,7 +858,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame )
frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() ); frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );
newTrack->m_End = pad->m_Pos; newTrack->m_End = TO_LEGACY_LU_WXP( pad->m_Pos );
newTrack->start = segment; newTrack->start = segment;
newTrack->end = pad; newTrack->end = pad;
...@@ -872,7 +872,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) ...@@ -872,7 +872,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame )
if( pad ) if( pad )
{ {
// test if the track end point is not exactly on the pad // test if the track end point is not exactly on the pad
if( segment->m_End != pad->m_Pos ) if( segment->m_End != TO_LEGACY_LU_WXP( pad->m_Pos ) )
{ {
if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, END ) == NULL ) if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, END ) == NULL )
{ {
...@@ -880,7 +880,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) ...@@ -880,7 +880,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame )
frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() ); frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() );
newTrack->m_Start = pad->m_Pos; newTrack->m_Start = TO_LEGACY_LU_WXP( pad->m_Pos );
newTrack->start = pad; newTrack->start = pad;
newTrack->end = segment; newTrack->end = segment;
......
...@@ -185,7 +185,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void ) ...@@ -185,7 +185,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void )
{ {
if( pad->m_DrillShape == PAD_CIRCLE ) if( pad->m_DrillShape == PAD_CIRCLE )
{ {
if( pad->m_Drill.x != ZERO_LENGTH ) if( pad->m_Drill.x() != ZERO_LENGTH )
{ {
if( pad->m_Attribut == PAD_HOLE_NOT_PLATED ) if( pad->m_Attribut == PAD_HOLE_NOT_PLATED )
m_notplatedPadsHoleCount++; m_notplatedPadsHoleCount++;
...@@ -195,7 +195,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void ) ...@@ -195,7 +195,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void )
} }
else else
{ {
if( MIN( TO_LEGACY_LU( pad->m_Drill.x ), TO_LEGACY_LU( 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 ) if( pad->m_Attribut == PAD_HOLE_NOT_PLATED )
m_notplatedPadsHoleCount++; m_notplatedPadsHoleCount++;
......
...@@ -117,7 +117,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) ...@@ -117,7 +117,7 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
drawInfo.m_Color = color; drawInfo.m_Color = color;
drawInfo.m_HoleColor = DARKGRAY; drawInfo.m_HoleColor = DARKGRAY;
drawInfo.m_Offset = m_dummyPad->m_Pos; drawInfo.m_Offset = TO_LEGACY_LU_WXP( m_dummyPad->m_Pos );
drawInfo.m_Display_padnum = true; drawInfo.m_Display_padnum = true;
drawInfo.m_Display_netname = true; drawInfo.m_Display_netname = true;
if( m_dummyPad->m_Attribut == PAD_HOLE_NOT_PLATED ) if( m_dummyPad->m_Attribut == PAD_HOLE_NOT_PLATED )
...@@ -130,11 +130,11 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) ...@@ -130,11 +130,11 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 ); dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 );
// Calculate a suitable scale to fit the available draw area // Calculate a suitable scale to fit the available draw area
int dim = TO_LEGACY_LU( m_dummyPad->m_Size.x + ABS( m_dummyPad->m_DeltaSize.y ) ); int dim = TO_LEGACY_LU( m_dummyPad->m_Size.x() + abs( m_dummyPad->m_DeltaSize.y() ) );
if( m_dummyPad->m_LocalClearance > ZERO_LENGTH ) if( m_dummyPad->m_LocalClearance > ZERO_LENGTH )
dim += TO_LEGACY_LU( m_dummyPad->m_LocalClearance * 2 ); dim += TO_LEGACY_LU( m_dummyPad->m_LocalClearance * 2 );
double scale = (double) dc_size.x / dim; double scale = (double) dc_size.x / dim;
dim = TO_LEGACY_LU( m_dummyPad->m_Size.y + ABS( m_dummyPad->m_DeltaSize.x ) ); dim = TO_LEGACY_LU( m_dummyPad->m_Size.y() + abs( m_dummyPad->m_DeltaSize.x() ) );
if( m_dummyPad->m_LocalClearance > ZERO_LENGTH ) if( m_dummyPad->m_LocalClearance > ZERO_LENGTH )
dim += TO_LEGACY_LU( m_dummyPad->m_LocalClearance * 2 ); dim += TO_LEGACY_LU( m_dummyPad->m_LocalClearance * 2 );
double altscale = (double) dc_size.y / dim; double altscale = (double) dc_size.y / dim;
...@@ -207,8 +207,8 @@ void DIALOG_PAD_PROPERTIES::initValues() ...@@ -207,8 +207,8 @@ void DIALOG_PAD_PROPERTIES::initValues()
if( m_isFlipped ) if( m_isFlipped )
{ {
NEGATE( m_dummyPad->m_Offset.y ); m_dummyPad->m_Offset.y( -m_dummyPad->m_Offset.y() );
NEGATE( m_dummyPad->m_DeltaSize.y ); m_dummyPad->m_DeltaSize.y( -m_dummyPad->m_DeltaSize.y() );
/* flip pads layers*/ /* flip pads layers*/
m_dummyPad->m_layerMask = ChangeSideMaskLayer( m_dummyPad->m_layerMask ); m_dummyPad->m_layerMask = ChangeSideMaskLayer( m_dummyPad->m_layerMask );
} }
...@@ -236,26 +236,26 @@ void DIALOG_PAD_PROPERTIES::initValues() ...@@ -236,26 +236,26 @@ void DIALOG_PAD_PROPERTIES::initValues()
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
// Display current pad parameters units: // Display current pad parameters units:
PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->m_Pos.x, internalUnits ); CTR_PUT_LENGTH( *m_PadPosition_X_Ctrl, m_dummyPad->m_Pos.x(), internalUnits );
PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->m_Pos.y, internalUnits ); CTR_PUT_LENGTH( *m_PadPosition_Y_Ctrl, m_dummyPad->m_Pos.y(), internalUnits );
CTR_PUT_LENGTH( *m_PadDrill_X_Ctrl, m_dummyPad->m_Drill.x, internalUnits ); CTR_PUT_LENGTH( *m_PadDrill_X_Ctrl, m_dummyPad->m_Drill.x(), internalUnits );
CTR_PUT_LENGTH( *m_PadDrill_Y_Ctrl, m_dummyPad->m_Drill.y, internalUnits ); CTR_PUT_LENGTH( *m_PadDrill_Y_Ctrl, m_dummyPad->m_Drill.y(), internalUnits );
CTR_PUT_LENGTH( *m_ShapeSize_X_Ctrl, m_dummyPad->m_Size.x, internalUnits ); CTR_PUT_LENGTH( *m_ShapeSize_X_Ctrl, m_dummyPad->m_Size.x(), internalUnits );
CTR_PUT_LENGTH( *m_ShapeSize_Y_Ctrl, m_dummyPad->m_Size.y, internalUnits ); CTR_PUT_LENGTH( *m_ShapeSize_Y_Ctrl, m_dummyPad->m_Size.y(), internalUnits );
CTR_PUT_LENGTH( *m_ShapeOffset_X_Ctrl, m_dummyPad->m_Offset.x, internalUnits ); CTR_PUT_LENGTH( *m_ShapeOffset_X_Ctrl, m_dummyPad->m_Offset.x(), internalUnits );
CTR_PUT_LENGTH( *m_ShapeOffset_Y_Ctrl, m_dummyPad->m_Offset.y, internalUnits ); CTR_PUT_LENGTH( *m_ShapeOffset_Y_Ctrl, m_dummyPad->m_Offset.y(), internalUnits );
if( m_dummyPad->m_DeltaSize.x != ZERO_LENGTH ) if( m_dummyPad->m_DeltaSize.x() != ZERO_LENGTH )
{ {
CTR_PUT_LENGTH( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.x, internalUnits ); CTR_PUT_LENGTH( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.x(), internalUnits );
m_radioBtnDeltaXdir->SetValue(true); m_radioBtnDeltaXdir->SetValue(true);
} }
else else
{ {
CTR_PUT_LENGTH( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.y, internalUnits ); CTR_PUT_LENGTH( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.y(), internalUnits );
m_radioBtnDeltaYdir->SetValue(true); m_radioBtnDeltaYdir->SetValue(true);
} }
...@@ -613,7 +613,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -613,7 +613,7 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
/* compute the pos 0 value, i.e. pad position for module orient = 0 i.e. /* compute the pos 0 value, i.e. pad position for module orient = 0 i.e.
* refer to module origin (module position) */ * refer to module origin (module position) */
m_CurrentPad->m_Pos0 = FROM_LEGACY_LU_VEC( m_CurrentPad->m_Pos ); m_CurrentPad->m_Pos0 = m_CurrentPad->m_Pos;
m_CurrentPad->m_Pos0 -= FROM_LEGACY_LU_VEC( Module->m_Pos ); m_CurrentPad->m_Pos0 -= FROM_LEGACY_LU_VEC( Module->m_Pos );
m_CurrentPad->m_Orient = (g_Pad_Master.m_Orient * isign) + Module->m_Orient; m_CurrentPad->m_Orient = (g_Pad_Master.m_Orient * isign) + Module->m_Orient;
wxPoint p = TO_LEGACY_LU_WXP( m_CurrentPad->m_Pos0 ); wxPoint p = TO_LEGACY_LU_WXP( m_CurrentPad->m_Pos0 );
...@@ -621,12 +621,12 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) ...@@ -621,12 +621,12 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
m_CurrentPad->m_Pos0 = FROM_LEGACY_LU_VEC( p ); m_CurrentPad->m_Pos0 = FROM_LEGACY_LU_VEC( p );
m_CurrentPad->m_Size = g_Pad_Master.m_Size; m_CurrentPad->m_Size = g_Pad_Master.m_Size;
m_CurrentPad->m_DeltaSize = g_Pad_Master.m_DeltaSize; m_CurrentPad->m_DeltaSize = g_Pad_Master.m_DeltaSize;
m_CurrentPad->m_DeltaSize.y *= isign; m_CurrentPad->m_DeltaSize.y( m_CurrentPad->m_DeltaSize.y() * isign );
m_CurrentPad->m_Drill = g_Pad_Master.m_Drill; m_CurrentPad->m_Drill = g_Pad_Master.m_Drill;
m_CurrentPad->m_DrillShape = g_Pad_Master.m_DrillShape; m_CurrentPad->m_DrillShape = g_Pad_Master.m_DrillShape;
m_CurrentPad->m_Offset = g_Pad_Master.m_Offset; m_CurrentPad->m_Offset = g_Pad_Master.m_Offset;
m_CurrentPad->m_Offset.y *= isign; m_CurrentPad->m_Offset.y( m_CurrentPad->m_Offset.y() * isign );
m_CurrentPad->m_LengthDie = g_Pad_Master.m_LengthDie; m_CurrentPad->m_LengthDie = g_Pad_Master.m_LengthDie;
...@@ -711,26 +711,26 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError ...@@ -711,26 +711,26 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
aPad->m_LocalSolderPasteMarginRatio = dtmp / 100; aPad->m_LocalSolderPasteMarginRatio = dtmp / 100;
// Read pad position: // Read pad position:
aPad->m_Pos.x = ReturnValueFromTextCtrl( *m_PadPosition_X_Ctrl, internalUnits ); aPad->m_Pos.x( CTR_GET_LENGTH( *m_PadPosition_X_Ctrl, internalUnits ) );
aPad->m_Pos.y = ReturnValueFromTextCtrl( *m_PadPosition_Y_Ctrl, internalUnits ); aPad->m_Pos.y( CTR_GET_LENGTH( *m_PadPosition_Y_Ctrl, internalUnits ) );
aPad->m_Pos0 = FROM_LEGACY_LU_VEC( aPad->m_Pos ); aPad->m_Pos0 = aPad->m_Pos;
// Read pad drill: // Read pad drill:
aPad->m_Drill.x = CTR_GET_LENGTH( *m_PadDrill_X_Ctrl, internalUnits ); aPad->m_Drill.x( CTR_GET_LENGTH( *m_PadDrill_X_Ctrl, internalUnits ) );
aPad->m_Drill.y = CTR_GET_LENGTH( *m_PadDrill_Y_Ctrl, internalUnits ); aPad->m_Drill.y( CTR_GET_LENGTH( *m_PadDrill_Y_Ctrl, internalUnits ) );
if( m_DrillShapeCtrl->GetSelection() == 0 ) if( m_DrillShapeCtrl->GetSelection() == 0 )
{ {
aPad->m_DrillShape = PAD_CIRCLE; aPad->m_DrillShape = PAD_CIRCLE;
aPad->m_Drill.y = aPad->m_Drill.x; aPad->m_Drill.y( aPad->m_Drill.x() );
} }
else else
aPad->m_DrillShape = PAD_OVAL; aPad->m_DrillShape = PAD_OVAL;
// Read pad shape size: // Read pad shape size:
aPad->m_Size.x = CTR_GET_LENGTH( *m_ShapeSize_X_Ctrl, internalUnits ); aPad->m_Size.x( CTR_GET_LENGTH( *m_ShapeSize_X_Ctrl, internalUnits ) );
aPad->m_Size.y = CTR_GET_LENGTH( *m_ShapeSize_Y_Ctrl, internalUnits ); aPad->m_Size.y( CTR_GET_LENGTH( *m_ShapeSize_Y_Ctrl, internalUnits ) );
if( aPad->m_PadShape == PAD_CIRCLE ) if( aPad->m_PadShape == PAD_CIRCLE )
aPad->m_Size.y = aPad->m_Size.x; aPad->m_Size.y( aPad->m_Size.x() );
// Read pad shape delta size: // Read pad shape delta size:
// m_DeltaSize.x or m_DeltaSize.y must be NULL. for a trapezoid. // m_DeltaSize.x or m_DeltaSize.y must be NULL. for a trapezoid.
...@@ -738,8 +738,8 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError ...@@ -738,8 +738,8 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
LENGTH_PCB delta; LENGTH_PCB delta;
delta = CTR_GET_LENGTH( *m_ShapeDelta_Ctrl, internalUnits ); delta = CTR_GET_LENGTH( *m_ShapeDelta_Ctrl, internalUnits );
aPad->m_DeltaSize = m_radioBtnDeltaXdir->GetValue()? aPad->m_DeltaSize = m_radioBtnDeltaXdir->GetValue()?
VECTOR_PCB( delta, ZERO_LENGTH ): VECTOR_PCB::fromXY( delta, ZERO_LENGTH ):
VECTOR_PCB( ZERO_LENGTH, delta ); VECTOR_PCB::fromXY( ZERO_LENGTH, delta );
// Read pad lenght die // Read pad lenght die
aPad->m_LengthDie = CTR_GET_LENGTH( *m_LengthDieCtrl, internalUnits ); aPad->m_LengthDie = CTR_GET_LENGTH( *m_LengthDieCtrl, internalUnits );
...@@ -747,30 +747,30 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError ...@@ -747,30 +747,30 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
// Test bad values (be sure delta values are not to large) // Test bad values (be sure delta values are not to large)
// remember DeltaSize.x is the Y size variation TODO: this can be optimized // remember DeltaSize.x is the Y size variation TODO: this can be optimized
bool error = false; bool error = false;
if( (aPad->m_DeltaSize.x < ZERO_LENGTH) && (aPad->m_DeltaSize.x <= -aPad->m_Size.y ) ) if( (aPad->m_DeltaSize.x() < ZERO_LENGTH) && (aPad->m_DeltaSize.x() <= -aPad->m_Size.y() ) )
{ {
aPad->m_DeltaSize.x = -aPad->m_Size.y + FROM_LEGACY_LU( 2 ); aPad->m_DeltaSize.x( -aPad->m_Size.y() + FROM_LEGACY_LU( 2 ) );
error = true; error = true;
} }
if( (aPad->m_DeltaSize.x > ZERO_LENGTH) && (aPad->m_DeltaSize.x >= aPad->m_Size.y ) ) if( (aPad->m_DeltaSize.x() > ZERO_LENGTH) && (aPad->m_DeltaSize.x() >= aPad->m_Size.y() ) )
{ {
aPad->m_DeltaSize.x = aPad->m_Size.y - FROM_LEGACY_LU( 2 ); aPad->m_DeltaSize.x( aPad->m_Size.y() - FROM_LEGACY_LU( 2 ) );
error = true; error = true;
} }
if( (aPad->m_DeltaSize.y < ZERO_LENGTH) && (aPad->m_DeltaSize.y <= -aPad->m_Size.x ) ) if( (aPad->m_DeltaSize.y() < ZERO_LENGTH) && (aPad->m_DeltaSize.y() <= -aPad->m_Size.x() ) )
{ {
aPad->m_DeltaSize.y = -aPad->m_Size.x + FROM_LEGACY_LU( 2 ); aPad->m_DeltaSize.y( -aPad->m_Size.x() + FROM_LEGACY_LU( 2 ) );
error = true; error = true;
} }
if( (aPad->m_DeltaSize.y > ZERO_LENGTH) && (aPad->m_DeltaSize.y >= aPad->m_Size.x ) ) if( (aPad->m_DeltaSize.y() > ZERO_LENGTH) && (aPad->m_DeltaSize.y() >= aPad->m_Size.x() ) )
{ {
aPad->m_DeltaSize.y = aPad->m_Size.x - FROM_LEGACY_LU( 2 ); aPad->m_DeltaSize.y( aPad->m_Size.x() - FROM_LEGACY_LU( 2 ) );
error = true; error = true;
} }
// Read pad shape offset: // Read pad shape offset:
aPad->m_Offset.x = CTR_GET_LENGTH( *m_ShapeOffset_X_Ctrl, internalUnits ); aPad->m_Offset.x( CTR_GET_LENGTH( *m_ShapeOffset_X_Ctrl, internalUnits ) );
aPad->m_Offset.y = CTR_GET_LENGTH( *m_ShapeOffset_Y_Ctrl, internalUnits ); aPad->m_Offset.y( CTR_GET_LENGTH( *m_ShapeOffset_Y_Ctrl, internalUnits ) );
long orient_value = 0; long orient_value = 0;
msg = m_PadOrientCtrl->GetValue(); msg = m_PadOrientCtrl->GetValue();
...@@ -785,17 +785,17 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError ...@@ -785,17 +785,17 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
switch( aPad->m_PadShape ) switch( aPad->m_PadShape )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); // wxSize( 0, 0 ); aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); // wxSize( 0, 0 );
aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );
aPad->m_Size.y = aPad->m_Size.x; aPad->m_Size.y( aPad->m_Size.x() );
break; break;
case PAD_RECT: case PAD_RECT:
aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );
break; break;
case PAD_OVAL: case PAD_OVAL:
aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );
break; break;
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
...@@ -809,14 +809,14 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError ...@@ -809,14 +809,14 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
case PAD_CONN: case PAD_CONN:
case PAD_SMD: case PAD_SMD:
aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );
aPad->m_Drill = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); aPad->m_Drill = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );
break; break;
case PAD_HOLE_NOT_PLATED: case PAD_HOLE_NOT_PLATED:
// Mechanical purpose only: // Mechanical purpose only:
// no offset, no net name, no pad name allowed // no offset, no net name, no pad name allowed
aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 ); aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 );
aPad->SetPadName( wxEmptyString ); aPad->SetPadName( wxEmptyString );
aPad->SetNetname( wxEmptyString ); aPad->SetNetname( wxEmptyString );
break; break;
...@@ -873,8 +873,8 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError ...@@ -873,8 +873,8 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
/* Test for incorrect values */ /* Test for incorrect values */
if( aPromptOnError ) if( aPromptOnError )
{ {
if( (aPad->m_Size.x < aPad->m_Drill.x ) if( (aPad->m_Size.x() < aPad->m_Drill.x() )
|| (aPad->m_Size.y < aPad->m_Drill.y ) ) || (aPad->m_Size.y() < aPad->m_Drill.y() ) )
{ {
DisplayError( NULL, _( "Incorrect value for pad drill: pad drill bigger than pad size" ) ); DisplayError( NULL, _( "Incorrect value for pad drill: pad drill bigger than pad size" ) );
return false; return false;
...@@ -883,7 +883,7 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError ...@@ -883,7 +883,7 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError
int padlayers_mask = PadLayerMask & (LAYER_BACK | LAYER_FRONT); int padlayers_mask = PadLayerMask & (LAYER_BACK | LAYER_FRONT);
if( padlayers_mask == 0 ) if( padlayers_mask == 0 )
{ {
if( aPad->m_Drill.x != ZERO_LENGTH || aPad->m_Drill.y != ZERO_LENGTH ) if( aPad->m_Drill.x() != ZERO_LENGTH || aPad->m_Drill.y() != ZERO_LENGTH )
{ {
msg = _( "Error: pad is not on a copper layer and has a hole" ); msg = _( "Error: pad is not on a copper layer and has a hole" );
if( aPad->m_Attribut == PAD_HOLE_NOT_PLATED ) if( aPad->m_Attribut == PAD_HOLE_NOT_PLATED )
...@@ -897,8 +897,8 @@ if you do not want this pad plotted in gerber files"); ...@@ -897,8 +897,8 @@ if you do not want this pad plotted in gerber files");
} }
} }
if( ( aPad->m_Size.x / 2 <= ABS( aPad->m_Offset.x ) ) if( ( aPad->m_Size.x() / 2 <= abs( aPad->m_Offset.x() ) )
|| ( aPad->m_Size.y / 2 <= ABS( aPad->m_Offset.y ) ) ) || ( aPad->m_Size.y() / 2 <= abs( aPad->m_Offset.y() ) ) )
{ {
DisplayError( NULL, _( "Incorrect value for pad offset" ) ); DisplayError( NULL, _( "Incorrect value for pad offset" ) );
return false; return false;
......
...@@ -52,7 +52,7 @@ void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC ) ...@@ -52,7 +52,7 @@ void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC )
if( pt_pad ) if( pt_pad )
{ {
pos = pt_pad->m_Pos - g_Offset_Module; pos = TO_LEGACY_LU_WXP( pt_pad->m_Pos ) - g_Offset_Module;
Track->m_Start = pos; Track->m_Start = pos;
} }
...@@ -60,7 +60,7 @@ void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC ) ...@@ -60,7 +60,7 @@ void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC )
if( pt_pad ) if( pt_pad )
{ {
pos = pt_pad->m_Pos - g_Offset_Module; pos = TO_LEGACY_LU_WXP( pt_pad->m_Pos ) - g_Offset_Module;
Track->m_End = pos; Track->m_End = pos;
} }
...@@ -105,7 +105,7 @@ void Build_1_Pad_SegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, D_PAD* PtPad ) ...@@ -105,7 +105,7 @@ void Build_1_Pad_SegmentsToDrag( EDA_DRAW_PANEL* panel, wxDC* DC, D_PAD* PtPad )
Track = pcb->m_Track->GetStartNetCode( net_code ); Track = pcb->m_Track->GetStartNetCode( net_code );
pos = PtPad->m_Pos; pos = TO_LEGACY_LU_WXP( PtPad->m_Pos );
LayerMask = PtPad->m_layerMask; LayerMask = PtPad->m_layerMask;
for( ; Track; Track = Track->Next() ) for( ; Track; Track = Track->Next() )
......
...@@ -592,7 +592,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li ...@@ -592,7 +592,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li
// We can stop the test when pad->m_Pos.x > x_limit // We can stop the test when pad->m_Pos.x > x_limit
// because the list is sorted by X values // because the list is sorted by X values
if( pad->m_Pos.x > x_limit ) if( TO_LEGACY_LU( pad->m_Pos.x() ) > x_limit )
break; break;
// No problem if pads are on different copper layers, // No problem if pads are on different copper layers,
...@@ -617,7 +617,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li ...@@ -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 /* Here, we must test clearance between holes and pads
* dummy pad size and shape is adjusted to pad drill size and shape * dummy pad size and shape is adjusted to pad drill size and shape
*/ */
if( pad->m_Drill.x != ZERO_LENGTH ) if( pad->m_Drill.x() != ZERO_LENGTH )
{ {
// pad under testing has a hole, test this hole against pad reference // pad under testing has a hole, test this hole against pad reference
dummypad.SetPosition( pad->GetPosition() ); dummypad.SetPosition( pad->GetPosition() );
...@@ -637,7 +637,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li ...@@ -637,7 +637,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li
} }
} }
if( aRefPad->m_Drill.x != ZERO_LENGTH ) // pad reference has a hole if( aRefPad->m_Drill.x() != ZERO_LENGTH ) // pad reference has a hole
{ {
dummypad.SetPosition( aRefPad->GetPosition() ); dummypad.SetPosition( aRefPad->GetPosition() );
dummypad.m_Size = aRefPad->m_Drill; dummypad.m_Size = aRefPad->m_Drill;
......
...@@ -290,7 +290,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) ...@@ -290,7 +290,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads )
* checkClearanceSegmToPad(),a pseudo pad is used, with a shape and a * checkClearanceSegmToPad(),a pseudo pad is used, with a shape and a
* size like the hole * size like the hole
*/ */
if( pad->m_Drill.x == ZERO_LENGTH ) if( pad->m_Drill.x() == ZERO_LENGTH )
continue; continue;
dummypad.m_Size = pad->m_Drill; dummypad.m_Size = pad->m_Drill;
...@@ -633,7 +633,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) ...@@ -633,7 +633,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
m_segmEnd.x = m_segmEnd.y = 0; m_segmEnd.x = m_segmEnd.y = 0;
m_padToTestPos = relativePadPos; m_padToTestPos = relativePadPos;
diag = checkClearanceSegmToPad( aPad, TO_LEGACY_LU( aRefPad->m_Size.x ), dist_min ); diag = checkClearanceSegmToPad( aPad, TO_LEGACY_LU( aRefPad->m_Size.x() ), dist_min );
break; break;
case PAD_RECT: case PAD_RECT:
...@@ -664,10 +664,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) ...@@ -664,10 +664,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
relativePadPos.x = ABS( relativePadPos.x ); relativePadPos.x = ABS( relativePadPos.x );
relativePadPos.y = ABS( relativePadPos.y ); relativePadPos.y = ABS( relativePadPos.y );
if( ( relativePadPos.x - ( (size.x + TO_LEGACY_LU( aRefPad->m_Size.x ) ) / 2 ) ) >= dist_min ) if( ( relativePadPos.x - ( (size.x + TO_LEGACY_LU( aRefPad->m_Size.x() ) ) / 2 ) ) >= dist_min )
diag = true; diag = true;
if( ( relativePadPos.y - ( (size.y + TO_LEGACY_LU( aRefPad->m_Size.y) ) / 2 ) ) >= dist_min ) if( ( relativePadPos.y - ( (size.y + TO_LEGACY_LU( aRefPad->m_Size.y() ) ) / 2 ) ) >= dist_min )
diag = true; diag = true;
} }
else // at least one pad has any other orient. Test is more tricky else // at least one pad has any other orient. Test is more tricky
...@@ -716,15 +716,15 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) ...@@ -716,15 +716,15 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad )
int segm_width; int segm_width;
m_segmAngle = aRefPad->m_Orient; // Segment orient. m_segmAngle = aRefPad->m_Orient; // Segment orient.
if( aRefPad->m_Size.y < aRefPad->m_Size.x ) // Build an horizontal equiv segment if( aRefPad->m_Size.y() < aRefPad->m_Size.x() ) // Build an horizontal equiv segment
{ {
segm_width = TO_LEGACY_LU( 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 ); 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 else // Vertical oval: build an horizontal equiv segment and rotate 90.0 deg
{ {
segm_width = TO_LEGACY_LU( 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_segmLength = TO_LEGACY_LU( aRefPad->m_Size.y() - aRefPad->m_Size.x() );
m_segmAngle += 900; m_segmAngle += 900;
} }
...@@ -796,13 +796,13 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi ...@@ -796,13 +796,13 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi
int segmHalfWidth = aSegmentWidth / 2; int segmHalfWidth = aSegmentWidth / 2;
seuil = segmHalfWidth + aMinDist; seuil = segmHalfWidth + aMinDist;
padHalfsize.x = TO_LEGACY_LU( aPad->m_Size.x / 2 ); padHalfsize.x = TO_LEGACY_LU( aPad->m_Size.x() / 2 );
padHalfsize.y = TO_LEGACY_LU( aPad->m_Size.y / 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 if( aPad->m_PadShape == PAD_TRAPEZOID ) // The size is bigger, due to m_DeltaSize extra size
{ {
padHalfsize.x += TO_LEGACY_LU( ABS(aPad->m_DeltaSize.y) / 2 ); // Remember: m_DeltaSize.y is the m_Size.x 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 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 ) if( aPad->m_PadShape == PAD_CIRCLE )
......
...@@ -82,7 +82,7 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod ) ...@@ -82,7 +82,7 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod )
for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() )
{ {
pt_pad->m_Pos0 += VECTOR_PCB( FROM_LEGACY_LU( moveVector.x ), FROM_LEGACY_LU( moveVector.y ) ); pt_pad->m_Pos0 += VECTOR_PCB::fromXY( FROM_LEGACY_LU( moveVector.x ), FROM_LEGACY_LU( moveVector.y ) );
} }
/* Update the draw element coordinates. */ /* Update the draw element coordinates. */
......
...@@ -125,7 +125,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) ...@@ -125,7 +125,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
pt_pad = (D_PAD*) LockPoint; pt_pad = (D_PAD*) LockPoint;
/* A pad is found: put the starting point on pad center */ /* A pad is found: put the starting point on pad center */
pos = pt_pad->m_Pos; pos = TO_LEGACY_LU_WXP( pt_pad->m_Pos );
GetBoard()->SetHighLightNet( pt_pad->GetNet() ); GetBoard()->SetHighLightNet( pt_pad->GetNet() );
} }
else /* A track segment is found */ else /* A track segment is found */
...@@ -1067,7 +1067,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList ) ...@@ -1067,7 +1067,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
*/ */
void EnsureEndTrackOnPad( D_PAD* Pad ) void EnsureEndTrackOnPad( D_PAD* Pad )
{ {
if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok ! if( g_CurrentTrackSegment->m_End == TO_LEGACY_LU_WXP( Pad->m_Pos ) ) // Ok !
{ {
g_CurrentTrackSegment->end = Pad; g_CurrentTrackSegment->end = Pad;
g_CurrentTrackSegment->SetState( END_ONPAD, ON ); g_CurrentTrackSegment->SetState( END_ONPAD, ON );
...@@ -1084,7 +1084,7 @@ void EnsureEndTrackOnPad( D_PAD* Pad ) ...@@ -1084,7 +1084,7 @@ void EnsureEndTrackOnPad( D_PAD* Pad )
lasttrack->end = g_CurrentTrackSegment; lasttrack->end = g_CurrentTrackSegment;
} }
g_CurrentTrackSegment->m_End = Pad->m_Pos; g_CurrentTrackSegment->m_End = TO_LEGACY_LU_WXP( Pad->m_Pos );
g_CurrentTrackSegment->SetState( END_ONPAD, OFF ); g_CurrentTrackSegment->SetState( END_ONPAD, OFF );
g_CurrentTrackSegment->end = Pad; g_CurrentTrackSegment->end = Pad;
......
...@@ -252,70 +252,70 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) ...@@ -252,70 +252,70 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb )
fprintf( file, "PAD PAD%d", pad->GetSubRatsnest() ); fprintf( file, "PAD PAD%d", pad->GetSubRatsnest() );
int dx = TO_LEGACY_LU( pad->m_Size.x / 2 ); int dx = TO_LEGACY_LU( pad->m_Size.x() / 2 );
int dy = TO_LEGACY_LU( pad->m_Size.y / 2 ); int dy = TO_LEGACY_LU( pad->m_Size.y() / 2 );
switch( pad->m_PadShape ) switch( pad->m_PadShape )
{ {
default: default:
case PAD_CIRCLE: case PAD_CIRCLE:
pad_type = "ROUND"; // how about oval holes? pad_type = "ROUND"; // how about oval holes?
fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) ); fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x() ) );
fprintf( file, "CIRCLE %d %d %d\n", fprintf( file, "CIRCLE %d %d %d\n",
TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ), dx ); TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ), dx );
break; break;
case PAD_RECT: case PAD_RECT:
pad_type = "RECTANGULAR"; pad_type = "RECTANGULAR";
fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( 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", fprintf( file, "RECTANGLE %d %d %d %d\n",
TO_LEGACY_LU( pad->m_Offset.x ) - dx, -TO_LEGACY_LU( pad->m_Offset.y ) - dy, 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 ) ); TO_LEGACY_LU( pad->m_Size.x() ), TO_LEGACY_LU( pad->m_Size.y() ) );
break; break;
case PAD_OVAL: /* Create outline by 2 lines and 2 arcs */ case PAD_OVAL: /* Create outline by 2 lines and 2 arcs */
{ {
pad_type = "FINGER"; pad_type = "FINGER";
fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) ); fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x() ) );
int dr = dx - dy; int dr = dx - dy;
if( dr >= 0 ) // Horizontal oval if( dr >= 0 ) // Horizontal oval
{ {
int radius = dy; int radius = dy;
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
-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 ) - 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", fprintf( file, "ARC %d %d %d %d %d %d\n",
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 ) + 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 ) ); dr + TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ) );
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
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 ) + 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", fprintf( file, "ARC %d %d %d %d %d %d\n",
-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 ) - 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 ) ); -dr + TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ) );
} }
else // Vertical oval else // Vertical oval
{ {
dr = -dr; dr = -dr;
int radius = dx; int radius = dx;
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
-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,
-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", fprintf( file, "ARC %d %d %d %d %d %d\n",
-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,
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 ); TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ) + dr );
fprintf( file, "LINE %d %d %d %d\n", fprintf( file, "LINE %d %d %d %d\n",
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,
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", fprintf( file, "ARC %d %d %d %d %d %d\n",
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,
-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 ); TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ) - dr );
} }
break; break;
} }
...@@ -410,7 +410,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) ...@@ -410,7 +410,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb )
NORMALIZE_ANGLE_POS( orient ); NORMALIZE_ANGLE_POS( orient );
fprintf( file, "PIN %s PAD%d %d %d %s %d %s", fprintf( file, "PIN %s PAD%d %d %d %s %d %s",
TO_UTF8( pinname ), pad->GetSubRatsnest(), TO_UTF8( pinname ), pad->GetSubRatsnest(),
TO_LEGACY_LU( pad->m_Pos0.x ), TO_LEGACY_LU( -pad->m_Pos0.y ), TO_LEGACY_LU( pad->m_Pos0.x() ), TO_LEGACY_LU( -pad->m_Pos0.y() ),
layer, orient / 10, mirror ); layer, orient / 10, mirror );
if( orient % 10 ) if( orient % 10 )
......
...@@ -881,11 +881,11 @@ static void export_vrml_edge_module( EDGE_MODULE* module ) /*{{{*/ ...@@ -881,11 +881,11 @@ static void export_vrml_edge_module( EDGE_MODULE* module ) /*{{{*/
static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/
{ {
double hole_drill_w = (double) TO_LEGACY_LU_DBL( pad->m_Drill.x / 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_h = (double) TO_LEGACY_LU_DBL( pad->m_Drill.y() / 2 );
double hole_drill = MIN( hole_drill_w, hole_drill_h ); double hole_drill = MIN( hole_drill_w, hole_drill_h );
double hole_x = pad->m_Pos.x; double hole_x = TO_LEGACY_LU_DBL( pad->m_Pos.x() );
double hole_y = pad->m_Pos.y; double hole_y = TO_LEGACY_LU_DBL( pad->m_Pos.y() );
/* Export the hole on the edge layer */ /* Export the hole on the edge layer */
if( hole_drill > 0 ) if( hole_drill > 0 )
...@@ -916,8 +916,8 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/ ...@@ -916,8 +916,8 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/
wxSize pad_delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize ); wxSize pad_delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize );
double pad_dx = pad_delta.x / 2; double pad_dx = pad_delta.x / 2;
double pad_dy = pad_delta.y / 2; double pad_dy = pad_delta.y / 2;
double pad_w = TO_LEGACY_LU_DBL( pad->m_Size.x / 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 ); double pad_h = TO_LEGACY_LU_DBL( pad->m_Size.y() / 2 );
for( int layer = FIRST_COPPER_LAYER; layer < copper_layers; layer++ ) for( int layer = FIRST_COPPER_LAYER; layer < copper_layers; layer++ )
{ {
......
...@@ -127,22 +127,22 @@ void Build_Holes_List( BOARD* aPcb, ...@@ -127,22 +127,22 @@ void Build_Holes_List( BOARD* aPcb,
if( aGenerateNPTH_list && pad->m_Attribut != PAD_HOLE_NOT_PLATED ) if( aGenerateNPTH_list && pad->m_Attribut != PAD_HOLE_NOT_PLATED )
continue; continue;
if( pad->m_Drill.x == ZERO_LENGTH ) if( pad->m_Drill.x() == ZERO_LENGTH )
continue; continue;
new_hole.m_Hole_NotPlated = (pad->m_Attribut == PAD_HOLE_NOT_PLATED); 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_Tool_Reference = -1; // Flag is: Not initialized
new_hole.m_Hole_Orient = pad->m_Orient; new_hole.m_Hole_Orient = pad->m_Orient;
new_hole.m_Hole_Shape = 0; // hole shape: round new_hole.m_Hole_Shape = 0; // hole shape: round
new_hole.m_Hole_Diameter = min( TO_LEGACY_LU( pad->m_Drill.x ), TO_LEGACY_LU( 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; new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter;
if( pad->m_DrillShape != PAD_CIRCLE ) if( pad->m_DrillShape != PAD_CIRCLE )
new_hole.m_Hole_Shape = 1; // oval flag set new_hole.m_Hole_Shape = 1; // oval flag set
new_hole.m_Hole_Size.x = TO_LEGACY_LU( pad->m_Drill.x ); 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_Size.y = TO_LEGACY_LU( pad->m_Drill.y() );
new_hole.m_Hole_Pos = pad->m_Pos; // hole position new_hole.m_Hole_Pos = TO_LEGACY_LU_WXP( pad->m_Pos ); // hole position
new_hole.m_Hole_Bottom_Layer = LAYER_N_BACK; new_hole.m_Hole_Bottom_Layer = LAYER_N_BACK;
new_hole.m_Hole_Top_Layer = LAYER_N_FRONT;// pad holes are through holes new_hole.m_Hole_Top_Layer = LAYER_N_FRONT;// pad holes are through holes
aHoleListBuffer.push_back( new_hole ); aHoleListBuffer.push_back( new_hole );
......
...@@ -438,19 +438,20 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) ...@@ -438,19 +438,20 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event )
{ {
fprintf( rptfile, "$PAD \"%.4s\"\n", pad->m_Padname ); fprintf( rptfile, "$PAD \"%.4s\"\n", pad->m_Padname );
sprintf( line, "position %9.6f %9.6f\n", sprintf( line, "position %9.6f %9.6f\n",
TO_LEGACY_LU_DBL( pad->m_Pos0.x ) * conv_unit, TO_LEGACY_LU_DBL( pad->m_Pos0.x() ) * conv_unit,
TO_LEGACY_LU_DBL( pad->m_Pos0.y ) * conv_unit ); TO_LEGACY_LU_DBL( pad->m_Pos0.y() ) * conv_unit );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "size %9.6f %9.6f\n", sprintf( line, "size %9.6f %9.6f\n",
TO_LEGACY_LU_DBL( pad->m_Size.x ) * conv_unit, TO_LEGACY_LU_DBL( pad->m_Size.x() ) * conv_unit,
TO_LEGACY_LU_DBL( pad->m_Size.y ) * conv_unit ); TO_LEGACY_LU_DBL( pad->m_Size.y() ) * conv_unit );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "drill %9.6f\n", TO_LEGACY_LU_DBL( 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 ); fputs( line, rptfile );
sprintf( line, "shape_offset %9.6f %9.6f\n", sprintf( line, "shape_offset %9.6f %9.6f\n",
TO_LEGACY_LU_DBL( pad->m_Offset.x ) * conv_unit, TO_LEGACY_LU_DBL( pad->m_Offset.x() ) * conv_unit,
TO_LEGACY_LU_DBL( pad->m_Offset.y ) * conv_unit ); TO_LEGACY_LU_DBL( pad->m_Offset.y() ) * conv_unit );
fputs( line, rptfile ); fputs( line, rptfile );
sprintf( line, "orientation %.2f\n", sprintf( line, "orientation %.2f\n",
......
...@@ -254,19 +254,19 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -254,19 +254,19 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw )
if( pt_pad->m_PadShape != PAD_TRAPEZOID ) if( pt_pad->m_PadShape != PAD_TRAPEZOID )
{ {
pt_pad->m_DeltaSize.x = ZERO_LENGTH; pt_pad->m_DeltaSize.x( ZERO_LENGTH );
pt_pad->m_DeltaSize.y = ZERO_LENGTH; pt_pad->m_DeltaSize.y( ZERO_LENGTH );
} }
if( pt_pad->m_PadShape == PAD_CIRCLE ) if( pt_pad->m_PadShape == PAD_CIRCLE )
pt_pad->m_Size.y = pt_pad->m_Size.x; pt_pad->m_Size.y( pt_pad->m_Size.x() );
switch( pt_pad->m_Attribut & 0x7F ) switch( pt_pad->m_Attribut & 0x7F )
{ {
case PAD_SMD: case PAD_SMD:
case PAD_CONN: case PAD_CONN:
pt_pad->m_Drill = VECTOR_PCB(ZERO_LENGTH, ZERO_LENGTH);//wxSize( 0, 0 ); pt_pad->m_Drill = VECTOR_PCB::fromXY(ZERO_LENGTH, ZERO_LENGTH);//wxSize( 0, 0 );
pt_pad->m_Offset.x = ZERO_LENGTH; pt_pad->m_Offset.x( ZERO_LENGTH );
pt_pad->m_Offset.y = ZERO_LENGTH; pt_pad->m_Offset.y( ZERO_LENGTH );
break; break;
default: default:
......
...@@ -369,16 +369,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) ...@@ -369,16 +369,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
{ {
Pad->SetPadName( params[10] ); Pad->SetPadName( params[10] );
} }
Pad->m_Pos.x = (ibuf[0] + ibuf[2]) / 2; Pad->m_Size.x( FROM_LEGACY_LU( ibuf[4] + abs( ibuf[0] - ibuf[2] ) ) );
Pad->m_Pos.y = (ibuf[1] + ibuf[3]) / 2; Pad->m_Size.y( FROM_LEGACY_LU( ibuf[4] + abs( ibuf[1] - ibuf[3] ) ) );
Pad->m_Size.x = FROM_LEGACY_LU( ibuf[4] + abs( ibuf[0] - ibuf[2] ) ); Pad->m_Pos.x( FROM_LEGACY_LU( (ibuf[0] + ibuf[2]) / 2 + m_Pos.x ) );
Pad->m_Size.y = FROM_LEGACY_LU( ibuf[4] + abs( ibuf[1] - ibuf[3] ) ); Pad->m_Pos.y( FROM_LEGACY_LU( (ibuf[1] + ibuf[3]) / 2 + m_Pos.y ) );
Pad->m_Pos.x += m_Pos.x;
Pad->m_Pos.y += m_Pos.y;
if( !TestFlags( params[iflgidx], 0x0100, wxT( "square" ) ) ) if( !TestFlags( params[iflgidx], 0x0100, wxT( "square" ) ) )
{ {
if( Pad->m_Size.x == Pad->m_Size.y ) if( Pad->m_Size.x() == Pad->m_Size.y() )
Pad->m_PadShape = PAD_ROUND; Pad->m_PadShape = PAD_ROUND;
else else
Pad->m_PadShape = PAD_OVAL; Pad->m_PadShape = PAD_OVAL;
...@@ -428,14 +426,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) ...@@ -428,14 +426,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName )
Pad->SetPadName( params[9] ); Pad->SetPadName( params[9] );
} }
Pad->m_Pos.x = ibuf[0]; Pad->m_Drill.x( FROM_LEGACY_LU( (int) ibuf[5] ) );
Pad->m_Pos.y = ibuf[1]; Pad->m_Drill.y( Pad->m_Drill.x() );
Pad->m_Drill.x = Pad->m_Drill.y = FROM_LEGACY_LU( (int) ibuf[5] ); Pad->m_Size.x( FROM_LEGACY_LU( ibuf[3] ) + Pad->m_Drill.x() );
Pad->m_Size.x = Pad->m_Size.y = FROM_LEGACY_LU( ibuf[3] ) + Pad->m_Drill.x; Pad->m_Size.y( Pad->m_Size.x() );
Pad->m_Pos.x += m_Pos.x; Pad->m_Pos.x( FROM_LEGACY_LU( ibuf[0] + m_Pos.x ) );
Pad->m_Pos.y += m_Pos.y; Pad->m_Pos.y( FROM_LEGACY_LU( ibuf[1] + m_Pos.y ) );
if( (Pad->m_PadShape == PAD_ROUND) && (Pad->m_Size.x != Pad->m_Size.y) ) if( (Pad->m_PadShape == PAD_ROUND) && (Pad->m_Size.x() != Pad->m_Size.y()) )
Pad->m_PadShape = PAD_OVAL; Pad->m_PadShape = PAD_OVAL;
m_Pads.PushBack( Pad ); m_Pads.PushBack( Pad );
......
...@@ -89,7 +89,7 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic ) ...@@ -89,7 +89,7 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic )
int dx, dy; int dx, dy;
wxPoint shape_pos = pt_pad->ReturnShapePos(); wxPoint shape_pos = pt_pad->ReturnShapePos();
dx = TO_LEGACY_LU( pt_pad->m_Size.x / 2 ); dx = TO_LEGACY_LU( pt_pad->m_Size.x() / 2 );
dx += marge; dx += marge;
if( pt_pad->m_PadShape == PAD_CIRCLE ) 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 ) ...@@ -100,13 +100,13 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic )
} }
dy = TO_LEGACY_LU( pt_pad->m_Size.y / 2 ); dy = TO_LEGACY_LU( pt_pad->m_Size.y() / 2 );
dy += marge; dy += marge;
if( pt_pad->m_PadShape == PAD_TRAPEZOID ) if( pt_pad->m_PadShape == PAD_TRAPEZOID )
{ {
dx += TO_LEGACY_LU( ABS( pt_pad->m_DeltaSize.y ) / 2 ); dx += TO_LEGACY_LU( abs( pt_pad->m_DeltaSize.y() ) / 2 );
dy += TO_LEGACY_LU( ABS( pt_pad->m_DeltaSize.x ) / 2 ); dy += TO_LEGACY_LU( abs( pt_pad->m_DeltaSize.x() ) / 2 );
} }
if( ( pt_pad->m_Orient % 900 ) == 0 ) /* The pad is a rectangle if( ( pt_pad->m_Orient % 900 ) == 0 ) /* The pad is a rectangle
......
...@@ -586,16 +586,16 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) ...@@ -586,16 +586,16 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "PadSize" ) == 0 ) if( stricmp( line, "PadSize" ) == 0 )
{ {
g_Pad_Master.m_Size.x = LENGTH_LOAD_STR( data ); g_Pad_Master.m_Size.x( LENGTH_LOAD_STR( data ) );
data = strtok( NULL, delims ); data = strtok( NULL, delims );
g_Pad_Master.m_Size.y = LENGTH_LOAD_STR( data ); g_Pad_Master.m_Size.y( LENGTH_LOAD_STR( data ) );
continue; continue;
} }
if( stricmp( line, "PadDrill" ) == 0 ) if( stricmp( line, "PadDrill" ) == 0 )
{ {
g_Pad_Master.m_Drill.x = LENGTH_LOAD_STR( data ); g_Pad_Master.m_Drill.x( LENGTH_LOAD_STR( data ) );
g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x; g_Pad_Master.m_Drill.y( g_Pad_Master.m_Drill.x() );
continue; continue;
} }
...@@ -757,8 +757,8 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) ...@@ -757,8 +757,8 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth ); fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth );
fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y ); fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y );
fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth ); fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth );
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, "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, "PadDrill "FM_LENSV"\n", ARG_LENSV( g_Pad_Master.m_Drill.x() ) );
fprintf( aFile, fprintf( aFile,
"Pad2MaskClearance %d\n", "Pad2MaskClearance %d\n",
aBoard->GetBoardDesignSettings()->m_SolderMaskMargin ); aBoard->GetBoardDesignSettings()->m_SolderMaskMargin );
......
...@@ -165,7 +165,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr ...@@ -165,7 +165,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr
if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() ) if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() )
return false; return false;
*curpos = pad->m_Pos; *curpos = TO_LEGACY_LU_WXP( pad->m_Pos );
return true; return true;
} }
} }
......
...@@ -708,18 +708,18 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) ...@@ -708,18 +708,18 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
for( ; pad != NULL; pad = (D_PAD*) pad->Next() ) for( ; pad != NULL; pad = (D_PAD*) pad->Next() )
{ {
pad->m_Pos0 = FROM_LEGACY_LU_VEC( pad->m_Pos ); pad->m_Pos0 = pad->m_Pos;
pad->m_Orient -= angle; pad->m_Orient -= angle;
wxPoint of; wxPoint of;
of.x = TO_LEGACY_LU( pad->m_Offset.x ); of.x = TO_LEGACY_LU( pad->m_Offset.x() );
of.y = TO_LEGACY_LU( pad->m_Offset.y ); of.y = TO_LEGACY_LU( pad->m_Offset.y() );
RotatePoint( &of.x, &of.y, angle ); RotatePoint( &of.x, &of.y, angle );
pad->m_Offset.x = FROM_LEGACY_LU( of.x ); pad->m_Offset.x( FROM_LEGACY_LU( of.x ) );
pad->m_Offset.y = FROM_LEGACY_LU( of.y ); pad->m_Offset.y( FROM_LEGACY_LU( of.y ) );
EXCHG( pad->m_Size.x, pad->m_Size.y ); EXCHG( pad->m_Size[0], pad->m_Size[1] ); /// @TODO: make it using geom. transform
wxSize delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize ); wxSize delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize );
RotatePoint( &delta.x, &delta.y, -angle ); RotatePoint( &delta.x, &delta.y, -angle );
pad->m_DeltaSize = VECTOR_PCB( FROM_LEGACY_LU( delta.x ), FROM_LEGACY_LU( delta.y ) ); pad->m_DeltaSize = VECTOR_PCB::fromXY( FROM_LEGACY_LU( delta.x ), FROM_LEGACY_LU( delta.y ) );
} }
module->m_Reference->m_Pos0 = module->m_Reference->m_Pos; module->m_Reference->m_Pos0 = module->m_Reference->m_Pos;
...@@ -756,10 +756,10 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) ...@@ -756,10 +756,10 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
case ID_MODEDIT_MODULE_MIRROR: case ID_MODEDIT_MODULE_MIRROR:
for( ; pad != NULL; pad = (D_PAD*) pad->Next() ) for( ; pad != NULL; pad = (D_PAD*) pad->Next() )
{ {
NEGATE( pad->m_Pos.y ); pad->m_Pos.y( -pad->m_Pos.y() );
NEGATE( pad->m_Pos0.y ); pad->m_Pos0.y( -pad->m_Pos0.y() );
NEGATE( pad->m_Offset.y ); pad->m_Offset.y( -pad->m_Offset.y() );
NEGATE( pad->m_DeltaSize.y ); pad->m_DeltaSize.y( -pad->m_DeltaSize.y() );
if( pad->m_Orient ) if( pad->m_Orient )
pad->m_Orient = 3600 - pad->m_Orient; pad->m_Orient = 3600 - pad->m_Orient;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
static D_PAD* s_CurrentSelectedPad; static D_PAD* s_CurrentSelectedPad;
static wxPoint Pad_OldPos; static VECTOR_PCB Pad_OldPos;
/* Cancel move pad command. /* Cancel move pad command.
...@@ -76,7 +76,7 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo ...@@ -76,7 +76,7 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo
if( aErase ) if( aErase )
pad->Draw( aPanel, aDC, GR_XOR ); pad->Draw( aPanel, aDC, GR_XOR );
pad->m_Pos = screen->GetCrossHairPosition(); pad->m_Pos = FROM_LEGACY_LU_VEC( screen->GetCrossHairPosition() );
pad->Draw( aPanel, aDC, GR_XOR ); pad->Draw( aPanel, aDC, GR_XOR );
if( !g_Drag_Pistes_On ) if( !g_Drag_Pistes_On )
...@@ -91,12 +91,12 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo ...@@ -91,12 +91,12 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo
if( g_DragSegmentList[ii].m_Pad_Start ) if( g_DragSegmentList[ii].m_Pad_Start )
{ {
Track->m_Start = pad->m_Pos; Track->m_Start = TO_LEGACY_LU_WXP( pad->m_Pos );
} }
if( g_DragSegmentList[ii].m_Pad_End ) if( g_DragSegmentList[ii].m_Pad_End )
{ {
Track->m_End = pad->m_Pos; Track->m_End = TO_LEGACY_LU_WXP( pad->m_Pos );
} }
Track->Draw( aPanel, aDC, GR_XOR ); Track->Draw( aPanel, aDC, GR_XOR );
...@@ -148,7 +148,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -148,7 +148,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
aPad->m_Orient = g_Pad_Master.m_Orient + aPad->m_Orient = g_Pad_Master.m_Orient +
( (MODULE*) aPad->GetParent() )->m_Orient; ( (MODULE*) aPad->GetParent() )->m_Orient;
aPad->m_Size = g_Pad_Master.m_Size; aPad->m_Size = g_Pad_Master.m_Size;
aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH );//wxSize( 0, 0 ); aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );//wxSize( 0, 0 );
aPad->m_Offset = g_Pad_Master.m_Offset; aPad->m_Offset = g_Pad_Master.m_Offset;
aPad->m_Drill = g_Pad_Master.m_Drill; aPad->m_Drill = g_Pad_Master.m_Drill;
aPad->m_DrillShape = g_Pad_Master.m_DrillShape; aPad->m_DrillShape = g_Pad_Master.m_DrillShape;
...@@ -160,7 +160,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -160,7 +160,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
break; break;
case PAD_CIRCLE: case PAD_CIRCLE:
aPad->m_Size.y = aPad->m_Size.x; aPad->m_Size.y( aPad->m_Size.x() );
break; break;
} }
...@@ -168,8 +168,8 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) ...@@ -168,8 +168,8 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw )
{ {
case PAD_SMD: case PAD_SMD:
case PAD_CONN: case PAD_CONN:
aPad->m_Drill = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 ); aPad->m_Drill = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 );
aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );
} }
aPad->ComputeShapeMaxRadius(); aPad->ComputeShapeMaxRadius();
...@@ -200,11 +200,11 @@ void PCB_BASE_FRAME::AddPad( MODULE* Module, bool draw ) ...@@ -200,11 +200,11 @@ void PCB_BASE_FRAME::AddPad( MODULE* Module, bool draw )
Import_Pad_Settings( Pad, false ); Import_Pad_Settings( Pad, false );
Pad->SetNetname( wxEmptyString ); Pad->SetNetname( wxEmptyString );
Pad->m_Pos = GetScreen()->GetCrossHairPosition(); Pad->m_Pos = FROM_LEGACY_LU_VEC( GetScreen()->GetCrossHairPosition() );
// Set the relative pad position // Set the relative pad position
// ( pad position for module orient, 0, and relative to the module position) // ( pad position for module orient, 0, and relative to the module position)
Pad->m_Pos0 = FROM_LEGACY_LU_VEC( Pad->m_Pos - Module->m_Pos ); Pad->m_Pos0 = Pad->m_Pos - FROM_LEGACY_LU_VEC( Module->m_Pos );
wxPoint p = TO_LEGACY_LU_WXP( Pad->m_Pos0 ); wxPoint p = TO_LEGACY_LU_WXP( Pad->m_Pos0 );
RotatePoint( &p, -Module->m_Orient ); RotatePoint( &p, -Module->m_Orient );
Pad->m_Pos0 = FROM_LEGACY_LU_VEC( p ); Pad->m_Pos0 = FROM_LEGACY_LU_VEC( p );
...@@ -317,17 +317,17 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -317,17 +317,17 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC )
// Set the old state // Set the old state
if( g_DragSegmentList[ii].m_Pad_Start ) if( g_DragSegmentList[ii].m_Pad_Start )
Track->m_Start = Pad_OldPos; Track->m_Start = TO_LEGACY_LU_WXP( Pad_OldPos );
if( g_DragSegmentList[ii].m_Pad_End ) if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad_OldPos; Track->m_End = TO_LEGACY_LU_WXP( Pad_OldPos );
picker.m_PickedItem = Track; picker.m_PickedItem = Track;
pickList.PushItem( picker ); pickList.PushItem( picker );
} }
/* Save old module and old items values */ /* Save old module and old items values */
wxPoint pad_curr_position = Pad->m_Pos; wxPoint pad_curr_position = TO_LEGACY_LU_WXP( Pad->m_Pos );
Pad->m_Pos = Pad_OldPos; Pad->m_Pos = Pad_OldPos;
...@@ -340,7 +340,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -340,7 +340,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC )
SaveCopyInUndoList( pickList, UR_CHANGED ); SaveCopyInUndoList( pickList, UR_CHANGED );
} }
Pad->m_Pos = pad_curr_position; Pad->m_Pos = FROM_LEGACY_LU_VEC( pad_curr_position );
Pad->Draw( DrawPanel, DC, GR_XOR ); Pad->Draw( DrawPanel, DC, GR_XOR );
/* Redraw dragged track segments */ /* Redraw dragged track segments */
...@@ -350,10 +350,10 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -350,10 +350,10 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC )
// Set the new state // Set the new state
if( g_DragSegmentList[ii].m_Pad_Start ) if( g_DragSegmentList[ii].m_Pad_Start )
Track->m_Start = Pad->m_Pos; Track->m_Start = TO_LEGACY_LU_WXP( Pad->m_Pos );
if( g_DragSegmentList[ii].m_Pad_End ) if( g_DragSegmentList[ii].m_Pad_End )
Track->m_End = Pad->m_Pos; Track->m_End = TO_LEGACY_LU_WXP( Pad->m_Pos );
Track->SetState( IN_EDIT, OFF ); Track->SetState( IN_EDIT, OFF );
...@@ -362,12 +362,12 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) ...@@ -362,12 +362,12 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC )
} }
/* Compute local coordinates (i.e refer to Module position and for Module orient = 0) */ /* Compute local coordinates (i.e refer to Module position and for Module orient = 0) */
dX = Pad->m_Pos.x - Pad_OldPos.x; dX = TO_LEGACY_LU( Pad->m_Pos.x() - Pad_OldPos.x() );
dY = Pad->m_Pos.y - Pad_OldPos.y; dY = TO_LEGACY_LU( Pad->m_Pos.y() - Pad_OldPos.y() );
RotatePoint( &dX, &dY, -Module->m_Orient ); RotatePoint( &dX, &dY, -Module->m_Orient );
Pad->m_Pos0.x += FROM_LEGACY_LU( dX ); Pad->m_Pos0.x( Pad->m_Pos0.x() + FROM_LEGACY_LU( dX ) );
s_CurrentSelectedPad->m_Pos0.y += FROM_LEGACY_LU( dY ); /// @BUG??? Pad->m_Pos0.y( Pad->m_Pos0.y() + FROM_LEGACY_LU( dY ) ); /// @BUG was it really s_CurrentSelectedPad ???
Pad->m_Flags = 0; Pad->m_Flags = 0;
...@@ -402,13 +402,13 @@ void PCB_BASE_FRAME::RotatePad( D_PAD* Pad, wxDC* DC ) ...@@ -402,13 +402,13 @@ void PCB_BASE_FRAME::RotatePad( D_PAD* Pad, wxDC* DC )
if( DC ) if( DC )
Module->Draw( DrawPanel, DC, GR_XOR ); Module->Draw( DrawPanel, DC, GR_XOR );
EXCHG( Pad->m_Size.x, Pad->m_Size.y ); EXCHG( Pad->m_Size[0], Pad->m_Size[1] ); /// @TODO: make it using geom. transform
EXCHG( Pad->m_Drill.x, Pad->m_Drill.y ); EXCHG( Pad->m_Drill[0], Pad->m_Drill[1] );
EXCHG( Pad->m_Offset.x, Pad->m_Offset.y ); EXCHG( Pad->m_Offset[0], Pad->m_Offset[1] );
Pad->m_Offset.y = -Pad->m_Offset.y; Pad->m_Offset.y( -Pad->m_Offset.y() );
EXCHG( Pad->m_DeltaSize.x, Pad->m_DeltaSize.y ); EXCHG( Pad->m_DeltaSize[0], Pad->m_DeltaSize[1] );
Pad->m_DeltaSize.x = -Pad->m_DeltaSize.x; Pad->m_DeltaSize.x( -Pad->m_DeltaSize.x() );
Module->CalculateBoundingBox(); Module->CalculateBoundingBox();
Pad->DisplayInfo( this ); Pad->DisplayInfo( this );
......
...@@ -260,10 +260,11 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) ...@@ -260,10 +260,11 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
Module->m_Pads.PushFront( PtPad ); Module->m_Pads.PushFront( PtPad );
PtPad->SetPadName( wxT( "1" ) ); PtPad->SetPadName( wxT( "1" ) );
PtPad->m_Pos = Mself.m_End; PtPad->m_Pos = FROM_LEGACY_LU_VEC( Mself.m_End );
PtPad->m_Pos0 = FROM_LEGACY_LU_VEC( PtPad->m_Pos - Module->m_Pos ); PtPad->m_Pos0 = PtPad->m_Pos - FROM_LEGACY_LU_VEC( Module->m_Pos );
PtPad->m_Size.x = PtPad->m_Size.y = FROM_LEGACY_LU( Mself.m_Width ); PtPad->m_Size.x( FROM_LEGACY_LU( Mself.m_Width ) );
PtPad->m_layerMask = g_TabOneLayerMask[Module->GetLayer()]; PtPad->m_Size.y( PtPad->m_Size.x() );
PtPad->m_layerMask = g_TabOneLayerMask[Module->GetLayer()];
PtPad->m_Attribut = PAD_SMD; PtPad->m_Attribut = PAD_SMD;
PtPad->m_PadShape = PAD_CIRCLE; PtPad->m_PadShape = PAD_CIRCLE;
PtPad->ComputeShapeMaxRadius(); PtPad->ComputeShapeMaxRadius();
...@@ -275,8 +276,8 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) ...@@ -275,8 +276,8 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
PtPad = newpad; PtPad = newpad;
PtPad->SetPadName( wxT( "2" ) ); PtPad->SetPadName( wxT( "2" ) );
PtPad->m_Pos = Mself.m_Start; PtPad->m_Pos = FROM_LEGACY_LU_VEC( Mself.m_Start );
PtPad->m_Pos0 = FROM_LEGACY_LU_VEC( PtPad->m_Pos - Module->m_Pos ); PtPad->m_Pos0 = PtPad->m_Pos - FROM_LEGACY_LU_VEC( Module->m_Pos );
/* Modify text positions. */ /* Modify text positions. */
Module->DisplayInfo( this ); Module->DisplayInfo( this );
...@@ -552,8 +553,9 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c ...@@ -552,8 +553,9 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c
Module->m_Pads.PushFront( pad ); Module->m_Pads.PushFront( pad );
pad->m_Size.x = pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ); pad->m_Size.x( FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ) );
pad->m_Pos = Module->m_Pos; pad->m_Size.y( pad->m_Size.x() );
pad->m_Pos = FROM_LEGACY_LU_VEC( Module->m_Pos );
pad->m_PadShape = PAD_RECT; pad->m_PadShape = PAD_RECT;
pad->m_Attribut = PAD_SMD; pad->m_Attribut = PAD_SMD;
pad->m_layerMask = LAYER_FRONT; pad->m_layerMask = LAYER_FRONT;
...@@ -656,19 +658,19 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) ...@@ -656,19 +658,19 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
switch( shape_type ) switch( shape_type )
{ {
case 0: //Gap : case 0: //Gap :
pad->m_Pos0.x = FROM_LEGACY_LU( oX = -( gap_size + TO_LEGACY_LU( pad->m_Size.x ) ) / 2 ); 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->m_Pos.x( pad->m_Pos.x() + pad->m_Pos0.x() );
pad = pad->Next(); pad = pad->Next();
pad->m_Pos0.x = FROM_LEGACY_LU( oX + gap_size + TO_LEGACY_LU( pad->m_Size.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 ); pad->m_Pos.x( pad->m_Pos.x() + pad->m_Pos0.x() );
break; break;
case 1: //Stub : case 1: //Stub :
pad->SetPadName( wxT( "1" ) ); pad->SetPadName( wxT( "1" ) );
pad = pad->Next(); pad = pad->Next();
pad->m_Pos0.y = FROM_LEGACY_LU( -( gap_size + TO_LEGACY_LU( pad->m_Size.y ) ) / 2 ); 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_Size.y( FROM_LEGACY_LU( gap_size ) );
pad->m_Pos.y += TO_LEGACY_LU( pad->m_Pos0.y ); pad->m_Pos.y( pad->m_Pos.y() + pad->m_Pos0.y() );
break; break;
case 2: // Arc Stub created by a polygonal approach: case 2: // Arc Stub created by a polygonal approach:
...@@ -683,7 +685,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) ...@@ -683,7 +685,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
std::vector<wxPoint> polyPoints = edge->GetPolyPoints(); std::vector<wxPoint> polyPoints = edge->GetPolyPoints();
polyPoints.reserve( numPoints ); polyPoints.reserve( numPoints );
edge->m_Start0.y = TO_LEGACY_LU( -pad->m_Size.y / 2 ); edge->m_Start0.y = TO_LEGACY_LU( -pad->m_Size.y() / 2 );
polyPoints.push_back( wxPoint( 0, 0 ) ); polyPoints.push_back( wxPoint( 0, 0 ) );
...@@ -968,12 +970,12 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() ...@@ -968,12 +970,12 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
Module = Create_MuWaveBasicShape( cmp_name, pad_count ); Module = Create_MuWaveBasicShape( cmp_name, pad_count );
pad1 = Module->m_Pads; pad1 = Module->m_Pads;
pad1->m_Pos0.x = FROM_LEGACY_LU( -ShapeSize.x / 2 ); pad1->m_Pos0.x( FROM_LEGACY_LU( -ShapeSize.x / 2 ) );
pad1->m_Pos.x += TO_LEGACY_LU( pad1->m_Pos0.x ); pad1->m_Pos.x( pad1->m_Pos.x() + pad1->m_Pos0.x() );
pad2 = (D_PAD*) pad1->Next(); pad2 = (D_PAD*) pad1->Next();
pad2->m_Pos0.x = pad1->m_Pos0.x + FROM_LEGACY_LU( ShapeSize.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 ); pad2->m_Pos.x( pad2->m_Pos.x() + pad2->m_Pos0.x() );
edge = new EDGE_MODULE( Module ); edge = new EDGE_MODULE( Module );
...@@ -987,13 +989,13 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() ...@@ -987,13 +989,13 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
polyPoints.reserve( 2 * PolyEdges.size() + 2 ); polyPoints.reserve( 2 * PolyEdges.size() + 2 );
// Init start point coord: // Init start point coord:
polyPoints.push_back( wxPoint( TO_LEGACY_LU( pad1->m_Pos0.x ), 0 ) ); polyPoints.push_back( wxPoint( TO_LEGACY_LU( pad1->m_Pos0.x() ), 0 ) );
wxPoint first_coordinate, last_coordinate; wxPoint first_coordinate, last_coordinate;
for( unsigned ii = 0; ii < PolyEdges.size(); ii++ ) // Copy points for( unsigned ii = 0; ii < PolyEdges.size(); ii++ ) // Copy points
{ {
last_coordinate.x = wxRound( PolyEdges[ii] * ShapeScaleX ) + TO_LEGACY_LU( 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 ); last_coordinate.y = -wxRound( PolyEdges[ii] * ShapeScaleY );
polyPoints.push_back( last_coordinate ); polyPoints.push_back( last_coordinate );
} }
...@@ -1005,15 +1007,17 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() ...@@ -1005,15 +1007,17 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
case 0: // Single case 0: // Single
case 2: // Single mirrored case 2: // Single mirrored
// Init end point coord: // Init end point coord:
pad2->m_Pos0.x = FROM_LEGACY_LU( last_coordinate.x ); pad2->m_Pos0.x( FROM_LEGACY_LU( last_coordinate.x ) );
polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) ); polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) );
pad1->m_Size.x = pad1->m_Size.y = FROM_LEGACY_LU( ABS( first_coordinate.y ) ); pad1->m_Size.x( FROM_LEGACY_LU( abs( first_coordinate.y ) ) );
pad2->m_Size.x = pad2->m_Size.y = FROM_LEGACY_LU( ABS( last_coordinate.y ) ); pad1->m_Size.y( pad1->m_Size.x() );
pad1->m_Pos0.y = FROM_LEGACY_LU( first_coordinate.y / 2 ); pad2->m_Size.x( FROM_LEGACY_LU( abs( last_coordinate.y ) ) );
pad2->m_Pos0.y = FROM_LEGACY_LU( last_coordinate.y / 2 ); pad2->m_Size.y( pad2->m_Size.x() );
pad1->m_Pos.y = TO_LEGACY_LU( pad1->m_Pos0.y ) + Module->m_Pos.y; pad1->m_Pos0.y( FROM_LEGACY_LU( first_coordinate.y / 2 ) );
pad2->m_Pos.y = TO_LEGACY_LU( pad2->m_Pos0.y ) + Module->m_Pos.y; pad2->m_Pos0.y( FROM_LEGACY_LU( last_coordinate.y / 2 ) );
pad1->m_Pos.y( pad1->m_Pos0.y() + FROM_LEGACY_LU( Module->m_Pos.y ) );
pad2->m_Pos.y( pad2->m_Pos0.y() + FROM_LEGACY_LU( Module->m_Pos.y ) );
break; break;
case 1: // Symmetric case 1: // Symmetric
...@@ -1026,8 +1030,10 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() ...@@ -1026,8 +1030,10 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape()
polyPoints.push_back( pt ); polyPoints.push_back( pt );
} }
pad1->m_Size.x = pad1->m_Size.y = FROM_LEGACY_LU( 2 * ABS( first_coordinate.y ) ); pad1->m_Size.x( FROM_LEGACY_LU( 2 * abs( first_coordinate.y ) ) );
pad2->m_Size.x = pad2->m_Size.y = FROM_LEGACY_LU( 2 * ABS( last_coordinate.y ) ); pad1->m_Size.y( pad1->m_Size.x() );
pad2->m_Size.x( FROM_LEGACY_LU( 2 * abs( last_coordinate.y ) ) );
pad2->m_Size.y( pad2->m_Size.x() );
break; break;
} }
...@@ -1073,7 +1079,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) ...@@ -1073,7 +1079,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module )
Module->Draw( DrawPanel, DC, GR_XOR ); Module->Draw( DrawPanel, DC, GR_XOR );
/* Calculate the current dimension. */ /* Calculate the current dimension. */
gap_size = TO_LEGACY_LU( 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. */ /* Entrer the desired length of the gap. */
msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() ); msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() );
...@@ -1086,21 +1092,29 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) ...@@ -1086,21 +1092,29 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module )
gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
/* Updating sizes of pads forming the gap. */ /* Updating sizes of pads forming the gap. */
pad->m_Size.x = pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ); pad->m_Size.x( FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ) );
pad->m_Pos0.y = ZERO_LENGTH; pad->m_Size.y( pad->m_Size.x() );
pad->m_Pos0.x = FROM_LEGACY_LU( oX = -( ( gap_size + TO_LEGACY_LU( pad->m_Size.x ) ) / 2 ) ); pad->m_Pos0.y( ZERO_LENGTH );
pad->m_Pos.x = TO_LEGACY_LU( pad->m_Pos0.x ) + Module->m_Pos.x; pad->m_Pos0.x( FROM_LEGACY_LU( oX = -( ( gap_size + TO_LEGACY_LU( pad->m_Size.x() ) ) / 2 ) ) );
pad->m_Pos.y = TO_LEGACY_LU( pad->m_Pos0.y ) + Module->m_Pos.y; pad->m_Pos.x( pad->m_Pos0.x() + FROM_LEGACY_LU( Module->m_Pos.x ) );
RotatePoint( &pad->m_Pos.x, &pad->m_Pos.y, pad->m_Pos.y( pad->m_Pos0.y() + FROM_LEGACY_LU( Module->m_Pos.y ) );
wxPoint pos = TO_LEGACY_LU_WXP( pad->m_Pos );
RotatePoint( &pos.x, &pos.y,
Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient ); Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
pad->m_Pos = FROM_LEGACY_LU_VEC( pos );
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_Size.x( FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ) );
next_pad->m_Pos0.x = FROM_LEGACY_LU( oX + gap_size + TO_LEGACY_LU( next_pad->m_Size.x ) ); next_pad->m_Size.y( 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_Pos0.y( ZERO_LENGTH );
next_pad->m_Pos.y = TO_LEGACY_LU( next_pad->m_Pos0.y ) + Module->m_Pos.y; next_pad->m_Pos0.x( FROM_LEGACY_LU( oX + gap_size + TO_LEGACY_LU( next_pad->m_Size.x() ) ) );
RotatePoint( &next_pad->m_Pos.x, &next_pad->m_Pos.y, next_pad->m_Pos.x( next_pad->m_Pos0.x() + FROM_LEGACY_LU( Module->m_Pos.x ) );
next_pad->m_Pos.y( next_pad->m_Pos0.y() + FROM_LEGACY_LU( Module->m_Pos.y ) );
pos = TO_LEGACY_LU_WXP( next_pad->m_Pos );
RotatePoint( &pos.x, &pos.y,
Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient ); Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient );
next_pad->m_Pos = FROM_LEGACY_LU_VEC( pos );
Module->Draw( DrawPanel, DC, GR_OR ); Module->Draw( DrawPanel, DC, GR_OR );
} }
...@@ -217,16 +217,25 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() ...@@ -217,16 +217,25 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters()
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&g_LibraryNames, &g_LibraryNames,
GROUPLIB ) ); GROUPLIB ) );
#ifdef KICAD_NANOMETRE //#ifdef KICAD_NANOMETRE
/* TODO: something should be done here!!! */ /* TODO: something should be done here!!! */
#else //#else
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDrlX" ), &g_Pad_Master.m_Drill.x, m_projectFileParams.push_back( new PARAM_CFG_LENGTH_PCB( wxT( "PadDrlX" ),
320, 0, 0x7FFF ) ); &g_Pad_Master.m_Drill[0],
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimH" ), &g_Pad_Master.m_Size.x, FROM_LEGACY_LU( 320 ),
550, 0, 0x7FFF ) ); ZERO_LENGTH,
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimV" ), &g_Pad_Master.m_Size.y, FROM_LEGACY_LU( 0x7FFF ) ) );
550, 0, 0x7FFF ) ); m_projectFileParams.push_back( new PARAM_CFG_LENGTH_PCB( wxT( "PadDimH" ),
#endif &g_Pad_Master.m_Size[0],
FROM_LEGACY_LU( 550 ),
ZERO_LENGTH,
FROM_LEGACY_LU( 0x7FFF ) ) );
m_projectFileParams.push_back( new PARAM_CFG_LENGTH_PCB( wxT( "PadDimV" ),
&g_Pad_Master.m_Size[1],
FROM_LEGACY_LU( 550 ),
ZERO_LENGTH,
FROM_LEGACY_LU( 0x7FFF ) ) );
//#endif
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ), m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ),
&boardDesignSettings.m_BoardThickness, &boardDesignSettings.m_BoardThickness,
630, 0, 0xFFFF ) ); 630, 0, 0xFFFF ) );
......
...@@ -97,7 +97,7 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* plotter, int aLayerMask, GRTraceMo ...@@ -97,7 +97,7 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* plotter, int aLayerMask, GRTraceMo
switch( pad->m_PadShape & 0x7F ) switch( pad->m_PadShape & 0x7F )
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
plotter->flash_pad_circle( shape_pos, TO_LEGACY_LU( pad->m_Size.x ), FILAIRE ); plotter->flash_pad_circle( shape_pos, TO_LEGACY_LU( pad->m_Size.x() ), FILAIRE );
break; break;
case PAD_OVAL: case PAD_OVAL:
...@@ -840,8 +840,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -840,8 +840,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
break; break;
} }
size.x = TO_LEGACY_LU( pad->m_Size.x ) + ( 2 * margin.x ); size.x = TO_LEGACY_LU( pad->m_Size.x() ) + ( 2 * margin.x );
size.y = TO_LEGACY_LU( pad->m_Size.y ) + ( 2 * margin.y ); size.y = TO_LEGACY_LU( pad->m_Size.y() ) + ( 2 * margin.y );
/* Don't draw a null size item : */ /* Don't draw a null size item : */
if( size.x <= 0 || size.y <= 0 ) if( size.x <= 0 || size.y <= 0 )
...@@ -851,8 +851,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -851,8 +851,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
{ {
case PAD_CIRCLE: case PAD_CIRCLE:
if( aSkipNPTH_Pads && if( aSkipNPTH_Pads &&
( pad->m_Size.x == pad->m_Drill.x ) && ( pad->m_Size.x() == pad->m_Drill.x() ) &&
( pad->m_Size.y == pad->m_Drill.y ) && ( pad->m_Size.y() == pad->m_Drill.y() ) &&
(pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) (pad->m_Attribut == PAD_HOLE_NOT_PLATED) )
break; break;
...@@ -861,8 +861,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, ...@@ -861,8 +861,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter,
case PAD_OVAL: case PAD_OVAL:
if( aSkipNPTH_Pads && if( aSkipNPTH_Pads &&
(pad->m_Size.x == pad->m_Drill.x ) && (pad->m_Size.x() == pad->m_Drill.x() ) &&
(pad->m_Size.y == pad->m_Drill.y ) && (pad->m_Size.y() == pad->m_Drill.y() ) &&
(pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) (pad->m_Attribut == PAD_HOLE_NOT_PLATED) )
break; break;
...@@ -1018,21 +1018,21 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter, ...@@ -1018,21 +1018,21 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter,
{ {
for( PtPad = Module->m_Pads; PtPad != NULL; PtPad = PtPad->Next() ) for( PtPad = Module->m_Pads; PtPad != NULL; PtPad = PtPad->Next() )
{ {
if( PtPad->m_Drill.x == ZERO_LENGTH ) if( PtPad->m_Drill.x() == ZERO_LENGTH )
continue; continue;
// Output hole shapes: // Output hole shapes:
pos = PtPad->m_Pos; pos = TO_LEGACY_LU_WXP( PtPad->m_Pos );
if( PtPad->m_DrillShape == PAD_OVAL ) if( PtPad->m_DrillShape == PAD_OVAL )
{ {
diam.x = TO_LEGACY_LU( PtPad->m_Drill.x ); diam.x = TO_LEGACY_LU( PtPad->m_Drill.x() );
diam.y = TO_LEGACY_LU( PtPad->m_Drill.y ); diam.y = TO_LEGACY_LU( PtPad->m_Drill.y() );
aPlotter->flash_pad_oval( pos, diam, PtPad->m_Orient, aTraceMode ); aPlotter->flash_pad_oval( pos, diam, PtPad->m_Orient, aTraceMode );
} }
else else
{ {
diam.x = aSmallDrillShape ? SMALL_DRILL : TO_LEGACY_LU( PtPad->m_Drill.x ); diam.x = aSmallDrillShape ? SMALL_DRILL : TO_LEGACY_LU( PtPad->m_Drill.x() );
aPlotter->flash_pad_circle( pos, diam.x, aTraceMode ); aPlotter->flash_pad_circle( pos, diam.x, aTraceMode );
} }
} }
......
...@@ -352,17 +352,17 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, ...@@ -352,17 +352,17 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
// Manage hole according to the print drill option // Manage hole according to the print drill option
wxSize drill_tmp; wxSize drill_tmp;
drill_tmp.x = TO_LEGACY_LU( pt_pad->m_Drill.x ); drill_tmp.x = TO_LEGACY_LU( pt_pad->m_Drill.x() );
drill_tmp.y = TO_LEGACY_LU( pt_pad->m_Drill.y ); drill_tmp.y = TO_LEGACY_LU( pt_pad->m_Drill.y() );
switch ( aDrillShapeOpt ) switch ( aDrillShapeOpt )
{ {
case PRINT_PARAMETERS::NO_DRILL_SHAPE: case PRINT_PARAMETERS::NO_DRILL_SHAPE:
pt_pad->m_Drill = VECTOR_PCB(ZERO_LENGTH, ZERO_LENGTH); //wxSize(0,0); pt_pad->m_Drill = VECTOR_PCB::fromXY(ZERO_LENGTH, ZERO_LENGTH); //wxSize(0,0);
break; break;
case PRINT_PARAMETERS::SMALL_DRILL_SHAPE: case PRINT_PARAMETERS::SMALL_DRILL_SHAPE:
pt_pad->m_Drill.x = MIN(FROM_LEGACY_LU( SMALL_DRILL ),pt_pad->m_Drill.x ); 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 ); pt_pad->m_Drill.y( min( FROM_LEGACY_LU( SMALL_DRILL ),pt_pad->m_Drill.y() ) );
break; break;
case PRINT_PARAMETERS::FULL_DRILL_SHAPE: case PRINT_PARAMETERS::FULL_DRILL_SHAPE:
// Do nothing // Do nothing
...@@ -370,8 +370,8 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, ...@@ -370,8 +370,8 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
} }
pt_pad->Draw( aPanel, aDC, aDraw_mode ); pt_pad->Draw( aPanel, aDC, aDraw_mode );
pt_pad->m_Drill.x = FROM_LEGACY_LU( drill_tmp.x ); pt_pad->m_Drill.x( FROM_LEGACY_LU( drill_tmp.x ) );
pt_pad->m_Drill.y = FROM_LEGACY_LU( drill_tmp.y ); pt_pad->m_Drill.y( FROM_LEGACY_LU( drill_tmp.y ) );
} }
/* Print footprint graphic shapes */ /* Print footprint graphic shapes */
......
...@@ -107,8 +107,8 @@ int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 ) ...@@ -107,8 +107,8 @@ int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 )
if( pad1 == pad2 ) if( pad1 == pad2 )
return 0; return 0;
int weight = abs( pad2->m_Pos.x - pad1->m_Pos.x ) + int weight = TO_LEGACY_LU( abs( pad2->m_Pos.x() - pad1->m_Pos.x() ) +
abs( pad2->m_Pos.y - pad1->m_Pos.y ); abs( pad2->m_Pos.y() - pad1->m_Pos.y() ) );
return weight + 1; return weight + 1;
} }
...@@ -667,7 +667,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) ...@@ -667,7 +667,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
local_rats.m_Lenght = INT_MAX; local_rats.m_Lenght = INT_MAX;
} }
pad_pos = pad_ref->m_Pos - g_Offset_Module; pad_pos = TO_LEGACY_LU_WXP( pad_ref->m_Pos ) - g_Offset_Module;
// Search the nearest external pad of this current pad // Search the nearest external pad of this current pad
for( unsigned jj = pads_module_count; jj < localPadList.size(); jj++ ) for( unsigned jj = pads_module_count; jj < localPadList.size(); jj++ )
...@@ -681,8 +681,8 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) ...@@ -681,8 +681,8 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule )
if( pad_externe->GetNet() > pad_ref->GetNet() ) // pads are sorted by net code if( pad_externe->GetNet() > pad_ref->GetNet() ) // pads are sorted by net code
break; break;
distance = abs( pad_externe->m_Pos.x - pad_pos.x ) + distance = abs( TO_LEGACY_LU( pad_externe->m_Pos.x() ) - pad_pos.x ) +
abs( pad_externe->m_Pos.y - pad_pos.y ); abs( TO_LEGACY_LU( pad_externe->m_Pos.y() ) - pad_pos.y );
if( distance < local_rats.m_Lenght ) if( distance < local_rats.m_Lenght )
{ {
...@@ -724,8 +724,8 @@ void PCB_BASE_FRAME::TraceModuleRatsNest( wxDC* DC ) ...@@ -724,8 +724,8 @@ void PCB_BASE_FRAME::TraceModuleRatsNest( wxDC* DC )
else else
{ {
g_ColorsSettings.SetItemColor(RATSNEST_VISIBLE, tmpcolor); g_ColorsSettings.SetItemColor(RATSNEST_VISIBLE, tmpcolor);
wxPoint tmp = rats->m_PadStart->m_Pos; VECTOR_PCB tmp = rats->m_PadStart->m_Pos;
rats->m_PadStart->m_Pos -= g_Offset_Module; rats->m_PadStart->m_Pos -= FROM_LEGACY_LU_VEC( g_Offset_Module );
rats->Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) ); rats->Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) );
rats->m_PadStart->m_Pos = tmp; rats->m_PadStart->m_Pos = tmp;
} }
...@@ -827,7 +827,7 @@ void PCB_BASE_FRAME::BuildAirWiresTargetsList( BOARD_CONNECTED_ITEM* aItemRef, ...@@ -827,7 +827,7 @@ void PCB_BASE_FRAME::BuildAirWiresTargetsList( BOARD_CONNECTED_ITEM* aItemRef,
continue; continue;
if( !pad->GetSubNet() || (pad->GetSubNet() != subnet) ) if( !pad->GetSubNet() || (pad->GetSubNet() != subnet) )
s_TargetsLocations.push_back( pad->m_Pos ); s_TargetsLocations.push_back( TO_LEGACY_LU_WXP( pad->m_Pos ) );
} }
// Create a list of tracks ends candidates, not already connected to the // Create a list of tracks ends candidates, not already connected to the
......
...@@ -464,8 +464,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -464,8 +464,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
int cY = ( Board.m_GridRouting * row_source ) int cY = ( Board.m_GridRouting * row_source )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
int dx = TO_LEGACY_LU( pt_cur_ch->m_PadStart->m_Size.x / 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 dy = TO_LEGACY_LU( pt_cur_ch->m_PadStart->m_Size.y() / 2 );
int px = pt_cur_ch->m_PadStart->GetPosition().x; int px = pt_cur_ch->m_PadStart->GetPosition().x;
int py = pt_cur_ch->m_PadStart->GetPosition().y; int py = pt_cur_ch->m_PadStart->GetPosition().y;
...@@ -479,8 +479,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, ...@@ -479,8 +479,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe,
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x;
cY = ( Board.m_GridRouting * row_target ) cY = ( Board.m_GridRouting * row_target )
+ pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y;
dx = TO_LEGACY_LU( pt_cur_ch->m_PadEnd->m_Size.x / 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 ); dy = TO_LEGACY_LU( pt_cur_ch->m_PadEnd->m_Size.y() / 2 );
px = pt_cur_ch->m_PadEnd->GetPosition().x; px = pt_cur_ch->m_PadEnd->GetPosition().x;
py = pt_cur_ch->m_PadEnd->GetPosition().y; py = pt_cur_ch->m_PadEnd->GetPosition().y;
......
...@@ -250,7 +250,7 @@ static bool isRoundKeepout( D_PAD* aPad ) ...@@ -250,7 +250,7 @@ static bool isRoundKeepout( D_PAD* aPad )
{ {
if( aPad->m_PadShape==PAD_CIRCLE ) if( aPad->m_PadShape==PAD_CIRCLE )
{ {
if( aPad->m_Drill.x >= aPad->m_Size.x ) if( aPad->m_Drill.x() >= aPad->m_Size.x() )
return true; return true;
if( (aPad->m_layerMask & ALL_CU_LAYERS) == 0 ) if( (aPad->m_layerMask & ALL_CU_LAYERS) == 0 )
...@@ -321,11 +321,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -321,11 +321,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
POINT dsnOffset; POINT dsnOffset;
if( aPad->m_Offset.x != ZERO_LENGTH || aPad->m_Offset.y != ZERO_LENGTH ) if( aPad->m_Offset.x() != ZERO_LENGTH || aPad->m_Offset.y() != ZERO_LENGTH )
{ {
char offsetTxt[64]; /// @BUG !!!Unsafe char offsetTxt[64]; /// @BUG !!!Unsafe
wxPoint offset( TO_LEGACY_LU( aPad->m_Offset.x ), TO_LEGACY_LU( aPad->m_Offset.y ) ); wxPoint offset( TO_LEGACY_LU( aPad->m_Offset.x() ), TO_LEGACY_LU( aPad->m_Offset.y() ) );
dsnOffset = mapPt( offset ); dsnOffset = mapPt( offset );
...@@ -341,7 +341,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -341,7 +341,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
default: default:
case PAD_CIRCLE: case PAD_CIRCLE:
{ {
double diameter = scale( TO_LEGACY_LU( aPad->m_Size.x ) ); double diameter = scale( TO_LEGACY_LU( aPad->m_Size.x() ) );
for( int ndx=0; ndx<reportedLayers; ++ndx ) for( int ndx=0; ndx<reportedLayers; ++ndx )
{ {
...@@ -357,7 +357,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -357,7 +357,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
} }
snprintf( name, sizeof(name), "Round%sPad_%.6g_mil", snprintf( name, sizeof(name), "Round%sPad_%.6g_mil",
uniqifier.c_str(), scale(TO_LEGACY_LU( aPad->m_Size.x ) ) ); uniqifier.c_str(), scale(TO_LEGACY_LU( aPad->m_Size.x() ) ) );
name[ sizeof(name)-1 ] = 0; name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name ); padstack->SetPadstackId( name );
...@@ -366,8 +366,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -366,8 +366,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
case PAD_RECT: case PAD_RECT:
{ {
double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 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 dy = scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) / 2.0;
POINT lowerLeft( -dx, -dy ); POINT lowerLeft( -dx, -dy );
POINT upperRight( dx, dy ); POINT upperRight( dx, dy );
...@@ -388,7 +388,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -388,7 +388,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
} }
snprintf( name, sizeof(name), "Rect%sPad_%.6gx%.6g_mil", snprintf( name, sizeof(name), "Rect%sPad_%.6gx%.6g_mil",
uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( 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; name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name ); padstack->SetPadstackId( name );
...@@ -397,8 +397,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -397,8 +397,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
case PAD_OVAL: case PAD_OVAL:
{ {
double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 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 dy = scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) / 2.0;
double dr = dx - dy; double dr = dx - dy;
double radius; double radius;
POINT start; POINT start;
...@@ -436,7 +436,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -436,7 +436,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
} }
snprintf( name, sizeof(name), "Oval%sPad_%.6gx%.6g_mil", snprintf( name, sizeof(name), "Oval%sPad_%.6gx%.6g_mil",
uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( 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; name[ sizeof(name)-1 ] = 0;
padstack->SetPadstackId( name ); padstack->SetPadstackId( name );
...@@ -445,11 +445,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -445,11 +445,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
case PAD_TRAPEZOID: case PAD_TRAPEZOID:
{ {
double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 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 dy = scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) / 2.0;
double ddx = scale( TO_LEGACY_LU( aPad->m_DeltaSize.x ) ) / 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; double ddy = scale( TO_LEGACY_LU( aPad->m_DeltaSize.y() ) ) / 2.0;
// see class_pad_draw_functions.cpp which draws the trapezoid pad // see class_pad_draw_functions.cpp which draws the trapezoid pad
POINT lowerLeft( -dx - ddy, -dy - ddx ); POINT lowerLeft( -dx - ddy, -dy - ddx );
...@@ -483,11 +483,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) ...@@ -483,11 +483,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad )
// this string _must_ be unique for a given physical shape // this string _must_ be unique for a given physical shape
snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_mil", snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_mil",
uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( aPad->m_Size.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', aPad->m_DeltaSize.x() < ZERO_LENGTH ? 'n' : 'p',
abs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.x ) )), fabs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.x() ) )),
aPad->m_DeltaSize.y < ZERO_LENGTH ? 'n' : 'p', aPad->m_DeltaSize.y() < ZERO_LENGTH ? 'n' : 'p',
abs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.y ) )) fabs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.y() ) ))
); );
name[ sizeof(name)-1 ] = 0; name[ sizeof(name)-1 ] = 0;
...@@ -527,7 +527,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) ...@@ -527,7 +527,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
// see if this pad is a through hole with no copper on its perimeter // see if this pad is a through hole with no copper on its perimeter
if( isRoundKeepout( pad ) ) if( isRoundKeepout( pad ) )
{ {
double diameter = scale( TO_LEGACY_LU( pad->m_Drill.x ) ); double diameter = scale( TO_LEGACY_LU( pad->m_Drill.x() ) );
POINT vertex = mapPt( TO_LEGACY_LU_WXP( pad->m_Pos0 ) ); POINT vertex = mapPt( TO_LEGACY_LU_WXP( pad->m_Pos0 ) );
int layerCount = aBoard->GetCopperLayerCount(); int layerCount = aBoard->GetCopperLayerCount();
......
...@@ -201,7 +201,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) ...@@ -201,7 +201,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb )
* inside the board (in fact inside the hole. Some photo diodes and Leds are * inside the board (in fact inside the hole. Some photo diodes and Leds are
* like this) * like this)
*/ */
if( (pad->m_Drill.x == ZERO_LENGTH) && (pad->m_Drill.y == ZERO_LENGTH) ) if( (pad->m_Drill.x() == ZERO_LENGTH) && (pad->m_Drill.y() == ZERO_LENGTH) )
continue; continue;
// Use a dummy pad to calculate a hole shape that have the same dimension as // 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 ...@@ -68,15 +68,15 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector<CPolyPt>& aCornerBuffe
// Thermal bridges are like a segment from a starting point inside the pad // Thermal bridges are like a segment from a starting point inside the pad
// to an ending point outside the pad // to an ending point outside the pad
wxPoint startpoint, endpoint; wxPoint startpoint, endpoint;
endpoint.x = ( TO_LEGACY_LU( pad->m_Size.x / 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; endpoint.y = ( TO_LEGACY_LU( pad->m_Size.y() / 2 ) ) + aZone->m_ThermalReliefGapValue;
int copperThickness = aZone->m_ThermalReliefCopperBridgeValue - aZone->m_ZoneMinThickness; int copperThickness = aZone->m_ThermalReliefCopperBridgeValue - aZone->m_ZoneMinThickness;
if( copperThickness < 0 ) if( copperThickness < 0 )
copperThickness = 0; copperThickness = 0;
startpoint.x = min( TO_LEGACY_LU( pad->m_Size.x ), copperThickness ); startpoint.x = min( TO_LEGACY_LU( pad->m_Size.x() ), copperThickness );
startpoint.y = min( TO_LEGACY_LU( pad->m_Size.y ), copperThickness ); startpoint.y = min( TO_LEGACY_LU( pad->m_Size.y() ), copperThickness );
startpoint.x /= 2; startpoint.x /= 2;
startpoint.y /= 2; startpoint.y /= 2;
......
...@@ -40,7 +40,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD ...@@ -40,7 +40,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD
if( pad->GetNet() != GetNet() ) if( pad->GetNet() != GetNet() )
continue; continue;
ListPointsCandidates.push_back( pad->m_Pos ); ListPointsCandidates.push_back( TO_LEGACY_LU_WXP( pad->m_Pos ) );
} }
} }
......
...@@ -111,7 +111,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) ...@@ -111,7 +111,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode )
if( item->Type() == PCB_PAD_T ) if( item->Type() == PCB_PAD_T )
{ {
pos1 = pos2 = ( (D_PAD*) item )->m_Pos; pos1 = pos2 = TO_LEGACY_LU_WXP( ( (D_PAD*) item )->m_Pos ); /// @BUG Unsafe type conversion
} }
else if( item->Type() == PCB_VIA_T ) else if( item->Type() == PCB_VIA_T )
{ {
......
// math stuff for graphics, from FreePCB // math stuff for graphics, from FreePCB
#ifndef abs /*#ifndef abs
#define abs(x) (((x) >=0) ? (x) : (-(x))) #define abs(x) (((x) >=0) ? (x) : (-(x)))
#endif #endif*/
typedef struct PointTag typedef struct PointTag
......
...@@ -73,6 +73,8 @@ static inline int floordiv( int a, int n ) ...@@ -73,6 +73,8 @@ static inline int floordiv( int a, int n )
/* Note: the following work for integers and other numeric types. */ /* Note: the following work for integers and other numeric types. */
/* those are bad programming practice because of several issues with
overloading and integer limits
#undef sign #undef sign
#undef abs #undef abs
#undef min #undef min
...@@ -84,6 +86,79 @@ static inline int floordiv( int a, int n ) ...@@ -84,6 +86,79 @@ static inline int floordiv( int a, int n )
#define min( a, b ) ( (a)<(b) ? (a) : (b) ) #define min( a, b ) ( (a)<(b) ? (a) : (b) )
#define max( a, b ) ( (a)>(b) ? (a) : (b) ) #define max( a, b ) ( (a)>(b) ? (a) : (b) )
#define sq( a ) ( (a) * (a) ) #define sq( a ) ( (a) * (a) )
#define cu( a ) ( (a) * (a) * (a) ) #define cu( a ) ( (a) * (a) * (a) )*/
// these functions better than macros because they do not cause double evaluation.
static inline int sign( int x )
{
return (0 < x) - (x < 0);
}
static inline int sign( long x )
{
return (0 < x) - (x < 0);
}
static inline int sign( double x )
{
return (0.0 < x) - (x < 0.0);
}
/*static inline int abs( int x ) is not required because exist in stdlib.h */
static inline long abs( long x )
{
return x < 0? -x : x;
}
static inline int max( int x, int y )
{
return x < y? y : x;
}
static inline long max( long x, long y )
{
return x < y? y : x;
}
static inline int min( int x, int y )
{
return x < y? x : y;
}
static inline long min( long x, long y )
{
return x < y? x : y;
}
static inline int sq( int x )
{
return x * x;
}
static inline long sq( long x )
{
return x * x;
}
static inline double sq( double x )
{
return x * x;
}
static inline int cu( int x )
{
return x * x * x;
}
static inline long cu( long x )
{
return x * x * x;
}
static inline double cu( double x )
{
return x * x * x;
}
#endif /* AUXILIARY_H */ #endif /* AUXILIARY_H */
...@@ -278,7 +278,7 @@ void render_curveto( render_t* rm, ...@@ -278,7 +278,7 @@ void render_curveto( render_t* rm,
* occur at an endpoint. */ * occur at an endpoint. */
dd0 = sq( x1 - 2 * x2 + x3 ) + sq( y1 - 2 * y2 + y3 ); dd0 = sq( x1 - 2 * x2 + x3 ) + sq( y1 - 2 * y2 + y3 );
dd1 = sq( x2 - 2 * x3 + x4 ) + sq( y2 - 2 * y3 + y4 ); dd1 = sq( x2 - 2 * x3 + x4 ) + sq( y2 - 2 * y3 + y4 );
dd = 6 * sqrt( max( dd0, dd1 ) ); dd = 6 * sqrt( fmax( dd0, dd1 ) );
e2 = 8 * delta <= dd ? 8 * delta / dd : 1; e2 = 8 * delta <= dd ? 8 * delta / dd : 1;
epsilon = sqrt( e2 ); /* necessary interval size */ epsilon = sqrt( e2 ); /* necessary interval size */
......
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