diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index b1fc59e58f..a6f4e7bc28 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -884,7 +884,7 @@ void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas ) } } -/** @TODO: move D_PAD method to appropriate file */ + /* Draw 3D pads. */ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) { @@ -903,8 +903,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) int color; scale = g_Parm_3D_Visu.m_BoardScale; - holeX = (double) TO_LEGACY_LU_DBL( m_Drill.x() ) * scale / 2; - holeY = (double) TO_LEGACY_LU_DBL( m_Drill.y() ) * scale / 2; + holeX = (double) m_Drill.x * scale / 2; + holeY = (double) m_Drill.y * scale / 2; hole = MIN( holeX, holeY ); /* Calculate the center of the pad. */ @@ -914,12 +914,12 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) xc = ux0; yc = uy0; - dx = dx0 = TO_LEGACY_LU( m_Size.x() ) >> 1; - dy = dy0 = TO_LEGACY_LU( m_Size.y() ) >> 1; + dx = dx0 = m_Size.x >> 1; + dy = dy0 = m_Size.y >> 1; angle = m_Orient; - drillx = TO_LEGACY_LU( m_Pos.x() ) * scale; - drilly = TO_LEGACY_LU( m_Pos.y() ) * scale; + drillx = m_Pos.x * scale; + drilly = m_Pos.y * scale; /* Draw the pad hole (TODO: draw OBLONG hole) */ if( holeX && holeY ) @@ -980,13 +980,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) { delta_cx = dx - dy; delta_cy = 0; - w = TO_LEGACY_LU( m_Size.y() ) * scale; + w = m_Size.y * scale; } else /* Vertical ellipse */ { delta_cx = 0; delta_cy = dy - dx; - w = TO_LEGACY_LU( m_Size.x() ) * scale; + w = m_Size.x * scale; } RotatePoint( &delta_cx, &delta_cy, angle ); diff --git a/CMakeLists.txt b/CMakeLists.txt index 0977347f35..6b0b01aa86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,6 @@ option(KICAD_GOST "enable/disable building using GOST notation for multiple gate #for those who bored with uppercase option(KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected") -#highly experimetnal option -option(KICAD_NANOMETRE "set length quantum to 1 nm for PCB") - option(USE_WX_GRAPHICS_CONTEXT "Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental") @@ -102,10 +99,6 @@ if(KICAD_KEEPCASE) add_definitions(-DKICAD_KEEPCASE) endif(KICAD_KEEPCASE) -if(KICAD_NANOMETRE) - add_definitions(-DKICAD_NANOMETRE) -endif(KICAD_NANOMETRE) - if(USE_WX_OVERLAY OR APPLE) add_definitions(-DUSE_WX_OVERLAY) endif(USE_WX_OVERLAY OR APPLE) diff --git a/bitmap2component/bitmap2component.cpp b/bitmap2component/bitmap2component.cpp index a94fcbae1b..3da52dfea8 100644 --- a/bitmap2component/bitmap2component.cpp +++ b/bitmap2component/bitmap2component.cpp @@ -37,6 +37,13 @@ #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 namespace bpl = boost::polygon; // bpl = boost polygon library using namespace bpl::operators; // +, -, =, ... @@ -469,7 +476,7 @@ void BezierToPolyline( std::vector & aCornersBuffer, * occur at an endpoint. */ 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 ); - dd = 6 * sqrt( fmax( dd0, dd1 ) ); + dd = 6 * sqrt( max( dd0, dd1 ) ); e2 = 8 * delta <= dd ? 8 * delta / dd : 1; epsilon = sqrt( e2 ); /* necessary interval size */ diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 6c1ec5122e..4f39888da3 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -518,20 +518,6 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event ) tmp << wxT( "OFF\n" ); #endif - tmp << wxT( " KICAD_NANOMETRE=" ); -#ifdef KICAD_NANOMETRE - tmp << wxT( "ON\n" ); -#else - tmp << wxT( "OFF\n" ); -#endif - - tmp << wxT( " KICAD_KEEPCASE=" ); -#ifdef KICAD_KEEPCASE - tmp << wxT( "ON\n" ); -#else - tmp << wxT( "OFF\n" ); -#endif - tmp << wxT( " USE_WX_GRAPHICS_CONTEXT=" ); #ifdef USE_WX_GRAPHICS_CONTEXT tmp << wxT( "ON\n" ); diff --git a/common/common.cpp b/common/common.cpp index bfae0c63df..65a9be0c62 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -410,193 +410,50 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int } -#ifdef KICAD_NANOMETRE - -/* - *New common length functions +/** + * Function wxStringSplit + * Split a String to a String List when founding 'splitter' + * @return the list + * @param txt : wxString : a String text + * @param splitter : wxChar : the 'split' character */ - -const LENGTH_UNIT_DESC MillimetreDesc = -{ - LENGTH_UNITS::millimetre(), - wxT( "mm" ), - 6 -}; - - -const LENGTH_UNIT_DESC InchDesc = -{ - LENGTH_UNITS::inch(), - wxT( "\"" ), - 7 -}; - - -const LENGTH_UNIT_DESC MilDesc = -{ - LENGTH_UNITS::mil(), - wxT( "mil" ), - 5 -}; - - -const LENGTH_UNIT_DESC UnscaledDesc = /* stub */ -{ - LENGTH_PCB::quantum(), - wxT( "" ), - 4 -}; - - -const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ) { - switch(aUnit) { - case INCHES: - return &InchDesc; - case MILLIMETRES: - return &MillimetreDesc; - default: - return &UnscaledDesc; /* should not be reached */ - } -} - - -/* TODO: localisation */ -wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_PCB aValue, - bool aAdd_unit_symbol ) { - wxString StringValue; - double value_to_print; - value_to_print = LENGTH(aValue) / LENGTH(aUnit->m_Value); - StringValue.Printf( wxT( "%.*f" ), aUnit->m_Precision, value_to_print); - size_t zero_tail = StringValue.find_last_not_of( wxT( "0" ) ); - - if( zero_tail != std::string::npos ) - { - //fprintf( stderr, "pos : %d", (int) zero_tail ); - size_t delim_pos = StringValue.Length() - aUnit->m_Precision; - - if( zero_tail < delim_pos) - zero_tail = delim_pos; - - StringValue.Truncate( zero_tail + 1 ); - } - - if( aAdd_unit_symbol && aUnit->m_Symbol != wxT( "" ) ) - { - StringValue += wxT( " " ); - - StringValue += wxGetTranslation( aUnit->m_Symbol ); - } - - return StringValue; -} - -LENGTH_PCB StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue ) -{ - - LENGTH_PCB Value; - double dtmp = 0; - - /* Acquire the 'right' decimal point separator */ - const struct lconv* lc = localeconv(); - wxChar decimal_point = lc->decimal_point[0]; - wxString buf( TextValue.Strip( wxString::both ) ); - - /* Convert the period in decimal point */ - buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) ); - - // An ugly fix needed by WxWidgets 2.9.1 that sometimes - // back to a point as separator, although the separator is the comma - // TODO: remove this line if WxWidgets 2.9.2 fixes this issue - buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) ); - - /* Find the end of the numeric part */ - unsigned brk_point = 0; - - while( brk_point < buf.Len() ) - { - wxChar ch = buf[brk_point]; - - if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) - || (ch == '-') || (ch == '+') ) ) - { - break; - } - - ++brk_point; - } - - /* Extract the numeric part */ - buf.Left( brk_point ).ToDouble( &dtmp ); - - /* Check the optional unit designator (2 ch significant) */ - wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() ); - - if( unit == wxT( "in" ) || unit == wxT( "\"" ) ) - { - aUnit = &InchDesc; - } - else if( unit == wxT( "mm" ) ) - { - aUnit = &MillimetreDesc; - } - else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) /* Mils or thous */ - { - aUnit = &MilDesc; - } - - Value = LENGTH_PCB( dtmp * LENGTH< double, 1 >( aUnit->m_Value ) ); - - return Value; -} - -void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_PCB Value ) -{ - wxString msg = LengthToString( UnitDescription( g_UserUnit ), Value ); - - TextCtr.SetValue( msg ); -} - -LENGTH_PCB LengthFromTextCtrl( const wxTextCtrl& TextCtr ) -{ - LENGTH_PCB value; - wxString msg = TextCtr.GetValue(); - - value = StringToLength( UnitDescription( g_UserUnit ), msg ); - - return value; -} - -#endif - - -wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ) +wxArrayString* wxStringSplit( wxString txt, wxChar splitter ) { wxArrayString* list = new wxArrayString(); while( 1 ) { - int index = aString.Find( aSplitter ); - + int index = txt.Find( splitter ); if( index == wxNOT_FOUND ) break; wxString tmp; - tmp = aString.Mid( 0, index ); - aString = aString.Mid( index + 1, aString.size() - index ); + tmp = txt.Mid( 0, index ); + txt = txt.Mid( index + 1, txt.size() - index ); list->Add( tmp ); } - if( !aString.IsEmpty() ) + if( !txt.IsEmpty() ) { - list->Add( aString ); + list->Add( txt ); } return list; } + +/** + * Function To_User_Unit + * Convert in inch or mm the variable "val" (double)given in internal units + * @return the converted value, in double + * @param aUnit : user measure unit + * @param val : double : the given value + * @param internal_unit_value = internal units per inch + */ double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) { + switch( aUnit ) { case MILLIMETRES: @@ -611,6 +468,9 @@ double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) } +/* + * Return in internal units the value "val" given in inch or mm + */ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) { double value; @@ -627,6 +487,7 @@ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) default: case UNSCALED_UNITS: + value = val; } @@ -634,6 +495,9 @@ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) } +/* + * Return the string date "day month year" like "23 jun 2005" + */ wxString GenDate() { static const wxString mois[12] = @@ -647,6 +511,7 @@ wxString GenDate() wxString string_date; time( &buftime ); + Date = gmtime( &buftime ); string_date.Printf( wxT( "%d %s %d" ), Date->tm_mday, GetChars( mois[Date->tm_mon] ), diff --git a/common/projet_config.cpp b/common/projet_config.cpp index d9900f9467..f382a1d48b 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -802,85 +802,3 @@ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) 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 -} diff --git a/gerbview/class_gerber_draw_item.h b/gerbview/class_gerber_draw_item.h index a94e94930e..83298c6c0f 100644 --- a/gerbview/class_gerber_draw_item.h +++ b/gerbview/class_gerber_draw_item.h @@ -167,15 +167,11 @@ public: * @return const wxPoint& - The position of this object. * This function exists mainly to satisfy the virtual GetPosition() in parent class */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Start; // it had to be start or end. } - void SetPosition( const wxPoint& pos ) { - m_Start = pos; - } - /** * Function GetABPosition * returns the image position of aPosition for this object. diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h index 21e36495f4..af7b255f73 100644 --- a/include/class_board_design_settings.h +++ b/include/class_board_design_settings.h @@ -7,10 +7,6 @@ #include "pcbstruct.h" // NB_COLORS -#include "lengthpcb.h" - -#include "class_via_dimension.h" - // Class for handle current printed board design settings class BOARD_DESIGN_SETTINGS { @@ -26,14 +22,11 @@ public: int m_EdgeSegmentWidth; // current graphic line width (EDGE layer only) int m_PcbTextWidth; // current Pcb (not module) Text width wxSize m_PcbTextSize; // current Pcb (not module) Text size - LENGTH_PCB m_TrackMinWidth; // track min value for width ((min copper size value - - VIA_DIMENSION m_MinVia; - VIA_DIMENSION m_MinMicroVia; - //LENGTH_PCB m_ViasMinSize; // vias (not micro vias) min diameter - //LENGTH_PCB m_ViasMinDrill; // vias (not micro vias) min drill diameter - //LENGTH_PCB m_MicroViasMinSize; // micro vias (not vias) min diameter - //LENGTH_PCB m_MicroViasMinDrill; // micro vias (not vias) min drill diameter + int m_TrackMinWidth; // track min value for width ((min copper size value + int m_ViasMinSize; // vias (not micro vias) min diameter + int m_ViasMinDrill; // vias (not micro vias) min drill diameter + int m_MicroViasMinSize; // micro vias (not vias) min diameter + int m_MicroViasMinDrill; // micro vias (not vias) min drill diameter // Global mask margins: int m_SolderMaskMargin; // Solder mask margin diff --git a/include/class_board_item.h b/include/class_board_item.h index 3b27117fc6..ead8d83f31 100644 --- a/include/class_board_item.h +++ b/include/class_board_item.h @@ -76,19 +76,9 @@ public: /** * Function GetPosition * returns the position of this object. - * @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. + * @return wxPoint& - The position of this object, non-const so it can be changed */ - 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; + virtual wxPoint& GetPosition() = 0; /** * Function GetLayer @@ -323,9 +313,10 @@ public: {} //-----< satisfy some virtual functions >------------------------------ - const wxPoint GetPosition() const + wxPoint& GetPosition() { - return wxPoint(0, 0); + static wxPoint dummy; + return dummy; } void Draw( EDA_DRAW_PANEL* DrawPanel, wxDC* DC, diff --git a/include/class_via_dimension.h b/include/class_via_dimension.h index 69b1d21dc9..bd1154f70b 100644 --- a/include/class_via_dimension.h +++ b/include/class_via_dimension.h @@ -22,11 +22,6 @@ public: m_Drill = FROM_LEGACY_LU( 0 ); } - VIA_DIMENSION( LENGTH_PCB diam, LENGTH_PCB drill ) - { - m_Diameter = diam; - m_Drill = drill; - } bool operator ==( const VIA_DIMENSION& other ) const { diff --git a/include/common.h b/include/common.h index 7e0560fb91..c59c446af5 100644 --- a/include/common.h +++ b/include/common.h @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 2007-2011 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2008-2011 Wayne Stambaugh * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * @@ -28,18 +29,13 @@ * @file common.h */ -#ifndef __INCLUDE__COMMON_H__ -#define __INCLUDE__COMMON_H__ 1 +#ifndef INCLUDE__COMMON_H_ +#define INCLUDE__COMMON_H_ #include "wx/wx.h" #include "wx/confbase.h" #include "wx/fileconf.h" - -#ifdef KICAD_NANOMETRE -#include "lengthpcb.h" -#endif - class wxAboutDialogInfo; class BASE_SCREEN; class EDA_DRAW_FRAME; @@ -358,90 +354,32 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int * @return a wxString what contains value and optionally the symbol unit (like * 2.000 mm) */ -wxString ReturnStringFromValue( EDA_UNITS_T aUnit, - int aValue, - int aInternal_Unit, - bool aAdd_unit_symbol = false ); +wxString ReturnStringFromValue( EDA_UNITS_T aUnit, + int aValue, + int aInternal_Unit, + bool aAdd_unit_symbol = false ); - -/** - * Function AddUnitSymbol - * adds string " (mm):" or " ("):" to the static text Stext. - * Used in dialog boxes for entering values depending on selected units - */ -void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit ); +void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit ); /* Add string " (mm):" or " ("):" to the static text Stext. * Used in dialog boxes for entering values depending on selected units */ -void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit ); +void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, + int Internal_Unit ); -/** - * Convert the number Value in a string according to the internal units +/* Convert the number Value in a string according to the internal units * and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl - */ -int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ); - -#ifdef KICAD_NANOMETRE - -struct LENGTH_UNIT_DESC -{ - LENGTH_PCB m_Value; - const wxString m_Symbol; - int m_Precision; -}; - -extern const LENGTH_UNIT_DESC MillimetreDesc, InchDesc, MilDesc; - -const LENGTH_UNIT_DESC *UnitDescription( EDA_UNITS_T aUnit ); - -LENGTH_PCB StringToLength( const LENGTH_UNIT_DESC *aUnit, const wxString& TextValue ); -wxString LengthToString( const LENGTH_UNIT_DESC *aUnit, LENGTH_PCB aValue, - bool aAdd_unit_symbol = false ); - -void LengthToTextCtrl( wxTextCtrl& TextCtr, LENGTH_PCB Value ); -LENGTH_PCB LengthFromTextCtrl( const wxTextCtrl& TextCtr ); - -/* transition macros */ -#define STR_TO_LENGTH( unit, str, iu ) \ - ( StringToLength( UnitDescription( ( unit ) ), ( str ) ) ) - -#define LENGTH_TO_STR( unit, l, iu ) \ - ( LengthToString( UnitDescription( ( unit ) ), ( l ) ) ) -#define LENGTH_TO_STR_SYM( unit, l, iu ) \ - ( LengthToString( UnitDescription( ( unit ) ), ( l ), true ) ) - -#define CTR_GET_LENGTH( ctr, iu ) \ - ( StringToLength( UnitDescription( g_UserUnit ), ( ctr ).GetValue() ) ) - -#define CTR_PUT_LENGTH( ctr, l, iu ) \ - ( ( ctr ).SetValue( LengthToString( UnitDescription( g_UserUnit ), ( l ) ) ) ) - -#else - -#define STR_TO_LENGTH( unit, str, iu ) \ - ReturnValueFromString( ( unit ), ( str ), ( iu ) ) - -#define LENGTH_TO_STR( unit, l, iu ) \ - ( ReturnStringFromValue( ( unit ), ( l ), ( iu ) ) ) -#define LENGTH_TO_STR_SYM( unit, l, iu ) \ - ( ReturnStringFromValue( ( unit ), ( l ), ( iu ), true ) ) - -#define CTR_GET_LENGTH( ctr, iu ) \ - ReturnValueFromString( g_UserUnit, ( ctr ).GetValue(), ( iu ) ) - -#define CTR_PUT_LENGTH( ctr, l, iu ) \ - ( ( ctr ).SetValue( ReturnStringFromValue( g_UserUnit, ( l ), ( iu ) ) ) ) - -#endif + **/ +int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, + int Internal_Unit ); /** * Function wxStringSplit - * splita \a aString to a string list when split by \a aSplitter. + * splits \a aString to a string list separated at \a aSplitter. * @return the list - * @param aString : wxString : a String text - * @param aSplitter : wxChar : the 'split' character + * @param aString is the text to split + * @param aSplitter is the 'split' character */ -wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ); +wxArrayString* wxStringSplit( wxString txt, wxChar aSplitter ); /** * Function To_User_Unit @@ -449,11 +387,12 @@ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ); * @return the converted value, in double * @param aUnit : user unit to be converted to * @param val : double : the given value + * @param internal_unit_value = internal units per inch */ double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); -/* +/** * Return in internal units the value "val" given in inch or mm */ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); @@ -465,4 +404,4 @@ int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); */ wxString GenDate(); -#endif // __INCLUDE__COMMON_H__ +#endif // INCLUDE__COMMON_H_ diff --git a/include/length.h b/include/length.h index a723618c10..537b01dacb 100644 --- a/include/length.h +++ b/include/length.h @@ -1,74 +1,18 @@ /** + * The physical length library. Made for nanometer scale. * @file length.h - * @brief The physical length library. Made for nanometer scale. */ -/* sorry if it is not styled correctly, i'll work on it further */ +/* sorry it is not styled correctly, i'll work on it further */ #ifndef LENGTH_H_INCLUDED #define LENGTH_H_INCLUDED 1 -#include - -template < typename T = double, int P = 1 > class LENGTH; - -template class LENGTH_UNITS; - -/*! - * The template that "inflate" LENGTH< T, 0 > class to T. Used with (*) and (/). - */ -template < typename T, int P > struct LENGTH_TRAITS -{ - typedef LENGTH flat; -}; - -template < typename T > struct LENGTH_TRAITS< T, 0 > -{ - /* length dimension to power 0 is just a number, so LENGTH should be automatically converted to T */ - typedef T flat; -}; - -/*! - * The template for value type conversions - */ -template < typename T > struct LENGTH_CASTS -{ - /*! This function to convert length value to given type T. */ - template< typename X > static T nearest( const X x ) - { - return T( x ); - } -}; - -template <> struct LENGTH_CASTS < int > -{ - static int nearest( const double x ) - { - return floor( x + 0.5 ); - } -}; - -template <> struct LENGTH_CASTS < long > -{ - static long nearest( const double x ) - { - 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 > > -{ - static LIMITED_INT< T > nearest( const double x ) - { - return LIMITED_INT< T > ( floor( x + 0.5 ) ); - } -}; +/* type to be used by length units by default */ +typedef int DEF_LENGTH_VALUE; /** - * Length template class. + * 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 @@ -88,7 +32,7 @@ template < typename T > struct LENGTH_CASTS < LIMITED_INT< T > > * - 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 + * 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 @@ -101,6 +45,28 @@ template < typename T > struct LENGTH_CASTS < LIMITED_INT< T > > * */ +template < typename T = DEF_LENGTH_VALUE, int P = 1 > class LENGTH; + +/** + * Length units contained in this class + */ + +template class LENGTH_UNITS; + +/** + * For internal needs + */ +template < typename T, int P > struct LENGTH_TRAITS +{ + typedef LENGTH flat; +}; + +template < typename T > struct LENGTH_TRAITS< T, 0 > +{ + /* length dimension to power 0 is just a number, so LENGTH should be automatically converted to T */ + typedef T flat; +}; + template< typename T, int P > class LENGTH { friend class LENGTH_UNITS< T >; @@ -108,242 +74,152 @@ template< typename T, int P > class LENGTH template < typename Y, int R > friend class LENGTH; protected: - T u; - - /** - * The 'direct' constructor which should not be accessed from outside - */ - LENGTH( T units ) : u( units ) + T m_U; + LENGTH( T units ) : m_U( units ) { } - + static T RawValue( const LENGTH &x ) + { + return x.m_U; + } + static T RawValue( const T& x ) + { + return x; + } public: typedef T value_type; - enum { dimension = P }; - - template< typename U > LENGTH( const LENGTH< U, P > &orig ) - : u( LENGTH_CASTS < T >::nearest( orig.u ) ) + LENGTH( const LENGTH &orig ) : m_U( orig.m_U ) { } - - LENGTH( void ) : u() + LENGTH( void ) : m_U() { } - - /** - * Zero length of given type - * @return A zero - */ + static LENGTH zero ( void ) { return T(0); } - /** - * Internal unit. Service function. Do not use this, please! - * @return An internal unit - */ - static LENGTH quantum ( void ) - { - return T(1); - } - LENGTH & operator = ( const LENGTH & y ) { - this->u = y.u; + this->m_U = y.m_U; return *this; } - /** @} */ - - /** - * @defgroup length-comparisons Comparisons and tests - * @{ - */ + template operator LENGTH< Y, P > ( void ) + { + return this->m_U; + } + /*************************/ + /* comparisons and tests */ + /*************************/ bool operator ==( const LENGTH < T, P > y ) const { - return u == y.u; + return m_U == y.m_U; } - bool operator !=( const LENGTH < T, P > y ) const { - return u != y.u; + return m_U != y.m_U; } - bool operator <( const LENGTH < T, P > y ) const { - return u < y.u; + return m_U < y.m_U; } - bool operator >=( const LENGTH < T, P > y ) const { - return u >= y.u; + return m_U >= y.m_U; } - bool operator >( const LENGTH < T, P > y ) const { - return u > y.u; + return m_U > y.m_U; } - bool operator <=( const LENGTH < T, P > y ) const { - return u <= y.u; + return m_U <= y.m_U; } - bool operator !( void ) const { - return !u; + return !m_U; } - /** @} */ - - /** - * @defgroup length-arithmetic Basic arithmetic - * @{ - */ + /*************************/ + /* basic arithmetic */ + /*************************/ LENGTH< T, P > operator - ( void ) const { - LENGTH< T, P > z; - z.u = -u; - return z; + return LENGTH(-this->m_U); } - - LENGTH< T, P >& operator -= ( const LENGTH< T, P > y ) + LENGTH< T, P > operator - ( const LENGTH< T, P > y ) const { - u -= y.u; - return *this; + return m_U - y.m_U; } - - friend LENGTH< T, P > operator - ( const LENGTH< T, P > x, const LENGTH< T, P > y ) + LENGTH< T, P > operator + ( const LENGTH< T, P > y ) const { - LENGTH< T, P > z = x; - z -= y; - return z; + return m_U + y.m_U; } - - LENGTH< T, P >& operator += ( const LENGTH< T, P > y ) - { - 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 > z = *this; - z *= y; - return z; - } - template < int R > typename LENGTH_TRAITS< T, P + R >::flat operator * ( const LENGTH &y ) const { - LENGTH< T, P + R > z; - z.u = u * y.u; - return z; + return m_U * y.m_U; + } + LENGTH< T, P > operator * ( const T & y) const + { + return m_U * y; } - LENGTH< T, P > friend operator * ( const T &y, const LENGTH &x ) { - return x.u * y; + return x.m_U * y; } - - LENGTH< T, P >& operator /= ( const T y ) + + template < int R > + typename LENGTH_TRAITS< T, P - R >::flat operator / ( const LENGTH &y ) const { - u /= y; - return *this; + return m_U / y.m_U; } - LENGTH< T, P > operator / ( const T &y ) const { - return u / y; + return m_U / y; } - - template < int R > - typename LENGTH_TRAITS< T, P - R >::flat operator / ( const LENGTH< T, R > &y ) const - { - return u / y.u; - } - LENGTH< T, -P > friend operator / ( const T &y, const LENGTH< T, P > &x ) { - return y / x.u; - } - /** @} */ - - /** - * @defgroup length-algebra Algebraic functions - * @{ - */ - /** Absolute value. */ - friend LENGTH< T, P > abs( LENGTH< T, P > y ) - { - return 0 < y.u? y : -y; + return y / x.m_U; } - /** Maximum of two values. */ - friend LENGTH< T, P > max( LENGTH< T, P > x, LENGTH< T, P > y ) - { - LENGTH< T, P > z; - z.u = max( x.u, y.u ); - return z; - } - - /** Minimum of two values. */ - friend LENGTH< T, P > min( LENGTH< T, P > x, LENGTH< T, P > y ) - { - LENGTH< T, P > z; - z.u = min( x.u, y.u ); - return z; - } - - /** Square root. */ friend LENGTH< T, P > sqrt( LENGTH< T, P*2 > y ) { - LENGTH< T, P > z; - z.u = sqrt( y.u ); - return z; + return sqrt( y.m_U ); } - - /** Cubic root. */ friend LENGTH< T, P > cbrt( LENGTH< T, P*3 > y ) { - LENGTH< T, P > z; - z.u = cbrt( y.u ); - return z; + return cbrt( y.m_U ); } - - /** Hypothenuse of a triangle given katheti. */ - friend LENGTH< T, P > hypot( LENGTH< T, P > x, LENGTH< T, P > y ) + /*************************/ + /* assignment arithmetic */ + /*************************/ + LENGTH< T, P >& operator -= ( const LENGTH< T, P > y ) { - LENGTH< T, P > z; - z.u = hypot( x.u, y.u ); - return z; + return m_U -= y.m_U; } - - /** Direction of vector given cartesian coords. */ - friend double atan2( LENGTH< T, P > x, LENGTH< T, P > y ) + LENGTH< T, P >& operator += ( const LENGTH< T, P > y ) { - return atan2( double ( x.u ), double( y.u ) ); + return m_U += y.m_U; } - /** @} */ + LENGTH< T, P >& operator *= ( const T y ) + { + return m_U *= y; + } + LENGTH< T, P >& operator /= ( const T y ) + { + return m_U /= y; + } + /*************************/ + /* more arithmetic */ + /*************************/ }; -/*! +/** * Units of length * * How to use them: @@ -355,74 +231,48 @@ public: * to get numeric value of length in specific units you should use a division * length/LENGTH_UNITS::metre() gives number of metres in length * legnth/LENGTH_UNITS::foot() gives number of feet in length - * - * Really these units are used in NEWPCB and printing routines, as EESCHEMA - * is going to use relative units. */ -template < typename T > class LENGTH_UNITS { +template < typename T = DEF_LENGTH_VALUE > class LENGTH_UNITS { protected: 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 }; - -public: - /** One metre. */ - static LENGTH< T, 1 > metre( void ) - { + public: + static LENGTH< T, 1 > metre( void ) { return T( METRE ); } - - /** One decimetre, 0.1 m. */ - static LENGTH< T, 1 > decimetre( void ) - { + static LENGTH< T, 1 > decimetre( void ) { return T( METRE / 10 ); } - - /** One centimetre, 0.01 m. */ - static LENGTH< T, 1 > centimetre( void ) - { + static LENGTH< T, 1 > centimetre( void ) { return T( METRE / 100 ); } - - /** One millimetre, 0.001 m. */ - static LENGTH< T, 1 > millimetre( void ) - { + static LENGTH< T, 1 > millimetre( void ) { return T( METRE / 1000 ); } - - /** One micrometre, 1E-6 m. */ - static LENGTH< T, 1 > micrometre( void ) - { + static LENGTH< T, 1 > micrometre( void ) { return T( METRE / 1000000 ); } - - /** One foot, 304.8 mm, 12 inch. */ - static LENGTH< T, 1 > foot( void ) - { + static LENGTH< T, 1 > foot( void ) { /* do not think this will ever need */ return T( INCH * 12 ); } - - /** One inch, 25.4 mm, 1/12 feet. */ - static LENGTH< T, 1 > inch( void ) - { + static LENGTH< T, 1 > inch( void ) { return T( INCH ); } - - /** One mil (or thou), 0.001 inch . */ - static LENGTH< T, 1 > mil( void ) - { + static LENGTH< T, 1 > mil( void ) { 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 > { }; -#endif /* def LENGTH_H_INCLUDED */ +#endif diff --git a/include/lengthpcb.h b/include/lengthpcb.h deleted file mode 100644 index 05602174f4..0000000000 --- a/include/lengthpcb.h +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @file lengthpcb.h - * @brief Length definitions for PCBNEW. - */ - -#ifndef LENGTHPCB_H_INCLUDED -#define LENGTHPCB_H_INCLUDED 1 - -#ifdef KICAD_NANOMETRE -#include "length.h" -#include "limited_int.h" - -/* switched type! */ -typedef LENGTH< LIMITED_INT< int >, 1 > LENGTH_PCB; -typedef LENGTH< double, 1 > LENGTH_PCB_DBL; - -/* Transition macros. they are used for unit conversion between - * nanometre scale and old (0.1 mil) scale */ - -#define PCB_LEGACY_INCH_SCALE 10000 -#define PCB_LEGACY_UNIT( T ) ( LENGTH_UNITS< T >::inch() / PCB_LEGACY_INCH_SCALE ) - -#define TO_LEGACY_LU( x ) \ - ( (int) ( LENGTH_PCB( x ) / PCB_LEGACY_UNIT( LENGTH_PCB ) ) ) -#define TO_LEGACY_LU_DBL( x ) \ - ( (double) ( LENGTH_PCB_DBL( x ) / PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) ) ) - -#ifdef __GNUC__ -#define NOT_USED __attribute__ ((unused)) -#else -#define NOT_USED -#endif - -static LENGTH_PCB NOT_USED from_legacy_lu( int x ) -{ - return x * PCB_LEGACY_UNIT( LENGTH_PCB ); -} - -static LENGTH_PCB NOT_USED from_legacy_lu( long x ) -{ - return x * PCB_LEGACY_UNIT( LENGTH_PCB ); -} - -static LENGTH_PCB NOT_USED from_legacy_lu( double x ) -{ - return LENGTH_PCB( x * PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) ); -} - -static LENGTH_PCB_DBL NOT_USED from_legacy_lu_dbl( double x ) -{ - return x * LENGTH_UNITS< LENGTH_PCB_DBL >::inch() / PCB_LEGACY_INCH_SCALE; -} - -#undef NOT_USED - -#define FROM_LEGACY_LU( x ) ( from_legacy_lu( x ) ) -#define FROM_LEGACY_LU_DBL( x ) ( from_legacy_lu_dbl( x ) ) - -#define ZERO_LENGTH ( LENGTH_PCB::zero() ) - -/* SAVE FILE macros */ -#define FM_LENSV "%lf" ///< format specifier for saving -#define ARG_LENSV( x ) TO_LEGACY_LU_DBL( x ) ///< argument for saving - -#else - -typedef int LENGTH_PCB; -typedef double LENGTH_PCB_DBL; - -/* transition macro stubs */ - -#define TO_LEGACY_LU( x ) ( x ) -#define TO_LEGACY_LU_DBL( x ) ( double( x ) ) - -#define FROM_LEGACY_LU( x ) ( x ) -#define FROM_LEGACY_LU_DBL( x ) ( double( x ) ) - -#define ZERO_LENGTH 0 - - -/* SAVE FILE macros */ -/** @TODO: after transition process this could be wrapped in some class */ -#define FM_LENSV "%d" -#define ARG_LENSV( x ) ( (int)( x ) ) - -#endif - - -/* LOAD FILE macros */ -#define FM_LENLD "%lf" ///< scanf format macro for loading -#define ARG_LENLD_TYPE double ///< tmp variable for length read -// they're set to flat type to help the transition process -// there would be some period while program gain ability to -// load float data but not acually save it - -#define LENGTH_LOAD_TMP( x ) ( FROM_LEGACY_LU( x ) ) ///< reads tmp value from above -#define LENGTH_LOAD_STR( s ) ( FROM_LEGACY_LU( atof( s ) ) ) ///< reads string - -/* used fo loading/saving config */ -#define LENGTH_MAX_CONFIG ( FROM_LEGACY_LU( 393700 ) ) - -#endif /* def LENGTHPCB_H_INCLUDED */ diff --git a/include/limited_int.h b/include/limited_int.h deleted file mode 100644 index 474f707417..0000000000 --- a/include/limited_int.h +++ /dev/null @@ -1,359 +0,0 @@ -/** - * @file limited_int.h - * @brief Integer class catching overflows. - */ - -/* sorry if it is not styled correctly, i'll work on it further */ - -#ifndef LIMITED_INT_H_INCLUDED -#define LIMITED_INT_H_INCLUDED 1 - -#include -#include -#include - -template < typename T = int > class LIMITED_INT { -private: - T m_Value; - -public: - LIMITED_INT( void ) : m_Value() { - } - - template LIMITED_INT( const LIMITED_INT< V >& orig ) - : m_Value( orig.m_Value ) - { - assert(std::numeric_limits::min() <= orig.m_Value); - assert(orig.m_Value <= std::numeric_limits::max()); - } - - template LIMITED_INT( const double v ) - : m_Value( floor(v+0.5) ) - { - assert(std::numeric_limits::min() <= v); - assert(v <= std::numeric_limits::max()); - } - - LIMITED_INT( T v ): m_Value( v ) - { - } - - operator T( void ) const - { - return m_Value; - } - - operator double( void ) const - { - return ( double )m_Value; - } - - LIMITED_INT & operator = ( LIMITED_INT< T > src ) - { - m_Value = src.m_Value; - return *this; - } - - LIMITED_INT & operator = ( T src ) - { - m_Value = src; - return *this; - } - - /*************************/ - /* comparisons and tests */ - /*************************/ - bool operator ! (void) const { - return !m_Value; - } - - bool operator == ( const LIMITED_INT< T > &y ) const - { - return m_Value == y.m_Value; - } - - bool operator == ( const T y ) const - { - return m_Value == y; - } - - friend bool operator == ( const T x, const LIMITED_INT< T > &y ) - { - return x == y.m_Value; - } - - bool operator != ( const LIMITED_INT &y ) const - { - return m_Value != y.m_Value; - } - - bool operator != ( const T y ) const - { - return m_Value != y; - } - - friend bool operator != ( const T x, const LIMITED_INT< T > &y ) - { - return x != y.m_Value; - } - - bool operator < ( const LIMITED_INT< T > &y ) const - { - return m_Value < y.m_Value; - } - - bool operator < ( const T y ) const - { - return m_Value < y; - } - - friend bool operator < ( const T x, const LIMITED_INT< T > &y ) - { - return x < y.m_Value; - } - - bool operator >= ( const LIMITED_INT< T > &y ) const - { - return m_Value >= y.m_Value; - } - - bool operator >= ( const T y ) const - { - return m_Value >= y; - } - - friend bool operator >= ( const T x, const LIMITED_INT &y ) - { - return x >= y.m_Value; - } - - bool operator > ( const LIMITED_INT< T > &y ) const - { - return m_Value > y.m_Value; - } - - bool operator > ( const T y ) const - { - return m_Value > y; - } - - friend bool operator > ( const T x, const LIMITED_INT< T > &y ) - { - return x > y.m_Value; - } - - bool operator <= ( const LIMITED_INT< T > &y ) const - { - return m_Value <= y.m_Value; - } - - bool operator <= ( const T y ) const - { - return m_Value <= y; - } - - friend bool operator <= ( const T x, const LIMITED_INT< T > &y ) - { - return x <= y.m_Value; - } - - /*************************/ - /* basic arithmetic */ - /*************************/ - LIMITED_INT< T > operator + ( const LIMITED_INT< T > &y ) const - { - assert( !( 0 < m_Value ) || y.m_Value <= std::numeric_limits< T >::max() - m_Value ); - assert( !( m_Value < 0 ) || std::numeric_limits< T >::min() - m_Value <= y.m_Value ); - return m_Value + y.m_Value; - } - - LIMITED_INT< T > operator + ( const T y ) const - { - return *this + LIMITED_INT< T >( y ); - } - - friend LIMITED_INT< T > operator + ( const T x, const LIMITED_INT< T > &y ) - { - return LIMITED_INT< T >( x ) + y; - } - - double operator + ( const double y ) const - { - return double( m_Value ) + y; - } - - friend double operator + ( const double x, const LIMITED_INT< T > &y ) - { - return x + double( y.m_Value ); - } - - LIMITED_INT< T > operator - ( void ) const - { - assert( -std::numeric_limits< T >::max() <= m_Value ); - return -m_Value; - } - - LIMITED_INT< T > operator - ( const LIMITED_INT< T > &y ) const - { - assert( !( 0 < m_Value ) || m_Value - std::numeric_limits< T >::max() <= y.m_Value ); - assert( !( m_Value < 0 ) || y.m_Value <= m_Value - std::numeric_limits< T >::min() ); - return m_Value - y.m_Value; - } - - LIMITED_INT< T > operator - ( const T y ) const - { - return *this - LIMITED_INT< T >( y ); - } - - friend LIMITED_INT< T > operator - ( const T x, const LIMITED_INT< T > &y ) - { - return LIMITED_INT< T >( x ) - y; - } - - double operator - ( const double y ) const - { - return double( m_Value ) - y; - } - - friend double operator - ( const double x, const LIMITED_INT< T > &y ) - { - return x - double( y.m_Value ); - } - - LIMITED_INT< T > operator * ( const LIMITED_INT< T > &y ) const - { - assert( !( 0 < m_Value && 0 < y.m_Value ) - || y.m_Value <= std::numeric_limits::max() / m_Value ); - assert( !( 0 < m_Value && y.m_Value < 0 ) - || std::numeric_limits::min() / m_Value <= y.m_Value ); - assert( !( m_Value < 0 && 0 < y.m_Value ) - || std::numeric_limits::min() / y.m_Value <= m_Value ); - assert( !( m_Value < 0 && y.m_Value < 0 ) - || std::numeric_limits::max() / m_Value <= y.m_Value ); - return m_Value * y.m_Value; - } - - LIMITED_INT operator * ( const T y) const - { - return *this * LIMITED_INT< T >( y ); - } - - friend LIMITED_INT< T > operator *( const T x, const LIMITED_INT< T > &y ) - { - return LIMITED_INT< T >( x ) * y; - } - - double operator * ( const double y ) const - { - return double( m_Value ) * y; - } - - friend double operator * ( const double x, const LIMITED_INT< T > &y ) - { - return x * double( y.m_Value ); - } - - LIMITED_INT operator / ( const LIMITED_INT &y ) const - { - assert( !( -1 == y.m_Value ) - || -std::numeric_limits< T >::max() <= m_Value ); - return m_Value / y.m_Value; - } - - LIMITED_INT operator / ( const T y ) const - { - return *this / LIMITED_INT(y); - } - - friend LIMITED_INT< T > operator / ( const T x, const LIMITED_INT< T > &y ) - { - return LIMITED_INT< T >( x ) / y; - } - - double operator / ( const double y ) const - { - return double( m_Value ) / y; - } - - friend double operator / ( const double x, const LIMITED_INT< T > &y ) - { - return x / double( y.m_Value ); - } - - LIMITED_INT operator % ( const LIMITED_INT &y ) const - { - return m_Value % y.m_Value; - } - - LIMITED_INT operator % ( const T y ) const - { - return *this % LIMITED_INT(y); - } - - friend LIMITED_INT< T > operator % ( const T x, const LIMITED_INT< T > &y ) - { - return LIMITED_INT< T >( x ) % y; - } - - LIMITED_INT< T >& operator += ( const LIMITED_INT< T > &y ) - { - *this = *this + y; - return *this; - } - - LIMITED_INT< T >& operator += ( const T y ) - { - *this = *this + y; - return *this; - } - - LIMITED_INT< T >& operator ++ ( void ) - { - *this = *this + 1; - return *this; - } - - LIMITED_INT< T >& operator -= ( const LIMITED_INT< T > &y ) - { - *this = *this - y; - return *this; - } - - LIMITED_INT< T >& operator -= ( const T y ) - { - *this = *this - y; - return *this; - } - - LIMITED_INT< T >& operator -- ( void ) - { - *this = *this - 1; - return *this; - } - - LIMITED_INT< T >& operator *= ( const LIMITED_INT< T > &y ) - { - *this = *this * y; - return *this; - } - - LIMITED_INT< T >& operator *= ( const T y ) - { - *this = *this * y; - return *this; - } - - LIMITED_INT< T >& operator /= ( const LIMITED_INT< T > &y ) - { - *this = *this / y; - return *this; - } - - LIMITED_INT< T >& operator /= ( const T y ) - { - *this = *this / y; - return *this; - } -}; - -#endif /* def LIMITED_INT_H_INCLUDED*/ diff --git a/include/macros.h b/include/macros.h index 7622df13ff..0278576eba 100644 --- a/include/macros.h +++ b/include/macros.h @@ -65,8 +65,7 @@ static inline const wxChar* GetChars( const wxString& s ) #endif #ifndef ABS -#define ABS( y ) ( MAX( ( y ), ( -y ) ) ) -// dirty trick: now this should work with LENGTH<> too +#define ABS( y ) ( (y) >= 0 ? (y) : ( -(y) ) ) #endif #define NEGATE( x ) (x = -x) diff --git a/include/param_config.h b/include/param_config.h index a8262305d5..436386fc96 100644 --- a/include/param_config.h +++ b/include/param_config.h @@ -10,7 +10,6 @@ #include "wx/fileconf.h" #include -#include "lengthpcb.h" /** Type of parameter in the configuration file */ enum paramcfg_id { @@ -86,35 +85,6 @@ public: PARAM_CFG_INT( const wxChar* ident, int* ptparam, 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 diff --git a/include/vectorpcb.h b/include/vectorpcb.h deleted file mode 100644 index 2a744e27a6..0000000000 --- a/include/vectorpcb.h +++ /dev/null @@ -1,162 +0,0 @@ -/** - * @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 */ diff --git a/pcbnew/block_module_editor.cpp b/pcbnew/block_module_editor.cpp index 5c10493dfa..056fd77d65 100644 --- a/pcbnew/block_module_editor.cpp +++ b/pcbnew/block_module_editor.cpp @@ -460,7 +460,7 @@ void MoveMarkedItems( MODULE* module, wxPoint offset ) continue; pad->SetPosition( pad->GetPosition() + offset ); - pad->m_Pos0 += FROM_LEGACY_LU_VEC( offset ); + pad->m_Pos0 += offset; } item = module->m_Drawings; @@ -538,7 +538,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) { #define SETMIRROR( z ) (z) -= offset.x; (z) = -(z); (z) += offset.x; EDA_ITEM* item; - wxPoint tmp; + if( module == NULL ) return; @@ -549,12 +549,10 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) if( pad->m_Selected == 0 ) continue; - tmp = pad->GetPosition(); - SETMIRROR( tmp.x ); - pad->SetPosition( tmp ); - 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() ); + SETMIRROR( pad->GetPosition().x ); + pad->m_Pos0.x = pad->GetPosition().x; + NEGATE( pad->m_Offset.x ); + NEGATE( pad->m_DeltaSize.x ); pad->m_Orient = 1800 - pad->m_Orient; NORMALIZE_ANGLE_POS( pad->m_Orient ); } @@ -580,9 +578,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset ) break; case PCB_MODULE_TEXT_T: - tmp = ( (TEXTE_MODULE*) item )->GetPosition(); - SETMIRROR( tmp.x ); - ( (TEXTE_MODULE*) item )->SetPosition( tmp ); + SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x ); ( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x; break; @@ -612,10 +608,9 @@ void RotateMarkedItems( MODULE* module, wxPoint offset ) { if( pad->m_Selected == 0 ) continue; - wxPoint pos = pad->GetPosition(); - ROTATE( pos ); - pad->SetPosition( pos ); - pad->m_Pos0 = FROM_LEGACY_LU_VEC( pad->GetPosition() ); + + ROTATE( pad->GetPosition() ); + pad->m_Pos0 = pad->GetPosition(); pad->m_Orient += 900; NORMALIZE_ANGLE_POS( pad->m_Orient ); } @@ -637,11 +632,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset ) break; case PCB_MODULE_TEXT_T: - { - wxPoint pos = ( (TEXTE_MODULE*) item )->m_Pos; - ROTATE( pos ); - ( (TEXTE_MODULE*) item )->m_Pos = pos; - } + ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() ); ( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition(); ( (TEXTE_MODULE*) item )->m_Orient += 900; break; diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index f99d9edac3..91f6f2d1cf 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -328,13 +328,13 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor { wxPoint corner_position; int ii, angle; - int dx = TO_LEGACY_LU( m_Size.x() / 2 ) + aClearanceValue; - int dy = TO_LEGACY_LU( m_Size.y() / 2 ) + aClearanceValue; + int dx = (m_Size.x / 2) + aClearanceValue; + int dy = (m_Size.y / 2) + aClearanceValue; int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset, * the pad position is NOT the shape position */ - wxSize psize = TO_LEGACY_LU_WXS( m_Size ); /* pad size unsed in RECT and TRAPEZOIDAL pads + wxSize psize = m_Size; /* pad size unsed in RECT and TRAPEZOIDAL pads * trapezoidal pads are considered as rect * pad shape having they boudary box size */ @@ -437,8 +437,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor default: case PAD_TRAPEZOID: - psize.x += TO_LEGACY_LU( abs( m_DeltaSize.y() ) ); - psize.y += TO_LEGACY_LU( abs( m_DeltaSize.x() ) ); + psize.x += ABS( m_DeltaSize.y ); + psize.y += ABS( m_DeltaSize.x ); // fall through case PAD_RECT: @@ -572,8 +572,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, wxPoint PadShapePos = aPad.ReturnShapePos(); /* Note: for pad having a shape offset, * the pad position is NOT the shape position */ wxSize copper_thickness; - int dx = TO_LEGACY_LU( aPad.m_Size.x() / 2 ); - int dy = TO_LEGACY_LU( aPad.m_Size.y() / 2 ); + int dx = aPad.m_Size.x / 2; + int dy = aPad.m_Size.y / 2; int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree @@ -684,8 +684,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, // Oval pad support along the lines of round and rectangular pads std::vector corners_buffer; // Polygon buffer as vector - 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 dx = (aPad.m_Size.x / 2) + aThermalGap; // Cutout radius x + int dy = (aPad.m_Size.y / 2) + aThermalGap; // Cutout radius y wxPoint shape_offset; @@ -839,8 +839,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, std::vector corners_buffer; // Polygon buffer as vector - 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 dx = (aPad.m_Size.x / 2) + aThermalGap; // Cutout radius x + int dy = (aPad.m_Size.y / 2) + aThermalGap; // Cutout radius y // The first point of polygon buffer is left lower corner, second the crosspoint of // thermal spoke sides, the third is upper right corner and the rest are rounding @@ -861,7 +861,7 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, RotatePoint( &corner_position, 1800 / aCircleToSegmentsCount ); // Start at half increment offset angle_pg = i * delta; RotatePoint( &corner_position, angle_pg ); // Rounding vector rotation - corner_position -= TO_LEGACY_LU_WXS( aPad.m_Size / 2 ); // Rounding vector + Pad corner offset + corner_position -= aPad.m_Size / 2; // Rounding vector + Pad corner offset corners_buffer.push_back( wxPoint( corner_position.x, corner_position.y ) ); } diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 6560d3e2a7..1810ed99c2 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -20,8 +20,6 @@ #include "class_zone.h" #include "class_marker_pcb.h" -#include "lengthpcb.h" - /* This is an odd place for this, but CvPcb won't link if it is * in class_board_item.cpp like I first tried it. @@ -239,22 +237,21 @@ bool BOARD::SetCurrentNetClass( const wxString& aNetClassName ) if( m_TrackWidthList.size() == 0 ) { lists_sizes_modified = true; - m_TrackWidthList.push_back( ZERO_LENGTH ); + m_TrackWidthList.push_back( 0 ); } /* note the m_ViasDimensionsList[0] and m_TrackWidthList[0] values * are always the Netclass values */ - if( TO_LEGACY_LU( m_ViasDimensionsList[0].m_Diameter ) != netClass->GetViaDiameter() ) + if( m_ViasDimensionsList[0].m_Diameter != netClass->GetViaDiameter() ) lists_sizes_modified = true; - m_ViasDimensionsList[0].m_Diameter = FROM_LEGACY_LU( netClass->GetViaDiameter() ); + m_ViasDimensionsList[0].m_Diameter = netClass->GetViaDiameter(); - /* NOTE: equality comparison on real values is bad... */ - if( TO_LEGACY_LU( m_TrackWidthList[0] ) != netClass->GetTrackWidth() ) + if( m_TrackWidthList[0] != netClass->GetTrackWidth() ) lists_sizes_modified = true; - m_TrackWidthList[0] = FROM_LEGACY_LU( netClass->GetTrackWidth() ); + m_TrackWidthList[0] = netClass->GetTrackWidth(); if( m_ViaSizeSelector >= m_ViasDimensionsList.size() ) m_ViaSizeSelector = m_ViasDimensionsList.size(); @@ -647,13 +644,13 @@ bool BOARD::IsModuleLayerVisible( int layer ) -const wxPoint BOARD::GetPosition() const +wxPoint& BOARD::GetPosition() { - return wxPoint ( 0, 0 ); + static wxPoint dummy( 0, 0 ); + + return dummy; // a reference } -void BOARD::SetPosition( const wxPoint& pos ) { -} void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl ) { @@ -1668,7 +1665,7 @@ D_PAD* BOARD::GetPadFast( const wxPoint& aPosition, int aLayerMask ) { D_PAD* pad = m_NetInfo->GetPad(i); - if( TO_LEGACY_LU_WXP( pad->m_Pos ) != aPosition ) + if( pad->m_Pos != aPosition ) continue; /* Pad found, it must be on the correct layer */ @@ -1699,7 +1696,7 @@ D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, i D_PAD* pad = aPadList[idx]; - if( TO_LEGACY_LU_WXP( pad->m_Pos ) == aPosition ) // candidate found + if( pad->m_Pos == aPosition ) // candidate found { // The pad must match the layer mask: if( (aLayerMask & pad->m_layerMask) != 0 ) @@ -1712,7 +1709,7 @@ D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, i for( int ii = idx+1; ii <= idxmax; ii++ ) { pad = aPadList[ii]; - if( TO_LEGACY_LU_WXP( pad->m_Pos ) != aPosition ) + if( pad->m_Pos != aPosition ) break; if( (aLayerMask & pad->m_layerMask) != 0 ) return pad; @@ -1721,7 +1718,7 @@ D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, i for( int ii = idx-1 ;ii >=0; ii-- ) { pad = aPadList[ii]; - if( TO_LEGACY_LU_WXP( pad->m_Pos ) != aPosition ) + if( pad->m_Pos != aPosition ) break; if( (aLayerMask & pad->m_layerMask) != 0 ) return pad; @@ -1731,9 +1728,9 @@ D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, i return 0; } - if( TO_LEGACY_LU( pad->m_Pos.x() ) == aPosition.x ) // Must search considering Y coordinate + if( pad->m_Pos.x == aPosition.x ) // Must search considering Y coordinate { - if( TO_LEGACY_LU( pad->m_Pos.y() ) < aPosition.y ) // Must search after this item + if(pad->m_Pos.y < aPosition.y) // Must search after this item { idx += delta; if( idx > idxmax ) @@ -1746,7 +1743,7 @@ D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, i idx = 0; } } - else if( TO_LEGACY_LU( pad->m_Pos.x() ) < aPosition.x ) // Must search after this item + else if( pad->m_Pos.x < aPosition.x ) // Must search after this item { idx += delta; if( idx > idxmax ) @@ -1770,9 +1767,9 @@ D_PAD* BOARD::GetPad( std::vector& aPadList, const wxPoint& aPosition, i */ static bool sortPadsByXthenYCoord( D_PAD* const & ref, D_PAD* const & comp ) { - if( ref->m_Pos.x() == comp->m_Pos.x() ) - return ref->m_Pos.y() < comp->m_Pos.y(); - return 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.x < comp->m_Pos.x; } @@ -2003,13 +2000,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, if( track->GetState( BEGIN_ONPAD ) ) { D_PAD * pad = (D_PAD *) track->start; - lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie ); + lenDie += (double) pad->m_LengthDie; } if( track->GetState( END_ONPAD ) ) { D_PAD * pad = (D_PAD *) track->end; - lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie ); + lenDie += (double) pad->m_LengthDie; } } } @@ -2033,13 +2030,13 @@ TRACK* BOARD::MarkTrace( TRACK* aTrace, if( track->GetState( BEGIN_ONPAD ) ) { D_PAD * pad = (D_PAD *) track->start; - lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie ); + lenDie += (double) pad->m_LengthDie; } if( track->GetState( END_ONPAD ) ) { D_PAD * pad = (D_PAD *) track->end; - lenDie += TO_LEGACY_LU_DBL( pad->m_LengthDie ); + lenDie += (double) pad->m_LengthDie; } } } diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index fd91b05426..0baf68968e 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -9,14 +9,12 @@ #include "dlist.h" -#include "lengthpcb.h" - #include "layers_id_colors_and_visibility.h" #include "class_netinfo.h" #include "class_pad.h" #include "class_colors_design_settings.h" #include "class_board_design_settings.h" -#include "class_via_dimension.h" + class PCB_BASE_FRAME; class PCB_EDIT_FRAME; @@ -82,6 +80,35 @@ struct LAYER }; +/** a small helper class to handle a stock of specific vias diameter and drill pair + * in the BOARD class + */ +class VIA_DIMENSION +{ +public: + int m_Diameter; // <= 0 means use Netclass via diameter + int m_Drill; // <= 0 means use Netclass via drill + + VIA_DIMENSION() + { + m_Diameter = 0; m_Drill = 0; + } + + + bool operator ==( const VIA_DIMENSION& other ) const + { + return (m_Diameter == other.m_Diameter) && (m_Drill == other.m_Drill); + } + + + bool operator <( const VIA_DIMENSION& other ) const + { + if( m_Diameter != other.m_Diameter ) + return m_Diameter < other.m_Diameter; + + return m_Drill < other.m_Drill; + } +}; // Helper class to handle high light nets @@ -179,7 +206,7 @@ public: // The first value is the current netclass via size // tracks widths (max count = HISTORY_MAX_COUNT) // The first value is the current netclass track width - std::vector m_TrackWidthList; + std::vector m_TrackWidthList; /// Index for m_ViaSizeList to select the value. /// 0 is the index selection of the default value Netclass @@ -226,9 +253,7 @@ public: * is a dummy. * @return const wxPoint& of (0,0) */ - const wxPoint GetPosition() const; - - void SetPosition( const wxPoint& pos ); + wxPoint& GetPosition(); /** * Function Add @@ -743,7 +768,7 @@ public: */ int GetCurrentTrackWidth() { - return TO_LEGACY_LU( m_TrackWidthList[m_TrackWidthSelector] ); + return m_TrackWidthList[m_TrackWidthSelector]; } @@ -755,7 +780,7 @@ public: */ int GetCurrentViaSize() { - return TO_LEGACY_LU( m_ViasDimensionsList[m_ViaSizeSelector].m_Diameter ); + return m_ViasDimensionsList[m_ViaSizeSelector].m_Diameter; } @@ -767,8 +792,8 @@ public: */ int GetCurrentViaDrill() { - int drill = TO_LEGACY_LU( m_ViasDimensionsList[m_ViaSizeSelector].m_Drill ); - return drill > 0 ? drill : -1; + return m_ViasDimensionsList[m_ViaSizeSelector].m_Drill > 0 ? + m_ViasDimensionsList[m_ViaSizeSelector].m_Drill : -1; } diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index 4bbbbb5174..1950c32978 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -32,13 +32,11 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() m_EdgeSegmentWidth = 100; // current graphic line width (EDGE layer only) m_PcbTextWidth = 100; // current Pcb (not module) Text width m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size - m_TrackMinWidth = FROM_LEGACY_LU( 80 ); // track min value for width ((min copper size value - m_MinVia = VIA_DIMENSION( FROM_LEGACY_LU( 350 ), FROM_LEGACY_LU( 200 ) ); - m_MinMicroVia = VIA_DIMENSION( FROM_LEGACY_LU( 200 ), FROM_LEGACY_LU( 50 ) ); - //m_ViasMinSize = FROM_LEGACY_LU( 350 ); // vias (not micro vias) min diameter - //m_ViasMinDrill = FROM_LEGACY_LU( 200 ); // vias (not micro vias) min drill diameter - //m_MicroViasMinSize = FROM_LEGACY_LU( 200 ); // micro vias (not vias) min diameter - //m_MicroViasMinDrill = FROM_LEGACY_LU( 50 ); // micro vias (not vias) min drill diameter + m_TrackMinWidth = 80; // track min value for width ((min copper size value + m_ViasMinSize = 350; // vias (not micro vias) min diameter + m_ViasMinDrill = 200; // vias (not micro vias) min drill diameter + m_MicroViasMinSize = 200; // micro vias (not vias) min diameter + m_MicroViasMinDrill = 50; // micro vias (not vias) min drill diameter // Global mask margins: m_SolderMaskMargin = 150; // Solder mask margin diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 2d617ae197..e2cc04e175 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -37,15 +37,11 @@ public: DIMENSION( BOARD_ITEM* aParent ); ~DIMENSION(); - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Pos; } - void SetPosition( const wxPoint& pos ) { - m_Pos = pos; - } - /** * Function SetLayer * sets the layer this item is on. diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index de1772da16..4da03f3e62 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -44,17 +44,13 @@ public: * Function GetPosition * returns the position of this object. * Required by pure virtual BOARD_ITEM::GetPosition() - * @return const wxPoint - The position of this object. + * @return const wxPoint& - The position of this object. */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Start; } - void SetPosition( const wxPoint& pos ) { - m_Start = pos; - } - /** * Function GetStart * returns the starting point of the graphic diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index f6c7a2dcb3..2396061164 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -81,14 +81,11 @@ public: * Function GetPosition * returns the position of this MARKER_PCB. */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { - return m_Pos; + return (wxPoint&) m_Pos; } - void SetPosition( const wxPoint& pos ) { - m_Pos = pos; - } /** * Function HitTest diff --git a/pcbnew/class_mire.h b/pcbnew/class_mire.h index 4cd6fe29f1..8106a3874b 100644 --- a/pcbnew/class_mire.h +++ b/pcbnew/class_mire.h @@ -30,14 +30,11 @@ public: PCB_TARGET* Next() const { return (PCB_TARGET*) Pnext; } PCB_TARGET* Back() const { return (PCB_TARGET*) Pnext; } - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Pos; } - void SetPosition( const wxPoint& pos ) { - m_Pos = pos; - } /** * Function Move diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 280a1451b6..9715d74a4e 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -534,10 +534,9 @@ int MODULE::ReadDescr( LINE_READER* aReader ) { D_PAD* pad = new D_PAD( this ); pad->ReadDescr( aReader ); - wxPoint pos = TO_LEGACY_LU_WXP( pad->m_Pos ); - RotatePoint( &pos, m_Orient ); - pad->m_Pos = FROM_LEGACY_LU_VEC( pos ); - pad->m_Pos += FROM_LEGACY_LU_VEC( m_Pos ); + RotatePoint( &pad->m_Pos, m_Orient ); + pad->m_Pos.x += m_Pos.x; + pad->m_Pos.y += m_Pos.y; m_Pads.PushBack( pad ); continue; diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 5964e61395..881b9d1f3e 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -135,9 +135,9 @@ public: * Function GetPosition * returns the position of this object. * Required by pure virtual BOARD_ITEM::GetPosition() - * @return const wxPoint - The position of this object. + * @return const wxPoint& - The position of this object. */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Pos; } diff --git a/pcbnew/class_module_transform_functions.cpp b/pcbnew/class_module_transform_functions.cpp index 79d4eb1a07..79afa57d46 100644 --- a/pcbnew/class_module_transform_functions.cpp +++ b/pcbnew/class_module_transform_functions.cpp @@ -183,24 +183,12 @@ void MODULE::Flip(const wxPoint& aCentre ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { - LENGTH_PCB tmpy = pt_pad->m_Pos.y(); - tmpy -= FROM_LEGACY_LU( m_Pos.y ); - tmpy = -tmpy; - tmpy += FROM_LEGACY_LU( m_Pos.y ); - pt_pad->m_Pos.y( tmpy ); - - 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 ); - + pt_pad->m_Pos.y -= m_Pos.y; + pt_pad->m_Pos.y = -pt_pad->m_Pos.y; + pt_pad->m_Pos.y += m_Pos.y; + NEGATE( pt_pad->m_Pos0.y ); + NEGATE( pt_pad->m_Offset.y ); + NEGATE( pt_pad->m_DeltaSize.y ); NEGATE_AND_NORMALIZE_ANGLE_POS( pt_pad->m_Orient ); /* flip pads layers*/ @@ -320,7 +308,7 @@ void MODULE::SetPosition( const wxPoint& newpos ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { - pad->m_Pos += FROM_LEGACY_LU_VEC( delta ); + pad->m_Pos += delta; } EDA_ITEM* PtStruct = m_Drawings; @@ -364,15 +352,15 @@ void MODULE::SetOrientation( int newangle ) for( D_PAD* pad = m_Pads; pad; pad = pad->Next() ) { - px = TO_LEGACY_LU( pad->m_Pos0.x() ); - py = TO_LEGACY_LU( pad->m_Pos0.y() ); + px = pad->m_Pos0.x; + py = pad->m_Pos0.y; pad->m_Orient += newangle; /* change m_Orientation */ NORMALIZE_ANGLE_POS( pad->m_Orient ); RotatePoint( &px, &py, m_Orient ); - pad->m_Pos.x( FROM_LEGACY_LU( m_Pos.x + px ) ); - pad->m_Pos.y( FROM_LEGACY_LU( m_Pos.y + py ) ); + pad->m_Pos.x = m_Pos.x + px; + pad->m_Pos.y = m_Pos.y + py; } /* Update of the reference and value. */ diff --git a/pcbnew/class_netclass.cpp b/pcbnew/class_netclass.cpp index c761fc4c12..2f10f27553 100644 --- a/pcbnew/class_netclass.cpp +++ b/pcbnew/class_netclass.cpp @@ -42,8 +42,8 @@ extern BOARD_DESIGN_SETTINGS boardDesignSettings; const wxString NETCLASS::Default = wxT("Default"); // Initial values for netclass initialization int NETCLASS::DEFAULT_CLEARANCE = 100; // track to track and track to pads clearance -int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill (TODO: should be gone on refactoring) -int NETCLASS::DEFAULT_UVIA_DRILL = 50; // micro via drill (TODO: --"--) +int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill +int NETCLASS::DEFAULT_UVIA_DRILL = 50; // micro via drill NETCLASS::NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initialParameters ) : @@ -55,39 +55,36 @@ NETCLASS::NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initi SetParams( initialParameters ); } + void NETCLASS::SetParams( const NETCLASS* defaults ) { if( defaults ) { SetClearance( defaults->GetClearance() ); SetTrackWidth( defaults->GetTrackWidth() ); - Via( defaults->Via() ); - MicroVia( defaults->MicroVia() ); + SetViaDiameter( defaults->GetViaDiameter() ); + SetViaDrill( defaults->GetViaDrill() ); + SetuViaDiameter( defaults->GetuViaDiameter() ); + SetuViaDrill( defaults->GetuViaDrill() ); } else - { - SetToDefault(); + { // We should use m_Parent->GetBoardDesignSettings() + // But when the NETCLASSES constructor is called + // (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD) + // is not run, and GetBoardDesignSettings() return a bad value + // TODO: see how change that. + const BOARD_DESIGN_SETTINGS& g = boardDesignSettings; + + SetTrackWidth( g.m_TrackMinWidth ); + SetViaDiameter( g.m_ViasMinSize ); + SetuViaDiameter(g.m_MicroViasMinSize ); + // Use default values for next parameters: + SetClearance( DEFAULT_CLEARANCE ); + SetViaDrill( DEFAULT_VIA_DRILL ); + SetuViaDrill( DEFAULT_UVIA_DRILL ); } } -void NETCLASS::SetToDefault() -{ - // We should use m_Parent->GetBoardDesignSettings() - // But when the NETCLASSES constructor is called - // (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD) - // is not run, and GetBoardDesignSettings() return a bad value - // TODO: see how change that. - const BOARD_DESIGN_SETTINGS& g = boardDesignSettings; - - TrackWidth( g.m_TrackMinWidth ); - - //SetViaDrill( TO_LEGACY_LU( g.m_ViasMinDrill ) ); // was DEFAULT_VIA_DRILL - //SetuViaDrill( TO_LEGACY_LU( g.m_MicroViasMinDrill ) ); // DEFAULT_UVIA_DRILL - Via( g.m_MinVia ); - MicroVia( g.m_MinMicroVia ); - // Use default values for next parameters: - Clearance( FROM_LEGACY_LU( DEFAULT_CLEARANCE ) ); -} NETCLASS::~NETCLASS() { @@ -297,14 +294,14 @@ bool NETCLASS::Save( FILE* aFile ) const // Write parameters - fprintf( aFile, "Clearance %f\n", TO_LEGACY_LU_DBL( Clearance() ) ); - fprintf( aFile, "TrackWidth %f\n", TO_LEGACY_LU_DBL( TrackWidth() ) ); + fprintf( aFile, "Clearance %d\n", GetClearance() ); + fprintf( aFile, "TrackWidth %d\n", GetTrackWidth() ); - fprintf( aFile, "ViaDia %f\n", TO_LEGACY_LU_DBL( Via().m_Diameter ) ); - fprintf( aFile, "ViaDrill %f\n", TO_LEGACY_LU_DBL( Via().m_Drill ) ); + fprintf( aFile, "ViaDia %d\n", GetViaDiameter() ); + fprintf( aFile, "ViaDrill %d\n", GetViaDrill() ); - fprintf( aFile, "uViaDia %f\n", TO_LEGACY_LU_DBL( MicroVia().m_Diameter ) ); - fprintf( aFile, "uViaDrill %f\n", TO_LEGACY_LU_DBL( MicroVia().m_Drill ) ); + fprintf( aFile, "uViaDia %d\n", GetuViaDiameter() ); + fprintf( aFile, "uViaDrill %d\n", GetuViaDrill() ); // Write members: for( const_iterator i = begin(); i!=end(); ++i ) @@ -345,8 +342,6 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader ) char* Line; char Buffer[1024]; wxString netname; - VIA_DIMENSION via = Via(); - VIA_DIMENSION uvia = MicroVia(); while( aReader->ReadLine() ) { @@ -367,37 +362,33 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader ) if( strnicmp( Line, "Clearance", 9 ) == 0 ) { - Clearance( FROM_LEGACY_LU( atof( Line + 9 ) ) ); + SetClearance( atoi( Line + 9 ) ); continue; } if( strnicmp( Line, "TrackWidth", 10 ) == 0 ) { - TrackWidth( FROM_LEGACY_LU( atof( Line + 10 ) ) ); + SetTrackWidth( atoi( Line + 10 ) ); continue; } if( strnicmp( Line, "ViaDia", 6 ) == 0 ) { - via.m_Diameter = FROM_LEGACY_LU( atof( Line + 6 ) ); - Via(via); + SetViaDiameter( atoi( Line + 6 ) ); continue; } if( strnicmp( Line, "ViaDrill", 8 ) == 0 ) { - via.m_Drill = FROM_LEGACY_LU( atof( Line + 8 ) ); - Via(via); + SetViaDrill( atoi( Line + 8 ) ); continue; } if( strnicmp( Line, "uViaDia", 7 ) == 0 ) { - uvia.m_Diameter = FROM_LEGACY_LU( atof( Line + 7 ) ); - MicroVia(uvia); + SetuViaDiameter( atoi( Line + 7 ) ); continue; } if( strnicmp( Line, "uViaDrill", 9 ) == 0 ) { - uvia.m_Drill = FROM_LEGACY_LU( atof( Line + 9 ) ); - MicroVia(uvia); + SetuViaDrill( atoi( Line + 9 ) ); continue; } @@ -421,27 +412,27 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader ) int NETCLASS::GetTrackMinWidth() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_TrackMinWidth ); + return m_Parent->GetBoardDesignSettings()->m_TrackMinWidth; } int NETCLASS::GetViaMinDiameter() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinVia.m_Diameter ); + return m_Parent->GetBoardDesignSettings()->m_ViasMinSize; } int NETCLASS::GetViaMinDrill() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinVia.m_Drill ); + return m_Parent->GetBoardDesignSettings()->m_ViasMinDrill; } int NETCLASS::GetuViaMinDiameter() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ); + return m_Parent->GetBoardDesignSettings()->m_MicroViasMinSize; } int NETCLASS::GetuViaMinDrill() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinMicroVia.m_Drill ); + return m_Parent->GetBoardDesignSettings()->m_MicroViasMinDrill; } diff --git a/pcbnew/class_netclass.h b/pcbnew/class_netclass.h index 015c1cffc3..8dc981b4c6 100644 --- a/pcbnew/class_netclass.h +++ b/pcbnew/class_netclass.h @@ -36,9 +36,6 @@ #include -#include "lengthpcb.h" - -#include "class_via_dimension.h" class LINE_READER; class BOARD; @@ -70,12 +67,14 @@ protected: /// The units on these parameters is 1/10000 of an inch, see define #PCB_INTERNAL_UNIT - LENGTH_PCB m_Clearance; ///< clearance when routing + int m_Clearance; ///< clearance when routing - LENGTH_PCB m_TrackWidth; ///< track width used to route NETs in this NETCLASS - - VIA_DIMENSION m_Via; ///< Specific normal via - VIA_DIMENSION m_uVia; ///< Specific microvia + int m_TrackWidth; ///< track width used to route NETs in this NETCLASS + int m_ViaDia; ///< via diameter + int m_ViaDrill; ///< via drill hole diameter + + int m_uViaDia; ///< microvia diameter + int m_uViaDrill; ///< microvia drill hole diameter public: @@ -172,40 +171,29 @@ public: const wxString& GetDescription() const { return m_Description; } void SetDescription( const wxString& aDesc ) { m_Description = aDesc; } - int GetClearance() const { return TO_LEGACY_LU( m_Clearance ); } - void SetClearance( int aClearance ) { m_Clearance = FROM_LEGACY_LU( aClearance ); } + int GetClearance() const { return m_Clearance; } + void SetClearance( int aClearance ) { m_Clearance = aClearance; } - int GetTrackWidth() const { return TO_LEGACY_LU( m_TrackWidth ); } + int GetTrackWidth() const { return m_TrackWidth; } int GetTrackMinWidth() const; - void SetTrackWidth( int aWidth ) { m_TrackWidth = FROM_LEGACY_LU( aWidth ); } - - int GetViaDiameter() const { return TO_LEGACY_LU( m_Via.m_Diameter ); } + void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; } + + int GetViaDiameter() const { return m_ViaDia; } int GetViaMinDiameter() const; - void SetViaDiameter( int aDia ) { m_Via.m_Diameter = FROM_LEGACY_LU( aDia ); } + void SetViaDiameter( int aDia ) { m_ViaDia = aDia; } - int GetViaDrill() const { return TO_LEGACY_LU( m_Via.m_Drill ); } + int GetViaDrill() const { return m_ViaDrill; } int GetViaMinDrill() const; - void SetViaDrill( int aSize ) { m_Via.m_Drill = FROM_LEGACY_LU( aSize ); } + void SetViaDrill( int aSize ) { m_ViaDrill = aSize; } - int GetuViaDiameter() const { return TO_LEGACY_LU( m_uVia.m_Diameter ); } + int GetuViaDiameter() const { return m_uViaDia; } int GetuViaMinDiameter() const; - void SetuViaDiameter( int aSize ) { m_uVia.m_Diameter = FROM_LEGACY_LU( aSize ); } + void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; } - int GetuViaDrill() const { return TO_LEGACY_LU( m_uVia.m_Drill ); } + int GetuViaDrill() const { return m_uViaDrill; } int GetuViaMinDrill() const; - void SetuViaDrill( int aSize ) { m_uVia.m_Drill = FROM_LEGACY_LU( aSize ); } + void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; } - LENGTH_PCB Clearance() const { return m_Clearance; } - LENGTH_PCB Clearance( const LENGTH_PCB a ) { return m_Clearance = a; } - - LENGTH_PCB TrackWidth() const { return m_TrackWidth; } - LENGTH_PCB TrackWidth( const LENGTH_PCB a ) { return m_TrackWidth = a; } - - VIA_DIMENSION Via() const { return m_Via; } - VIA_DIMENSION Via( const VIA_DIMENSION a ) { return m_Via = a; } - - VIA_DIMENSION MicroVia() const { return m_uVia; } - VIA_DIMENSION MicroVia( const VIA_DIMENSION a ) { return m_uVia = a; } /** * Function SetParams @@ -216,11 +204,6 @@ public: */ void SetParams( const NETCLASS* defaults = NULL ); - /** - * Sets Parameters to their default state. - */ - void SetToDefault(); - /** * Function Save * writes the data structures for this object out to a FILE in "*.brd" format. diff --git a/pcbnew/class_netinfo_item.cpp b/pcbnew/class_netinfo_item.cpp index 203b30c84d..ec0689de0d 100644 --- a/pcbnew/class_netinfo_item.cpp +++ b/pcbnew/class_netinfo_item.cpp @@ -153,7 +153,7 @@ void NETINFO_ITEM::DisplayInfo( EDA_DRAW_FRAME* frame ) if( pad->GetNet() == GetNet() ) { count++; - lengthdie += TO_LEGACY_LU_DBL( pad->m_LengthDie ); + lengthdie += pad->m_LengthDie; } } } @@ -224,6 +224,6 @@ void RATSNEST_ITEM::Draw( EDA_DRAW_PANEL* panel, { GRSetDrawMode( DC, aDrawMode ); int color = g_ColorsSettings.GetItemColor(RATSNEST_VISIBLE); - GRLine( &panel->m_ClipBox, DC, TO_LEGACY_LU_WXP( m_PadStart->m_Pos ) - aOffset, - TO_LEGACY_LU_WXP( m_PadEnd->m_Pos ) - aOffset, 0, color ); + GRLine( &panel->m_ClipBox, DC, m_PadStart->m_Pos - aOffset, + m_PadEnd->m_Pos - aOffset, 0, color ); } diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 081699eeef..e73408a2fb 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -27,23 +27,22 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, PCB_PAD_T ) { m_NumPadName = 0; - m_Size[0] = m_Size[1] = FROM_LEGACY_LU( 500 ); // give it a reasonable size - /// TODO: remove hardcoded constant + m_Size.x = m_Size.y = 500; // give it a reasonable size m_Orient = 0; // Pad rotation in 1/10 degrees - m_LengthDie = ZERO_LENGTH; + m_LengthDie = 0; if( m_Parent && (m_Parent->Type() == PCB_MODULE_T) ) { - m_Pos = FROM_LEGACY_LU_VEC( ( (MODULE*) m_Parent )->GetPosition() ); + m_Pos = ( (MODULE*) m_Parent )->GetPosition(); } m_PadShape = PAD_CIRCLE; // Shape: PAD_CIRCLE, PAD_RECT PAD_OVAL // PAD_TRAPEZOID m_Attribut = PAD_STANDARD; // Type: NORMAL, PAD_SMD, PAD_CONN m_DrillShape = PAD_CIRCLE; // Drill shape = circle - m_LocalClearance = ZERO_LENGTH; - m_LocalSolderMaskMargin = ZERO_LENGTH; - m_LocalSolderPasteMargin = ZERO_LENGTH; + m_LocalClearance = 0; + m_LocalSolderMaskMargin = 0; + m_LocalSolderPasteMargin = 0; m_LocalSolderPasteMarginRatio = 0.0; m_layerMask = PAD_STANDARD_DEFAULT_LAYERS; // set layers mask to // default for a standard pad @@ -68,23 +67,21 @@ int D_PAD::GetMaxRadius() const switch( m_PadShape & 0x7F ) { case PAD_CIRCLE: - radius = TO_LEGACY_LU( m_Size.x() / 2 ); + radius = m_Size.x / 2; break; case PAD_OVAL: - radius = TO_LEGACY_LU( max( m_Size.x(), m_Size.y() ) / 2 ); + radius = MAX( m_Size.x, m_Size.y ) / 2; break; case PAD_RECT: - x = TO_LEGACY_LU( m_Size.x() ); - y = TO_LEGACY_LU( m_Size.y() ); - radius = 1 + (int) ( sqrt( (double) y * y - + (double) x * x ) / 2 ); + radius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y + + (double) m_Size.x * m_Size.x ) / 2 ); break; case PAD_TRAPEZOID: - 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 + x = m_Size.x + ABS( m_DeltaSize.y ); // Remember: m_DeltaSize.y is the m_Size.x change + y = 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 ); break; @@ -114,7 +111,7 @@ EDA_RECT D_PAD::GetBoundingBox() const EDA_RECT area; int radius = GetMaxRadius(); // Calculate the radius of the area, considered as a circle - area.SetOrigin( TO_LEGACY_LU_WXP( m_Pos ) ); + area.SetOrigin( m_Pos ); area.Inflate( radius ); return area; @@ -124,19 +121,19 @@ EDA_RECT D_PAD::GetBoundingBox() const // Returns the position of the pad. const wxPoint D_PAD::ReturnShapePos() { - if( m_Offset[0] == ZERO_LENGTH && m_Offset[0] == ZERO_LENGTH ) - return TO_LEGACY_LU_WXP( m_Pos ); + if( m_Offset.x == 0 && m_Offset.y == 0 ) + return m_Pos; wxPoint shape_pos; int dX, dY; - dX = TO_LEGACY_LU( m_Offset[0] ); - dY = TO_LEGACY_LU( m_Offset[1] ); + dX = m_Offset.x; + dY = m_Offset.y; RotatePoint( &dX, &dY, m_Orient ); - shape_pos.x = TO_LEGACY_LU( m_Pos.x() ) + dX; - shape_pos.y = TO_LEGACY_LU( m_Pos.y() ) + dY; + shape_pos.x = m_Pos.x + dX; + shape_pos.y = m_Pos.y + dY; return shape_pos; } @@ -245,11 +242,10 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const { // A pad can have specific clearance parameters that // overrides its NETCLASS clearance value - int clearance = TO_LEGACY_LU( m_LocalClearance ); + int clearance = m_LocalClearance; if( clearance == 0 ) { // If local clearance is 0, use the parent footprint clearance value - /// @BUG unsafe type cast style if( GetParent() && ( (MODULE*) GetParent() )->m_LocalClearance ) clearance = ( (MODULE*) GetParent() )->m_LocalClearance; } @@ -283,7 +279,7 @@ int D_PAD::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const */ int D_PAD::GetSolderMaskMargin() { - int margin = TO_LEGACY_LU( m_LocalSolderMaskMargin ); + int margin = m_LocalSolderMaskMargin; MODULE * module = (MODULE*) GetParent(); if( module ) @@ -304,7 +300,7 @@ int D_PAD::GetSolderMaskMargin() // ensure mask have a size always >= 0 if( margin < 0 ) { - int minsize = TO_LEGACY_LU( -min( m_Size.x(), m_Size.y() ) / 2 ); + int minsize = -MIN( m_Size.x, m_Size.y ) / 2; if( margin < minsize ) minsize = minsize; @@ -325,7 +321,7 @@ int D_PAD::GetSolderMaskMargin() */ wxSize D_PAD::GetSolderPasteMargin() { - int margin = TO_LEGACY_LU( m_LocalSolderPasteMargin ); + int margin = m_LocalSolderPasteMargin; double mratio = m_LocalSolderPasteMarginRatio; MODULE * module = (MODULE*) GetParent(); @@ -349,15 +345,15 @@ wxSize D_PAD::GetSolderPasteMargin() } wxSize pad_margin; - 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.x = margin + wxRound( m_Size.x * mratio ); + pad_margin.y = margin + wxRound( m_Size.y * mratio ); // ensure mask have a size always >= 0 - if( pad_margin.x < TO_LEGACY_LU( -m_Size.x() / 2 ) ) - pad_margin.x = TO_LEGACY_LU( -m_Size.x() / 2 ); + if( pad_margin.x < -m_Size.x / 2 ) + pad_margin.x = -m_Size.x / 2; - if( pad_margin.y < TO_LEGACY_LU( -m_Size.y() / 2 ) ) - pad_margin.y = TO_LEGACY_LU( -m_Size.y() / 2 ); + if( pad_margin.y < -m_Size.y / 2 ) + pad_margin.y = -m_Size.y / 2; return pad_margin; } @@ -379,8 +375,7 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) char* Line; char BufLine[1024], BufCar[256]; char* PtLine; - int nn, ll; - ARG_LENLD_TYPE sx, sy, ox, oy, dr, dx, dy; + int nn, ll, dx, dy; while( aReader->ReadLine() ) { @@ -422,14 +417,11 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) if( *PtLine == '"' ) PtLine++; - nn = sscanf( PtLine, " %s "FM_LENLD" "FM_LENLD" "FM_LENLD" "FM_LENLD" %d", - BufCar, &sx, &sy, - &dx, &dy, + nn = sscanf( PtLine, " %s %d %d %d %d %d", + BufCar, &m_Size.x, &m_Size.y, + &m_DeltaSize.x, &m_DeltaSize.y, &m_Orient ); - m_Size.x( LENGTH_LOAD_TMP( sx ) ); - m_Size.y( LENGTH_LOAD_TMP( sy ) ); - m_DeltaSize.x( LENGTH_LOAD_TMP( dx ) ); - m_DeltaSize.y( LENGTH_LOAD_TMP( dy ) ); + ll = 0xFF & BufCar[0]; /* Read pad shape */ @@ -455,20 +447,16 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) case 'D': BufCar[0] = 0; - nn = sscanf( PtLine, FM_LENLD" "FM_LENLD" "FM_LENLD" %s "FM_LENLD" "FM_LENLD, &dr, - &ox, &oy, BufCar, &dx, &dy ); - m_Offset.x( LENGTH_LOAD_TMP( ox ) ); - m_Offset.y( LENGTH_LOAD_TMP( oy ) ); - m_Drill.x( LENGTH_LOAD_TMP( dr ) ); - m_Drill.y( m_Drill.x() ); + nn = sscanf( PtLine, "%d %d %d %s %d %d", &m_Drill.x, + &m_Offset.x, &m_Offset.y, BufCar, &dx, &dy ); + m_Drill.y = m_Drill.x; m_DrillShape = PAD_CIRCLE; if( nn >= 6 ) // Drill shape = OVAL ? { if( BufCar[0] == 'O' ) { - m_Drill.x( FROM_LEGACY_LU( dx ) ); - m_Drill.y( FROM_LEGACY_LU( dy ) ); + m_Drill.x = dx; m_Drill.y = dy; m_DrillShape = PAD_OVAL; } } @@ -476,7 +464,7 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) break; case 'A': - nn = sscanf( PtLine, "%s %s %X", BufLine, BufCar, /// @BUG Stack overflow vulnerability! + nn = sscanf( PtLine, "%s %s %X", BufLine, BufCar, &m_layerMask ); /* BufCar is not used now update attributes */ @@ -503,25 +491,25 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) break; case 'P': - nn = sscanf( PtLine, FM_LENLD" "FM_LENLD, &ox, &oy ); - m_Pos0 = VECTOR_PCB::fromXY( LENGTH_LOAD_TMP( ox ), LENGTH_LOAD_TMP( oy ) ); + nn = sscanf( PtLine, "%d %d", &m_Pos0.x, &m_Pos0.y ); m_Pos = m_Pos0; break; case 'L': - nn = sscanf( PtLine, FM_LENLD, &ox ); - m_LengthDie = LENGTH_LOAD_TMP( ox ); + int lengthdie; + nn = sscanf( PtLine, "%d", &lengthdie ); + m_LengthDie = lengthdie; break; case '.': /* Read specific data */ if( strnicmp( Line, ".SolderMask ", 12 ) == 0 ) - m_LocalSolderMaskMargin = FROM_LEGACY_LU( atof( Line + 12 ) ); + m_LocalSolderMaskMargin = atoi( Line + 12 ); else if( strnicmp( Line, ".SolderPaste ", 13 ) == 0 ) - m_LocalSolderPasteMargin = FROM_LEGACY_LU( atoi( Line + 13 ) ); + m_LocalSolderPasteMargin = atoi( Line + 13 ); else if( strnicmp( Line, ".SolderPasteRatio ", 18 ) == 0 ) m_LocalSolderPasteMarginRatio = atoi( Line + 18 ); else if( strnicmp( Line, ".LocalClearance ", 16 ) == 0 ) - m_LocalClearance = FROM_LEGACY_LU( atof( Line + 16 ) ); + m_LocalClearance = atoi( Line + 16 ); break; default: @@ -563,15 +551,15 @@ bool D_PAD::Save( FILE* aFile ) const break; } - 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() ), - ARG_LENSV( m_DeltaSize.x() ), ARG_LENSV( m_DeltaSize.y() ), m_Orient ); + fprintf( aFile, "Sh \"%.4s\" %c %d %d %d %d %d\n", + m_Padname, cshape, m_Size.x, m_Size.y, + m_DeltaSize.x, 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 %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); 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 %d %d", 'O', m_Drill.x, m_Drill.y ); } fprintf( aFile, "\n" ); @@ -600,22 +588,22 @@ bool D_PAD::Save( FILE* aFile ) const 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 %d %d\n", m_Pos0.x, m_Pos0.y ); - if( m_LengthDie != ZERO_LENGTH ) - fprintf( aFile, "Le "FM_LENSV"\n", ARG_LENSV( m_LengthDie ) ); + if( m_LengthDie != 0 ) + fprintf( aFile, "Le %d\n", m_LengthDie ); - if( m_LocalSolderMaskMargin != ZERO_LENGTH ) - fprintf( aFile, ".SolderMask "FM_LENSV"\n", ARG_LENSV( m_LocalSolderMaskMargin ) ); + if( m_LocalSolderMaskMargin != 0 ) + fprintf( aFile, ".SolderMask %d\n", m_LocalSolderMaskMargin ); - if( m_LocalSolderPasteMargin != ZERO_LENGTH ) - fprintf( aFile, ".SolderPaste "FM_LENSV"\n", ARG_LENSV( m_LocalSolderPasteMargin ) ); + if( m_LocalSolderPasteMargin != 0 ) + fprintf( aFile, ".SolderPaste %d\n", m_LocalSolderPasteMargin ); if( m_LocalSolderPasteMarginRatio != 0 ) fprintf( aFile, ".SolderPasteRatio %g\n", m_LocalSolderPasteMarginRatio ); - if( m_LocalClearance != ZERO_LENGTH ) - fprintf( aFile, ".LocalClearance "FM_LENSV"\n", ARG_LENSV( m_LocalClearance ) ); + if( m_LocalClearance != 0 ) + fprintf( aFile, ".LocalClearance %d\n", m_LocalClearance ); if( fprintf( aFile, "$EndPAD\n" ) != sizeof("$EndPAD\n") - 1 ) return false; @@ -756,13 +744,13 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( ShowPadShape(), ShowPadAttr(), DARKGREEN ); - valeur_param( TO_LEGACY_LU( m_Size.x() ), Line ); + valeur_param( m_Size.x, Line ); frame->AppendMsgPanel( _( "H Size" ), Line, RED ); - valeur_param( TO_LEGACY_LU( m_Size.y() ), Line ); + valeur_param( m_Size.y, Line ); frame->AppendMsgPanel( _( "V Size" ), Line, RED ); - valeur_param( (unsigned)(int) TO_LEGACY_LU( m_Drill.x() ), Line ); + valeur_param( (unsigned) m_Drill.x, Line ); if( m_DrillShape == PAD_CIRCLE ) { @@ -770,9 +758,9 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) } else { - valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.x() ), Line ); + valeur_param( (unsigned) m_Drill.x, Line ); wxString msg; - valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.y() ), msg ); + valeur_param( (unsigned) m_Drill.y, msg ); Line += wxT( " / " ) + msg; frame->AppendMsgPanel( _( "Drill X / Y" ), Line, RED ); } @@ -788,15 +776,15 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Orient" ), Line, LIGHTBLUE ); - valeur_param( TO_LEGACY_LU( m_Pos.x() ), Line ); + valeur_param( m_Pos.x, Line ); frame->AppendMsgPanel( _( "X Pos" ), Line, LIGHTBLUE ); - valeur_param( TO_LEGACY_LU( m_Pos.y() ), Line ); + valeur_param( m_Pos.y, Line ); frame->AppendMsgPanel( _( "Y pos" ), Line, LIGHTBLUE ); - if( m_LengthDie != ZERO_LENGTH ) + if( m_LengthDie ) { - valeur_param( TO_LEGACY_LU( m_LengthDie ), Line ); + valeur_param( m_LengthDie, Line ); frame->AppendMsgPanel( _( "Length on die" ), Line, CYAN ); } } @@ -828,8 +816,8 @@ bool D_PAD::HitTest( const wxPoint& refPos ) if( ( abs( delta.x ) > m_ShapeMaxRadius ) || ( abs( delta.y ) > m_ShapeMaxRadius ) ) return false; - dx = TO_LEGACY_LU( m_Size.x() / 2 ); // dx also is the radius for rounded pads - dy = TO_LEGACY_LU( m_Size.y() / 2 ); + dx = m_Size.x >> 1; // dx also is the radius for rounded pads + dy = m_Size.y >> 1; switch( m_PadShape & 0x7F ) { @@ -866,25 +854,25 @@ int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp ) { int diff; - if( ( diff = padref->m_PadShape - padcmp->m_PadShape) ) + if( (diff = padref->m_PadShape - padcmp->m_PadShape) ) return diff; - if( ( diff = TO_LEGACY_LU( padref->m_Size.x() - padcmp->m_Size.x() ) ) ) + if( (diff = padref->m_Size.x - padcmp->m_Size.x) ) return diff; - if( ( diff = TO_LEGACY_LU( padref->m_Size.y() - padcmp->m_Size.y() ) ) ) + if( (diff = padref->m_Size.y - padcmp->m_Size.y) ) return diff; - if( ( diff = TO_LEGACY_LU( padref->m_Offset.x() - padcmp->m_Offset.x() ) ) ) + if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) ) return diff; - if( ( diff = TO_LEGACY_LU( padref->m_Offset.y() - padcmp->m_Offset.y() ) ) ) + if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) ) return diff; - if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.x() - padcmp->m_DeltaSize.x() ) ) ) + if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) ) return diff; - if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.y() - padcmp->m_DeltaSize.y() ) ) ) + if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) ) return diff; // @todo check if export_gencad still works: @@ -988,7 +976,7 @@ void D_PAD::Show( int nestLevel, std::ostream& os ) " num=\"" << padname << '"' << " net=\"" << m_Netname.mb_str() << '"' << " netcode=\"" << GetNet() << '"' << - " layerMask=\"" << layerMask << '"' << TO_LEGACY_LU_WXP( m_Pos ) << "/>\n"; + " layerMask=\"" << layerMask << '"' << m_Pos << "/>\n"; // NestedSpace( nestLevel+1, os ) << m_Text.mb_str() << '\n'; diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index ce8f8d0b0f..37d4914287 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -11,8 +11,6 @@ #include "pad_shapes.h" #include "PolyLine.h" -#include "lengthpcb.h" -#include "vectorpcb.h" class LINE_READER; class EDA_3D_CANVAS; @@ -72,9 +70,8 @@ private: wxString m_ShortNetname; // short net name, like vout from /mysheet/mysubsheet/vout -public: /** TODO: that's not so good if parameters are easily modifiable outside - (e. g. m_Pos, which could be coherent with m_Pos and module orient/pos ) */ - VECTOR_PCB m_Pos; // pad Position on board +public: + wxPoint m_Pos; // pad Position on board union { @@ -88,17 +85,14 @@ public: /** TODO: that's not so good if parameters are easily modifiable outside // 2..14 = internal layers // 16 .. 31 = technical layers - int m_PadShape; ///< Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID - int m_DrillShape; ///< Shape PAD_CIRCLE, PAD_OVAL - /// @TODO: as m_DrillShape is eqv. to m_Drill.x==.y - /// it would be relatively easy to remove - /// this redundant flag. + int m_PadShape; // Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID + int m_DrillShape; // Shape PAD_CIRCLE, PAD_OVAL - VECTOR_PCB m_Drill; ///< Drill diam (drill shape = PAD_CIRCLE) or drill size - /// (shape = OVAL) for drill shape = PAD_CIRCLE, drill - /// diam = m_Drill.x + wxSize m_Drill; // Drill diam (drill shape = PAD_CIRCLE) or drill size + // (shape = OVAL) for drill shape = PAD_CIRCLE, drill + // diam = m_Drill.x - VECTOR_PCB m_Offset; /* This parameter is useful only for oblong pads (it can be used for other + wxSize m_Offset; /* This parameter is useful only for oblong pads (it can be used for other * shapes, but without any interest). * this is the offset between the pad hole and the pad shape (you must * understand here pad shape = copper area around the hole) @@ -111,11 +105,11 @@ public: /** TODO: that's not so good if parameters are easily modifiable outside * D_PAD::ReturnShapePos() returns the physical shape position according to * the offset and the pad rotation.*/ - VECTOR_PCB m_Size; // X and Y size ( relative to orient 0) + wxSize m_Size; // X and Y size ( relative to orient 0) - VECTOR_PCB m_DeltaSize; // delta on rectangular shapes + wxSize m_DeltaSize; // delta on rectangular shapes - VECTOR_PCB m_Pos0; // Initial Pad position (i.e. pad position relative to the + wxPoint m_Pos0; // Initial Pad position (i.e. pas position relative to the // module anchor, orientation 0 int m_ShapeMaxRadius; // radius of the circle containing the pad shape @@ -124,16 +118,16 @@ public: /** TODO: that's not so good if parameters are easily modifiable outside static int m_PadSketchModePenSize; // Pen size used to draw pads in sketch mode // (mode used to print pads on silkscreen layer) - LENGTH_PCB m_LengthDie; // Length net from pad to die on chip + int m_LengthDie; // Length net from pad to die on chip // Local clearance. When null, the module default value is used. // when the module default value is null, the netclass value is used // Usually the local clearance is null - LENGTH_PCB m_LocalClearance; + int m_LocalClearance; // Local mask margins: when NULL, the parent footprint design values are used - LENGTH_PCB m_LocalSolderMaskMargin; // Local solder mask margin - LENGTH_PCB m_LocalSolderPasteMargin; // Local solder paste margin absolute value + int m_LocalSolderMaskMargin; // Local solder mask margin + int m_LocalSolderPasteMargin; // Local solder paste margin absolute value double m_LocalSolderPasteMarginRatio; // Local solder mask margin ratio value of pad size // The final margin is the sum of these 2 values @@ -178,17 +172,16 @@ public: * Function GetPosition * returns the position of this object. * @return const wxPoint& - The position of this object. - * @TODO: could move virtual method to .c file */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { - return TO_LEGACY_LU_WXP( m_Pos ); + return m_Pos; } void SetPosition( const wxPoint& aPos ) { - m_Pos = FROM_LEGACY_LU_VEC( aPos ); + m_Pos = aPos; } /** @@ -387,7 +380,7 @@ public: */ virtual void Move( const wxPoint& aMoveVector ) { - m_Pos += FROM_LEGACY_LU_VEC( aMoveVector ); + m_Pos += aMoveVector; } diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 9bb5107184..d28ae08bb4 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -392,9 +392,9 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) // calculate pad shape position : wxPoint shape_pos = ReturnShapePos() - aDrawInfo.m_Offset; - wxSize halfsize = TO_LEGACY_LU_WXS( m_Size ); - halfsize.x /= 2; - halfsize.y /= 2; + wxSize halfsize = m_Size; + halfsize.x >>= 1; + halfsize.y >>= 1; switch( GetShape() ) { @@ -475,8 +475,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) } /* Draw the pad hole */ - wxPoint holepos = TO_LEGACY_LU_WXP( m_Pos ) - aDrawInfo.m_Offset; - int hole = TO_LEGACY_LU( m_Drill.x() ) / 2; + wxPoint holepos = m_Pos - aDrawInfo.m_Offset; + int hole = m_Drill.x >> 1; bool drawhole = hole > 0; @@ -513,20 +513,20 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) break; case PAD_OVAL: - halfsize.x = TO_LEGACY_LU( m_Drill.x() ) / 2; - halfsize.y = TO_LEGACY_LU( m_Drill.y() ) / 2; + halfsize.x = m_Drill.x >> 1; + halfsize.y = m_Drill.y >> 1; - if( m_Drill.x() > m_Drill.y() ) /* horizontal */ + if( m_Drill.x > m_Drill.y ) /* horizontal */ { delta_cx = halfsize.x - halfsize.y; delta_cy = 0; - seg_width = TO_LEGACY_LU( m_Drill.y() ); + seg_width = m_Drill.y; } else /* vertical */ { delta_cx = 0; delta_cy = halfsize.y - halfsize.x; - seg_width = TO_LEGACY_LU( m_Drill.x() ); + seg_width = m_Drill.x; } RotatePoint( &delta_cx, &delta_cy, angle ); @@ -576,13 +576,13 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( GetShape() == PAD_CIRCLE ) angle = 0; - AreaSize = TO_LEGACY_LU_WXS( m_Size ); + AreaSize = m_Size; - if( m_Size.y() > m_Size.x() ) + if( m_Size.y > m_Size.x ) { angle += 900; - AreaSize.x = TO_LEGACY_LU( m_Size.y() ); - AreaSize.y = TO_LEGACY_LU( m_Size.x() ); + AreaSize.x = m_Size.y; + AreaSize.y = m_Size.x; } 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 { 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 = ( m_Size.x - m_Size.y ) / 2; aSegStart.x = -delta; aSegStart.y = 0; aSegEnd.x = delta; aSegEnd.y = 0; - width = TO_LEGACY_LU( m_Size.y() ); + width = m_Size.y; } else // Vertical oval: build a vertical equiv segment { - int delta = TO_LEGACY_LU( ( m_Size.y() -m_Size.x() ) / 2 ); + int delta = ( m_Size.y -m_Size.x ) / 2; aSegStart.x = 0; aSegStart.y = -delta; aSegEnd.x = 0; aSegEnd.y = delta; - width = TO_LEGACY_LU( m_Size.x() ); + width = m_Size.x; } if( aRotation ) @@ -701,8 +701,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat wxSize delta; wxSize halfsize; - halfsize.x = TO_LEGACY_LU( m_Size.x() / 2 ); - halfsize.y = TO_LEGACY_LU( m_Size.y() / 2 ); + halfsize.x = m_Size.x >> 1; + halfsize.y = m_Size.y >> 1; /* For rectangular shapes, inflate is easy */ @@ -721,8 +721,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat else { // Trapezoidal pad: verify delta values - delta.x = TO_LEGACY_LU( m_DeltaSize.x() / 2 ); - delta.y = TO_LEGACY_LU( m_DeltaSize.y() / 2 ); + delta.x = ( m_DeltaSize.x >> 1 ); + delta.y = ( m_DeltaSize.y >> 1 ); // be sure delta values are not to large if( (delta.x < 0) && (delta.x <= -halfsize.y) ) @@ -762,7 +762,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat if( delta.y ) // lower and upper segment is horizontal { // Calculate angle of left (or right) segment with vertical axis - angle = atan2( m_DeltaSize.y(), m_Size.y() ); + angle = atan2( double( m_DeltaSize.y ), double( m_Size.y ) ); // left and right sides are moved by aInflateValue.x in their perpendicular direction // We must calculate the corresponding displacement on the horizontal axis @@ -778,7 +778,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat else if( delta.x ) // left and right segment is vertical { // Calculate angle of lower (or upper) segment with horizontal axis - angle = atan2( m_DeltaSize.x(), m_Size.x() ); + angle = atan2( double( m_DeltaSize.x ), double( m_Size.x ) ); // lower and upper sides are moved by aInflateValue.x in their perpendicular direction // We must calculate the corresponding displacement on the vertical axis diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index c946678ce8..21cd41b90e 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -26,15 +26,11 @@ public: * returns the position of this object. * @return wxPoint& - The position of this object, non-const so it can be changed */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Pos; // within EDA_TEXT } - void SetPosition( const wxPoint& pos ) { - m_Pos = pos; - } - /** * Function Move * move this object. diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 76b775db38..d1a28b1def 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -51,14 +51,11 @@ public: * Required by pure virtual BOARD_ITEM::GetPosition() * @return const wxPoint& - The position of this object. */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Pos; } - void SetPosition( const wxPoint& pos ) { - m_Pos = pos; - } void Copy( TEXTE_MODULE* source ); // copy structure diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index 24582b6ac9..c360aeefdb 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -120,21 +120,13 @@ public: /** * Function GetPosition * returns the position of this object. - * @return const wxPoint - The position of this object. + * @return const wxPoint& - The position of this object. */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { 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; /** @@ -478,11 +470,12 @@ public: * returns the position of this object. * @return const wxPoint& - The position of this object. */ - const wxPoint GetPosition() const + wxPoint& GetPosition() { return m_Start; } + void SetPosition( const wxPoint& aPoint ) { m_Start = aPoint; m_End = aPoint; } /** diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index e66702803a..2b2c4748d2 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -84,13 +84,20 @@ bool ZONE_CONTAINER::UnFill() } -const wxPoint ZONE_CONTAINER::GetPosition() const +wxPoint& ZONE_CONTAINER::GetPosition() { - return m_Poly? GetCornerPosition( 0 ) : wxPoint( 0, 0 ); + static wxPoint pos; + + 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 ) { diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index 319d008f53..114c22be55 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -118,8 +118,8 @@ public: * Function GetPosition * @return a wxPoint, position of the first point of the outline */ - const wxPoint GetPosition() const; - void SetPosition( const wxPoint& pos ); + wxPoint& GetPosition(); + /** * Function copy * copy useful data from the source. diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index 2f61b41c37..746ebf8c06 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -850,7 +850,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) if( pad ) { // test if the track start point is not exactly starting on the pad - if( segment->m_Start != TO_LEGACY_LU_WXP( pad->m_Pos ) ) + if( segment->m_Start != pad->m_Pos ) { if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, START ) == NULL ) { @@ -858,7 +858,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() ); - newTrack->m_End = TO_LEGACY_LU_WXP( pad->m_Pos ); + newTrack->m_End = pad->m_Pos; newTrack->start = segment; newTrack->end = pad; @@ -872,7 +872,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) if( pad ) { // test if the track end point is not exactly on the pad - if( segment->m_End != TO_LEGACY_LU_WXP( pad->m_Pos ) ) + if( segment->m_End != pad->m_Pos ) { if( segment->GetTrace( frame->GetBoard()->m_Track, NULL, END ) == NULL ) { @@ -880,7 +880,7 @@ void ConnectDanglingEndToPad( PCB_EDIT_FRAME* frame ) frame->GetBoard()->m_Track.Insert( newTrack, segment->Next() ); - newTrack->m_Start = TO_LEGACY_LU_WXP( pad->m_Pos ); + newTrack->m_Start = pad->m_Pos; newTrack->start = pad; newTrack->end = segment; diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index 4c0f62b0cf..8cd8ff62ad 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -212,21 +212,21 @@ void DIALOG_DESIGN_RULES::PrintCurrentSettings() m_MessagesList->AppendToPage( _( "Current general settings:
" ) ); // Display min values: - value = LENGTH_TO_STR_SYM( g_UserUnit, - m_BrdSettings->m_TrackMinWidth, - internal_units ); + value = ReturnStringFromValue( g_UserUnit, + m_BrdSettings->m_TrackMinWidth, + internal_units, + true ); msg.Printf( _( "Minimum value for tracks width: %s
\n" ), GetChars( value ) ); m_MessagesList->AppendToPage( msg ); - value = LENGTH_TO_STR_SYM( g_UserUnit, - m_BrdSettings->m_MinVia.m_Diameter, - internal_units ); + value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_ViasMinSize, internal_units, true ); msg.Printf( _( "Minimum value for vias diameter: %s
\n" ), GetChars( value ) ); m_MessagesList->AppendToPage( msg ); - value = LENGTH_TO_STR_SYM( g_UserUnit, - m_BrdSettings->m_MinMicroVia.m_Diameter, - internal_units ); + value = ReturnStringFromValue( g_UserUnit, + m_BrdSettings->m_MicroViasMinSize, + internal_units, + true ); msg.Printf( _( "Minimum value for microvias diameter: %s
\n" ), GetChars( value ) ); m_MessagesList->AppendToPage( msg ); } @@ -291,26 +291,21 @@ void DIALOG_DESIGN_RULES::InitGlobalRules() AddUnitSymbol( *m_TrackMinWidthTitle ); int Internal_Unit = m_Parent->m_InternalUnits; + PutValueInLocalUnits( *m_SetViasMinSizeCtrl, m_BrdSettings->m_ViasMinSize, Internal_Unit ); + PutValueInLocalUnits( *m_SetViasMinDrillCtrl, m_BrdSettings->m_ViasMinDrill, Internal_Unit ); + if( m_BrdSettings->m_CurrentViaType != VIA_THROUGH ) m_OptViaType->SetSelection( 1 ); m_AllowMicroViaCtrl->SetSelection( m_BrdSettings->m_MicroViasAllowed ? 1 : 0 ); + PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl, + m_BrdSettings->m_MicroViasMinSize, + Internal_Unit ); + PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl, + m_BrdSettings->m_MicroViasMinDrill, + Internal_Unit ); - CTR_PUT_LENGTH( *m_SetViasMinSizeCtrl, - m_BrdSettings->m_MinVia.m_Diameter, - Internal_Unit ); - CTR_PUT_LENGTH( *m_SetViasMinDrillCtrl, - m_BrdSettings->m_MinVia.m_Drill, - Internal_Unit ); - CTR_PUT_LENGTH( *m_SetMicroViasMinSizeCtrl, - m_BrdSettings->m_MinMicroVia.m_Diameter, - Internal_Unit ); - CTR_PUT_LENGTH( *m_SetMicroViasMinDrillCtrl, - m_BrdSettings->m_MinMicroVia.m_Drill, - Internal_Unit ); - CTR_PUT_LENGTH( *m_SetTrackMinWidthCtrl, - m_BrdSettings->m_TrackMinWidth, - Internal_Unit ); + PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings->m_TrackMinWidth, Internal_Unit ); // Initialize Vias and Tracks sizes lists. // note we display only extra values, never the current netclass value. @@ -352,21 +347,19 @@ void DIALOG_DESIGN_RULES::InitDimensionsLists() for( unsigned ii = 0; ii < m_TracksWidthList.size(); ii++ ) { - msg = LENGTH_TO_STR( g_UserUnit, m_TracksWidthList[ii], Internal_Unit); + msg = ReturnStringFromValue( g_UserUnit, m_TracksWidthList[ii], Internal_Unit, false ); m_gridTrackWidthList->SetCellValue( ii, 0, msg ); } for( unsigned ii = 0; ii < m_ViasDimensionsList.size(); ii++ ) { - msg = LENGTH_TO_STR( g_UserUnit, - m_ViasDimensionsList[ii].m_Diameter, - Internal_Unit ); + msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Diameter, + Internal_Unit, false ); m_gridViaSizeList->SetCellValue( ii, 0, msg ); - if( m_ViasDimensionsList[ii].m_Drill > ZERO_LENGTH ) + if( m_ViasDimensionsList[ii].m_Drill > 0 ) { - msg = LENGTH_TO_STR( g_UserUnit, - m_ViasDimensionsList[ii].m_Drill, - Internal_Unit ); + msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Drill, + Internal_Unit, false ); m_gridViaSizeList->SetCellValue( ii, 1, msg ); } } @@ -502,12 +495,23 @@ static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc, int units ) // label is netclass name grid->SetRowLabelValue( row, nc->GetName() ); - grid->SetCellValue( row, GRID_CLEARANCE, LENGTH_TO_STR( g_UserUnit, nc->Clearance(), units ) ); - grid->SetCellValue( row, GRID_TRACKSIZE, LENGTH_TO_STR( g_UserUnit, nc->TrackWidth(), units ) ); - grid->SetCellValue( row, GRID_VIASIZE, LENGTH_TO_STR( g_UserUnit, nc->Via().m_Diameter, units ) ); - grid->SetCellValue( row, GRID_VIADRILL, LENGTH_TO_STR( g_UserUnit, nc->Via().m_Drill, units ) ); - grid->SetCellValue( row, GRID_uVIASIZE, LENGTH_TO_STR( g_UserUnit, nc->MicroVia().m_Diameter, units ) ); - grid->SetCellValue( row, GRID_uVIADRILL, LENGTH_TO_STR( g_UserUnit, nc->MicroVia().m_Drill, units ) ); + msg = ReturnStringFromValue( g_UserUnit, nc->GetClearance(), units ); + grid->SetCellValue( row, GRID_CLEARANCE, msg ); + + msg = ReturnStringFromValue( g_UserUnit, nc->GetTrackWidth(), units ); + grid->SetCellValue( row, GRID_TRACKSIZE, msg ); + + msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDiameter(), units ); + grid->SetCellValue( row, GRID_VIASIZE, msg ); + + msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDrill(), units ); + grid->SetCellValue( row, GRID_VIADRILL, msg ); + + msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDiameter(), units ); + grid->SetCellValue( row, GRID_uVIASIZE, msg ); + + msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDrill(), units ); + grid->SetCellValue( row, GRID_uVIADRILL, msg ); } @@ -541,16 +545,15 @@ void DIALOG_DESIGN_RULES::InitRulesList() static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units ) { - nc->Clearance( - STR_TO_LENGTH( g_UserUnit, grid->GetCellValue( row, GRID_CLEARANCE ), units ) ); - nc->TrackWidth( - STR_TO_LENGTH( g_UserUnit, grid->GetCellValue( row, GRID_TRACKSIZE ), units ) ); - nc->Via( VIA_DIMENSION( - STR_TO_LENGTH( g_UserUnit, grid->GetCellValue( row, GRID_VIASIZE ), units ), - STR_TO_LENGTH( g_UserUnit, grid->GetCellValue( row, GRID_VIADRILL ), units ) ) ); - nc->MicroVia( VIA_DIMENSION( - STR_TO_LENGTH( g_UserUnit, grid->GetCellValue( row, GRID_uVIASIZE ), units ), - STR_TO_LENGTH( g_UserUnit, grid->GetCellValue( row, GRID_uVIADRILL ), units ) ) ); +#define MYCELL( col ) \ + ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ), units ) + + nc->SetClearance( MYCELL( GRID_CLEARANCE ) ); + nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) ); + nc->SetViaDiameter( MYCELL( GRID_VIASIZE ) ); + nc->SetViaDrill( MYCELL( GRID_VIADRILL ) ); + nc->SetuViaDiameter( MYCELL( GRID_uVIASIZE ) ); + nc->SetuViaDrill( MYCELL( GRID_uVIADRILL ) ); } @@ -606,22 +609,23 @@ void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard() if( m_OptViaType->GetSelection() > 0 ) m_BrdSettings->m_CurrentViaType = VIA_BLIND_BURIED; + // Update vias minimum values for DRC + m_BrdSettings->m_ViasMinSize = + ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, m_Parent->m_InternalUnits ); + m_BrdSettings->m_ViasMinDrill = + ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, m_Parent->m_InternalUnits ); + m_BrdSettings->m_MicroViasAllowed = m_AllowMicroViaCtrl->GetSelection() == 1; - // Update vias minimum values for DRC - m_BrdSettings->m_MinVia.m_Diameter = - CTR_GET_LENGTH( *m_SetViasMinSizeCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_MinVia.m_Drill = - CTR_GET_LENGTH( *m_SetViasMinDrillCtrl, m_Parent->m_InternalUnits ); - // Update microvias minimum values for DRC - m_BrdSettings->m_MinMicroVia.m_Diameter = - CTR_GET_LENGTH( *m_SetMicroViasMinSizeCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_MinMicroVia.m_Drill = - CTR_GET_LENGTH( *m_SetMicroViasMinDrillCtrl, m_Parent->m_InternalUnits ); + m_BrdSettings->m_MicroViasMinSize = + ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, m_Parent->m_InternalUnits ); + m_BrdSettings->m_MicroViasMinDrill = + ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, m_Parent->m_InternalUnits ); + // Update tracks minimum values for DRC m_BrdSettings->m_TrackMinWidth = - CTR_GET_LENGTH( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits ); + ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits ); } @@ -638,25 +642,28 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard() msg = m_gridTrackWidthList->GetCellValue( row, 0 ); if( msg.IsEmpty() ) continue; - m_TracksWidthList.push_back( STR_TO_LENGTH( g_UserUnit, msg, m_Parent->m_InternalUnits ) ); + int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ); + m_TracksWidthList.push_back( value ); } // Sort new list by by increasing value sort( m_TracksWidthList.begin(), m_TracksWidthList.end() ); - // Reinitialize m_ViaSizeList + // Reinitialize m_TrackWidthList m_ViasDimensionsList.clear(); for( int row = 0; row < m_gridViaSizeList->GetNumberRows(); ++row ) { msg = m_gridViaSizeList->GetCellValue( row, 0 ); if( msg.IsEmpty() ) continue; + int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ); VIA_DIMENSION via_dim; - via_dim.m_Diameter = STR_TO_LENGTH( g_UserUnit, msg, m_Parent->m_InternalUnits ); + via_dim.m_Diameter = value; msg = m_gridViaSizeList->GetCellValue( row, 1 ); if( !msg.IsEmpty() ) { - via_dim.m_Drill = STR_TO_LENGTH( g_UserUnit, msg, m_Parent->m_InternalUnits ); + value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits ); + via_dim.m_Drill = value; } m_ViasDimensionsList.push_back( via_dim ); } @@ -664,7 +671,7 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard() // Sort new list by by increasing value sort( m_ViasDimensionsList.begin(), m_ViasDimensionsList.end() ); - std::vector < LENGTH_PCB >* tlist = &m_Parent->GetBoard()->m_TrackWidthList; + std::vector * tlist = &m_Parent->GetBoard()->m_TrackWidthList; tlist->erase( tlist->begin() + 1, tlist->end() ); // Remove old "custom" sizes tlist->insert( tlist->end(), m_TracksWidthList.begin(), m_TracksWidthList.end() ); //Add new "custom" sizes diff --git a/pcbnew/dialogs/dialog_design_rules.h b/pcbnew/dialogs/dialog_design_rules.h index c02f19abe4..e5bdcd190b 100644 --- a/pcbnew/dialogs/dialog_design_rules.h +++ b/pcbnew/dialogs/dialog_design_rules.h @@ -57,7 +57,7 @@ private: // List of values to "customize" some tracks and vias std::vector m_ViasDimensionsList; - std::vector m_TracksWidthList; + std::vector m_TracksWidthList; private: void OnNetClassesNameLeftClick( wxGridEvent& event ){ event.Skip(); } diff --git a/pcbnew/dialogs/dialog_design_rules_base.cpp b/pcbnew/dialogs/dialog_design_rules_base.cpp index 2f275d59dd..94350bf42a 100644 --- a/pcbnew/dialogs/dialog_design_rules_base.cpp +++ b/pcbnew/dialogs/dialog_design_rules_base.cpp @@ -213,6 +213,7 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID fgMinValuesSizer->Add( m_MicroViaMinSizeTitle, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT, 5 ); m_SetMicroViasMinSizeCtrl = new wxTextCtrl( m_panelGolbalDesignRules, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_SetMicroViasMinSizeCtrl->SetMaxLength( 6 ); fgMinValuesSizer->Add( m_SetMicroViasMinSizeCtrl, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); m_MicroViaMinDrillTitle = new wxStaticText( m_panelGolbalDesignRules, wxID_ANY, _("Min uvia drill dia"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -220,6 +221,7 @@ DIALOG_DESIGN_RULES_BASE::DIALOG_DESIGN_RULES_BASE( wxWindow* parent, wxWindowID fgMinValuesSizer->Add( m_MicroViaMinDrillTitle, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 ); m_SetMicroViasMinDrillCtrl = new wxTextCtrl( m_panelGolbalDesignRules, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_SetMicroViasMinDrillCtrl->SetMaxLength( 6 ); fgMinValuesSizer->Add( m_SetMicroViasMinDrillCtrl, 0, wxEXPAND|wxALL, 5 ); sbMinSizesSizer->Add( fgMinValuesSizer, 0, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 8ded4dde81..a461fa4400 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -130,21 +130,12 @@ void DIALOG_DRC_CONTROL::InitValues() */ void DIALOG_DRC_CONTROL::SetDrcParmeters( ) { -#ifdef KICAD_NANOMETRE - m_BrdSettings->m_TrackMinWidth = - LengthFromTextCtrl( *m_SetTrackMinWidthCtrl ); - m_BrdSettings->m_MinVia.m_Diameter = - LengthFromTextCtrl( *m_SetViaMinSizeCtrl ); - m_BrdSettings->m_MinMicroVia.m_Diameter = - LengthFromTextCtrl( *m_SetMicroViakMinSizeCtrl ); -#else - m_BrdSettings->m_TrackMinWidth = + m_BrdSettings->m_TrackMinWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_MinVia.m_Diameter = + m_BrdSettings->m_ViasMinSize = ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_MinMicroVia.m_Diameter = + m_BrdSettings->m_MicroViasMinSize = ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->m_InternalUnits ); -#endif } diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index 5633751725..32301f0fa8 100644 --- a/pcbnew/dialogs/dialog_gendrill.cpp +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -185,7 +185,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void ) { if( pad->m_DrillShape == PAD_CIRCLE ) { - if( pad->m_Drill.x() != ZERO_LENGTH ) + if( pad->m_Drill.x != 0 ) { if( pad->m_Attribut == PAD_HOLE_NOT_PLATED ) m_notplatedPadsHoleCount++; @@ -195,7 +195,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void ) } else { - if( min( TO_LEGACY_LU( pad->m_Drill.x() ), TO_LEGACY_LU( pad->m_Drill.y() ) ) != 0 ) + if( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 ) { if( pad->m_Attribut == PAD_HOLE_NOT_PLATED ) m_notplatedPadsHoleCount++; diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 287201baaf..04e38d2f89 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -117,26 +117,26 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) drawInfo.m_Color = color; drawInfo.m_HoleColor = DARKGRAY; - drawInfo.m_Offset = TO_LEGACY_LU_WXP( m_dummyPad->m_Pos ); + drawInfo.m_Offset = m_dummyPad->m_Pos; drawInfo.m_Display_padnum = true; drawInfo.m_Display_netname = true; if( m_dummyPad->m_Attribut == PAD_HOLE_NOT_PLATED ) drawInfo.m_ShowNotPlatedHole = true; // Shows the local pad clearance - drawInfo.m_PadClearance = TO_LEGACY_LU( m_dummyPad->m_LocalClearance ); + drawInfo.m_PadClearance = m_dummyPad->m_LocalClearance; wxSize dc_size = dc.GetSize(); dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 ); // 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() ) ); - if( m_dummyPad->m_LocalClearance > ZERO_LENGTH ) - dim += TO_LEGACY_LU( m_dummyPad->m_LocalClearance * 2 ); + int dim = m_dummyPad->m_Size.x + ABS( m_dummyPad->m_DeltaSize.y); + if( m_dummyPad->m_LocalClearance > 0 ) + dim += m_dummyPad->m_LocalClearance * 2; double scale = (double) dc_size.x / dim; - dim = TO_LEGACY_LU( m_dummyPad->m_Size.y() + abs( m_dummyPad->m_DeltaSize.x() ) ); - if( m_dummyPad->m_LocalClearance > ZERO_LENGTH ) - dim += TO_LEGACY_LU( m_dummyPad->m_LocalClearance * 2 ); + dim = m_dummyPad->m_Size.y + ABS( m_dummyPad->m_DeltaSize.x); + if( m_dummyPad->m_LocalClearance > 0 ) + dim += m_dummyPad->m_LocalClearance * 2; double altscale = (double) dc_size.y / dim; scale = MIN( scale, altscale ); @@ -207,8 +207,8 @@ void DIALOG_PAD_PROPERTIES::initValues() if( m_isFlipped ) { - m_dummyPad->m_Offset.y( -m_dummyPad->m_Offset.y() ); - m_dummyPad->m_DeltaSize.y( -m_dummyPad->m_DeltaSize.y() ); + NEGATE( m_dummyPad->m_Offset.y ); + NEGATE( m_dummyPad->m_DeltaSize.y ); /* flip pads layers*/ m_dummyPad->m_layerMask = ChangeSideMaskLayer( m_dummyPad->m_layerMask ); } @@ -236,40 +236,41 @@ void DIALOG_PAD_PROPERTIES::initValues() m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); // Display current pad parameters units: - CTR_PUT_LENGTH( *m_PadPosition_X_Ctrl, m_dummyPad->m_Pos.x(), internalUnits ); - CTR_PUT_LENGTH( *m_PadPosition_Y_Ctrl, m_dummyPad->m_Pos.y(), internalUnits ); + PutValueInLocalUnits( *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_PadDrill_X_Ctrl, m_dummyPad->m_Drill.x(), internalUnits ); - CTR_PUT_LENGTH( *m_PadDrill_Y_Ctrl, m_dummyPad->m_Drill.y(), internalUnits ); + PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->m_Drill.x, internalUnits ); + PutValueInLocalUnits( *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_Y_Ctrl, m_dummyPad->m_Size.y(), internalUnits ); + PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->m_Size.x, internalUnits ); + PutValueInLocalUnits( *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_Y_Ctrl, m_dummyPad->m_Offset.y(), internalUnits ); + PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->m_Offset.x, internalUnits ); + PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->m_Offset.y, internalUnits ); - if( m_dummyPad->m_DeltaSize.x() != ZERO_LENGTH ) + if( m_dummyPad->m_DeltaSize.x ) { - CTR_PUT_LENGTH( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.x(), internalUnits ); + PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.x, internalUnits ); m_radioBtnDeltaXdir->SetValue(true); } else { - CTR_PUT_LENGTH( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.y(), internalUnits ); + PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.y, internalUnits ); m_radioBtnDeltaYdir->SetValue(true); } - CTR_PUT_LENGTH( *m_LengthDieCtrl, m_dummyPad->m_LengthDie, internalUnits ); + PutValueInLocalUnits( *m_LengthDieCtrl, m_dummyPad->m_LengthDie, internalUnits ); - CTR_PUT_LENGTH( *m_NetClearanceValueCtrl, - m_dummyPad->m_LocalClearance, internalUnits ); - CTR_PUT_LENGTH( *m_SolderMaskMarginCtrl, - m_dummyPad->m_LocalSolderMaskMargin, internalUnits ); + PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->m_LocalClearance, internalUnits ); + PutValueInLocalUnits( *m_SolderMaskMarginCtrl, + m_dummyPad->m_LocalSolderMaskMargin, + internalUnits ); // These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0 - CTR_PUT_LENGTH( *m_SolderPasteMarginCtrl, m_dummyPad->m_LocalSolderPasteMargin, + PutValueInLocalUnits( *m_SolderPasteMarginCtrl, + m_dummyPad->m_LocalSolderPasteMargin, internalUnits ); - if( m_dummyPad->m_LocalSolderPasteMargin == ZERO_LENGTH ) + if( m_dummyPad->m_LocalSolderPasteMargin == 0 ) m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() ); msg.Printf( wxT( "%.1f" ), m_dummyPad->m_LocalSolderPasteMarginRatio * 100.0 ); @@ -614,19 +615,17 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event ) /* compute the pos 0 value, i.e. pad position for module orient = 0 i.e. * refer to module origin (module position) */ m_CurrentPad->m_Pos0 = m_CurrentPad->m_Pos; - m_CurrentPad->m_Pos0 -= FROM_LEGACY_LU_VEC( Module->m_Pos ); + m_CurrentPad->m_Pos0 -= Module->m_Pos; m_CurrentPad->m_Orient = (g_Pad_Master.m_Orient * isign) + Module->m_Orient; - wxPoint p = TO_LEGACY_LU_WXP( m_CurrentPad->m_Pos0 ); - RotatePoint( &p.x, &p.y, -Module->m_Orient ); - m_CurrentPad->m_Pos0 = FROM_LEGACY_LU_VEC( p ); + RotatePoint( &m_CurrentPad->m_Pos0.x, &m_CurrentPad->m_Pos0.y, -Module->m_Orient ); m_CurrentPad->m_Size = g_Pad_Master.m_Size; - m_CurrentPad->m_DeltaSize = g_Pad_Master.m_DeltaSize; - m_CurrentPad->m_DeltaSize.y( m_CurrentPad->m_DeltaSize.y() * isign ); - m_CurrentPad->m_Drill = g_Pad_Master.m_Drill; - m_CurrentPad->m_DrillShape = g_Pad_Master.m_DrillShape; - m_CurrentPad->m_Offset = g_Pad_Master.m_Offset; - m_CurrentPad->m_Offset.y( m_CurrentPad->m_Offset.y() * isign ); + m_CurrentPad->m_DeltaSize = g_Pad_Master.m_DeltaSize; + m_CurrentPad->m_DeltaSize.y *= isign; + m_CurrentPad->m_Drill = g_Pad_Master.m_Drill; + m_CurrentPad->m_DrillShape = g_Pad_Master.m_DrillShape; + m_CurrentPad->m_Offset = g_Pad_Master.m_Offset; + m_CurrentPad->m_Offset.y *= isign; m_CurrentPad->m_LengthDie = g_Pad_Master.m_LengthDie; @@ -696,9 +695,12 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError aPad->m_PadShape = CodeShape[m_PadShape->GetSelection()]; // Read pad clearances values: - aPad->m_LocalClearance = CTR_GET_LENGTH( *m_NetClearanceValueCtrl, internalUnits ); - aPad->m_LocalSolderMaskMargin = CTR_GET_LENGTH( *m_SolderMaskMarginCtrl, internalUnits ); - aPad->m_LocalSolderPasteMargin = CTR_GET_LENGTH( *m_SolderPasteMarginCtrl, internalUnits ); + aPad->m_LocalClearance = ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, + internalUnits ); + aPad->m_LocalSolderMaskMargin = ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, + internalUnits ); + aPad->m_LocalSolderPasteMargin = ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, + internalUnits ); double dtmp = 0.0; msg = m_SolderPasteMarginRatioCtrl->GetValue(); msg.ToDouble( &dtmp ); @@ -711,66 +713,66 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError aPad->m_LocalSolderPasteMarginRatio = dtmp / 100; // Read pad position: - aPad->m_Pos.x( CTR_GET_LENGTH( *m_PadPosition_X_Ctrl, internalUnits ) ); - aPad->m_Pos.y( CTR_GET_LENGTH( *m_PadPosition_Y_Ctrl, internalUnits ) ); + aPad->m_Pos.x = ReturnValueFromTextCtrl( *m_PadPosition_X_Ctrl, internalUnits ); + aPad->m_Pos.y = ReturnValueFromTextCtrl( *m_PadPosition_Y_Ctrl, internalUnits ); aPad->m_Pos0 = aPad->m_Pos; // Read pad drill: - 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.x = ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl, internalUnits ); + aPad->m_Drill.y = ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl, internalUnits ); if( m_DrillShapeCtrl->GetSelection() == 0 ) { aPad->m_DrillShape = PAD_CIRCLE; - aPad->m_Drill.y( aPad->m_Drill.x() ); + aPad->m_Drill.y = aPad->m_Drill.x; } else aPad->m_DrillShape = PAD_OVAL; // Read pad shape size: - 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.x = ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl, internalUnits ); + aPad->m_Size.y = ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl, internalUnits ); 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: // m_DeltaSize.x or m_DeltaSize.y must be NULL. for a trapezoid. - //wxSize delta; - LENGTH_PCB delta; - delta = CTR_GET_LENGTH( *m_ShapeDelta_Ctrl, internalUnits ); - aPad->m_DeltaSize = m_radioBtnDeltaXdir->GetValue()? - VECTOR_PCB::fromXY( delta, ZERO_LENGTH ): - VECTOR_PCB::fromXY( ZERO_LENGTH, delta ); + wxSize delta; + if( m_radioBtnDeltaXdir->GetValue() ) + delta.x = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits ); + else + delta.y = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits ); + aPad->m_DeltaSize = delta; // Read pad lenght die - aPad->m_LengthDie = CTR_GET_LENGTH( *m_LengthDieCtrl, internalUnits ); + aPad->m_LengthDie = ReturnValueFromTextCtrl( *m_LengthDieCtrl, internalUnits ); // 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 bool error = false; - if( (aPad->m_DeltaSize.x() < ZERO_LENGTH) && (aPad->m_DeltaSize.x() <= -aPad->m_Size.y() ) ) + if( (aPad->m_DeltaSize.x < 0) && (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 + 2; error = true; } - if( (aPad->m_DeltaSize.x() > ZERO_LENGTH) && (aPad->m_DeltaSize.x() >= aPad->m_Size.y() ) ) + if( (aPad->m_DeltaSize.x > 0) && (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 - 2; error = true; } - if( (aPad->m_DeltaSize.y() < ZERO_LENGTH) && (aPad->m_DeltaSize.y() <= -aPad->m_Size.x() ) ) + if( (aPad->m_DeltaSize.y < 0) && (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 + 2; error = true; } - if( (aPad->m_DeltaSize.y() > ZERO_LENGTH) && (aPad->m_DeltaSize.y() >= aPad->m_Size.x() ) ) + if( (aPad->m_DeltaSize.y > 0) && (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 - 2; error = true; } // Read pad shape offset: - 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.x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl, internalUnits ); + aPad->m_Offset.y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl, internalUnits ); long orient_value = 0; msg = m_PadOrientCtrl->GetValue(); @@ -785,17 +787,17 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError switch( aPad->m_PadShape ) { case PAD_CIRCLE: - aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); // wxSize( 0, 0 ); - aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); - aPad->m_Size.y( aPad->m_Size.x() ); + aPad->m_Offset = wxSize( 0, 0 ); + aPad->m_DeltaSize = wxSize( 0, 0 ); + aPad->m_Size.y = aPad->m_Size.x; break; case PAD_RECT: - aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); + aPad->m_DeltaSize = wxSize( 0, 0 ); break; case PAD_OVAL: - aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); + aPad->m_DeltaSize = wxSize( 0, 0 ); break; case PAD_TRAPEZOID: @@ -809,14 +811,14 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError case PAD_CONN: case PAD_SMD: - aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); - aPad->m_Drill = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); + aPad->m_Offset = wxSize( 0, 0 ); + aPad->m_Drill = wxSize( 0, 0 ); break; case PAD_HOLE_NOT_PLATED: // Mechanical purpose only: // no offset, no net name, no pad name allowed - aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 ); + aPad->m_Offset = wxSize( 0, 0 ); aPad->SetPadName( wxEmptyString ); aPad->SetNetname( wxEmptyString ); break; @@ -873,8 +875,8 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError /* Test for incorrect values */ if( aPromptOnError ) { - if( (aPad->m_Size.x() < aPad->m_Drill.x() ) - || (aPad->m_Size.y() < aPad->m_Drill.y() ) ) + if( (aPad->m_Size.x < aPad->m_Drill.x) + || (aPad->m_Size.y < aPad->m_Drill.y) ) { DisplayError( NULL, _( "Incorrect value for pad drill: pad drill bigger than pad size" ) ); return false; @@ -883,7 +885,7 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError int padlayers_mask = PadLayerMask & (LAYER_BACK | LAYER_FRONT); if( padlayers_mask == 0 ) { - if( aPad->m_Drill.x() != ZERO_LENGTH || aPad->m_Drill.y() != ZERO_LENGTH ) + if( aPad->m_Drill.x || aPad->m_Drill.y ) { msg = _( "Error: pad is not on a copper layer and has a hole" ); if( aPad->m_Attribut == PAD_HOLE_NOT_PLATED ) @@ -897,8 +899,8 @@ if you do not want this pad plotted in gerber files"); } } - if( ( aPad->m_Size.x() / 2 <= abs( aPad->m_Offset.x() ) ) - || ( aPad->m_Size.y() / 2 <= abs( aPad->m_Offset.y() ) ) ) + if( ( aPad->m_Size.x / 2 <= ABS( aPad->m_Offset.x ) ) + || ( aPad->m_Size.y / 2 <= ABS( aPad->m_Offset.y ) ) ) { DisplayError( NULL, _( "Incorrect value for pad offset" ) ); return false; diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index 274114f9af..f20c389b43 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -52,7 +52,7 @@ void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC ) if( pt_pad ) { - pos = TO_LEGACY_LU_WXP( pt_pad->m_Pos ) - g_Offset_Module; + pos = pt_pad->m_Pos - g_Offset_Module; Track->m_Start = pos; } @@ -60,7 +60,7 @@ void DrawSegmentWhileMovingFootprint( EDA_DRAW_PANEL* panel, wxDC* DC ) if( pt_pad ) { - pos = TO_LEGACY_LU_WXP( pt_pad->m_Pos ) - g_Offset_Module; + pos = pt_pad->m_Pos - g_Offset_Module; Track->m_End = pos; } @@ -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 ); - pos = TO_LEGACY_LU_WXP( PtPad->m_Pos ); + pos = PtPad->m_Pos; LayerMask = PtPad->m_layerMask; for( ; Track; Track = Track->Next() ) diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index d510dc3a27..fc7cbfbc3b 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -54,24 +54,15 @@ void DRC::ShowDialog() // copy data retained in this DRC object into the m_ui DrcPanel: -#ifdef KICAD_NANOMETRE - LengthToTextCtrl( *m_ui->m_SetTrackMinWidthCtrl, - m_pcb->GetBoardDesignSettings()->m_TrackMinWidth ); - LengthToTextCtrl( *m_ui->m_SetViaMinSizeCtrl, - m_pcb->GetBoardDesignSettings()->m_MinVia.m_Diameter ); - LengthToTextCtrl( *m_ui->m_SetMicroViakMinSizeCtrl, - m_pcb->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ); -#else PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl, - TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_TrackMinWidth ), + m_pcb->GetBoardDesignSettings()->m_TrackMinWidth, m_mainWindow->m_InternalUnits ); PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl, - TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MinVia.m_Diameter ), + m_pcb->GetBoardDesignSettings()->m_ViasMinSize, m_mainWindow->m_InternalUnits ); PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl, - TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ), + m_pcb->GetBoardDesignSettings()->m_MicroViasMinSize, m_mainWindow->m_InternalUnits ); -#endif m_ui->m_CreateRptCtrl->SetValue( m_doCreateRptFile ); m_ui->m_RptFilenameCtrl->SetValue( m_rptFilename ); @@ -321,12 +312,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) } #endif - if( nc->GetTrackWidth() < TO_LEGACY_LU( g.m_TrackMinWidth ) ) + if( nc->GetTrackWidth() < g.m_TrackMinWidth ) { msg.Printf( _( "NETCLASS: '%s' has TrackWidth:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetTrackWidth() ), - FmtVal( TO_LEGACY_LU( g.m_TrackMinWidth ) ) + FmtVal( g.m_TrackMinWidth ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_TRACKWIDTH, msg, m_currentMarker ); @@ -335,12 +326,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetViaDiameter() < TO_LEGACY_LU( g.m_MinVia.m_Diameter ) ) + if( nc->GetViaDiameter() < g.m_ViasMinSize ) { msg.Printf( _( "NETCLASS: '%s' has Via Dia:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetViaDiameter() ), - FmtVal( TO_LEGACY_LU( g.m_MinVia.m_Diameter ) ) + FmtVal( g.m_ViasMinSize ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_VIASIZE, msg, m_currentMarker ); @@ -349,12 +340,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetViaDrill() < TO_LEGACY_LU( g.m_MinVia.m_Drill ) ) + if( nc->GetViaDrill() < g.m_ViasMinDrill ) { msg.Printf( _( "NETCLASS: '%s' has Via Drill:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetViaDrill() ), - FmtVal( TO_LEGACY_LU( g.m_MinVia.m_Drill ) ) + FmtVal( g.m_ViasMinDrill ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_VIADRILLSIZE, msg, m_currentMarker ); @@ -363,12 +354,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetuViaDiameter() < TO_LEGACY_LU( g.m_MinMicroVia.m_Diameter ) ) + if( nc->GetuViaDiameter() < g.m_MicroViasMinSize ) { msg.Printf( _( "NETCLASS: '%s' has uVia Dia:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetuViaDiameter() ), - FmtVal( TO_LEGACY_LU( g.m_MinMicroVia.m_Diameter ) ) + FmtVal( g.m_MicroViasMinSize ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_uVIASIZE, msg, m_currentMarker ); @@ -377,12 +368,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetuViaDrill() < TO_LEGACY_LU( g.m_MinMicroVia.m_Drill ) ) + if( nc->GetuViaDrill() < g.m_MicroViasMinDrill ) { msg.Printf( _( "NETCLASS: '%s' has uVia Drill:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetuViaDrill() ), - FmtVal( TO_LEGACY_LU( g.m_MinMicroVia.m_Drill ) ) + FmtVal( g.m_MicroViasMinDrill ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_uVIADRILLSIZE, msg, m_currentMarker ); @@ -577,7 +568,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li MODULE dummymodule( m_pcb ); // Creates a dummy parent D_PAD dummypad( &dummymodule ); dummypad.m_layerMask |= ALL_CU_LAYERS; // Ensure the hole is on all copper layers - dummypad.m_LocalClearance = FROM_LEGACY_LU( 1 ); /* Use the minimal local clearance value for the dummy pad + dummypad.m_LocalClearance = 1; /* Use the minimal local clearance value for the dummy pad * the clearance of the active pad will be used * as minimum distance to a hole * (a value = 0 means use netclass value) @@ -592,7 +583,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 // because the list is sorted by X values - if( TO_LEGACY_LU( pad->m_Pos.x() ) > x_limit ) + if( pad->m_Pos.x > x_limit ) break; // No problem if pads are on different copper layers, @@ -617,7 +608,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li /* Here, we must test clearance between holes and pads * dummy pad size and shape is adjusted to pad drill size and shape */ - if( pad->m_Drill.x() != ZERO_LENGTH ) + if( pad->m_Drill.x ) { // pad under testing has a hole, test this hole against pad reference dummypad.SetPosition( pad->GetPosition() ); @@ -637,7 +628,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 ) // pad reference has a hole { dummypad.SetPosition( aRefPad->GetPosition() ); dummypad.m_Size = aRefPad->m_Drill; diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index 785a2f3ef3..63358f1436 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -290,10 +290,10 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) * checkClearanceSegmToPad(),a pseudo pad is used, with a shape and a * size like the hole */ - if( pad->m_Drill.x() == ZERO_LENGTH ) + if( pad->m_Drill.x == 0 ) continue; - dummypad.m_Size = pad->m_Drill; + dummypad.m_Size = pad->m_Drill; dummypad.SetPosition( pad->GetPosition() ); dummypad.m_PadShape = pad->m_DrillShape; dummypad.m_Orient = pad->m_Orient; @@ -633,7 +633,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) m_segmEnd.x = m_segmEnd.y = 0; m_padToTestPos = relativePadPos; - diag = checkClearanceSegmToPad( aPad, TO_LEGACY_LU( aRefPad->m_Size.x() ), dist_min ); + diag = checkClearanceSegmToPad( aPad, aRefPad->m_Size.x, dist_min ); break; case PAD_RECT: @@ -644,7 +644,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) if( aPad->m_PadShape == PAD_RECT ) { - wxSize size = TO_LEGACY_LU_WXS( aPad->m_Size ); + wxSize size = aPad->m_Size; // The trivial case is if both rects are rotated by multiple of 90 deg // Most of time this is the case, and the test is fast @@ -664,10 +664,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) relativePadPos.x = ABS( relativePadPos.x ); relativePadPos.y = ABS( relativePadPos.y ); - if( ( relativePadPos.x - ( (size.x + TO_LEGACY_LU( aRefPad->m_Size.x() ) ) / 2 ) ) >= dist_min ) + if( ( relativePadPos.x - ( (size.x + aRefPad->m_Size.x) / 2 ) ) >= dist_min ) diag = true; - if( ( relativePadPos.y - ( (size.y + TO_LEGACY_LU( aRefPad->m_Size.y() ) ) / 2 ) ) >= dist_min ) + if( ( relativePadPos.y - ( (size.y + aRefPad->m_Size.y) / 2 ) ) >= dist_min ) diag = true; } 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 ) int segm_width; 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() ); - m_segmLength = TO_LEGACY_LU( aRefPad->m_Size.x() - aRefPad->m_Size.y() ); + segm_width = aRefPad->m_Size.y; + m_segmLength = aRefPad->m_Size.x - aRefPad->m_Size.y; } else // Vertical oval: build an horizontal equiv segment and rotate 90.0 deg { - segm_width = TO_LEGACY_LU( aRefPad->m_Size.x() ); - m_segmLength = TO_LEGACY_LU( aRefPad->m_Size.y() - aRefPad->m_Size.x() ); + segm_width = aRefPad->m_Size.x; + m_segmLength = aRefPad->m_Size.y - aRefPad->m_Size.x; m_segmAngle += 900; } @@ -796,13 +796,13 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi int segmHalfWidth = aSegmentWidth / 2; seuil = segmHalfWidth + aMinDist; - padHalfsize.x = TO_LEGACY_LU( aPad->m_Size.x() / 2 ); - padHalfsize.y = TO_LEGACY_LU( aPad->m_Size.y() / 2 ); + padHalfsize.x = aPad->m_Size.x >> 1; + padHalfsize.y = aPad->m_Size.y >> 1; 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.y += TO_LEGACY_LU( abs( aPad->m_DeltaSize.x() ) / 2 ); // Remember: m_DeltaSize.x is the m_Size.y change + padHalfsize.x += ABS(aPad->m_DeltaSize.y) / 2; // Remember: m_DeltaSize.y is the m_Size.x change + padHalfsize.y += ABS(aPad->m_DeltaSize.x) / 2; // Remember: m_DeltaSize.x is the m_Size.y change } if( aPad->m_PadShape == PAD_CIRCLE ) diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h index 643979d0af..086ce4be25 100644 --- a/pcbnew/drc_stuff.h +++ b/pcbnew/drc_stuff.h @@ -69,10 +69,10 @@ #define DRCE_TOO_SMALL_MICROVIA 29 ///< Too small micro via size #define DRCE_NETCLASS_TRACKWIDTH 30 ///< netclass has TrackWidth < board.m_designSettings->m_TrackMinWidth #define DRCE_NETCLASS_CLEARANCE 31 ///< netclass has Clearance < board.m_designSettings->m_TrackClearance -#define DRCE_NETCLASS_VIASIZE 32 ///< netclass has ViaSize < board.m_designSettings->m_MinVia.m_Diameter -#define DRCE_NETCLASS_VIADRILLSIZE 33 ///< netclass has ViaDrillSize < board.m_designSettings->m_MinVia.m_Drill -#define DRCE_NETCLASS_uVIASIZE 34 ///< netclass has ViaSize < board.m_designSettings->m_MinMicroVia.m_Diameter -#define DRCE_NETCLASS_uVIADRILLSIZE 35 ///< netclass has ViaSize < board.m_designSettings->m_MinMicroVia.m_Drill +#define DRCE_NETCLASS_VIASIZE 32 ///< netclass has ViaSize < board.m_designSettings->m_ViasMinSize +#define DRCE_NETCLASS_VIADRILLSIZE 33 ///< netclass has ViaDrillSize < board.m_designSettings->m_ViasMinDrill +#define DRCE_NETCLASS_uVIASIZE 34 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinSize +#define DRCE_NETCLASS_uVIADRILLSIZE 35 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinDrill class EDA_DRAW_PANEL; diff --git a/pcbnew/editmod.cpp b/pcbnew/editmod.cpp index 6c8362bee4..5592b84084 100644 --- a/pcbnew/editmod.cpp +++ b/pcbnew/editmod.cpp @@ -82,7 +82,7 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod ) for( ; pt_pad != NULL; pt_pad = pt_pad->Next() ) { - pt_pad->m_Pos0 += VECTOR_PCB::fromXY( FROM_LEGACY_LU( moveVector.x ), FROM_LEGACY_LU( moveVector.y ) ); + pt_pad->m_Pos0 += moveVector; } /* Update the draw element coordinates. */ @@ -93,7 +93,7 @@ void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod ) switch( PtStruct->Type() ) { case PCB_MODULE_EDGE_T: - #undef STRUCT /// @BUG: unsafe type cast + #undef STRUCT #define STRUCT ( (EDGE_MODULE*) PtStruct ) STRUCT->m_Start0 += moveVector; STRUCT->m_End0 += moveVector; diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 8c37a12788..7bff597fc5 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -125,7 +125,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) pt_pad = (D_PAD*) LockPoint; /* A pad is found: put the starting point on pad center */ - pos = TO_LEGACY_LU_WXP( pt_pad->m_Pos ); + pos = pt_pad->m_Pos; GetBoard()->SetHighLightNet( pt_pad->GetNet() ); } else /* A track segment is found */ @@ -783,7 +783,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo if( g_FirstTrackSegment->GetState( BEGIN_ONPAD ) ) { D_PAD * pad = (D_PAD *) g_FirstTrackSegment->start; - lenDie = TO_LEGACY_LU_DBL( pad->m_LengthDie ); + lenDie = (double) pad->m_LengthDie; } // calculate track len on board: @@ -1067,7 +1067,7 @@ void DeleteNullTrackSegments( BOARD* pcb, DLIST& aTrackList ) */ void EnsureEndTrackOnPad( D_PAD* Pad ) { - if( g_CurrentTrackSegment->m_End == TO_LEGACY_LU_WXP( Pad->m_Pos ) ) // Ok ! + if( g_CurrentTrackSegment->m_End == Pad->m_Pos ) // Ok ! { g_CurrentTrackSegment->end = Pad; g_CurrentTrackSegment->SetState( END_ONPAD, ON ); @@ -1084,7 +1084,7 @@ void EnsureEndTrackOnPad( D_PAD* Pad ) lasttrack->end = g_CurrentTrackSegment; } - g_CurrentTrackSegment->m_End = TO_LEGACY_LU_WXP( Pad->m_Pos ); + g_CurrentTrackSegment->m_End = Pad->m_Pos; g_CurrentTrackSegment->SetState( END_ONPAD, OFF ); g_CurrentTrackSegment->end = Pad; diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index b2f588342d..07531ce9bf 100644 --- a/pcbnew/export_gencad.cpp +++ b/pcbnew/export_gencad.cpp @@ -252,70 +252,70 @@ void CreatePadsShapesSection( FILE* file, BOARD* pcb ) fprintf( file, "PAD PAD%d", pad->GetSubRatsnest() ); - int dx = TO_LEGACY_LU( pad->m_Size.x() / 2 ); - int dy = TO_LEGACY_LU( pad->m_Size.y() / 2 ); + int dx = pad->m_Size.x / 2; + int dy = pad->m_Size.y / 2; switch( pad->m_PadShape ) { default: case PAD_CIRCLE: - pad_type = "ROUND"; // how about oval holes? - fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x() ) ); + pad_type = "ROUND"; + fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); fprintf( file, "CIRCLE %d %d %d\n", - TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ), dx ); + pad->m_Offset.x, -pad->m_Offset.y, dx ); break; case PAD_RECT: 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, pad->m_Drill.x ); 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_Size.x() ), TO_LEGACY_LU( pad->m_Size.y() ) ); + pad->m_Offset.x - dx, -pad->m_Offset.y - dy, + pad->m_Size.x, pad->m_Size.y ); break; case PAD_OVAL: /* Create outline by 2 lines and 2 arcs */ { pad_type = "FINGER"; - fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x() ) ); + fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); int dr = dx - dy; if( dr >= 0 ) // Horizontal oval { int radius = dy; fprintf( file, "LINE %d %d %d %d\n", - -dr + 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 + pad->m_Offset.x, -pad->m_Offset.y - radius, + dr + pad->m_Offset.x, -pad->m_Offset.y - radius ); 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() ) ); + dr + pad->m_Offset.x, -pad->m_Offset.y - radius, + dr + pad->m_Offset.x, -pad->m_Offset.y + radius, + dr + pad->m_Offset.x, -pad->m_Offset.y ); 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 + pad->m_Offset.x, -pad->m_Offset.y + radius, + -dr + pad->m_Offset.x, -pad->m_Offset.y + radius ); 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() ) ); + -dr + pad->m_Offset.x, -pad->m_Offset.y + radius, + -dr + pad->m_Offset.x, -pad->m_Offset.y - radius, + -dr + pad->m_Offset.x, -pad->m_Offset.y ); } else // Vertical oval { dr = -dr; int radius = dx; 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 + pad->m_Offset.x, -pad->m_Offset.y - dr, + -radius + pad->m_Offset.x, -pad->m_Offset.y + dr ); 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, - TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ) + dr ); + -radius + pad->m_Offset.x, -pad->m_Offset.y + dr, + radius + pad->m_Offset.x, -pad->m_Offset.y + dr, + pad->m_Offset.x, -pad->m_Offset.y + dr ); 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 + pad->m_Offset.x, -pad->m_Offset.y + dr, + radius + pad->m_Offset.x, -pad->m_Offset.y - dr ); 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, - TO_LEGACY_LU( pad->m_Offset.x() ), -TO_LEGACY_LU( pad->m_Offset.y() ) - dr ); + radius + pad->m_Offset.x, -pad->m_Offset.y - dr, + -radius + pad->m_Offset.x, -pad->m_Offset.y - dr, + pad->m_Offset.x, -pad->m_Offset.y - dr ); } break; } @@ -410,7 +410,7 @@ void CreateShapesSection( FILE* file, BOARD* pcb ) NORMALIZE_ANGLE_POS( orient ); fprintf( file, "PIN %s PAD%d %d %d %s %d %s", TO_UTF8( pinname ), pad->GetSubRatsnest(), - TO_LEGACY_LU( pad->m_Pos0.x() ), TO_LEGACY_LU( -pad->m_Pos0.y() ), + pad->m_Pos0.x, -pad->m_Pos0.y, layer, orient / 10, mirror ); if( orient % 10 ) diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index e6aa6a81ae..c4d4ca86d1 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -881,11 +881,11 @@ static void export_vrml_edge_module( EDGE_MODULE* module ) /*{{{*/ 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_h = (double) TO_LEGACY_LU_DBL( pad->m_Drill.y() / 2 ); + double hole_drill_w = (double) pad->m_Drill.x / 2; + double hole_drill_h = (double) pad->m_Drill.y / 2; double hole_drill = MIN( hole_drill_w, hole_drill_h ); - double hole_x = TO_LEGACY_LU_DBL( pad->m_Pos.x() ); - double hole_y = TO_LEGACY_LU_DBL( pad->m_Pos.y() ); + double hole_x = pad->m_Pos.x; + double hole_y = pad->m_Pos.y; /* Export the hole on the edge layer */ if( hole_drill > 0 ) @@ -913,11 +913,11 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/ wxPoint pad_pos = pad->ReturnShapePos(); double pad_x = pad_pos.x; double pad_y = pad_pos.y; - wxSize pad_delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize ); + wxSize pad_delta = pad->m_DeltaSize; double pad_dx = pad_delta.x / 2; double pad_dy = pad_delta.y / 2; - double pad_w = TO_LEGACY_LU_DBL( pad->m_Size.x() / 2 ); - double pad_h = TO_LEGACY_LU_DBL( pad->m_Size.y() / 2 ); + double pad_w = pad->m_Size.x / 2; + double pad_h = pad->m_Size.y / 2; for( int layer = FIRST_COPPER_LAYER; layer < copper_layers; layer++ ) { diff --git a/pcbnew/gen_holes_and_tools_lists_for_drill.cpp b/pcbnew/gen_holes_and_tools_lists_for_drill.cpp index fc6927a527..8f486b3708 100644 --- a/pcbnew/gen_holes_and_tools_lists_for_drill.cpp +++ b/pcbnew/gen_holes_and_tools_lists_for_drill.cpp @@ -127,22 +127,21 @@ void Build_Holes_List( BOARD* aPcb, if( aGenerateNPTH_list && pad->m_Attribut != PAD_HOLE_NOT_PLATED ) continue; - if( pad->m_Drill.x() == ZERO_LENGTH ) + if( pad->m_Drill.x == 0 ) continue; new_hole.m_Hole_NotPlated = (pad->m_Attribut == PAD_HOLE_NOT_PLATED); new_hole.m_Tool_Reference = -1; // Flag is: Not initialized new_hole.m_Hole_Orient = pad->m_Orient; new_hole.m_Hole_Shape = 0; // hole shape: round - new_hole.m_Hole_Diameter = min( TO_LEGACY_LU( pad->m_Drill.x() ), TO_LEGACY_LU( pad->m_Drill.y() ) ); + new_hole.m_Hole_Diameter = min( pad->m_Drill.x, pad->m_Drill.y ); new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter; if( pad->m_DrillShape != PAD_CIRCLE ) new_hole.m_Hole_Shape = 1; // oval flag set - new_hole.m_Hole_Size.x = TO_LEGACY_LU( pad->m_Drill.x() ); - new_hole.m_Hole_Size.y = TO_LEGACY_LU( pad->m_Drill.y() ); - new_hole.m_Hole_Pos = TO_LEGACY_LU_WXP( pad->m_Pos ); // hole position + new_hole.m_Hole_Size = pad->m_Drill; + new_hole.m_Hole_Pos = pad->m_Pos; // hole position new_hole.m_Hole_Bottom_Layer = LAYER_N_BACK; new_hole.m_Hole_Top_Layer = LAYER_N_FRONT;// pad holes are through holes aHoleListBuffer.push_back( new_hole ); diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index 0b07d63b04..dd30b96db5 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -438,20 +438,19 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) { fprintf( rptfile, "$PAD \"%.4s\"\n", pad->m_Padname ); sprintf( line, "position %9.6f %9.6f\n", - TO_LEGACY_LU_DBL( pad->m_Pos0.x() ) * conv_unit, - TO_LEGACY_LU_DBL( pad->m_Pos0.y() ) * conv_unit ); + pad->m_Pos0.x * conv_unit, + pad->m_Pos0.y * conv_unit ); fputs( line, rptfile ); 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.y() ) * conv_unit ); + pad->m_Size.x * conv_unit, + pad->m_Size.y * conv_unit ); 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", pad->m_Drill.x * conv_unit ); fputs( line, rptfile ); 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.y() ) * conv_unit ); + pad->m_Offset.x * conv_unit, + pad->m_Offset.y * conv_unit ); fputs( line, rptfile ); sprintf( line, "orientation %.2f\n", diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 82ecb13d19..51c77339dc 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -254,19 +254,19 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) if( pt_pad->m_PadShape != PAD_TRAPEZOID ) { - pt_pad->m_DeltaSize.x( ZERO_LENGTH ); - pt_pad->m_DeltaSize.y( ZERO_LENGTH ); + pt_pad->m_DeltaSize.x = 0; + pt_pad->m_DeltaSize.y = 0; } 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 ) { case PAD_SMD: case PAD_CONN: - 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.y( ZERO_LENGTH ); + pt_pad->m_Drill = wxSize( 0, 0 ); + pt_pad->m_Offset.x = 0; + pt_pad->m_Offset.y = 0; break; default: diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index d41f5c96d7..a510248ec4 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -369,14 +369,16 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) { Pad->SetPadName( params[10] ); } - Pad->m_Size.x( FROM_LEGACY_LU( ibuf[4] + abs( ibuf[0] - ibuf[2] ) ) ); - Pad->m_Size.y( FROM_LEGACY_LU( ibuf[4] + abs( ibuf[1] - ibuf[3] ) ) ); - Pad->m_Pos.x( FROM_LEGACY_LU( (ibuf[0] + ibuf[2]) / 2 + m_Pos.x ) ); - Pad->m_Pos.y( FROM_LEGACY_LU( (ibuf[1] + ibuf[3]) / 2 + m_Pos.y ) ); + Pad->m_Pos.x = (ibuf[0] + ibuf[2]) / 2; + Pad->m_Pos.y = (ibuf[1] + ibuf[3]) / 2; + Pad->m_Size.x = ibuf[4] + abs( ibuf[0] - ibuf[2] ); + Pad->m_Size.y = ibuf[4] + abs( ibuf[1] - ibuf[3] ); + Pad->m_Pos.x += m_Pos.x; + Pad->m_Pos.y += m_Pos.y; 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; else Pad->m_PadShape = PAD_OVAL; @@ -426,14 +428,14 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) Pad->SetPadName( params[9] ); } - Pad->m_Drill.x( FROM_LEGACY_LU( (int) ibuf[5] ) ); - Pad->m_Drill.y( Pad->m_Drill.x() ); - Pad->m_Size.x( FROM_LEGACY_LU( ibuf[3] ) + Pad->m_Drill.x() ); - Pad->m_Size.y( Pad->m_Size.x() ); - Pad->m_Pos.x( FROM_LEGACY_LU( ibuf[0] + m_Pos.x ) ); - Pad->m_Pos.y( FROM_LEGACY_LU( ibuf[1] + m_Pos.y ) ); + Pad->m_Pos.x = ibuf[0]; + Pad->m_Pos.y = ibuf[1]; + Pad->m_Drill.x = Pad->m_Drill.y = ibuf[5]; + Pad->m_Size.x = Pad->m_Size.y = ibuf[3] + Pad->m_Drill.x; + Pad->m_Pos.x += m_Pos.x; + Pad->m_Pos.y += 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; m_Pads.PushBack( Pad ); diff --git a/pcbnew/graphpcb.cpp b/pcbnew/graphpcb.cpp index ed0753d8f3..8550b6e3c9 100644 --- a/pcbnew/graphpcb.cpp +++ b/pcbnew/graphpcb.cpp @@ -89,7 +89,7 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic ) int dx, dy; wxPoint shape_pos = pt_pad->ReturnShapePos(); - dx = TO_LEGACY_LU( pt_pad->m_Size.x() / 2 ); + dx = pt_pad->m_Size.x / 2; dx += marge; if( pt_pad->m_PadShape == PAD_CIRCLE ) @@ -100,13 +100,13 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic ) } - dy = TO_LEGACY_LU( pt_pad->m_Size.y() / 2 ); + dy = pt_pad->m_Size.y / 2; dy += marge; if( pt_pad->m_PadShape == PAD_TRAPEZOID ) { - dx += TO_LEGACY_LU( abs( pt_pad->m_DeltaSize.y() ) / 2 ); - dy += TO_LEGACY_LU( abs( pt_pad->m_DeltaSize.x() ) / 2 ); + dx += abs( pt_pad->m_DeltaSize.y ) / 2; + dy += abs( pt_pad->m_DeltaSize.x ) / 2; } if( ( pt_pad->m_Orient % 900 ) == 0 ) /* The pad is a rectangle diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 590f89339d..7d90c55537 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -436,21 +436,20 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "TrackWidthList" ) == 0 ) { - //double tmp = atof( data ); - GetBoard()->m_TrackWidthList.push_back( LENGTH_LOAD_STR( data ) ); + int tmp = atoi( data ); + GetBoard()->m_TrackWidthList.push_back( tmp ); continue; } if( stricmp( line, "TrackClearence" ) == 0 ) { - netclass_default->Clearance( LENGTH_LOAD_STR( data ) ); + netclass_default->SetClearance( atoi( data ) ); continue; } if( stricmp( line, "TrackMinWidth" ) == 0 ) { - //double width = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_TrackMinWidth = LENGTH_LOAD_STR( data ); + GetBoard()->GetBoardDesignSettings()->m_TrackMinWidth = atoi( data ); continue; } @@ -479,8 +478,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "ViaMinSize" ) == 0 ) { - //double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_MinVia.m_Diameter = LENGTH_LOAD_STR( data ); + GetBoard()->GetBoardDesignSettings()->m_ViasMinSize = atoi( data ); continue; } @@ -491,23 +489,21 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "MicroViaMinSize" ) == 0 ) { - //double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter = LENGTH_LOAD_STR( data ); + GetBoard()->GetBoardDesignSettings()->m_MicroViasMinSize = atoi( data ); continue; } if( stricmp( line, "ViaSizeList" ) == 0 ) { - //double tmp = atof( data ); + int tmp = atoi( data ); VIA_DIMENSION via_dim; - via_dim.m_Diameter = LENGTH_LOAD_STR( data ); + via_dim.m_Diameter = tmp; data = strtok( NULL, " \n\r" ); if( data ) { - //tmp = atof( data ); - LENGTH_PCB tmp = LENGTH_LOAD_STR( data ); - via_dim.m_Drill = tmp > ZERO_LENGTH ? tmp : ZERO_LENGTH; + tmp = atoi( data ); + via_dim.m_Drill = tmp > 0 ? tmp : 0; } GetBoard()->m_ViasDimensionsList.push_back( via_dim ); @@ -516,31 +512,28 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "ViaDrill" ) == 0 ) { - VIA_DIMENSION via = netclass_default->Via(); - via.m_Drill = LENGTH_LOAD_STR( data ); - netclass_default->Via( via ); + int diameter = atoi( data ); + netclass_default->SetViaDrill( diameter ); continue; } if( stricmp( line, "ViaMinDrill" ) == 0 ) { - //double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_MinVia.m_Drill = LENGTH_LOAD_STR( data ); + GetBoard()->GetBoardDesignSettings()->m_ViasMinDrill = atoi( data ); continue; } if( stricmp( line, "MicroViaDrill" ) == 0 ) { - VIA_DIMENSION via = netclass_default->MicroVia(); - via.m_Drill = LENGTH_LOAD_STR( data ); - netclass_default->MicroVia( via ); + int diameter = atoi( data ); + netclass_default->SetuViaDrill( diameter ); continue; } if( stricmp( line, "MicroViaMinDrill" ) == 0 ) { - //double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_MinMicroVia.m_Drill = LENGTH_LOAD_STR( data ); + int diameter = atoi( data ); + GetBoard()->GetBoardDesignSettings()->m_MicroViasMinDrill = diameter; continue; } @@ -586,16 +579,16 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "PadSize" ) == 0 ) { - g_Pad_Master.m_Size.x( LENGTH_LOAD_STR( data ) ); + g_Pad_Master.m_Size.x = atoi( data ); data = strtok( NULL, delims ); - g_Pad_Master.m_Size.y( LENGTH_LOAD_STR( data ) ); + g_Pad_Master.m_Size.y = atoi( data ); continue; } if( stricmp( line, "PadDrill" ) == 0 ) { - 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.x = atoi( data ); + g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x; continue; } @@ -696,57 +689,41 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) // Save custom tracks width list (the first is not saved here: this is the netclass value for( unsigned ii = 1; ii < aBoard->m_TrackWidthList.size(); ii++ ) - fprintf( aFile, "TrackWidthList "FM_LENSV"\n", ARG_LENSV( aBoard->m_TrackWidthList[ii] ) ); + fprintf( aFile, "TrackWidthList %d\n", aBoard->m_TrackWidthList[ii] ); - fprintf( aFile, - "TrackClearence "FM_LENSV"\n", - ARG_LENSV( netclass_default->Clearance() ) ); + fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() ); fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); - fprintf( aFile, - "TrackMinWidth "FM_LENSV"\n", - ARG_LENSV( aBoard->GetBoardDesignSettings()->m_TrackMinWidth ) ); + fprintf( aFile, "TrackMinWidth %d\n", aBoard->GetBoardDesignSettings()->m_TrackMinWidth ); fprintf( aFile, "DrawSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_DrawSegmentWidth ); fprintf( aFile, "EdgeSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_EdgeSegmentWidth ); // Save current default via size, for compatibility with older Pcbnew version; - fprintf( aFile, - "ViaSize "FM_LENSV"\n", - ARG_LENSV( netclass_default->Via().m_Diameter ) ); - fprintf( aFile, - "ViaDrill "FM_LENSV"\n", - ARG_LENSV( netclass_default->Via().m_Drill ) ); - fprintf( aFile, - "ViaMinSize "FM_LENSV"\n", - ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinVia.m_Diameter ) ); - fprintf( aFile, - "ViaMinDrill "FM_LENSV"\n", - ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinVia.m_Drill ) ); + fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() ); + fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() ); + fprintf( aFile, "ViaMinSize %d\n", aBoard->GetBoardDesignSettings()->m_ViasMinSize ); + fprintf( aFile, "ViaMinDrill %d\n", aBoard->GetBoardDesignSettings()->m_ViasMinDrill ); // Save custom vias diameters list (the first is not saved here: this is // the netclass value for( unsigned ii = 1; ii < aBoard->m_ViasDimensionsList.size(); ii++ ) - fprintf( aFile, "ViaSizeList "FM_LENSV" "FM_LENSV"\n", - ARG_LENSV( aBoard->m_ViasDimensionsList[ii].m_Diameter ), - ARG_LENSV( aBoard->m_ViasDimensionsList[ii].m_Drill ) ); + fprintf( aFile, "ViaSizeList %d %d\n", + aBoard->m_ViasDimensionsList[ii].m_Diameter, + aBoard->m_ViasDimensionsList[ii].m_Drill ); // for old versions compatibility: - fprintf( aFile, - "MicroViaSize "FM_LENSV"\n", - ARG_LENSV( netclass_default->MicroVia().m_Diameter ) ); - fprintf( aFile, - "MicroViaDrill "FM_LENSV"\n", - ARG_LENSV( netclass_default->MicroVia().m_Drill ) ); + fprintf( aFile, "MicroViaSize %d\n", netclass_default->GetuViaDiameter() ); + fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() ); fprintf( aFile, "MicroViasAllowed %d\n", aBoard->GetBoardDesignSettings()->m_MicroViasAllowed ); fprintf( aFile, - "MicroViaMinSize "FM_LENSV"\n", - ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ) ); + "MicroViaMinSize %d\n", + aBoard->GetBoardDesignSettings()->m_MicroViasMinSize ); fprintf( aFile, - "MicroViaMinDrill "FM_LENSV"\n", - ARG_LENSV( aBoard->GetBoardDesignSettings()->m_MinMicroVia.m_Drill ) ); + "MicroViaMinDrill %d\n", + aBoard->GetBoardDesignSettings()->m_MicroViasMinDrill ); fprintf( aFile, "TextPcbWidth %d\n", aBoard->GetBoardDesignSettings()->m_PcbTextWidth ); fprintf( aFile, @@ -757,8 +734,8 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth ); fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y ); fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth ); - fprintf( aFile, "PadSize "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, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); + fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); fprintf( aFile, "Pad2MaskClearance %d\n", aBoard->GetBoardDesignSettings()->m_SolderMaskMargin ); diff --git a/pcbnew/magnetic_tracks_functions.cpp b/pcbnew/magnetic_tracks_functions.cpp index fed6be7779..a9e4791471 100644 --- a/pcbnew/magnetic_tracks_functions.cpp +++ b/pcbnew/magnetic_tracks_functions.cpp @@ -165,7 +165,7 @@ bool Magnetize( BOARD* m_Pcb, PCB_EDIT_FRAME* frame, int aCurrentTool, wxSize gr if( doCheckNet && currTrack && currTrack->GetNet() != pad->GetNet() ) return false; - *curpos = TO_LEGACY_LU_WXP( pad->m_Pos ); + *curpos = pad->m_Pos; return true; } } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index adcee931af..d5176ca4bb 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -692,7 +692,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) DrawPanel->Refresh(); } -// TODO: this should be refactored in the name of good programming style + void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) { D_PAD* pad = module->m_Pads; @@ -710,16 +710,9 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) { pad->m_Pos0 = pad->m_Pos; pad->m_Orient -= angle; - wxPoint of; - of.x = TO_LEGACY_LU( pad->m_Offset.x() ); - of.y = TO_LEGACY_LU( pad->m_Offset.y() ); - RotatePoint( &of.x, &of.y, angle ); - pad->m_Offset.x( FROM_LEGACY_LU( of.x ) ); - pad->m_Offset.y( FROM_LEGACY_LU( of.y ) ); - EXCHG( pad->m_Size[0], pad->m_Size[1] ); /// @TODO: make it using geom. transform - wxSize delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize ); - RotatePoint( &delta.x, &delta.y, -angle ); - pad->m_DeltaSize = VECTOR_PCB::fromXY( FROM_LEGACY_LU( delta.x ), FROM_LEGACY_LU( delta.y ) ); + RotatePoint( &pad->m_Offset.x, &pad->m_Offset.y, angle ); + EXCHG( pad->m_Size.x, pad->m_Size.y ); + RotatePoint( &pad->m_DeltaSize.x, &pad->m_DeltaSize.y, -angle ); } module->m_Reference->m_Pos0 = module->m_Reference->m_Pos; @@ -756,10 +749,10 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) case ID_MODEDIT_MODULE_MIRROR: for( ; pad != NULL; pad = (D_PAD*) pad->Next() ) { - pad->m_Pos.y( -pad->m_Pos.y() ); - pad->m_Pos0.y( -pad->m_Pos0.y() ); - pad->m_Offset.y( -pad->m_Offset.y() ); - pad->m_DeltaSize.y( -pad->m_DeltaSize.y() ); + NEGATE( pad->m_Pos.y ); + NEGATE( pad->m_Pos0.y ); + NEGATE( pad->m_Offset.y ); + NEGATE( pad->m_DeltaSize.y ); if( pad->m_Orient ) pad->m_Orient = 3600 - pad->m_Orient; diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index dd6951a7b5..a00d3c0c76 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -23,7 +23,7 @@ static D_PAD* s_CurrentSelectedPad; -static VECTOR_PCB Pad_OldPos; +static wxPoint Pad_OldPos; /* Cancel move pad command. @@ -76,7 +76,7 @@ static void Show_Pad_Move( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPo if( aErase ) pad->Draw( aPanel, aDC, GR_XOR ); - pad->m_Pos = FROM_LEGACY_LU_VEC( screen->GetCrossHairPosition() ); + pad->m_Pos = screen->GetCrossHairPosition(); pad->Draw( aPanel, aDC, GR_XOR ); if( !g_Drag_Pistes_On ) @@ -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 ) { - Track->m_Start = TO_LEGACY_LU_WXP( pad->m_Pos ); + Track->m_Start = pad->m_Pos; } if( g_DragSegmentList[ii].m_Pad_End ) { - Track->m_End = TO_LEGACY_LU_WXP( pad->m_Pos ); + Track->m_End = pad->m_Pos; } Track->Draw( aPanel, aDC, GR_XOR ); @@ -148,7 +148,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) aPad->m_Orient = g_Pad_Master.m_Orient + ( (MODULE*) aPad->GetParent() )->m_Orient; aPad->m_Size = g_Pad_Master.m_Size; - aPad->m_DeltaSize = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH );//wxSize( 0, 0 ); + aPad->m_DeltaSize = wxSize( 0, 0 ); aPad->m_Offset = g_Pad_Master.m_Offset; aPad->m_Drill = g_Pad_Master.m_Drill; aPad->m_DrillShape = g_Pad_Master.m_DrillShape; @@ -160,7 +160,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) break; case PAD_CIRCLE: - aPad->m_Size.y( aPad->m_Size.x() ); + aPad->m_Size.y = aPad->m_Size.x; break; } @@ -168,8 +168,9 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) { case PAD_SMD: case PAD_CONN: - aPad->m_Drill = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 ); - aPad->m_Offset = VECTOR_PCB::fromXY( ZERO_LENGTH, ZERO_LENGTH ); + aPad->m_Drill = wxSize( 0, 0 ); + aPad->m_Offset.x = 0; + aPad->m_Offset.y = 0; } aPad->ComputeShapeMaxRadius(); @@ -200,14 +201,12 @@ void PCB_BASE_FRAME::AddPad( MODULE* Module, bool draw ) Import_Pad_Settings( Pad, false ); Pad->SetNetname( wxEmptyString ); - Pad->m_Pos = FROM_LEGACY_LU_VEC( GetScreen()->GetCrossHairPosition() ); + Pad->m_Pos = GetScreen()->GetCrossHairPosition(); // Set the relative pad position // ( pad position for module orient, 0, and relative to the module position) - Pad->m_Pos0 = Pad->m_Pos - FROM_LEGACY_LU_VEC( Module->m_Pos ); - wxPoint p = TO_LEGACY_LU_WXP( Pad->m_Pos0 ); - RotatePoint( &p, -Module->m_Orient ); - Pad->m_Pos0 = FROM_LEGACY_LU_VEC( p ); + Pad->m_Pos0 = Pad->m_Pos - Module->m_Pos; + RotatePoint( &Pad->m_Pos0, -Module->m_Orient ); /* Automatically increment the current pad number. */ long num = 0; @@ -317,17 +316,17 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) // Set the old state if( g_DragSegmentList[ii].m_Pad_Start ) - Track->m_Start = TO_LEGACY_LU_WXP( Pad_OldPos ); + Track->m_Start = Pad_OldPos; if( g_DragSegmentList[ii].m_Pad_End ) - Track->m_End = TO_LEGACY_LU_WXP( Pad_OldPos ); + Track->m_End = Pad_OldPos; picker.m_PickedItem = Track; pickList.PushItem( picker ); } /* Save old module and old items values */ - wxPoint pad_curr_position = TO_LEGACY_LU_WXP( Pad->m_Pos ); + wxPoint pad_curr_position = Pad->m_Pos; Pad->m_Pos = Pad_OldPos; @@ -340,7 +339,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) SaveCopyInUndoList( pickList, UR_CHANGED ); } - Pad->m_Pos = FROM_LEGACY_LU_VEC( pad_curr_position ); + Pad->m_Pos = pad_curr_position; Pad->Draw( DrawPanel, DC, GR_XOR ); /* Redraw dragged track segments */ @@ -350,10 +349,10 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) // Set the new state if( g_DragSegmentList[ii].m_Pad_Start ) - Track->m_Start = TO_LEGACY_LU_WXP( Pad->m_Pos ); + Track->m_Start = Pad->m_Pos; if( g_DragSegmentList[ii].m_Pad_End ) - Track->m_End = TO_LEGACY_LU_WXP( Pad->m_Pos ); + Track->m_End = Pad->m_Pos; Track->SetState( IN_EDIT, OFF ); @@ -362,12 +361,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) */ - dX = TO_LEGACY_LU( Pad->m_Pos.x() - Pad_OldPos.x() ); - dY = TO_LEGACY_LU( Pad->m_Pos.y() - Pad_OldPos.y() ); + dX = Pad->m_Pos.x - Pad_OldPos.x; + dY = Pad->m_Pos.y - Pad_OldPos.y; RotatePoint( &dX, &dY, -Module->m_Orient ); - Pad->m_Pos0.x( Pad->m_Pos0.x() + FROM_LEGACY_LU( dX ) ); - Pad->m_Pos0.y( Pad->m_Pos0.y() + FROM_LEGACY_LU( dY ) ); /// @BUG was it really s_CurrentSelectedPad ??? + Pad->m_Pos0.x += dX; + s_CurrentSelectedPad->m_Pos0.y += dY; Pad->m_Flags = 0; @@ -402,13 +401,13 @@ void PCB_BASE_FRAME::RotatePad( D_PAD* Pad, wxDC* DC ) if( DC ) Module->Draw( DrawPanel, DC, GR_XOR ); - EXCHG( Pad->m_Size[0], Pad->m_Size[1] ); /// @TODO: make it using geom. transform - EXCHG( Pad->m_Drill[0], Pad->m_Drill[1] ); - EXCHG( Pad->m_Offset[0], Pad->m_Offset[1] ); - Pad->m_Offset.y( -Pad->m_Offset.y() ); + EXCHG( Pad->m_Size.x, Pad->m_Size.y ); + EXCHG( Pad->m_Drill.x, Pad->m_Drill.y ); + EXCHG( Pad->m_Offset.x, Pad->m_Offset.y ); + Pad->m_Offset.y = -Pad->m_Offset.y; - EXCHG( Pad->m_DeltaSize[0], Pad->m_DeltaSize[1] ); - Pad->m_DeltaSize.x( -Pad->m_DeltaSize.x() ); + EXCHG( Pad->m_DeltaSize.x, Pad->m_DeltaSize.y ); + Pad->m_DeltaSize.x = -Pad->m_DeltaSize.x; Module->CalculateBoundingBox(); Pad->DisplayInfo( this ); diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 424861ccbc..6cba5d2d9c 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -260,11 +260,10 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) Module->m_Pads.PushFront( PtPad ); PtPad->SetPadName( wxT( "1" ) ); - PtPad->m_Pos = FROM_LEGACY_LU_VEC( Mself.m_End ); - PtPad->m_Pos0 = PtPad->m_Pos - FROM_LEGACY_LU_VEC( Module->m_Pos ); - PtPad->m_Size.x( FROM_LEGACY_LU( Mself.m_Width ) ); - PtPad->m_Size.y( PtPad->m_Size.x() ); - PtPad->m_layerMask = g_TabOneLayerMask[Module->GetLayer()]; + PtPad->m_Pos = Mself.m_End; + PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos; + PtPad->m_Size.x = PtPad->m_Size.y = Mself.m_Width; + PtPad->m_layerMask = g_TabOneLayerMask[Module->GetLayer()]; PtPad->m_Attribut = PAD_SMD; PtPad->m_PadShape = PAD_CIRCLE; PtPad->ComputeShapeMaxRadius(); @@ -276,8 +275,8 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) PtPad = newpad; PtPad->SetPadName( wxT( "2" ) ); - PtPad->m_Pos = FROM_LEGACY_LU_VEC( Mself.m_Start ); - PtPad->m_Pos0 = PtPad->m_Pos - FROM_LEGACY_LU_VEC( Module->m_Pos ); + PtPad->m_Pos = Mself.m_Start; + PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos; /* Modify text positions. */ Module->DisplayInfo( this ); @@ -553,9 +552,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c Module->m_Pads.PushFront( pad ); - pad->m_Size.x( FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ) ); - pad->m_Size.y( pad->m_Size.x() ); - pad->m_Pos = FROM_LEGACY_LU_VEC( Module->m_Pos ); + pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); + pad->m_Pos = Module->m_Pos; pad->m_PadShape = PAD_RECT; pad->m_Attribut = PAD_SMD; pad->m_layerMask = LAYER_FRONT; @@ -658,19 +656,19 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) switch( shape_type ) { case 0: //Gap : - pad->m_Pos0.x( FROM_LEGACY_LU( oX = -( gap_size + TO_LEGACY_LU( pad->m_Size.x() ) ) / 2 ) ); - pad->m_Pos.x( pad->m_Pos.x() + pad->m_Pos0.x() ); + oX = pad->m_Pos0.x = -( gap_size + pad->m_Size.x ) / 2; + pad->m_Pos.x += pad->m_Pos0.x; pad = pad->Next(); - pad->m_Pos0.x( FROM_LEGACY_LU( oX + gap_size + TO_LEGACY_LU( pad->m_Size.x() ) ) ); - pad->m_Pos.x( pad->m_Pos.x() + pad->m_Pos0.x() ); + pad->m_Pos0.x = oX + gap_size + pad->m_Size.x; + pad->m_Pos.x += pad->m_Pos0.x; break; case 1: //Stub : pad->SetPadName( wxT( "1" ) ); pad = pad->Next(); - pad->m_Pos0.y( FROM_LEGACY_LU( -( gap_size + TO_LEGACY_LU( pad->m_Size.y() ) ) / 2 ) ); - pad->m_Size.y( FROM_LEGACY_LU( gap_size ) ); - pad->m_Pos.y( pad->m_Pos.y() + pad->m_Pos0.y() ); + pad->m_Pos0.y = -( gap_size + pad->m_Size.y ) / 2; + pad->m_Size.y = gap_size; + pad->m_Pos.y += pad->m_Pos0.y; break; case 2: // Arc Stub created by a polygonal approach: @@ -685,7 +683,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) std::vector polyPoints = edge->GetPolyPoints(); polyPoints.reserve( numPoints ); - edge->m_Start0.y = TO_LEGACY_LU( -pad->m_Size.y() / 2 ); + edge->m_Start0.y = -pad->m_Size.y / 2; polyPoints.push_back( wxPoint( 0, 0 ) ); @@ -970,12 +968,12 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() Module = Create_MuWaveBasicShape( cmp_name, pad_count ); pad1 = Module->m_Pads; - pad1->m_Pos0.x( FROM_LEGACY_LU( -ShapeSize.x / 2 ) ); - pad1->m_Pos.x( pad1->m_Pos.x() + pad1->m_Pos0.x() ); + pad1->m_Pos0.x = -ShapeSize.x / 2; + pad1->m_Pos.x += pad1->m_Pos0.x; pad2 = (D_PAD*) pad1->Next(); - pad2->m_Pos0.x( pad1->m_Pos0.x() + FROM_LEGACY_LU( ShapeSize.x ) ); - pad2->m_Pos.x( pad2->m_Pos.x() + pad2->m_Pos0.x() ); + pad2->m_Pos0.x = pad1->m_Pos0.x + ShapeSize.x; + pad2->m_Pos.x += pad2->m_Pos0.x; edge = new EDGE_MODULE( Module ); @@ -989,13 +987,13 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() polyPoints.reserve( 2 * PolyEdges.size() + 2 ); // Init start point coord: - polyPoints.push_back( wxPoint( TO_LEGACY_LU( pad1->m_Pos0.x() ), 0 ) ); + polyPoints.push_back( wxPoint( pad1->m_Pos0.x, 0 ) ); wxPoint first_coordinate, last_coordinate; 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 ) + pad1->m_Pos0.x; last_coordinate.y = -wxRound( PolyEdges[ii] * ShapeScaleY ); polyPoints.push_back( last_coordinate ); } @@ -1007,17 +1005,15 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() case 0: // Single case 2: // Single mirrored // Init end point coord: - pad2->m_Pos0.x( FROM_LEGACY_LU( last_coordinate.x ) ); + pad2->m_Pos0.x = last_coordinate.x; polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) ); - pad1->m_Size.x( FROM_LEGACY_LU( abs( first_coordinate.y ) ) ); - pad1->m_Size.y( pad1->m_Size.x() ); - pad2->m_Size.x( FROM_LEGACY_LU( abs( last_coordinate.y ) ) ); - pad2->m_Size.y( pad2->m_Size.x() ); - pad1->m_Pos0.y( FROM_LEGACY_LU( first_coordinate.y / 2 ) ); - pad2->m_Pos0.y( FROM_LEGACY_LU( last_coordinate.y / 2 ) ); - pad1->m_Pos.y( 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 ) ); + pad1->m_Size.x = pad1->m_Size.y = ABS( first_coordinate.y ); + pad2->m_Size.x = pad2->m_Size.y = ABS( last_coordinate.y ); + pad1->m_Pos0.y = first_coordinate.y / 2; + pad2->m_Pos0.y = last_coordinate.y / 2; + pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y; + pad2->m_Pos.y = pad2->m_Pos0.y + Module->m_Pos.y; break; case 1: // Symmetric @@ -1030,10 +1026,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() polyPoints.push_back( pt ); } - pad1->m_Size.x( FROM_LEGACY_LU( 2 * abs( first_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() ); + pad1->m_Size.x = pad1->m_Size.y = 2 * ABS( first_coordinate.y ); + pad2->m_Size.x = pad2->m_Size.y = 2 * ABS( last_coordinate.y ); break; } @@ -1079,7 +1073,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) Module->Draw( DrawPanel, DC, GR_XOR ); /* Calculate the current dimension. */ - gap_size = TO_LEGACY_LU( next_pad->m_Pos0.x() - pad->m_Pos0.x() - pad->m_Size.x() ); + gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x; /* Entrer the desired length of the gap. */ msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() ); @@ -1092,29 +1086,21 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); /* Updating sizes of pads forming the gap. */ - pad->m_Size.x( FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ) ); - pad->m_Size.y( pad->m_Size.x() ); - pad->m_Pos0.y( ZERO_LENGTH ); - pad->m_Pos0.x( FROM_LEGACY_LU( oX = -( ( gap_size + TO_LEGACY_LU( pad->m_Size.x() ) ) / 2 ) ) ); - pad->m_Pos.x( pad->m_Pos0.x() + FROM_LEGACY_LU( Module->m_Pos.x ) ); - 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, + pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); + pad->m_Pos0.y = 0; + oX = pad->m_Pos0.x = -( (gap_size + pad->m_Size.x) / 2 ); + pad->m_Pos.x = pad->m_Pos0.x + Module->m_Pos.x; + pad->m_Pos.y = pad->m_Pos0.y + Module->m_Pos.y; + RotatePoint( &pad->m_Pos.x, &pad->m_Pos.y, Module->m_Pos.x, Module->m_Pos.y, Module->m_Orient ); - pad->m_Pos = FROM_LEGACY_LU_VEC( pos ); - next_pad->m_Size.x( FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ) ); - next_pad->m_Size.y( next_pad->m_Size.x() ); - next_pad->m_Pos0.y( ZERO_LENGTH ); - next_pad->m_Pos0.x( FROM_LEGACY_LU( oX + gap_size + TO_LEGACY_LU( next_pad->m_Size.x() ) ) ); - next_pad->m_Pos.x( 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, + next_pad->m_Size.x = next_pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); + next_pad->m_Pos0.y = 0; + next_pad->m_Pos0.x = oX + gap_size + next_pad->m_Size.x; + next_pad->m_Pos.x = next_pad->m_Pos0.x + Module->m_Pos.x; + next_pad->m_Pos.y = next_pad->m_Pos0.y + Module->m_Pos.y; + RotatePoint( &next_pad->m_Pos.x, &next_pad->m_Pos.y, 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 ); } diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 915ed934ba..92fb54b6a3 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -839,8 +839,7 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard ) for( unsigned ii = 0; ii < aBoard->m_TrackWidthList.size(); ii++ ) { - value = ReturnStringFromValue( g_UserUnit, - TO_LEGACY_LU( aBoard->m_TrackWidthList[ii] ), + value = ReturnStringFromValue( g_UserUnit, aBoard->m_TrackWidthList[ii], PCB_INTERNAL_UNIT, true ); msg.Printf( _( "Track %s" ), GetChars( value ) ); @@ -854,14 +853,13 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard ) for( unsigned ii = 0; ii < aBoard->m_ViasDimensionsList.size(); ii++ ) { - value = ReturnStringFromValue( g_UserUnit, - TO_LEGACY_LU( aBoard->m_ViasDimensionsList[ii].m_Diameter ), + value = ReturnStringFromValue( g_UserUnit, aBoard->m_ViasDimensionsList[ii].m_Diameter, PCB_INTERNAL_UNIT, true ); wxString drill = ReturnStringFromValue( g_UserUnit, - TO_LEGACY_LU( aBoard->m_ViasDimensionsList[ii].m_Drill ), + aBoard->m_ViasDimensionsList[ii].m_Drill, PCB_INTERNAL_UNIT, true ); - if( TO_LEGACY_LU( aBoard->m_ViasDimensionsList[ii].m_Drill ) <= 0 ) + if( aBoard->m_ViasDimensionsList[ii].m_Drill <= 0 ) { msg.Printf( _( "Via %s" ), GetChars( value ) ); } diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 3437e087c9..6b114cbbca 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -217,25 +217,12 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), &g_LibraryNames, GROUPLIB ) ); -//#ifdef KICAD_NANOMETRE -/* TODO: something should be done here!!! */ -//#else - m_projectFileParams.push_back( new PARAM_CFG_LENGTH_PCB( wxT( "PadDrlX" ), - &g_Pad_Master.m_Drill[0], - FROM_LEGACY_LU( 320 ), - ZERO_LENGTH, - FROM_LEGACY_LU( 0x7FFF ) ) ); - m_projectFileParams.push_back( new PARAM_CFG_LENGTH_PCB( wxT( "PadDimH" ), - &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( "PadDrlX" ), &g_Pad_Master.m_Drill.x, + 320, 0, 0x7FFF ) ); + m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimH" ), &g_Pad_Master.m_Size.x, + 550, 0, 0x7FFF ) ); + m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimV" ), &g_Pad_Master.m_Size.y, + 550, 0, 0x7FFF ) ); m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ), &boardDesignSettings.m_BoardThickness, 630, 0, 0xFFFF ) ); diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 2dddfbc1dc..50a43bfc89 100644 --- a/pcbnew/plot_rtn.cpp +++ b/pcbnew/plot_rtn.cpp @@ -97,11 +97,11 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* plotter, int aLayerMask, GRTraceMo switch( pad->m_PadShape & 0x7F ) { case PAD_CIRCLE: - plotter->flash_pad_circle( shape_pos, TO_LEGACY_LU( pad->m_Size.x() ), FILAIRE ); + plotter->flash_pad_circle( shape_pos, pad->m_Size.x, FILAIRE ); break; case PAD_OVAL: - plotter->flash_pad_oval( shape_pos, TO_LEGACY_LU_WXS( pad->m_Size ), pad->m_Orient, FILAIRE ); + plotter->flash_pad_oval( shape_pos, pad->m_Size, pad->m_Orient, FILAIRE ); break; case PAD_TRAPEZOID: @@ -114,7 +114,7 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* plotter, int aLayerMask, GRTraceMo case PAD_RECT: default: - plotter->flash_pad_rect( shape_pos, TO_LEGACY_LU_WXS( pad->m_Size ), pad->m_Orient, FILAIRE ); + plotter->flash_pad_rect( shape_pos, pad->m_Size, pad->m_Orient, FILAIRE ); break; } } @@ -840,8 +840,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, break; } - 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.x = pad->m_Size.x + ( 2 * margin.x ); + size.y = pad->m_Size.y + ( 2 * margin.y ); /* Don't draw a null size item : */ if( size.x <= 0 || size.y <= 0 ) @@ -851,8 +851,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, { case PAD_CIRCLE: if( aSkipNPTH_Pads && - ( pad->m_Size.x() == pad->m_Drill.x() ) && - ( pad->m_Size.y() == pad->m_Drill.y() ) && + (pad->m_Size == pad->m_Drill) && (pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) break; @@ -861,8 +860,7 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, case PAD_OVAL: if( aSkipNPTH_Pads && - (pad->m_Size.x() == pad->m_Drill.x() ) && - (pad->m_Size.y() == pad->m_Drill.y() ) && + (pad->m_Size == pad->m_Drill) && (pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) break; @@ -1018,21 +1016,20 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter, { for( PtPad = Module->m_Pads; PtPad != NULL; PtPad = PtPad->Next() ) { - if( PtPad->m_Drill.x() == ZERO_LENGTH ) + if( PtPad->m_Drill.x == 0 ) continue; // Output hole shapes: - pos = TO_LEGACY_LU_WXP( PtPad->m_Pos ); + pos = PtPad->m_Pos; if( PtPad->m_DrillShape == PAD_OVAL ) { - diam.x = TO_LEGACY_LU( PtPad->m_Drill.x() ); - diam.y = TO_LEGACY_LU( PtPad->m_Drill.y() ); + diam = PtPad->m_Drill; aPlotter->flash_pad_oval( pos, diam, PtPad->m_Orient, aTraceMode ); } else { - diam.x = aSmallDrillShape ? SMALL_DRILL : TO_LEGACY_LU( PtPad->m_Drill.x() ); + diam.x = aSmallDrillShape ? SMALL_DRILL : PtPad->m_Drill.x; aPlotter->flash_pad_circle( pos, diam.x, aTraceMode ); } } diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index fa1f44a206..5887f5bd76 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -351,18 +351,16 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, continue; // Manage hole according to the print drill option - wxSize drill_tmp; - drill_tmp.x = TO_LEGACY_LU( pt_pad->m_Drill.x() ); - drill_tmp.y = TO_LEGACY_LU( pt_pad->m_Drill.y() ); + wxSize drill_tmp = pt_pad->m_Drill; switch ( aDrillShapeOpt ) { case PRINT_PARAMETERS::NO_DRILL_SHAPE: - pt_pad->m_Drill = VECTOR_PCB::fromXY(ZERO_LENGTH, ZERO_LENGTH); //wxSize(0,0); + pt_pad->m_Drill = wxSize(0,0); break; 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.y( min( FROM_LEGACY_LU( SMALL_DRILL ),pt_pad->m_Drill.y() ) ); + pt_pad->m_Drill.x = MIN(SMALL_DRILL,pt_pad->m_Drill.x); + pt_pad->m_Drill.y = MIN(SMALL_DRILL,pt_pad->m_Drill.y); break; case PRINT_PARAMETERS::FULL_DRILL_SHAPE: // Do nothing @@ -370,8 +368,7 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, } pt_pad->Draw( aPanel, aDC, aDraw_mode ); - 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 = drill_tmp; } /* Print footprint graphic shapes */ diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index b9081a426e..39ddd4446b 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -107,8 +107,8 @@ int MIN_SPAN_TREE_PADS::GetWeight( int aItem1, int aItem2 ) if( pad1 == pad2 ) return 0; - int weight = TO_LEGACY_LU( abs( pad2->m_Pos.x() - pad1->m_Pos.x() ) + - abs( pad2->m_Pos.y() - pad1->m_Pos.y() ) ); + int weight = abs( pad2->m_Pos.x - pad1->m_Pos.x ) + + abs( pad2->m_Pos.y - pad1->m_Pos.y ); return weight + 1; } @@ -667,7 +667,7 @@ void PCB_BASE_FRAME::build_ratsnest_module( MODULE* aModule ) local_rats.m_Lenght = INT_MAX; } - pad_pos = TO_LEGACY_LU_WXP( pad_ref->m_Pos ) - g_Offset_Module; + pad_pos = pad_ref->m_Pos - g_Offset_Module; // Search the nearest external pad of this current pad for( unsigned jj = pads_module_count; jj < localPadList.size(); jj++ ) @@ -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 break; - distance = abs( TO_LEGACY_LU( pad_externe->m_Pos.x() ) - pad_pos.x ) + - abs( TO_LEGACY_LU( pad_externe->m_Pos.y() ) - pad_pos.y ); + distance = abs( pad_externe->m_Pos.x - pad_pos.x ) + + abs( pad_externe->m_Pos.y - pad_pos.y ); if( distance < local_rats.m_Lenght ) { @@ -724,8 +724,8 @@ void PCB_BASE_FRAME::TraceModuleRatsNest( wxDC* DC ) else { g_ColorsSettings.SetItemColor(RATSNEST_VISIBLE, tmpcolor); - VECTOR_PCB tmp = rats->m_PadStart->m_Pos; - rats->m_PadStart->m_Pos -= FROM_LEGACY_LU_VEC( g_Offset_Module ); + wxPoint tmp = rats->m_PadStart->m_Pos; + rats->m_PadStart->m_Pos -= g_Offset_Module; rats->Draw( DrawPanel, DC, GR_XOR, wxPoint( 0, 0 ) ); rats->m_PadStart->m_Pos = tmp; } @@ -827,7 +827,7 @@ void PCB_BASE_FRAME::BuildAirWiresTargetsList( BOARD_CONNECTED_ITEM* aItemRef, continue; if( !pad->GetSubNet() || (pad->GetSubNet() != subnet) ) - s_TargetsLocations.push_back( TO_LEGACY_LU_WXP( pad->m_Pos ) ); + s_TargetsLocations.push_back( pad->m_Pos ); } // Create a list of tracks ends candidates, not already connected to the diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index a44aa3529d..ca8429f7df 100644 --- a/pcbnew/solve.cpp +++ b/pcbnew/solve.cpp @@ -464,8 +464,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; int cY = ( Board.m_GridRouting * row_source ) + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; - int dx = 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 dx = pt_cur_ch->m_PadStart->m_Size.x / 2; + int dy = pt_cur_ch->m_PadStart->m_Size.y / 2; int px = pt_cur_ch->m_PadStart->GetPosition().x; int py = pt_cur_ch->m_PadStart->GetPosition().y; @@ -479,8 +479,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; cY = ( Board.m_GridRouting * row_target ) + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; - dx = 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 ); + dx = pt_cur_ch->m_PadEnd->m_Size.x / 2; + dy = pt_cur_ch->m_PadEnd->m_Size.y / 2; px = pt_cur_ch->m_PadEnd->GetPosition().x; py = pt_cur_ch->m_PadEnd->GetPosition().y; diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 5e37e96565..f0b24eecb8 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -250,7 +250,7 @@ static bool isRoundKeepout( D_PAD* aPad ) { 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; if( (aPad->m_layerMask & ALL_CU_LAYERS) == 0 ) @@ -321,11 +321,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) POINT dsnOffset; - if( aPad->m_Offset.x() != ZERO_LENGTH || aPad->m_Offset.y() != ZERO_LENGTH ) + if( aPad->m_Offset.x || aPad->m_Offset.y ) { - char offsetTxt[64]; /// @BUG !!!Unsafe + char offsetTxt[64]; - wxPoint offset( TO_LEGACY_LU( aPad->m_Offset.x() ), TO_LEGACY_LU( aPad->m_Offset.y() ) ); + wxPoint offset( aPad->m_Offset.x, aPad->m_Offset.y ); dsnOffset = mapPt( offset ); @@ -341,7 +341,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) default: case PAD_CIRCLE: { - double diameter = scale( TO_LEGACY_LU( aPad->m_Size.x() ) ); + double diameter = scale(aPad->m_Size.x); for( int ndx=0; ndxm_Size.x() ) ) ); + uniqifier.c_str(), scale(aPad->m_Size.x) ); name[ sizeof(name)-1 ] = 0; padstack->SetPadstackId( name ); @@ -366,8 +366,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) case PAD_RECT: { - double dx = scale( TO_LEGACY_LU( aPad->m_Size.x() ) ) / 2.0; - double dy = scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) / 2.0; + double dx = scale( aPad->m_Size.x ) / 2.0; + double dy = scale( aPad->m_Size.y ) / 2.0; POINT lowerLeft( -dx, -dy ); POINT upperRight( dx, dy ); @@ -388,7 +388,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) } snprintf( name, sizeof(name), "Rect%sPad_%.6gx%.6g_mil", - uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x() ) ), scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) ); + uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y) ); name[ sizeof(name)-1 ] = 0; padstack->SetPadstackId( name ); @@ -397,8 +397,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) case PAD_OVAL: { - double dx = scale( TO_LEGACY_LU( aPad->m_Size.x() ) ) / 2.0; - double dy = scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) / 2.0; + double dx = scale( aPad->m_Size.x ) / 2.0; + double dy = scale( aPad->m_Size.y ) / 2.0; double dr = dx - dy; double radius; POINT start; @@ -436,7 +436,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) } snprintf( name, sizeof(name), "Oval%sPad_%.6gx%.6g_mil", - uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x() ) ), scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) ); + uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y) ); name[ sizeof(name)-1 ] = 0; padstack->SetPadstackId( name ); @@ -445,11 +445,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) case PAD_TRAPEZOID: { - double dx = scale( TO_LEGACY_LU( aPad->m_Size.x() ) ) / 2.0; - double dy = scale( TO_LEGACY_LU( aPad->m_Size.y() ) ) / 2.0; + double dx = scale( aPad->m_Size.x ) / 2.0; + double dy = scale( aPad->m_Size.y ) / 2.0; - double ddx = scale( TO_LEGACY_LU( aPad->m_DeltaSize.x() ) ) / 2.0; - double ddy = scale( TO_LEGACY_LU( aPad->m_DeltaSize.y() ) ) / 2.0; + double ddx = scale( aPad->m_DeltaSize.x ) / 2.0; + double ddy = scale( aPad->m_DeltaSize.y ) / 2.0; // see class_pad_draw_functions.cpp which draws the trapezoid pad POINT lowerLeft( -dx - ddy, -dy - ddx ); @@ -479,15 +479,15 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) polygon->AppendPoint( lowerRight ); } - D(printf( "m_DeltaSize: %d,%d\n", TO_LEGACY_LU( aPad->m_DeltaSize.x() ), TO_LEGACY_LU( aPad->m_DeltaSize.y() ) );) + D(printf( "m_DeltaSize: %d,%d\n", aPad->m_DeltaSize.x, aPad->m_DeltaSize.y );) // this string _must_ be unique for a given physical shape snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_mil", - uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x() ) ), scale( TO_LEGACY_LU( aPad->m_Size.y() ) ), - aPad->m_DeltaSize.x() < ZERO_LENGTH ? 'n' : 'p', - fabs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.x() ) )), - aPad->m_DeltaSize.y() < ZERO_LENGTH ? 'n' : 'p', - fabs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.y() ) )) + uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y), + aPad->m_DeltaSize.x < 0 ? 'n' : 'p', + abs( scale( aPad->m_DeltaSize.x )), + aPad->m_DeltaSize.y < 0 ? 'n' : 'p', + abs( scale( aPad->m_DeltaSize.y )) ); name[ sizeof(name)-1 ] = 0; @@ -527,8 +527,8 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) // see if this pad is a through hole with no copper on its perimeter if( isRoundKeepout( pad ) ) { - double diameter = scale( TO_LEGACY_LU( pad->m_Drill.x() ) ); - POINT vertex = mapPt( TO_LEGACY_LU_WXP( pad->m_Pos0 ) ); + double diameter = scale( pad->m_Drill.x ); + POINT vertex = mapPt( pad->m_Pos0 ); int layerCount = aBoard->GetCopperLayerCount(); for( int layer=0; layerSetRotation( angle / 10.0 ); } - wxPoint pos( TO_LEGACY_LU_WXP( pad->m_Pos0 ) ); + wxPoint pos( pad->m_Pos0 ); pin->SetVertex( mapPt( pos ) ); } @@ -1309,8 +1309,8 @@ void SPECCTRA_DB::FromBOARD( BOARD* aBoard ) throw( IO_ERROR ) // using LookupVia(). for( unsigned i=0; i < aBoard->m_ViasDimensionsList.size(); ++i ) { - int viaSize = TO_LEGACY_LU( aBoard->m_ViasDimensionsList[i].m_Diameter ); - int viaDrill = TO_LEGACY_LU( aBoard->m_ViasDimensionsList[i].m_Drill ); + int viaSize = aBoard->m_ViasDimensionsList[i].m_Diameter; + int viaDrill = aBoard->m_ViasDimensionsList[i].m_Drill; via = makeVia( viaSize, viaDrill, 0, aBoard->GetCopperLayerCount()-1 ); diff --git a/pcbnew/tool_pcb.cpp b/pcbnew/tool_pcb.cpp index f9de65c8b6..dfec27be5e 100644 --- a/pcbnew/tool_pcb.cpp +++ b/pcbnew/tool_pcb.cpp @@ -576,7 +576,7 @@ void PCB_EDIT_FRAME::updateTraceWidthSelectBox() for( unsigned ii = 0; ii < GetBoard()->m_TrackWidthList.size(); ii++ ) { - msg = _( "Track " ) + CoordinateToString( TO_LEGACY_LU( GetBoard()->m_TrackWidthList[ii] ), true ); + msg = _( "Track " ) + CoordinateToString( GetBoard()->m_TrackWidthList[ii], true ); if( ii == 0 ) msg << _( " *" ); @@ -601,11 +601,11 @@ void PCB_EDIT_FRAME::updateViaSizeSelectBox() for( unsigned ii = 0; ii < GetBoard()->m_ViasDimensionsList.size(); ii++ ) { msg = _( "Via " ); - msg << CoordinateToString( TO_LEGACY_LU( GetBoard()->m_ViasDimensionsList[ii].m_Diameter ), true ); + msg << CoordinateToString( GetBoard()->m_ViasDimensionsList[ii].m_Diameter, true ); - if( 0 != TO_LEGACY_LU( GetBoard()->m_ViasDimensionsList[ii].m_Drill ) ) + if( GetBoard()->m_ViasDimensionsList[ii].m_Drill ) msg << wxT("/ ") - << CoordinateToString( TO_LEGACY_LU( GetBoard()->m_ViasDimensionsList[ii].m_Drill ), true ); + << CoordinateToString( GetBoard()->m_ViasDimensionsList[ii].m_Drill, true ); if( ii == 0 ) msg << _( " *" ); @@ -625,7 +625,7 @@ LAYER_BOX_SELECTOR* PCB_EDIT_FRAME::ReCreateLayerBox( EDA_TOOLBAR* parent ) m_SelLayerBox->m_hotkeys = g_Board_Editor_Hokeys_Descr; m_SelLayerBox->Resync(); - m_SelLayerBox->SetToolTip( _( "+/- to switch" ) ); // TODO: actual hotkeys + m_SelLayerBox->SetToolTip( _( "+/- to switch" ) ); return m_SelLayerBox; } diff --git a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp index 60ff998379..459d67885b 100644 --- a/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp +++ b/pcbnew/zones_convert_brd_items_to_polygons_with_Boost.cpp @@ -201,7 +201,7 @@ void ZONE_CONTAINER::AddClearanceAreasPolygonsToPolysList( BOARD* aPcb ) * inside the board (in fact inside the hole. Some photo diodes and Leds are * like this) */ - if( (pad->m_Drill.x() == ZERO_LENGTH) && (pad->m_Drill.y() == ZERO_LENGTH) ) + if( (pad->m_Drill.x == 0) && (pad->m_Drill.y == 0) ) continue; // Use a dummy pad to calculate a hole shape that have the same dimension as diff --git a/pcbnew/zones_convert_to_polygons_aux_functions.cpp b/pcbnew/zones_convert_to_polygons_aux_functions.cpp index cd357c5541..e23707786f 100644 --- a/pcbnew/zones_convert_to_polygons_aux_functions.cpp +++ b/pcbnew/zones_convert_to_polygons_aux_functions.cpp @@ -68,15 +68,15 @@ void BuildUnconnectedThermalStubsPolygonList( std::vector& aCornerBuffe // Thermal bridges are like a segment from a starting point inside the pad // to an ending point outside the pad wxPoint startpoint, endpoint; - endpoint.x = ( 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.x = ( pad->m_Size.x / 2 ) + aZone->m_ThermalReliefGapValue; + endpoint.y = ( pad->m_Size.y / 2 ) + aZone->m_ThermalReliefGapValue; int copperThickness = aZone->m_ThermalReliefCopperBridgeValue - aZone->m_ZoneMinThickness; if( copperThickness < 0 ) copperThickness = 0; - startpoint.x = min( TO_LEGACY_LU( pad->m_Size.x() ), copperThickness ); - startpoint.y = min( TO_LEGACY_LU( pad->m_Size.y() ), copperThickness ); + startpoint.x = min( pad->m_Size.x, copperThickness ); + startpoint.y = min( pad->m_Size.y, copperThickness ); startpoint.x /= 2; startpoint.y /= 2; diff --git a/pcbnew/zones_polygons_insulated_copper_islands.cpp b/pcbnew/zones_polygons_insulated_copper_islands.cpp index be7d1439eb..587d19a1a8 100644 --- a/pcbnew/zones_polygons_insulated_copper_islands.cpp +++ b/pcbnew/zones_polygons_insulated_copper_islands.cpp @@ -40,7 +40,7 @@ void ZONE_CONTAINER::Test_For_Copper_Island_And_Remove_Insulated_Islands( BOARD if( pad->GetNet() != GetNet() ) continue; - ListPointsCandidates.push_back( TO_LEGACY_LU_WXP( pad->m_Pos ) ); + ListPointsCandidates.push_back( pad->m_Pos ); } } diff --git a/pcbnew/zones_polygons_test_connections.cpp b/pcbnew/zones_polygons_test_connections.cpp index 65bebde7e7..145e57b2e3 100644 --- a/pcbnew/zones_polygons_test_connections.cpp +++ b/pcbnew/zones_polygons_test_connections.cpp @@ -111,7 +111,7 @@ void BOARD::Test_Connections_To_Copper_Areas( int aNetcode ) if( item->Type() == PCB_PAD_T ) { - pos1 = pos2 = TO_LEGACY_LU_WXP( ( (D_PAD*) item )->m_Pos ); /// @BUG Unsafe type conversion + pos1 = pos2 = ( (D_PAD*) item )->m_Pos; } else if( item->Type() == PCB_VIA_T ) { diff --git a/polygon/math_for_graphics.h b/polygon/math_for_graphics.h index e791f28a01..99271bbe6d 100644 --- a/polygon/math_for_graphics.h +++ b/polygon/math_for_graphics.h @@ -1,8 +1,8 @@ // math stuff for graphics, from FreePCB -/*#ifndef abs +#ifndef abs #define abs(x) (((x) >=0) ? (x) : (-(x))) -#endif*/ +#endif typedef struct PointTag diff --git a/potrace/auxiliary.h b/potrace/auxiliary.h index e883eb02d2..041e2a30b7 100644 --- a/potrace/auxiliary.h +++ b/potrace/auxiliary.h @@ -73,8 +73,6 @@ static inline int floordiv( int a, int n ) /* 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 abs #undef min @@ -86,79 +84,6 @@ overloading and integer limits #define min( a, b ) ( (a)<(b) ? (a) : (b) ) #define max( a, b ) ( (a)>(b) ? (a) : (b) ) #define sq( 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; -} +#define cu( a ) ( (a) * (a) * (a) ) #endif /* AUXILIARY_H */ diff --git a/potrace/render.cpp b/potrace/render.cpp index 01461d1a54..9f310c399d 100644 --- a/potrace/render.cpp +++ b/potrace/render.cpp @@ -278,7 +278,7 @@ void render_curveto( render_t* rm, * occur at an endpoint. */ dd0 = sq( x1 - 2 * x2 + x3 ) + sq( y1 - 2 * y2 + y3 ); dd1 = sq( x2 - 2 * x3 + x4 ) + sq( y2 - 2 * y3 + y4 ); - dd = 6 * sqrt( fmax( dd0, dd1 ) ); + dd = 6 * sqrt( max( dd0, dd1 ) ); e2 = 8 * delta <= dd ? 8 * delta / dd : 1; epsilon = sqrt( e2 ); /* necessary interval size */