diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index a6f4e7bc28..99a9230e8e 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -903,8 +903,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) int color; scale = g_Parm_3D_Visu.m_BoardScale; - holeX = (double) m_Drill.x * scale / 2; - holeY = (double) m_Drill.y * scale / 2; + holeX = (double) TO_LEGACY_LU_DBL( m_Drill.x ) * scale / 2; + holeY = (double) TO_LEGACY_LU_DBL( m_Drill.y ) * scale / 2; hole = MIN( holeX, holeY ); /* Calculate the center of the pad. */ @@ -914,8 +914,8 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) xc = ux0; yc = uy0; - dx = dx0 = m_Size.x >> 1; - dy = dy0 = m_Size.y >> 1; + dx = dx0 = TO_LEGACY_LU( m_Size.x ) >> 1; + dy = dy0 = TO_LEGACY_LU( m_Size.y ) >> 1; angle = m_Orient; drillx = m_Pos.x * scale; @@ -980,13 +980,13 @@ void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas ) { delta_cx = dx - dy; delta_cy = 0; - w = m_Size.y * scale; + w = TO_LEGACY_LU( m_Size.y ) * scale; } else /* Vertical ellipse */ { delta_cx = 0; delta_cy = dy - dx; - w = m_Size.x * scale; + w = TO_LEGACY_LU( m_Size.x ) * scale; } RotatePoint( &delta_cx, &delta_cy, angle ); diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h index fc558bc4b2..21e36495f4 100644 --- a/include/class_board_design_settings.h +++ b/include/class_board_design_settings.h @@ -9,6 +9,8 @@ #include "lengthpcb.h" +#include "class_via_dimension.h" + // Class for handle current printed board design settings class BOARD_DESIGN_SETTINGS { @@ -25,10 +27,13 @@ public: int m_PcbTextWidth; // current Pcb (not module) Text width wxSize m_PcbTextSize; // current Pcb (not module) Text size LENGTH_PCB m_TrackMinWidth; // track min value for width ((min copper size value - LENGTH_PCB m_ViasMinSize; // vias (not micro vias) min diameter - LENGTH_PCB m_ViasMinDrill; // vias (not micro vias) min drill diameter - LENGTH_PCB m_MicroViasMinSize; // micro vias (not vias) min diameter - LENGTH_PCB m_MicroViasMinDrill; // micro vias (not vias) min drill diameter + + VIA_DIMENSION m_MinVia; + VIA_DIMENSION m_MinMicroVia; + //LENGTH_PCB m_ViasMinSize; // vias (not micro vias) min diameter + //LENGTH_PCB m_ViasMinDrill; // vias (not micro vias) min drill diameter + //LENGTH_PCB m_MicroViasMinSize; // micro vias (not vias) min diameter + //LENGTH_PCB m_MicroViasMinDrill; // micro vias (not vias) min drill diameter // Global mask margins: int m_SolderMaskMargin; // Solder mask margin diff --git a/pcbnew/class_via_dimension.h b/include/class_via_dimension.h similarity index 85% rename from pcbnew/class_via_dimension.h rename to include/class_via_dimension.h index bd1154f70b..69b1d21dc9 100644 --- a/pcbnew/class_via_dimension.h +++ b/include/class_via_dimension.h @@ -22,6 +22,11 @@ public: m_Drill = FROM_LEGACY_LU( 0 ); } + VIA_DIMENSION( LENGTH_PCB diam, LENGTH_PCB drill ) + { + m_Diameter = diam; + m_Drill = drill; + } bool operator ==( const VIA_DIMENSION& other ) const { diff --git a/include/length.h b/include/length.h index c72218f244..65c5266253 100644 --- a/include/length.h +++ b/include/length.h @@ -230,6 +230,33 @@ public: return y / x.m_U; } + /*************************/ + /* assignment arithmetic */ + /*************************/ + LENGTH< T, P >& operator -= ( const LENGTH< T, P > y ) + { + m_U -= y.m_U; + return *this; + } + LENGTH< T, P >& operator += ( const LENGTH< T, P > y ) + { + m_U += y.m_U; + return *this; + } + LENGTH< T, P >& operator *= ( const T y ) + { + m_U *= y; + return *this; + } + LENGTH< T, P >& operator /= ( const T y ) + { + m_U /= y; + return *this; + } + + /*************************/ + /* more functions */ + /*************************/ friend LENGTH< T, P > sqrt( LENGTH< T, P*2 > y ) { return sqrt( y.m_U ); @@ -238,28 +265,15 @@ public: { return cbrt( y.m_U ); } - /*************************/ - /* assignment arithmetic */ - /*************************/ - LENGTH< T, P >& operator -= ( const LENGTH< T, P > y ) + friend LENGTH< T, P > hypot( LENGTH< T, P > x, LENGTH< T, P > y ) { - return m_U -= y.m_U; + return hypot( x.m_U, y.m_U ); } - LENGTH< T, P >& operator += ( const LENGTH< T, P > y ) + friend double atan2( LENGTH< T, P > x, LENGTH< T, P > y ) { - return m_U += y.m_U; + return atan2( double ( x.m_U ), double( 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 */ - /*************************/ + }; /** diff --git a/include/lengthpcb.h b/include/lengthpcb.h index 040d7f8874..40b6d9f301 100644 --- a/include/lengthpcb.h +++ b/include/lengthpcb.h @@ -20,13 +20,16 @@ typedef LENGTH< double, 1 > LENGTH_PCB_DBL; #define PCB_LEGACY_UNIT( T ) ( LENGTH_UNITS< T >::inch() / PCB_LEGACY_INCH_SCALE ) #define TO_LEGACY_LU( x ) \ - ( LENGTH_PCB( x ) / PCB_LEGACY_UNIT( LENGTH_PCB ) ) + ( (int) ( LENGTH_PCB( x ) / PCB_LEGACY_UNIT( LENGTH_PCB ) ) ) #define TO_LEGACY_LU_DBL( x ) \ - ( LENGTH_PCB_DBL( x ) / PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) ) + ( (double) ( LENGTH_PCB_DBL( x ) / PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) ) ) static LENGTH_PCB from_legacy_lu( int x ) { return x * PCB_LEGACY_UNIT( LENGTH_PCB ); } +static LENGTH_PCB from_legacy_lu( long x ) { + return x * PCB_LEGACY_UNIT( LENGTH_PCB ); +} static LENGTH_PCB from_legacy_lu( double x ) { return LENGTH_PCB( x * PCB_LEGACY_UNIT( LENGTH_PCB_DBL ) ); } @@ -41,6 +44,7 @@ static LENGTH_PCB_DBL from_legacy_lu_dbl( double x ) { #define ZERO_LENGTH ( LENGTH_PCB::zero() ) + #else typedef int LENGTH_PCB; @@ -58,5 +62,43 @@ typedef double LENGTH_PCB_DBL; #endif +/// @TODO: nice template and refiling for it +struct VECTOR_PCB +{ + LENGTH_PCB x, y; + VECTOR_PCB() + { + } + VECTOR_PCB( LENGTH_PCB ax, LENGTH_PCB ay ): x( ax ), y( ay ) + { + } + bool operator == ( const VECTOR_PCB &a ) const { + return x == a.x && y == a.y; + } + bool operator != ( const VECTOR_PCB &a ) const { + return x != a.x || y != a.y; + } + VECTOR_PCB & operator = (const VECTOR_PCB &a ) { + x = a.x; + y = a.y; + return *this; + } + VECTOR_PCB operator + (VECTOR_PCB add) const { + return VECTOR_PCB(x + add.x, y + add.y); + } + VECTOR_PCB operator - (VECTOR_PCB add) const { + return VECTOR_PCB(x - add.x, y - add.y); + } + VECTOR_PCB operator * (int factor) const { + return VECTOR_PCB(x * factor, y * factor); + } + VECTOR_PCB operator / (int factor) const { + return VECTOR_PCB(x / factor, y / factor); + } +}; + +#define TO_LEGACY_LU_WXP( p ) ( wxPoint( TO_LEGACY_LU( ( p ).x ), TO_LEGACY_LU( ( p ).y ) ) ) +#define TO_LEGACY_LU_WXS( p ) ( wxSize( TO_LEGACY_LU( ( p ).x ), TO_LEGACY_LU( ( p ).y ) ) ) + #endif /* def LENGTHPCB_H_INCLUDED */ diff --git a/include/limited_int.h b/include/limited_int.h index 67d9fb8d2a..f87e33a3bf 100644 --- a/include/limited_int.h +++ b/include/limited_int.h @@ -164,6 +164,11 @@ public: return x + double( y.m_Value ); } + LIMITED_INT< T > operator - ( void ) const + { + assert( -std::numeric_limits< T >::max() <= m_Value ); + return -m_Value; + } LIMITED_INT< T > operator - ( const LIMITED_INT< T > &y ) const { assert( !( 0 < m_Value ) || m_Value - std::numeric_limits< T >::max() <= y.m_Value ); diff --git a/include/macros.h b/include/macros.h index 0278576eba..7622df13ff 100644 --- a/include/macros.h +++ b/include/macros.h @@ -65,7 +65,8 @@ static inline const wxChar* GetChars( const wxString& s ) #endif #ifndef ABS -#define ABS( y ) ( (y) >= 0 ? (y) : ( -(y) ) ) +#define ABS( y ) ( MAX( ( y ), ( -y ) ) ) +// dirty trick: now this should work with LENGTH<> too #endif #define NEGATE( x ) (x = -x) diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index 91f6f2d1cf..ef6b7d3840 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 = (m_Size.x / 2) + aClearanceValue; - int dy = (m_Size.y / 2) + aClearanceValue; + int dx = TO_LEGACY_LU( m_Size.x / 2 ) + aClearanceValue; + int dy = TO_LEGACY_LU( m_Size.y / 2 ) + aClearanceValue; int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree wxPoint PadShapePos = ReturnShapePos(); /* Note: for pad having a shape offset, * the pad position is NOT the shape position */ - wxSize psize = m_Size; /* pad size unsed in RECT and TRAPEZOIDAL pads + wxSize psize = TO_LEGACY_LU_WXS( m_Size ); /* pad size unsed in RECT and TRAPEZOIDAL pads * trapezoidal pads are considered as rect * pad shape having they boudary box size */ @@ -437,8 +437,8 @@ void D_PAD:: TransformShapeWithClearanceToPolygon( std:: vector < CPolyPt>& aCor default: case PAD_TRAPEZOID: - psize.x += ABS( m_DeltaSize.y ); - psize.y += ABS( m_DeltaSize.x ); + psize.x += TO_LEGACY_LU( ABS( m_DeltaSize.y ) ); + psize.y += TO_LEGACY_LU( ABS( m_DeltaSize.x ) ); // fall through case PAD_RECT: @@ -572,8 +572,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, wxPoint PadShapePos = aPad.ReturnShapePos(); /* Note: for pad having a shape offset, * the pad position is NOT the shape position */ wxSize copper_thickness; - int dx = aPad.m_Size.x / 2; - int dy = aPad.m_Size.y / 2; + int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ); + int dy = TO_LEGACY_LU( aPad.m_Size.y / 2 ); int delta = 3600 / aCircleToSegmentsCount; // rot angle in 0.1 degree @@ -684,8 +684,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, // Oval pad support along the lines of round and rectangular pads std::vector corners_buffer; // Polygon buffer as vector - int dx = (aPad.m_Size.x / 2) + aThermalGap; // Cutout radius x - int dy = (aPad.m_Size.y / 2) + aThermalGap; // Cutout radius y + int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ) + aThermalGap; // Cutout radius x + int dy = TO_LEGACY_LU( aPad.m_Size.y / 2 ) + aThermalGap; // Cutout radius y wxPoint shape_offset; @@ -839,8 +839,8 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, std::vector corners_buffer; // Polygon buffer as vector - int dx = (aPad.m_Size.x / 2) + aThermalGap; // Cutout radius x - int dy = (aPad.m_Size.y / 2) + aThermalGap; // Cutout radius y + int dx = TO_LEGACY_LU( aPad.m_Size.x / 2 ) + aThermalGap; // Cutout radius x + int dy = TO_LEGACY_LU( aPad.m_Size.y / 2 ) + aThermalGap; // Cutout radius y // The first point of polygon buffer is left lower corner, second the crosspoint of // thermal spoke sides, the third is upper right corner and the rest are rounding @@ -861,7 +861,7 @@ void CreateThermalReliefPadPolygon( std::vector& aCornerBuffer, RotatePoint( &corner_position, 1800 / aCircleToSegmentsCount ); // Start at half increment offset angle_pg = i * delta; RotatePoint( &corner_position, angle_pg ); // Rounding vector rotation - corner_position -= aPad.m_Size / 2; // Rounding vector + Pad corner offset + corner_position -= TO_LEGACY_LU_WXS( aPad.m_Size / 2 ); // Rounding vector + Pad corner offset corners_buffer.push_back( wxPoint( corner_position.x, corner_position.y ) ); } diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index 9bcaea4cec..4bbbbb5174 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -33,10 +33,12 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() m_PcbTextWidth = 100; // current Pcb (not module) Text width m_PcbTextSize = wxSize( 500, 500 ); // current Pcb (not module) Text size m_TrackMinWidth = FROM_LEGACY_LU( 80 ); // track min value for width ((min copper size value - m_ViasMinSize = FROM_LEGACY_LU( 350 ); // vias (not micro vias) min diameter - m_ViasMinDrill = FROM_LEGACY_LU( 200 ); // vias (not micro vias) min drill diameter - m_MicroViasMinSize = FROM_LEGACY_LU( 200 ); // micro vias (not vias) min diameter - m_MicroViasMinDrill = FROM_LEGACY_LU( 50 ); // micro vias (not vias) min drill diameter + m_MinVia = VIA_DIMENSION( FROM_LEGACY_LU( 350 ), FROM_LEGACY_LU( 200 ) ); + m_MinMicroVia = VIA_DIMENSION( FROM_LEGACY_LU( 200 ), FROM_LEGACY_LU( 50 ) ); + //m_ViasMinSize = FROM_LEGACY_LU( 350 ); // vias (not micro vias) min diameter + //m_ViasMinDrill = FROM_LEGACY_LU( 200 ); // vias (not micro vias) min drill diameter + //m_MicroViasMinSize = FROM_LEGACY_LU( 200 ); // micro vias (not vias) min diameter + //m_MicroViasMinDrill = FROM_LEGACY_LU( 50 ); // micro vias (not vias) min drill diameter // Global mask margins: m_SolderMaskMargin = 150; // Solder mask margin diff --git a/pcbnew/class_netclass.cpp b/pcbnew/class_netclass.cpp index 187ce9d977..c761fc4c12 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 -int NETCLASS::DEFAULT_UVIA_DRILL = 50; // micro via drill +int NETCLASS::DEFAULT_VIA_DRILL = 250; // default via drill (TODO: should be gone on refactoring) +int NETCLASS::DEFAULT_UVIA_DRILL = 50; // micro via drill (TODO: --"--) NETCLASS::NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initialParameters ) : @@ -55,36 +55,39 @@ NETCLASS::NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initi SetParams( initialParameters ); } - void NETCLASS::SetParams( const NETCLASS* defaults ) { if( defaults ) { SetClearance( defaults->GetClearance() ); SetTrackWidth( defaults->GetTrackWidth() ); - SetViaDiameter( defaults->GetViaDiameter() ); - SetViaDrill( defaults->GetViaDrill() ); - SetuViaDiameter( defaults->GetuViaDiameter() ); - SetuViaDrill( defaults->GetuViaDrill() ); + Via( defaults->Via() ); + MicroVia( defaults->MicroVia() ); } else - { // We should use m_Parent->GetBoardDesignSettings() - // But when the NETCLASSES constructor is called - // (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD) - // is not run, and GetBoardDesignSettings() return a bad value - // TODO: see how change that. - const BOARD_DESIGN_SETTINGS& g = boardDesignSettings; - - SetTrackWidth( TO_LEGACY_LU( g.m_TrackMinWidth ) ); - SetViaDiameter( TO_LEGACY_LU( g.m_ViasMinSize ) ); - SetuViaDiameter( TO_LEGACY_LU( g.m_MicroViasMinSize ) ); - // Use default values for next parameters: - SetClearance( DEFAULT_CLEARANCE ); - SetViaDrill( DEFAULT_VIA_DRILL ); - SetuViaDrill( DEFAULT_UVIA_DRILL ); + { + SetToDefault(); } } +void NETCLASS::SetToDefault() +{ + // We should use m_Parent->GetBoardDesignSettings() + // But when the NETCLASSES constructor is called + // (it call NETCLASS constructor), the m_Parent constructor (see BOARD::BOARD) + // is not run, and GetBoardDesignSettings() return a bad value + // TODO: see how change that. + const BOARD_DESIGN_SETTINGS& g = boardDesignSettings; + + 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() { @@ -294,14 +297,14 @@ bool NETCLASS::Save( FILE* aFile ) const // Write parameters - fprintf( aFile, "Clearance %d\n", GetClearance() ); - fprintf( aFile, "TrackWidth %d\n", GetTrackWidth() ); + fprintf( aFile, "Clearance %f\n", TO_LEGACY_LU_DBL( Clearance() ) ); + fprintf( aFile, "TrackWidth %f\n", TO_LEGACY_LU_DBL( TrackWidth() ) ); - fprintf( aFile, "ViaDia %d\n", GetViaDiameter() ); - fprintf( aFile, "ViaDrill %d\n", GetViaDrill() ); + fprintf( aFile, "ViaDia %f\n", TO_LEGACY_LU_DBL( Via().m_Diameter ) ); + fprintf( aFile, "ViaDrill %f\n", TO_LEGACY_LU_DBL( Via().m_Drill ) ); - fprintf( aFile, "uViaDia %d\n", GetuViaDiameter() ); - fprintf( aFile, "uViaDrill %d\n", GetuViaDrill() ); + fprintf( aFile, "uViaDia %f\n", TO_LEGACY_LU_DBL( MicroVia().m_Diameter ) ); + fprintf( aFile, "uViaDrill %f\n", TO_LEGACY_LU_DBL( MicroVia().m_Drill ) ); // Write members: for( const_iterator i = begin(); i!=end(); ++i ) @@ -342,6 +345,8 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader ) char* Line; char Buffer[1024]; wxString netname; + VIA_DIMENSION via = Via(); + VIA_DIMENSION uvia = MicroVia(); while( aReader->ReadLine() ) { @@ -362,33 +367,37 @@ bool NETCLASS::ReadDescr( LINE_READER* aReader ) if( strnicmp( Line, "Clearance", 9 ) == 0 ) { - SetClearance( atoi( Line + 9 ) ); + Clearance( FROM_LEGACY_LU( atof( Line + 9 ) ) ); continue; } if( strnicmp( Line, "TrackWidth", 10 ) == 0 ) { - SetTrackWidth( atoi( Line + 10 ) ); + TrackWidth( FROM_LEGACY_LU( atof( Line + 10 ) ) ); continue; } if( strnicmp( Line, "ViaDia", 6 ) == 0 ) { - SetViaDiameter( atoi( Line + 6 ) ); + via.m_Diameter = FROM_LEGACY_LU( atof( Line + 6 ) ); + Via(via); continue; } if( strnicmp( Line, "ViaDrill", 8 ) == 0 ) { - SetViaDrill( atoi( Line + 8 ) ); + via.m_Drill = FROM_LEGACY_LU( atof( Line + 8 ) ); + Via(via); continue; } if( strnicmp( Line, "uViaDia", 7 ) == 0 ) { - SetuViaDiameter( atoi( Line + 7 ) ); + uvia.m_Diameter = FROM_LEGACY_LU( atof( Line + 7 ) ); + MicroVia(uvia); continue; } if( strnicmp( Line, "uViaDrill", 9 ) == 0 ) { - SetuViaDrill( atoi( Line + 9 ) ); + uvia.m_Drill = FROM_LEGACY_LU( atof( Line + 9 ) ); + MicroVia(uvia); continue; } @@ -417,22 +426,22 @@ int NETCLASS::GetTrackMinWidth() const int NETCLASS::GetViaMinDiameter() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_ViasMinSize ); + return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinVia.m_Diameter ); } int NETCLASS::GetViaMinDrill() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_ViasMinDrill ); + return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinVia.m_Drill ); } int NETCLASS::GetuViaMinDiameter() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MicroViasMinSize ); + return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ); } int NETCLASS::GetuViaMinDrill() const { - return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MicroViasMinDrill ); + return TO_LEGACY_LU( m_Parent->GetBoardDesignSettings()->m_MinMicroVia.m_Drill ); } diff --git a/pcbnew/class_netclass.h b/pcbnew/class_netclass.h index c42cb1f2e1..015c1cffc3 100644 --- a/pcbnew/class_netclass.h +++ b/pcbnew/class_netclass.h @@ -178,7 +178,7 @@ public: int GetTrackWidth() const { return TO_LEGACY_LU( 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 ); } int GetViaMinDiameter() const; void SetViaDiameter( int aDia ) { m_Via.m_Diameter = FROM_LEGACY_LU( aDia ); } @@ -195,6 +195,17 @@ public: int GetuViaMinDrill() const; void SetuViaDrill( int aSize ) { m_uVia.m_Drill = FROM_LEGACY_LU( aSize ); } + LENGTH_PCB Clearance() const { return m_Clearance; } + LENGTH_PCB Clearance( const LENGTH_PCB a ) { return m_Clearance = a; } + + LENGTH_PCB TrackWidth() const { return m_TrackWidth; } + LENGTH_PCB TrackWidth( const LENGTH_PCB a ) { return m_TrackWidth = a; } + + VIA_DIMENSION Via() const { return m_Via; } + VIA_DIMENSION Via( const VIA_DIMENSION a ) { return m_Via = a; } + + VIA_DIMENSION MicroVia() const { return m_uVia; } + VIA_DIMENSION MicroVia( const VIA_DIMENSION a ) { return m_uVia = a; } /** * Function SetParams @@ -205,6 +216,11 @@ public: */ void SetParams( const NETCLASS* defaults = NULL ); + /** + * Sets Parameters to their default state. + */ + void SetToDefault(); + /** * Function Save * writes the data structures for this object out to a FILE in "*.brd" format. diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index e73408a2fb..e02be2c686 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -27,7 +27,8 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, PCB_PAD_T ) { m_NumPadName = 0; - m_Size.x = m_Size.y = 500; // give it a reasonable size + m_Size.x = m_Size.y = FROM_LEGACY_LU( 500 ); // give it a reasonable size + /// TODO: remove hardcoded constant m_Orient = 0; // Pad rotation in 1/10 degrees m_LengthDie = 0; @@ -67,21 +68,23 @@ int D_PAD::GetMaxRadius() const switch( m_PadShape & 0x7F ) { case PAD_CIRCLE: - radius = m_Size.x / 2; + radius = TO_LEGACY_LU( m_Size.x / 2 ); break; case PAD_OVAL: - radius = MAX( m_Size.x, m_Size.y ) / 2; + radius = TO_LEGACY_LU( MAX( m_Size.x, m_Size.y ) / 2 ); break; case PAD_RECT: - radius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y - + (double) m_Size.x * m_Size.x ) / 2 ); + 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 ); break; case PAD_TRAPEZOID: - 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 + 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 radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 ); break; @@ -121,14 +124,14 @@ EDA_RECT D_PAD::GetBoundingBox() const // Returns the position of the pad. const wxPoint D_PAD::ReturnShapePos() { - if( m_Offset.x == 0 && m_Offset.y == 0 ) + if( m_Offset.x == ZERO_LENGTH && m_Offset.y == ZERO_LENGTH ) return m_Pos; wxPoint shape_pos; int dX, dY; - dX = m_Offset.x; - dY = m_Offset.y; + dX = TO_LEGACY_LU( m_Offset.x ); + dY = TO_LEGACY_LU( m_Offset.y ); RotatePoint( &dX, &dY, m_Orient ); @@ -300,7 +303,7 @@ int D_PAD::GetSolderMaskMargin() // ensure mask have a size always >= 0 if( margin < 0 ) { - int minsize = -MIN( m_Size.x, m_Size.y ) / 2; + int minsize = TO_LEGACY_LU( -MIN( m_Size.x, m_Size.y ) / 2 ); if( margin < minsize ) minsize = minsize; @@ -345,15 +348,15 @@ wxSize D_PAD::GetSolderPasteMargin() } wxSize pad_margin; - pad_margin.x = margin + wxRound( m_Size.x * mratio ); - pad_margin.y = margin + wxRound( m_Size.y * mratio ); + pad_margin.x = margin + wxRound( TO_LEGACY_LU_DBL( m_Size.x ) * mratio ); + pad_margin.y = margin + wxRound( TO_LEGACY_LU_DBL( m_Size.y ) * mratio ); // ensure mask have a size always >= 0 - if( pad_margin.x < -m_Size.x / 2 ) - pad_margin.x = -m_Size.x / 2; + if( pad_margin.x < TO_LEGACY_LU( -m_Size.x / 2 ) ) + pad_margin.x = TO_LEGACY_LU( -m_Size.x / 2 ); - if( pad_margin.y < -m_Size.y / 2 ) - pad_margin.y = -m_Size.y / 2; + if( pad_margin.y < TO_LEGACY_LU( -m_Size.y / 2 ) ) + pad_margin.y = TO_LEGACY_LU( -m_Size.y / 2 ); return pad_margin; } @@ -375,7 +378,8 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) char* Line; char BufLine[1024], BufCar[256]; char* PtLine; - int nn, ll, dx, dy; + int nn, ll; + double sx, sy, ox, oy, dr, dx, dy; while( aReader->ReadLine() ) { @@ -417,11 +421,14 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) if( *PtLine == '"' ) PtLine++; - nn = sscanf( PtLine, " %s %d %d %d %d %d", - BufCar, &m_Size.x, &m_Size.y, - &m_DeltaSize.x, &m_DeltaSize.y, + nn = sscanf( PtLine, " %s %lf %lf %lf %lf %d", + BufCar, &sx, &sy, + &dx, &dy, &m_Orient ); - + m_Size.x = FROM_LEGACY_LU( sx ); + m_Size.y = FROM_LEGACY_LU( sy ); + m_DeltaSize.x = FROM_LEGACY_LU( dx ); + m_DeltaSize.y = FROM_LEGACY_LU( dy ); ll = 0xFF & BufCar[0]; /* Read pad shape */ @@ -447,16 +454,19 @@ int D_PAD::ReadDescr( LINE_READER* aReader ) case 'D': BufCar[0] = 0; - 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; + nn = sscanf( PtLine, "%lf %lf %lf %s %lf %lf", &dr, + &ox, &oy, BufCar, &dx, &dy ); + m_Offset.x = FROM_LEGACY_LU( ox ); + m_Offset.y = FROM_LEGACY_LU( oy ); + m_Drill.y = m_Drill.x = FROM_LEGACY_LU( dr ); m_DrillShape = PAD_CIRCLE; if( nn >= 6 ) // Drill shape = OVAL ? { if( BufCar[0] == 'O' ) { - m_Drill.x = dx; m_Drill.y = dy; + m_Drill.x = FROM_LEGACY_LU( dx ); + m_Drill.y = FROM_LEGACY_LU( dy ); m_DrillShape = PAD_OVAL; } } @@ -551,15 +561,15 @@ bool D_PAD::Save( FILE* aFile ) const break; } - 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, "Sh \"%.4s\" %c %d %d %d %d %d\n", // TODO: pad name length limit! + m_Padname, cshape, TO_LEGACY_LU( m_Size.x ), TO_LEGACY_LU( m_Size.y ), + TO_LEGACY_LU( m_DeltaSize.x ), TO_LEGACY_LU( m_DeltaSize.y ), m_Orient ); - fprintf( aFile, "Dr %d %d %d", m_Drill.x, m_Offset.x, m_Offset.y ); + fprintf( aFile, "Dr %d %d %d", TO_LEGACY_LU( m_Drill.x ), TO_LEGACY_LU( m_Offset.x ), TO_LEGACY_LU( m_Offset.y ) ); if( m_DrillShape == PAD_OVAL ) { - fprintf( aFile, " %c %d %d", 'O', m_Drill.x, m_Drill.y ); + fprintf( aFile, " %c %d %d", 'O', TO_LEGACY_LU( m_Drill.x ), TO_LEGACY_LU( m_Drill.y ) ); } fprintf( aFile, "\n" ); @@ -744,13 +754,13 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( ShowPadShape(), ShowPadAttr(), DARKGREEN ); - valeur_param( m_Size.x, Line ); + valeur_param( TO_LEGACY_LU( m_Size.x ), Line ); frame->AppendMsgPanel( _( "H Size" ), Line, RED ); - valeur_param( m_Size.y, Line ); + valeur_param( TO_LEGACY_LU( m_Size.y ), Line ); frame->AppendMsgPanel( _( "V Size" ), Line, RED ); - valeur_param( (unsigned) m_Drill.x, Line ); + valeur_param( (unsigned)(int) TO_LEGACY_LU( m_Drill.x ), Line ); if( m_DrillShape == PAD_CIRCLE ) { @@ -758,9 +768,9 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame ) } else { - valeur_param( (unsigned) m_Drill.x, Line ); + valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.x ), Line ); wxString msg; - valeur_param( (unsigned) m_Drill.y, msg ); + valeur_param( (unsigned) TO_LEGACY_LU( m_Drill.y ), msg ); Line += wxT( " / " ) + msg; frame->AppendMsgPanel( _( "Drill X / Y" ), Line, RED ); } @@ -816,8 +826,8 @@ bool D_PAD::HitTest( const wxPoint& refPos ) if( ( abs( delta.x ) > m_ShapeMaxRadius ) || ( abs( delta.y ) > m_ShapeMaxRadius ) ) return false; - dx = m_Size.x >> 1; // dx also is the radius for rounded pads - dy = m_Size.y >> 1; + dx = TO_LEGACY_LU( m_Size.x / 2 ); // dx also is the radius for rounded pads + dy = TO_LEGACY_LU( m_Size.y / 2 ); switch( m_PadShape & 0x7F ) { @@ -854,25 +864,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 = padref->m_Size.x - padcmp->m_Size.x) ) + if( ( diff = TO_LEGACY_LU( padref->m_Size.x - padcmp->m_Size.x ) ) ) return diff; - if( (diff = padref->m_Size.y - padcmp->m_Size.y) ) + if( ( diff = TO_LEGACY_LU( padref->m_Size.y - padcmp->m_Size.y ) ) ) return diff; - if( (diff = padref->m_Offset.x - padcmp->m_Offset.x) ) + if( ( diff = TO_LEGACY_LU( padref->m_Offset.x - padcmp->m_Offset.x ) ) ) return diff; - if( (diff = padref->m_Offset.y - padcmp->m_Offset.y) ) + if( ( diff = TO_LEGACY_LU( padref->m_Offset.y - padcmp->m_Offset.y ) ) ) return diff; - if( (diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x) ) + if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.x - padcmp->m_DeltaSize.x ) ) ) return diff; - if( (diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y) ) + if( ( diff = TO_LEGACY_LU( padref->m_DeltaSize.y - padcmp->m_DeltaSize.y ) ) ) return diff; // @todo check if export_gencad still works: diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 37d4914287..42d11da9f8 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -11,6 +11,8 @@ #include "pad_shapes.h" #include "PolyLine.h" +#include "lengthpcb.h" + class LINE_READER; class EDA_3D_CANVAS; @@ -85,14 +87,17 @@ public: // 2..14 = internal layers // 16 .. 31 = technical layers - int m_PadShape; // Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID - int m_DrillShape; // Shape PAD_CIRCLE, PAD_OVAL + int m_PadShape; ///< Shape: PAD_CIRCLE, PAD_RECT, PAD_OVAL, PAD_TRAPEZOID + int m_DrillShape; ///< Shape PAD_CIRCLE, PAD_OVAL + /// @TODO: as m_DrillShape is eqv. to m_Drill.x==.y + /// it would be relatively easy to remove + /// this redundant flag. - wxSize m_Drill; // Drill diam (drill shape = PAD_CIRCLE) or drill size - // (shape = OVAL) for drill shape = PAD_CIRCLE, drill - // diam = m_Drill.x + VECTOR_PCB m_Drill; ///< Drill diam (drill shape = PAD_CIRCLE) or drill size + /// (shape = OVAL) for drill shape = PAD_CIRCLE, drill + /// diam = m_Drill.x - wxSize m_Offset; /* This parameter is useful only for oblong pads (it can be used for other + VECTOR_PCB m_Offset; /* This parameter is useful only for oblong pads (it can be used for other * shapes, but without any interest). * this is the offset between the pad hole and the pad shape (you must * understand here pad shape = copper area around the hole) @@ -105,9 +110,9 @@ public: * D_PAD::ReturnShapePos() returns the physical shape position according to * the offset and the pad rotation.*/ - wxSize m_Size; // X and Y size ( relative to orient 0) + VECTOR_PCB m_Size; // X and Y size ( relative to orient 0) - wxSize m_DeltaSize; // delta on rectangular shapes + VECTOR_PCB m_DeltaSize; // delta on rectangular shapes wxPoint m_Pos0; // Initial Pad position (i.e. pas position relative to the // module anchor, orientation 0 diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index d28ae08bb4..beabb2bf8c 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 = m_Size; - halfsize.x >>= 1; - halfsize.y >>= 1; + wxSize halfsize = TO_LEGACY_LU_WXS( m_Size ); + halfsize.x /= 2; + halfsize.y /= 2; switch( GetShape() ) { @@ -476,7 +476,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) /* Draw the pad hole */ wxPoint holepos = m_Pos - aDrawInfo.m_Offset; - int hole = m_Drill.x >> 1; + int hole = TO_LEGACY_LU( m_Drill.x ) / 2; bool drawhole = hole > 0; @@ -513,20 +513,20 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) break; case PAD_OVAL: - halfsize.x = m_Drill.x >> 1; - halfsize.y = m_Drill.y >> 1; + halfsize.x = TO_LEGACY_LU( m_Drill.x ) / 2; + halfsize.y = TO_LEGACY_LU( m_Drill.y ) / 2; if( m_Drill.x > m_Drill.y ) /* horizontal */ { delta_cx = halfsize.x - halfsize.y; delta_cy = 0; - seg_width = m_Drill.y; + seg_width = TO_LEGACY_LU( m_Drill.y ); } else /* vertical */ { delta_cx = 0; delta_cy = halfsize.y - halfsize.x; - seg_width = m_Drill.x; + seg_width = TO_LEGACY_LU( m_Drill.x ); } RotatePoint( &delta_cx, &delta_cy, angle ); @@ -576,13 +576,13 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) if( GetShape() == PAD_CIRCLE ) angle = 0; - AreaSize = m_Size; + AreaSize = TO_LEGACY_LU_WXS( m_Size ); if( m_Size.y > m_Size.x ) { angle += 900; - AreaSize.x = m_Size.y; - AreaSize.y = m_Size.x; + AreaSize.x = TO_LEGACY_LU( m_Size.y ); + AreaSize.y = TO_LEGACY_LU( m_Size.x ); } if( shortname_len > 0 ) // if there is a netname, provides room to display this netname @@ -666,21 +666,21 @@ int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd, int a if( m_Size.y < m_Size.x ) // Build an horizontal equiv segment { - int delta = ( m_Size.x - m_Size.y ) / 2; + int delta = TO_LEGACY_LU( ( m_Size.x - m_Size.y ) / 2 ); aSegStart.x = -delta; aSegStart.y = 0; aSegEnd.x = delta; aSegEnd.y = 0; - width = m_Size.y; + width = TO_LEGACY_LU( m_Size.y ); } else // Vertical oval: build a vertical equiv segment { - int delta = ( m_Size.y -m_Size.x ) / 2; + int delta = TO_LEGACY_LU( ( m_Size.y -m_Size.x ) / 2 ); aSegStart.x = 0; aSegStart.y = -delta; aSegEnd.x = 0; aSegEnd.y = delta; - width = m_Size.x; + width = TO_LEGACY_LU( m_Size.x ); } if( aRotation ) @@ -701,8 +701,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat wxSize delta; wxSize halfsize; - halfsize.x = m_Size.x >> 1; - halfsize.y = m_Size.y >> 1; + halfsize.x = TO_LEGACY_LU( m_Size.x / 2 ); + halfsize.y = TO_LEGACY_LU( m_Size.y / 2 ); /* For rectangular shapes, inflate is easy */ @@ -721,8 +721,8 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat else { // Trapezoidal pad: verify delta values - delta.x = ( m_DeltaSize.x >> 1 ); - delta.y = ( m_DeltaSize.y >> 1 ); + delta.x = TO_LEGACY_LU( m_DeltaSize.x / 2 ); + delta.y = TO_LEGACY_LU( m_DeltaSize.y / 2 ); // be sure delta values are not to large if( (delta.x < 0) && (delta.x <= -halfsize.y) ) @@ -762,7 +762,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat if( delta.y ) // lower and upper segment is horizontal { // Calculate angle of left (or right) segment with vertical axis - angle = atan2( double( m_DeltaSize.y ), double( m_Size.y ) ); + angle = atan2( m_DeltaSize.y, m_Size.y ); /// TODO: make atan2 available to LENGTH // left and right sides are moved by aInflateValue.x in their perpendicular direction // We must calculate the corresponding displacement on the horizontal axis @@ -778,7 +778,7 @@ void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue, int aRotat else if( delta.x ) // left and right segment is vertical { // Calculate angle of lower (or upper) segment with horizontal axis - angle = atan2( double( m_DeltaSize.x ), double( m_Size.x ) ); + angle = atan2( m_DeltaSize.x, m_Size.x ); // lower and upper sides are moved by aInflateValue.x in their perpendicular direction // We must calculate the corresponding displacement on the vertical axis diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index 570dc4cf7a..fb7795513f 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -227,11 +227,11 @@ void DIALOG_DESIGN_RULES::PrintCurrentSettings() #ifdef KICAD_NANOMETRE value = LengthToString( UnitDescription( g_UserUnit ), - m_BrdSettings->m_ViasMinSize, + m_BrdSettings->m_MinVia.m_Diameter, true ); #else value = ReturnStringFromValue( g_UserUnit, - TO_LEGACY_LU( m_BrdSettings->m_ViasMinSize ), + TO_LEGACY_LU( m_BrdSettings->m_MinVia.m_Diameter ), internal_units, true ); #endif @@ -240,11 +240,11 @@ void DIALOG_DESIGN_RULES::PrintCurrentSettings() #ifdef KICAD_NANOMETRE value = LengthToString( UnitDescription( g_UserUnit ), - m_BrdSettings->m_MicroViasMinSize, + m_BrdSettings->m_MinMicroVia.m_Diameter, true ); #else value = ReturnStringFromValue( g_UserUnit, - TO_LEGACY_LU( m_BrdSettings->m_MicroViasMinSize ), + TO_LEGACY_LU( m_BrdSettings->m_MinMicroVia.m_Diameter ), internal_units, true ); #endif @@ -312,30 +312,29 @@ void DIALOG_DESIGN_RULES::InitGlobalRules() AddUnitSymbol( *m_TrackMinWidthTitle ); int Internal_Unit = m_Parent->m_InternalUnits; -#ifdef KICAD_NANOMETRE - LengthToTextCtrl( *m_SetViasMinSizeCtrl, m_BrdSettings->m_ViasMinSize ); - LengthToTextCtrl( *m_SetViasMinDrillCtrl, m_BrdSettings->m_ViasMinDrill ); -#else - PutValueInLocalUnits( *m_SetViasMinSizeCtrl, - m_BrdSettings->m_ViasMinSize, - Internal_Unit ); - PutValueInLocalUnits( *m_SetViasMinDrillCtrl, m_BrdSettings->m_ViasMinDrill, Internal_Unit ); -#endif - if( m_BrdSettings->m_CurrentViaType != VIA_THROUGH ) m_OptViaType->SetSelection( 1 ); m_AllowMicroViaCtrl->SetSelection( m_BrdSettings->m_MicroViasAllowed ? 1 : 0 ); + #ifdef KICAD_NANOMETRE - LengthToTextCtrl( *m_SetMicroViasMinSizeCtrl, m_BrdSettings->m_MicroViasMinSize ); - LengthToTextCtrl( *m_SetMicroViasMinDrillCtrl, m_BrdSettings->m_MicroViasMinDrill ); + LengthToTextCtrl( *m_SetViasMinSizeCtrl, m_BrdSettings->m_MinVia.m_Diameter ); + LengthToTextCtrl( *m_SetViasMinDrillCtrl, m_BrdSettings->m_MinVia.m_Drill ); + LengthToTextCtrl( *m_SetMicroViasMinSizeCtrl, m_BrdSettings->m_MinMicroVia.m_Diameter ); + LengthToTextCtrl( *m_SetMicroViasMinDrillCtrl, m_BrdSettings->m_MinMicroVia.m_Drill ); LengthToTextCtrl( *m_SetTrackMinWidthCtrl, m_BrdSettings->m_TrackMinWidth ); #else + PutValueInLocalUnits( *m_SetViasMinSizeCtrl, + m_BrdSettings->m_MinVia.m_Diameter, + Internal_Unit ); + PutValueInLocalUnits( *m_SetViasMinDrillCtrl, + m_BrdSettings->m_MinVia.m_Drill, + Internal_Unit ); PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl, - m_BrdSettings->m_MicroViasMinSize, + m_BrdSettings->m_MinMicroVia.m_Diameter, Internal_Unit ); PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl, - TO_LEGACY_LU( m_BrdSettings->m_MicroViasMinDrill ), + m_BrdSettings->m_MinMicroVia.m_Drill, Internal_Unit ); PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings->m_TrackMinWidth, @@ -550,6 +549,15 @@ static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc, int units ) // label is netclass name grid->SetRowLabelValue( row, nc->GetName() ); +#ifdef KICAD_NANOMETRE + const LENGTH_UNIT_DESC *ud = UnitDescription( g_UserUnit ); + grid->SetCellValue( row, GRID_CLEARANCE, LengthToString( ud, nc->Clearance() ) ); + grid->SetCellValue( row, GRID_TRACKSIZE, LengthToString( ud, nc->TrackWidth() ) ); + grid->SetCellValue( row, GRID_VIASIZE, LengthToString( ud, nc->Via().m_Diameter ) ); + grid->SetCellValue( row, GRID_VIADRILL, LengthToString( ud, nc->Via().m_Drill ) ); + grid->SetCellValue( row, GRID_uVIASIZE, LengthToString( ud, nc->MicroVia().m_Diameter ) ); + grid->SetCellValue( row, GRID_uVIADRILL, LengthToString( ud, nc->MicroVia().m_Drill ) ); +#else msg = ReturnStringFromValue( g_UserUnit, nc->GetClearance(), units ); grid->SetCellValue( row, GRID_CLEARANCE, msg ); @@ -567,6 +575,7 @@ static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc, int units ) msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDrill(), units ); grid->SetCellValue( row, GRID_uVIADRILL, msg ); +#endif } @@ -600,6 +609,17 @@ void DIALOG_DESIGN_RULES::InitRulesList() static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units ) { +#ifdef KICAD_NANOMETRE + const LENGTH_UNIT_DESC *ud = UnitDescription( g_UserUnit ); + nc->Clearance( StringToLength( ud, grid->GetCellValue( row, GRID_CLEARANCE ) ) ); + nc->TrackWidth( StringToLength( ud, grid->GetCellValue( row, GRID_TRACKSIZE ) ) ); + nc->Via( VIA_DIMENSION( + StringToLength( ud, grid->GetCellValue( row, GRID_VIASIZE ) ), + StringToLength( ud, grid->GetCellValue( row, GRID_VIADRILL ) ) ) ); + nc->MicroVia( VIA_DIMENSION( + StringToLength( ud, grid->GetCellValue( row, GRID_uVIASIZE ) ), + StringToLength( ud, grid->GetCellValue( row, GRID_uVIADRILL ) ) ) ); +#else #define MYCELL( col ) \ ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ), units ) @@ -609,6 +629,7 @@ static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units ) nc->SetViaDrill( MYCELL( GRID_VIADRILL ) ); nc->SetuViaDiameter( MYCELL( GRID_uVIASIZE ) ); nc->SetuViaDrill( MYCELL( GRID_uVIADRILL ) ); +#endif } @@ -668,15 +689,15 @@ void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard() #ifdef KICAD_NANOMETRE // Update vias minimum values for DRC - m_BrdSettings->m_ViasMinSize = + m_BrdSettings->m_MinVia.m_Diameter = LengthFromTextCtrl( *m_SetViasMinSizeCtrl ); - m_BrdSettings->m_ViasMinDrill = + m_BrdSettings->m_MinVia.m_Drill = LengthFromTextCtrl( *m_SetViasMinDrillCtrl ); // Update microvias minimum values for DRC - m_BrdSettings->m_MicroViasMinSize = + m_BrdSettings->m_MinMicroVia.m_Diameter = LengthFromTextCtrl( *m_SetMicroViasMinSizeCtrl ); - m_BrdSettings->m_MicroViasMinDrill = + m_BrdSettings->m_MinMicroVia.m_Drill = LengthFromTextCtrl( *m_SetMicroViasMinDrillCtrl ); // Update tracks minimum values for DRC @@ -684,15 +705,15 @@ void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard() LengthFromTextCtrl( *m_SetTrackMinWidthCtrl ); #else // Update vias minimum values for DRC - m_BrdSettings->m_ViasMinSize = + m_BrdSettings->m_MinVia.m_Diameter = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_ViasMinDrill = + m_BrdSettings->m_MinVia.m_Drill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, m_Parent->m_InternalUnits ); // Update microvias minimum values for DRC - m_BrdSettings->m_MicroViasMinSize = + m_BrdSettings->m_MinMicroVia.m_Diameter = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_MicroViasMinDrill = + m_BrdSettings->m_MinMicroVia.m_Drill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, m_Parent->m_InternalUnits ); // Update tracks minimum values for DRC m_BrdSettings->m_TrackMinWidth = diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 3126730b5c..8ded4dde81 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -133,16 +133,16 @@ void DIALOG_DRC_CONTROL::SetDrcParmeters( ) #ifdef KICAD_NANOMETRE m_BrdSettings->m_TrackMinWidth = LengthFromTextCtrl( *m_SetTrackMinWidthCtrl ); - m_BrdSettings->m_ViasMinSize = + m_BrdSettings->m_MinVia.m_Diameter = LengthFromTextCtrl( *m_SetViaMinSizeCtrl ); - m_BrdSettings->m_MicroViasMinSize = + m_BrdSettings->m_MinMicroVia.m_Diameter = LengthFromTextCtrl( *m_SetMicroViakMinSizeCtrl ); #else m_BrdSettings->m_TrackMinWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_ViasMinSize = + m_BrdSettings->m_MinVia.m_Diameter = ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->m_InternalUnits ); - m_BrdSettings->m_MicroViasMinSize = + m_BrdSettings->m_MinMicroVia.m_Diameter = ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->m_InternalUnits ); #endif } diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index 32301f0fa8..7e7b572197 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 != 0 ) + if( pad->m_Drill.x != ZERO_LENGTH ) { if( pad->m_Attribut == PAD_HOLE_NOT_PLATED ) m_notplatedPadsHoleCount++; @@ -195,7 +195,7 @@ void DIALOG_GENDRILL::InitDisplayParams( void ) } else { - if( MIN( pad->m_Drill.x, pad->m_Drill.y ) != 0 ) + if( MIN( TO_LEGACY_LU( pad->m_Drill.x ), TO_LEGACY_LU( pad->m_Drill.y ) ) != 0 ) { if( pad->m_Attribut == PAD_HOLE_NOT_PLATED ) m_notplatedPadsHoleCount++; diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 04e38d2f89..186ed18a62 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -130,11 +130,11 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event ) dc.SetDeviceOrigin( dc_size.x / 2, dc_size.y / 2 ); // Calculate a suitable scale to fit the available draw area - int dim = m_dummyPad->m_Size.x + ABS( m_dummyPad->m_DeltaSize.y); + int dim = TO_LEGACY_LU( m_dummyPad->m_Size.x + ABS( m_dummyPad->m_DeltaSize.y ) ); if( m_dummyPad->m_LocalClearance > 0 ) dim += m_dummyPad->m_LocalClearance * 2; double scale = (double) dc_size.x / dim; - dim = m_dummyPad->m_Size.y + ABS( m_dummyPad->m_DeltaSize.x); + dim = TO_LEGACY_LU( m_dummyPad->m_Size.y + ABS( m_dummyPad->m_DeltaSize.x ) ); if( m_dummyPad->m_LocalClearance > 0 ) dim += m_dummyPad->m_LocalClearance * 2; double altscale = (double) dc_size.y / dim; @@ -239,23 +239,23 @@ void DIALOG_PAD_PROPERTIES::initValues() PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->m_Pos.x, internalUnits ); PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->m_Pos.y, internalUnits ); - PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->m_Drill.x, internalUnits ); - PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->m_Drill.y, internalUnits ); + PutValueInLocalUnits( *m_PadDrill_X_Ctrl, TO_LEGACY_LU( m_dummyPad->m_Drill.x ), internalUnits ); + PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, TO_LEGACY_LU( m_dummyPad->m_Drill.y ), internalUnits ); - PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->m_Size.x, internalUnits ); - PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->m_Size.y, internalUnits ); + PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, TO_LEGACY_LU( m_dummyPad->m_Size.x ), internalUnits ); + PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, TO_LEGACY_LU( m_dummyPad->m_Size.y ), internalUnits ); - PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->m_Offset.x, internalUnits ); - PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->m_Offset.y, internalUnits ); + PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, TO_LEGACY_LU( m_dummyPad->m_Offset.x ), internalUnits ); + PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, TO_LEGACY_LU( m_dummyPad->m_Offset.y ), internalUnits ); - if( m_dummyPad->m_DeltaSize.x ) + if( m_dummyPad->m_DeltaSize.x != ZERO_LENGTH ) { - PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.x, internalUnits ); + PutValueInLocalUnits( *m_ShapeDelta_Ctrl, TO_LEGACY_LU( m_dummyPad->m_DeltaSize.x ), internalUnits ); m_radioBtnDeltaXdir->SetValue(true); } else { - PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->m_DeltaSize.y, internalUnits ); + PutValueInLocalUnits( *m_ShapeDelta_Ctrl, TO_LEGACY_LU( m_dummyPad->m_DeltaSize.y ), internalUnits ); m_radioBtnDeltaYdir->SetValue(true); } @@ -718,8 +718,8 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError aPad->m_Pos0 = aPad->m_Pos; // Read pad drill: - aPad->m_Drill.x = ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl, internalUnits ); - aPad->m_Drill.y = ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl, internalUnits ); + aPad->m_Drill.x = FROM_LEGACY_LU( ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl, internalUnits ) ); + aPad->m_Drill.y = FROM_LEGACY_LU( ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl, internalUnits ) ); if( m_DrillShapeCtrl->GetSelection() == 0 ) { aPad->m_DrillShape = PAD_CIRCLE; @@ -729,8 +729,8 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError aPad->m_DrillShape = PAD_OVAL; // Read pad shape size: - aPad->m_Size.x = ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl, internalUnits ); - aPad->m_Size.y = ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl, internalUnits ); + aPad->m_Size.x = FROM_LEGACY_LU( ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl, internalUnits ) ); + aPad->m_Size.y = FROM_LEGACY_LU( ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl, internalUnits ) ); if( aPad->m_PadShape == PAD_CIRCLE ) aPad->m_Size.y = aPad->m_Size.x; @@ -741,38 +741,38 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError delta.x = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits ); else delta.y = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits ); - aPad->m_DeltaSize = delta; + aPad->m_DeltaSize = VECTOR_PCB( FROM_LEGACY_LU( delta.x ), FROM_LEGACY_LU( delta.y ) ); // Read pad lenght die 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 + // remember DeltaSize.x is the Y size variation TODO: this can be optimized bool error = false; - if( (aPad->m_DeltaSize.x < 0) && (aPad->m_DeltaSize.x <= -aPad->m_Size.y) ) + if( (aPad->m_DeltaSize.x < ZERO_LENGTH) && (aPad->m_DeltaSize.x <= -aPad->m_Size.y ) ) { - aPad->m_DeltaSize.x = -aPad->m_Size.y + 2; + aPad->m_DeltaSize.x = -aPad->m_Size.y + FROM_LEGACY_LU( 2 ); error = true; } - if( (aPad->m_DeltaSize.x > 0) && (aPad->m_DeltaSize.x >= aPad->m_Size.y) ) + if( (aPad->m_DeltaSize.x > ZERO_LENGTH) && (aPad->m_DeltaSize.x >= aPad->m_Size.y ) ) { - aPad->m_DeltaSize.x = aPad->m_Size.y - 2; + aPad->m_DeltaSize.x = aPad->m_Size.y - FROM_LEGACY_LU( 2 ); error = true; } - if( (aPad->m_DeltaSize.y < 0) && (aPad->m_DeltaSize.y <= -aPad->m_Size.x) ) + if( (aPad->m_DeltaSize.y < ZERO_LENGTH) && (aPad->m_DeltaSize.y <= -aPad->m_Size.x ) ) { - aPad->m_DeltaSize.y = -aPad->m_Size.x + 2; + aPad->m_DeltaSize.y = -aPad->m_Size.x + FROM_LEGACY_LU( 2 ); error = true; } - if( (aPad->m_DeltaSize.y > 0) && (aPad->m_DeltaSize.y >= aPad->m_Size.x) ) + if( (aPad->m_DeltaSize.y > ZERO_LENGTH) && (aPad->m_DeltaSize.y >= aPad->m_Size.x ) ) { - aPad->m_DeltaSize.y = aPad->m_Size.x - 2; + aPad->m_DeltaSize.y = aPad->m_Size.x - FROM_LEGACY_LU( 2 ); error = true; } // Read pad shape offset: - aPad->m_Offset.x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl, internalUnits ); - aPad->m_Offset.y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl, internalUnits ); + aPad->m_Offset.x = FROM_LEGACY_LU( ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl, internalUnits ) ); + aPad->m_Offset.y = FROM_LEGACY_LU( ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl, internalUnits ) ); long orient_value = 0; msg = m_PadOrientCtrl->GetValue(); @@ -787,17 +787,17 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError switch( aPad->m_PadShape ) { case PAD_CIRCLE: - aPad->m_Offset = wxSize( 0, 0 ); - aPad->m_DeltaSize = wxSize( 0, 0 ); + aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); // wxSize( 0, 0 ); + aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); aPad->m_Size.y = aPad->m_Size.x; break; case PAD_RECT: - aPad->m_DeltaSize = wxSize( 0, 0 ); + aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); break; case PAD_OVAL: - aPad->m_DeltaSize = wxSize( 0, 0 ); + aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); break; case PAD_TRAPEZOID: @@ -811,14 +811,14 @@ bool DIALOG_PAD_PROPERTIES::TransfertDataToPad( D_PAD* aPad, bool aPromptOnError case PAD_CONN: case PAD_SMD: - aPad->m_Offset = wxSize( 0, 0 ); - aPad->m_Drill = wxSize( 0, 0 ); + aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); + aPad->m_Drill = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); break; case PAD_HOLE_NOT_PLATED: // Mechanical purpose only: // no offset, no net name, no pad name allowed - aPad->m_Offset = wxSize( 0, 0 ); + aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 ); aPad->SetPadName( wxEmptyString ); aPad->SetNetname( wxEmptyString ); break; @@ -875,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; @@ -885,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 || aPad->m_Drill.y ) + if( aPad->m_Drill.x != ZERO_LENGTH || aPad->m_Drill.y != ZERO_LENGTH ) { msg = _( "Error: pad is not on a copper layer and has a hole" ); if( aPad->m_Attribut == PAD_HOLE_NOT_PLATED ) diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 15648fad38..d4b41193cf 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -58,18 +58,18 @@ void DRC::ShowDialog() LengthToTextCtrl( *m_ui->m_SetTrackMinWidthCtrl, m_pcb->GetBoardDesignSettings()->m_TrackMinWidth ); LengthToTextCtrl( *m_ui->m_SetViaMinSizeCtrl, - m_pcb->GetBoardDesignSettings()->m_ViasMinSize ); + m_pcb->GetBoardDesignSettings()->m_MinVia.m_Diameter ); LengthToTextCtrl( *m_ui->m_SetMicroViakMinSizeCtrl, - m_pcb->GetBoardDesignSettings()->m_MicroViasMinSize ); + m_pcb->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ); #else PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl, TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_TrackMinWidth ), m_mainWindow->m_InternalUnits ); PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl, - TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_ViasMinSize ), + TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MinVia.m_Diameter ), m_mainWindow->m_InternalUnits ); PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl, - TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MicroViasMinSize ), + TO_LEGACY_LU( m_pcb->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ), m_mainWindow->m_InternalUnits ); #endif @@ -335,12 +335,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetViaDiameter() < TO_LEGACY_LU( g.m_ViasMinSize ) ) + if( nc->GetViaDiameter() < TO_LEGACY_LU( g.m_MinVia.m_Diameter ) ) { msg.Printf( _( "NETCLASS: '%s' has Via Dia:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetViaDiameter() ), - FmtVal( TO_LEGACY_LU( g.m_ViasMinSize ) ) + FmtVal( TO_LEGACY_LU( g.m_MinVia.m_Diameter ) ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_VIASIZE, msg, m_currentMarker ); @@ -349,12 +349,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetViaDrill() < TO_LEGACY_LU( g.m_ViasMinDrill ) ) + if( nc->GetViaDrill() < TO_LEGACY_LU( g.m_MinVia.m_Drill ) ) { msg.Printf( _( "NETCLASS: '%s' has Via Drill:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetViaDrill() ), - FmtVal( TO_LEGACY_LU( g.m_ViasMinDrill ) ) + FmtVal( TO_LEGACY_LU( g.m_MinVia.m_Drill ) ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_VIADRILLSIZE, msg, m_currentMarker ); @@ -363,12 +363,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetuViaDiameter() < TO_LEGACY_LU( g.m_MicroViasMinSize ) ) + if( nc->GetuViaDiameter() < TO_LEGACY_LU( g.m_MinMicroVia.m_Diameter ) ) { msg.Printf( _( "NETCLASS: '%s' has uVia Dia:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetuViaDiameter() ), - FmtVal( TO_LEGACY_LU( g.m_MicroViasMinSize ) ) + FmtVal( TO_LEGACY_LU( g.m_MinMicroVia.m_Diameter ) ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_uVIASIZE, msg, m_currentMarker ); @@ -377,12 +377,12 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) ret = false; } - if( nc->GetuViaDrill() < TO_LEGACY_LU( g.m_MicroViasMinDrill ) ) + if( nc->GetuViaDrill() < TO_LEGACY_LU( g.m_MinMicroVia.m_Drill ) ) { msg.Printf( _( "NETCLASS: '%s' has uVia Drill:%s which is less than global:%s" ), GetChars( nc->GetName() ), FmtVal( nc->GetuViaDrill() ), - FmtVal( TO_LEGACY_LU( g.m_MicroViasMinDrill ) ) + FmtVal( TO_LEGACY_LU( g.m_MinMicroVia.m_Drill ) ) ); m_currentMarker = fillMarker( DRCE_NETCLASS_uVIADRILLSIZE, msg, m_currentMarker ); @@ -617,7 +617,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li /* Here, we must test clearance between holes and pads * dummy pad size and shape is adjusted to pad drill size and shape */ - if( pad->m_Drill.x ) + if( pad->m_Drill.x != ZERO_LENGTH ) { // pad under testing has a hole, test this hole against pad reference dummypad.SetPosition( pad->GetPosition() ); @@ -637,7 +637,7 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li } } - if( aRefPad->m_Drill.x ) // pad reference has a hole + if( aRefPad->m_Drill.x != ZERO_LENGTH ) // pad reference has a hole { dummypad.SetPosition( aRefPad->GetPosition() ); dummypad.m_Size = aRefPad->m_Drill; diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index 63358f1436..ab57d617d7 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 == 0 ) + if( pad->m_Drill.x == ZERO_LENGTH ) 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, aRefPad->m_Size.x, dist_min ); + diag = checkClearanceSegmToPad( aPad, TO_LEGACY_LU( aRefPad->m_Size.x ), dist_min ); break; case PAD_RECT: @@ -644,7 +644,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) if( aPad->m_PadShape == PAD_RECT ) { - wxSize size = aPad->m_Size; + wxSize size = TO_LEGACY_LU_WXS( aPad->m_Size ); // The trivial case is if both rects are rotated by multiple of 90 deg // Most of time this is the case, and the test is fast @@ -664,10 +664,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) relativePadPos.x = ABS( relativePadPos.x ); relativePadPos.y = ABS( relativePadPos.y ); - if( ( relativePadPos.x - ( (size.x + aRefPad->m_Size.x) / 2 ) ) >= dist_min ) + if( ( relativePadPos.x - ( (size.x + TO_LEGACY_LU( aRefPad->m_Size.x ) ) / 2 ) ) >= dist_min ) diag = true; - if( ( relativePadPos.y - ( (size.y + aRefPad->m_Size.y) / 2 ) ) >= dist_min ) + if( ( relativePadPos.y - ( (size.y + TO_LEGACY_LU( aRefPad->m_Size.y) ) / 2 ) ) >= dist_min ) diag = true; } else // at least one pad has any other orient. Test is more tricky @@ -718,13 +718,13 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) if( aRefPad->m_Size.y < aRefPad->m_Size.x ) // Build an horizontal equiv segment { - segm_width = aRefPad->m_Size.y; - m_segmLength = aRefPad->m_Size.x - aRefPad->m_Size.y; + segm_width = TO_LEGACY_LU( aRefPad->m_Size.y ); + m_segmLength = TO_LEGACY_LU( aRefPad->m_Size.x - aRefPad->m_Size.y ); } else // Vertical oval: build an horizontal equiv segment and rotate 90.0 deg { - segm_width = aRefPad->m_Size.x; - m_segmLength = aRefPad->m_Size.y - aRefPad->m_Size.x; + segm_width = TO_LEGACY_LU( aRefPad->m_Size.x ); + m_segmLength = TO_LEGACY_LU( aRefPad->m_Size.y - aRefPad->m_Size.x ); m_segmAngle += 900; } @@ -796,13 +796,13 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMi int segmHalfWidth = aSegmentWidth / 2; seuil = segmHalfWidth + aMinDist; - padHalfsize.x = aPad->m_Size.x >> 1; - padHalfsize.y = aPad->m_Size.y >> 1; + padHalfsize.x = TO_LEGACY_LU( aPad->m_Size.x / 2 ); + padHalfsize.y = TO_LEGACY_LU( aPad->m_Size.y / 2 ); if( aPad->m_PadShape == PAD_TRAPEZOID ) // The size is bigger, due to m_DeltaSize extra size { - padHalfsize.x += ABS(aPad->m_DeltaSize.y) / 2; // Remember: m_DeltaSize.y is the m_Size.x change - padHalfsize.y += ABS(aPad->m_DeltaSize.x) / 2; // Remember: m_DeltaSize.x is the m_Size.y change + padHalfsize.x += TO_LEGACY_LU( ABS(aPad->m_DeltaSize.y) / 2 ); // Remember: m_DeltaSize.y is the m_Size.x change + padHalfsize.y += TO_LEGACY_LU( ABS(aPad->m_DeltaSize.x) / 2 ); // Remember: m_DeltaSize.x is the m_Size.y change } if( aPad->m_PadShape == PAD_CIRCLE ) diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h index 086ce4be25..643979d0af 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_ViasMinSize -#define DRCE_NETCLASS_VIADRILLSIZE 33 ///< netclass has ViaDrillSize < board.m_designSettings->m_ViasMinDrill -#define DRCE_NETCLASS_uVIASIZE 34 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinSize -#define DRCE_NETCLASS_uVIADRILLSIZE 35 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinDrill +#define DRCE_NETCLASS_VIASIZE 32 ///< netclass has ViaSize < board.m_designSettings->m_MinVia.m_Diameter +#define DRCE_NETCLASS_VIADRILLSIZE 33 ///< netclass has ViaDrillSize < board.m_designSettings->m_MinVia.m_Drill +#define DRCE_NETCLASS_uVIASIZE 34 ///< netclass has ViaSize < board.m_designSettings->m_MinMicroVia.m_Diameter +#define DRCE_NETCLASS_uVIADRILLSIZE 35 ///< netclass has ViaSize < board.m_designSettings->m_MinMicroVia.m_Drill class EDA_DRAW_PANEL; diff --git a/pcbnew/export_gencad.cpp b/pcbnew/export_gencad.cpp index 07531ce9bf..204f8d1516 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 = pad->m_Size.x / 2; - int dy = pad->m_Size.y / 2; + int dx = TO_LEGACY_LU( pad->m_Size.x / 2 ); + int dy = TO_LEGACY_LU( pad->m_Size.y / 2 ); switch( pad->m_PadShape ) { default: case PAD_CIRCLE: - pad_type = "ROUND"; - fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); + pad_type = "ROUND"; // how about oval holes? + fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) ); fprintf( file, "CIRCLE %d %d %d\n", - pad->m_Offset.x, -pad->m_Offset.y, dx ); + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ), dx ); break; case PAD_RECT: pad_type = "RECTANGULAR"; - fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); + fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) ); fprintf( file, "RECTANGLE %d %d %d %d\n", - pad->m_Offset.x - dx, -pad->m_Offset.y - dy, - pad->m_Size.x, pad->m_Size.y ); + TO_LEGACY_LU( pad->m_Offset.x ) - dx, -TO_LEGACY_LU( pad->m_Offset.y ) - dy, + TO_LEGACY_LU( pad->m_Size.x ), TO_LEGACY_LU( pad->m_Size.y ) ); break; case PAD_OVAL: /* Create outline by 2 lines and 2 arcs */ { pad_type = "FINGER"; - fprintf( file, " %s %d\n", pad_type, pad->m_Drill.x ); + fprintf( file, " %s %d\n", pad_type, ( int )TO_LEGACY_LU( pad->m_Drill.x ) ); int dr = dx - dy; if( dr >= 0 ) // Horizontal oval { int radius = dy; fprintf( file, "LINE %d %d %d %d\n", - -dr + pad->m_Offset.x, -pad->m_Offset.y - radius, - dr + pad->m_Offset.x, -pad->m_Offset.y - radius ); + -dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius, + dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius ); fprintf( file, "ARC %d %d %d %d %d %d\n", - dr + pad->m_Offset.x, -pad->m_Offset.y - radius, - dr + pad->m_Offset.x, -pad->m_Offset.y + radius, - dr + pad->m_Offset.x, -pad->m_Offset.y ); + dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius, + dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius, + dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) ); fprintf( file, "LINE %d %d %d %d\n", - dr + pad->m_Offset.x, -pad->m_Offset.y + radius, - -dr + pad->m_Offset.x, -pad->m_Offset.y + radius ); + dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius, + -dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius ); fprintf( file, "ARC %d %d %d %d %d %d\n", - -dr + pad->m_Offset.x, -pad->m_Offset.y + radius, - -dr + pad->m_Offset.x, -pad->m_Offset.y - radius, - -dr + pad->m_Offset.x, -pad->m_Offset.y ); + -dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + radius, + -dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - radius, + -dr + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) ); } else // Vertical oval { dr = -dr; int radius = dx; fprintf( file, "LINE %d %d %d %d\n", - -radius + pad->m_Offset.x, -pad->m_Offset.y - dr, - -radius + pad->m_Offset.x, -pad->m_Offset.y + dr ); + -radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr, + -radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr ); fprintf( file, "ARC %d %d %d %d %d %d\n", - -radius + pad->m_Offset.x, -pad->m_Offset.y + dr, - radius + pad->m_Offset.x, -pad->m_Offset.y + dr, - pad->m_Offset.x, -pad->m_Offset.y + dr ); + -radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr, + radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr, + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr ); fprintf( file, "LINE %d %d %d %d\n", - radius + pad->m_Offset.x, -pad->m_Offset.y + dr, - radius + pad->m_Offset.x, -pad->m_Offset.y - dr ); + radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) + dr, + radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr ); fprintf( file, "ARC %d %d %d %d %d %d\n", - radius + pad->m_Offset.x, -pad->m_Offset.y - dr, - -radius + pad->m_Offset.x, -pad->m_Offset.y - dr, - pad->m_Offset.x, -pad->m_Offset.y - dr ); + radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr, + -radius + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr, + TO_LEGACY_LU( pad->m_Offset.x ), -TO_LEGACY_LU( pad->m_Offset.y ) - dr ); } break; } diff --git a/pcbnew/export_vrml.cpp b/pcbnew/export_vrml.cpp index c4d4ca86d1..8a8925af86 100644 --- a/pcbnew/export_vrml.cpp +++ b/pcbnew/export_vrml.cpp @@ -881,8 +881,8 @@ static void export_vrml_edge_module( EDGE_MODULE* module ) /*{{{*/ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/ { - double hole_drill_w = (double) pad->m_Drill.x / 2; - double hole_drill_h = (double) pad->m_Drill.y / 2; + double hole_drill_w = (double) TO_LEGACY_LU_DBL( pad->m_Drill.x / 2 ); + double hole_drill_h = (double) TO_LEGACY_LU_DBL( pad->m_Drill.y / 2 ); double hole_drill = MIN( hole_drill_w, hole_drill_h ); double hole_x = pad->m_Pos.x; double hole_y = pad->m_Pos.y; @@ -913,11 +913,11 @@ static void export_vrml_pad( BOARD* pcb, D_PAD* pad ) /*{{{*/ wxPoint pad_pos = pad->ReturnShapePos(); double pad_x = pad_pos.x; double pad_y = pad_pos.y; - wxSize pad_delta = pad->m_DeltaSize; + wxSize pad_delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize ); double pad_dx = pad_delta.x / 2; double pad_dy = pad_delta.y / 2; - double pad_w = pad->m_Size.x / 2; - double pad_h = pad->m_Size.y / 2; + double pad_w = TO_LEGACY_LU_DBL( pad->m_Size.x / 2 ); + double pad_h = TO_LEGACY_LU_DBL( pad->m_Size.y / 2 ); for( int layer = FIRST_COPPER_LAYER; layer < copper_layers; layer++ ) { diff --git a/pcbnew/gen_holes_and_tools_lists_for_drill.cpp b/pcbnew/gen_holes_and_tools_lists_for_drill.cpp index 8f486b3708..fb4e456ce2 100644 --- a/pcbnew/gen_holes_and_tools_lists_for_drill.cpp +++ b/pcbnew/gen_holes_and_tools_lists_for_drill.cpp @@ -127,20 +127,21 @@ void Build_Holes_List( BOARD* aPcb, if( aGenerateNPTH_list && pad->m_Attribut != PAD_HOLE_NOT_PLATED ) continue; - if( pad->m_Drill.x == 0 ) + if( pad->m_Drill.x == ZERO_LENGTH ) continue; new_hole.m_Hole_NotPlated = (pad->m_Attribut == PAD_HOLE_NOT_PLATED); new_hole.m_Tool_Reference = -1; // Flag is: Not initialized new_hole.m_Hole_Orient = pad->m_Orient; new_hole.m_Hole_Shape = 0; // hole shape: round - new_hole.m_Hole_Diameter = min( pad->m_Drill.x, pad->m_Drill.y ); + new_hole.m_Hole_Diameter = min( TO_LEGACY_LU( pad->m_Drill.x ), TO_LEGACY_LU( pad->m_Drill.y ) ); new_hole.m_Hole_Size.x = new_hole.m_Hole_Size.y = new_hole.m_Hole_Diameter; if( pad->m_DrillShape != PAD_CIRCLE ) new_hole.m_Hole_Shape = 1; // oval flag set - new_hole.m_Hole_Size = pad->m_Drill; + new_hole.m_Hole_Size.x = TO_LEGACY_LU( pad->m_Drill.x ); + new_hole.m_Hole_Size.y = TO_LEGACY_LU( pad->m_Drill.y ); new_hole.m_Hole_Pos = pad->m_Pos; // hole position new_hole.m_Hole_Bottom_Layer = LAYER_N_BACK; new_hole.m_Hole_Top_Layer = LAYER_N_FRONT;// pad holes are through holes diff --git a/pcbnew/gen_modules_placefile.cpp b/pcbnew/gen_modules_placefile.cpp index dd30b96db5..0bea991f74 100644 --- a/pcbnew/gen_modules_placefile.cpp +++ b/pcbnew/gen_modules_placefile.cpp @@ -443,14 +443,14 @@ void PCB_EDIT_FRAME::GenModuleReport( wxCommandEvent& event ) fputs( line, rptfile ); sprintf( line, "size %9.6f %9.6f\n", - pad->m_Size.x * conv_unit, - pad->m_Size.y * conv_unit ); + TO_LEGACY_LU_DBL( pad->m_Size.x ) * conv_unit, + TO_LEGACY_LU_DBL( pad->m_Size.y ) * conv_unit ); fputs( line, rptfile ); - sprintf( line, "drill %9.6f\n", pad->m_Drill.x * conv_unit ); + sprintf( line, "drill %9.6f\n", TO_LEGACY_LU_DBL( pad->m_Drill.x ) * conv_unit ); fputs( line, rptfile ); sprintf( line, "shape_offset %9.6f %9.6f\n", - pad->m_Offset.x * conv_unit, - pad->m_Offset.y * conv_unit ); + TO_LEGACY_LU_DBL( pad->m_Offset.x ) * conv_unit, + TO_LEGACY_LU_DBL( pad->m_Offset.y ) * conv_unit ); fputs( line, rptfile ); sprintf( line, "orientation %.2f\n", diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 51c77339dc..72baa60953 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -254,8 +254,8 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) if( pt_pad->m_PadShape != PAD_TRAPEZOID ) { - pt_pad->m_DeltaSize.x = 0; - pt_pad->m_DeltaSize.y = 0; + pt_pad->m_DeltaSize.x = ZERO_LENGTH; + pt_pad->m_DeltaSize.y = ZERO_LENGTH; } if( pt_pad->m_PadShape == PAD_CIRCLE ) pt_pad->m_Size.y = pt_pad->m_Size.x; @@ -264,9 +264,9 @@ void PCB_BASE_FRAME::Global_Import_Pad_Settings( D_PAD* aPad, bool aDraw ) { case PAD_SMD: case PAD_CONN: - pt_pad->m_Drill = wxSize( 0, 0 ); - pt_pad->m_Offset.x = 0; - pt_pad->m_Offset.y = 0; + pt_pad->m_Drill = VECTOR_PCB(ZERO_LENGTH, ZERO_LENGTH);//wxSize( 0, 0 ); + pt_pad->m_Offset.x = ZERO_LENGTH; + pt_pad->m_Offset.y = ZERO_LENGTH; break; default: diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index a510248ec4..75ce134ab7 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -371,8 +371,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) } Pad->m_Pos.x = (ibuf[0] + ibuf[2]) / 2; Pad->m_Pos.y = (ibuf[1] + ibuf[3]) / 2; - Pad->m_Size.x = ibuf[4] + abs( ibuf[0] - ibuf[2] ); - Pad->m_Size.y = ibuf[4] + abs( ibuf[1] - ibuf[3] ); + Pad->m_Size.x = FROM_LEGACY_LU( ibuf[4] + abs( ibuf[0] - ibuf[2] ) ); + Pad->m_Size.y = FROM_LEGACY_LU( ibuf[4] + abs( ibuf[1] - ibuf[3] ) ); Pad->m_Pos.x += m_Pos.x; Pad->m_Pos.y += m_Pos.y; @@ -430,8 +430,8 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) Pad->m_Pos.x = ibuf[0]; Pad->m_Pos.y = ibuf[1]; - Pad->m_Drill.x = Pad->m_Drill.y = ibuf[5]; - Pad->m_Size.x = Pad->m_Size.y = ibuf[3] + Pad->m_Drill.x; + Pad->m_Drill.x = Pad->m_Drill.y = FROM_LEGACY_LU( (int) ibuf[5] ); + Pad->m_Size.x = Pad->m_Size.y = FROM_LEGACY_LU( ibuf[3] ) + Pad->m_Drill.x; Pad->m_Pos.x += m_Pos.x; Pad->m_Pos.y += m_Pos.y; diff --git a/pcbnew/graphpcb.cpp b/pcbnew/graphpcb.cpp index 8550b6e3c9..169beeaa6a 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 = pt_pad->m_Size.x / 2; + dx = TO_LEGACY_LU( pt_pad->m_Size.x / 2 ); dx += marge; if( pt_pad->m_PadShape == PAD_CIRCLE ) @@ -100,13 +100,13 @@ void PlacePad( BOARD* Pcb, D_PAD* pt_pad, int color, int marge, int op_logic ) } - dy = pt_pad->m_Size.y / 2; + dy = TO_LEGACY_LU( pt_pad->m_Size.y / 2 ); dy += marge; if( pt_pad->m_PadShape == PAD_TRAPEZOID ) { - dx += abs( pt_pad->m_DeltaSize.y ) / 2; - dy += abs( pt_pad->m_DeltaSize.x ) / 2; + dx += TO_LEGACY_LU( ABS( pt_pad->m_DeltaSize.y ) / 2 ); + dy += TO_LEGACY_LU( ABS( pt_pad->m_DeltaSize.x ) / 2 ); } if( ( pt_pad->m_Orient % 900 ) == 0 ) /* The pad is a rectangle diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 91754be465..a981c39dec 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -443,7 +443,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "TrackClearence" ) == 0 ) { - netclass_default->SetClearance( atoi( data ) ); + netclass_default->Clearance( FROM_LEGACY_LU( atof( data ) ) ); continue; } @@ -480,7 +480,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "ViaMinSize" ) == 0 ) { double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_ViasMinSize = FROM_LEGACY_LU( diameter ); + GetBoard()->GetBoardDesignSettings()->m_MinVia.m_Diameter = FROM_LEGACY_LU( diameter ); continue; } @@ -492,7 +492,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "MicroViaMinSize" ) == 0 ) { double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_MicroViasMinSize = FROM_LEGACY_LU( diameter ); + GetBoard()->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter = FROM_LEGACY_LU( diameter ); continue; } @@ -515,29 +515,31 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "ViaDrill" ) == 0 ) { - int diameter = atoi( data ); - netclass_default->SetViaDrill( diameter ); + VIA_DIMENSION via = netclass_default->Via(); + via.m_Drill = FROM_LEGACY_LU( atof( data ) ); + netclass_default->Via( via ); continue; } if( stricmp( line, "ViaMinDrill" ) == 0 ) { double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_ViasMinDrill = FROM_LEGACY_LU( diameter ); + GetBoard()->GetBoardDesignSettings()->m_MinVia.m_Drill = FROM_LEGACY_LU( diameter ); continue; } if( stricmp( line, "MicroViaDrill" ) == 0 ) { - int diameter = atoi( data ); - netclass_default->SetuViaDrill( diameter ); + VIA_DIMENSION via = netclass_default->MicroVia(); + via.m_Drill = FROM_LEGACY_LU( atof( data ) ); + netclass_default->MicroVia( via ); continue; } if( stricmp( line, "MicroViaMinDrill" ) == 0 ) { double diameter = atof( data ); - GetBoard()->GetBoardDesignSettings()->m_MicroViasMinDrill = FROM_LEGACY_LU( diameter ); + GetBoard()->GetBoardDesignSettings()->m_MinMicroVia.m_Drill = FROM_LEGACY_LU( diameter ); continue; } @@ -583,15 +585,15 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) if( stricmp( line, "PadSize" ) == 0 ) { - g_Pad_Master.m_Size.x = atoi( data ); + g_Pad_Master.m_Size.x = FROM_LEGACY_LU( atof( data ) ); data = strtok( NULL, delims ); - g_Pad_Master.m_Size.y = atoi( data ); + g_Pad_Master.m_Size.y = FROM_LEGACY_LU( atof( data ) ); continue; } if( stricmp( line, "PadDrill" ) == 0 ) { - g_Pad_Master.m_Drill.x = atoi( data ); + g_Pad_Master.m_Drill.x = FROM_LEGACY_LU( atof( data ) ); g_Pad_Master.m_Drill.y = g_Pad_Master.m_Drill.x; continue; } @@ -696,7 +698,9 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) fprintf( aFile, "TrackWidthList %f\n", TO_LEGACY_LU_DBL( aBoard->m_TrackWidthList[ii] ) ); - fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() ); + fprintf( aFile, + "TrackClearence %f\n", + TO_LEGACY_LU_DBL( netclass_default->Clearance() ) ); fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); fprintf( aFile, "TrackMinWidth %f\n", @@ -706,14 +710,18 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) fprintf( aFile, "EdgeSegmWidth %d\n", aBoard->GetBoardDesignSettings()->m_EdgeSegmentWidth ); // Save current default via size, for compatibility with older Pcbnew version; - fprintf( aFile, "ViaSize %d\n", netclass_default->GetViaDiameter() ); - fprintf( aFile, "ViaDrill %d\n", netclass_default->GetViaDrill() ); + fprintf( aFile, + "ViaSize %f\n", + TO_LEGACY_LU_DBL( netclass_default->Via().m_Diameter ) ); + fprintf( aFile, + "ViaDrill %f\n", + TO_LEGACY_LU_DBL( netclass_default->Via().m_Drill ) ); fprintf( aFile, "ViaMinSize %f\n", - TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_ViasMinSize ) ); + TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MinVia.m_Diameter ) ); fprintf( aFile, "ViaMinDrill %f\n", - TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_ViasMinDrill ) ); + TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MinVia.m_Drill ) ); // Save custom vias diameters list (the first is not saved here: this is // the netclass value @@ -723,17 +731,21 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) TO_LEGACY_LU_DBL( aBoard->m_ViasDimensionsList[ii].m_Drill ) ); // for old versions compatibility: - fprintf( aFile, "MicroViaSize %d\n", netclass_default->GetuViaDiameter() ); - fprintf( aFile, "MicroViaDrill %d\n", netclass_default->GetuViaDrill() ); + fprintf( aFile, + "MicroViaSize %f\n", + TO_LEGACY_LU_DBL( netclass_default->MicroVia().m_Diameter ) ); + fprintf( aFile, + "MicroViaDrill %f\n", + TO_LEGACY_LU_DBL( netclass_default->MicroVia().m_Drill ) ); fprintf( aFile, "MicroViasAllowed %d\n", aBoard->GetBoardDesignSettings()->m_MicroViasAllowed ); fprintf( aFile, "MicroViaMinSize %f\n", - TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MicroViasMinSize ) ); + TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MinMicroVia.m_Diameter ) ); fprintf( aFile, "MicroViaMinDrill %f\n", - TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MicroViasMinDrill ) ); + TO_LEGACY_LU_DBL( aBoard->GetBoardDesignSettings()->m_MinMicroVia.m_Drill ) ); fprintf( aFile, "TextPcbWidth %d\n", aBoard->GetBoardDesignSettings()->m_PcbTextWidth ); fprintf( aFile, @@ -744,8 +756,8 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) fprintf( aFile, "EdgeModWidth %d\n", g_ModuleSegmentWidth ); fprintf( aFile, "TextModSize %d %d\n", g_ModuleTextSize.x, g_ModuleTextSize.y ); fprintf( aFile, "TextModWidth %d\n", g_ModuleTextWidth ); - fprintf( aFile, "PadSize %d %d\n", g_Pad_Master.m_Size.x, g_Pad_Master.m_Size.y ); - fprintf( aFile, "PadDrill %d\n", g_Pad_Master.m_Drill.x ); + fprintf( aFile, "PadSize %d %d\n", TO_LEGACY_LU( g_Pad_Master.m_Size.x ), TO_LEGACY_LU( g_Pad_Master.m_Size.y ) ); + fprintf( aFile, "PadDrill %d\n", ( int )TO_LEGACY_LU( g_Pad_Master.m_Drill.x ) ); fprintf( aFile, "Pad2MaskClearance %d\n", aBoard->GetBoardDesignSettings()->m_SolderMaskMargin ); diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index d5176ca4bb..b7e4f128bf 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,9 +710,16 @@ void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) { pad->m_Pos0 = pad->m_Pos; pad->m_Orient -= angle; - RotatePoint( &pad->m_Offset.x, &pad->m_Offset.y, angle ); + wxPoint of; + of.x = TO_LEGACY_LU( pad->m_Offset.x ); + of.y = TO_LEGACY_LU( pad->m_Offset.y ); + RotatePoint( &of.x, &of.y, angle ); + pad->m_Offset.x = FROM_LEGACY_LU( of.x ); + pad->m_Offset.y = FROM_LEGACY_LU( of.y ); EXCHG( pad->m_Size.x, pad->m_Size.y ); - RotatePoint( &pad->m_DeltaSize.x, &pad->m_DeltaSize.y, -angle ); + wxSize delta = TO_LEGACY_LU_WXS( pad->m_DeltaSize ); + RotatePoint( &delta.x, &delta.y, -angle ); + pad->m_DeltaSize = VECTOR_PCB( FROM_LEGACY_LU( delta.x ), FROM_LEGACY_LU( delta.y ) ); } module->m_Reference->m_Pos0 = module->m_Reference->m_Pos; diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index a00d3c0c76..698050ae53 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -148,7 +148,7 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) aPad->m_Orient = g_Pad_Master.m_Orient + ( (MODULE*) aPad->GetParent() )->m_Orient; aPad->m_Size = g_Pad_Master.m_Size; - aPad->m_DeltaSize = wxSize( 0, 0 ); + aPad->m_DeltaSize = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH );//wxSize( 0, 0 ); aPad->m_Offset = g_Pad_Master.m_Offset; aPad->m_Drill = g_Pad_Master.m_Drill; aPad->m_DrillShape = g_Pad_Master.m_DrillShape; @@ -168,9 +168,8 @@ void PCB_BASE_FRAME::Import_Pad_Settings( D_PAD* aPad, bool aDraw ) { case PAD_SMD: case PAD_CONN: - aPad->m_Drill = wxSize( 0, 0 ); - aPad->m_Offset.x = 0; - aPad->m_Offset.y = 0; + aPad->m_Drill = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); //wxSize( 0, 0 ); + aPad->m_Offset = VECTOR_PCB( ZERO_LENGTH, ZERO_LENGTH ); } aPad->ComputeShapeMaxRadius(); diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index 6ed53ce937..9391d6cd85 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -262,7 +262,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) PtPad->SetPadName( wxT( "1" ) ); PtPad->m_Pos = Mself.m_End; PtPad->m_Pos0 = PtPad->m_Pos - Module->m_Pos; - PtPad->m_Size.x = PtPad->m_Size.y = Mself.m_Width; + PtPad->m_Size.x = PtPad->m_Size.y = FROM_LEGACY_LU( Mself.m_Width ); PtPad->m_layerMask = g_TabOneLayerMask[Module->GetLayer()]; PtPad->m_Attribut = PAD_SMD; PtPad->m_PadShape = PAD_CIRCLE; @@ -552,7 +552,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveBasicShape( const wxString& name, int pad_c Module->m_Pads.PushFront( pad ); - pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); + pad->m_Size.x = pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ); pad->m_Pos = Module->m_Pos; pad->m_PadShape = PAD_RECT; pad->m_Attribut = PAD_SMD; @@ -656,18 +656,18 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) switch( shape_type ) { case 0: //Gap : - oX = pad->m_Pos0.x = -( gap_size + pad->m_Size.x ) / 2; + oX = pad->m_Pos0.x = -( gap_size + TO_LEGACY_LU( pad->m_Size.x ) ) / 2; pad->m_Pos.x += pad->m_Pos0.x; pad = pad->Next(); - pad->m_Pos0.x = oX + gap_size + pad->m_Size.x; + pad->m_Pos0.x = oX + gap_size + TO_LEGACY_LU( 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 = -( gap_size + pad->m_Size.y ) / 2; - pad->m_Size.y = gap_size; + pad->m_Pos0.y = -( 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_Pos0.y; break; @@ -683,7 +683,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) std::vector polyPoints = edge->GetPolyPoints(); polyPoints.reserve( numPoints ); - edge->m_Start0.y = -pad->m_Size.y / 2; + edge->m_Start0.y = TO_LEGACY_LU( -pad->m_Size.y / 2 ); polyPoints.push_back( wxPoint( 0, 0 ) ); @@ -1008,8 +1008,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() pad2->m_Pos0.x = last_coordinate.x; polyPoints.push_back( wxPoint( last_coordinate.x, 0 ) ); - pad1->m_Size.x = pad1->m_Size.y = ABS( first_coordinate.y ); - pad2->m_Size.x = pad2->m_Size.y = ABS( last_coordinate.y ); + pad1->m_Size.x = pad1->m_Size.y = FROM_LEGACY_LU( ABS( first_coordinate.y ) ); + pad2->m_Size.x = pad2->m_Size.y = FROM_LEGACY_LU( ABS( last_coordinate.y ) ); pad1->m_Pos0.y = first_coordinate.y / 2; pad2->m_Pos0.y = last_coordinate.y / 2; pad1->m_Pos.y = pad1->m_Pos0.y + Module->m_Pos.y; @@ -1026,8 +1026,8 @@ MODULE* PCB_EDIT_FRAME::Create_MuWavePolygonShape() polyPoints.push_back( pt ); } - pad1->m_Size.x = pad1->m_Size.y = 2 * ABS( first_coordinate.y ); - pad2->m_Size.x = pad2->m_Size.y = 2 * ABS( last_coordinate.y ); + pad1->m_Size.x = pad1->m_Size.y = FROM_LEGACY_LU( 2 * ABS( first_coordinate.y ) ); + pad2->m_Size.x = pad2->m_Size.y = FROM_LEGACY_LU( 2 * ABS( last_coordinate.y ) ); break; } @@ -1073,7 +1073,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) Module->Draw( DrawPanel, DC, GR_XOR ); /* Calculate the current dimension. */ - gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x; + gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - TO_LEGACY_LU( pad->m_Size.x ); /* Entrer the desired length of the gap. */ msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() ); @@ -1086,17 +1086,17 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* Module ) gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() ); /* Updating sizes of pads forming the gap. */ - pad->m_Size.x = pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); + pad->m_Size.x = pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ); pad->m_Pos0.y = 0; - oX = pad->m_Pos0.x = -( (gap_size + pad->m_Size.x) / 2 ); + oX = pad->m_Pos0.x = -( ( gap_size + TO_LEGACY_LU( 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 ); - next_pad->m_Size.x = next_pad->m_Size.y = GetBoard()->GetCurrentTrackWidth(); + next_pad->m_Size.x = next_pad->m_Size.y = FROM_LEGACY_LU( GetBoard()->GetCurrentTrackWidth() ); next_pad->m_Pos0.y = 0; - next_pad->m_Pos0.x = oX + gap_size + next_pad->m_Size.x; + next_pad->m_Pos0.x = oX + gap_size + TO_LEGACY_LU( 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, diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 6b114cbbca..388cc84bcc 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -217,12 +217,16 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), &g_LibraryNames, GROUPLIB ) ); +#ifdef KICAD_NANOMETRE +/* TODO: something should be done here!!! */ +#else m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDrlX" ), &g_Pad_Master.m_Drill.x, 320, 0, 0x7FFF ) ); m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimH" ), &g_Pad_Master.m_Size.x, 550, 0, 0x7FFF ) ); m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDimV" ), &g_Pad_Master.m_Size.y, 550, 0, 0x7FFF ) ); +#endif m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "BoardThickness" ), &boardDesignSettings.m_BoardThickness, 630, 0, 0xFFFF ) ); diff --git a/pcbnew/plot_rtn.cpp b/pcbnew/plot_rtn.cpp index 50a43bfc89..d3a3ed10c0 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, pad->m_Size.x, FILAIRE ); + plotter->flash_pad_circle( shape_pos, TO_LEGACY_LU( pad->m_Size.x ), FILAIRE ); break; case PAD_OVAL: - plotter->flash_pad_oval( shape_pos, pad->m_Size, pad->m_Orient, FILAIRE ); + plotter->flash_pad_oval( shape_pos, TO_LEGACY_LU_WXS( pad->m_Size ), pad->m_Orient, FILAIRE ); break; case PAD_TRAPEZOID: @@ -114,7 +114,7 @@ void PCB_BASE_FRAME::PlotSilkScreen( PLOTTER* plotter, int aLayerMask, GRTraceMo case PAD_RECT: default: - plotter->flash_pad_rect( shape_pos, pad->m_Size, pad->m_Orient, FILAIRE ); + plotter->flash_pad_rect( shape_pos, TO_LEGACY_LU_WXS( pad->m_Size ), pad->m_Orient, FILAIRE ); break; } } @@ -840,8 +840,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, break; } - size.x = pad->m_Size.x + ( 2 * margin.x ); - size.y = pad->m_Size.y + ( 2 * margin.y ); + size.x = TO_LEGACY_LU( pad->m_Size.x ) + ( 2 * margin.x ); + size.y = TO_LEGACY_LU( pad->m_Size.y ) + ( 2 * margin.y ); /* Don't draw a null size item : */ if( size.x <= 0 || size.y <= 0 ) @@ -851,7 +851,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, { case PAD_CIRCLE: if( aSkipNPTH_Pads && - (pad->m_Size == pad->m_Drill) && + ( pad->m_Size.x == pad->m_Drill.x ) && + ( pad->m_Size.y == pad->m_Drill.y ) && (pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) break; @@ -860,7 +861,8 @@ void PCB_BASE_FRAME::Plot_Standard_Layer( PLOTTER* aPlotter, case PAD_OVAL: if( aSkipNPTH_Pads && - (pad->m_Size == pad->m_Drill) && + (pad->m_Size.x == pad->m_Drill.x ) && + (pad->m_Size.y == pad->m_Drill.y ) && (pad->m_Attribut == PAD_HOLE_NOT_PLATED) ) break; @@ -1016,7 +1018,7 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter, { for( PtPad = Module->m_Pads; PtPad != NULL; PtPad = PtPad->Next() ) { - if( PtPad->m_Drill.x == 0 ) + if( PtPad->m_Drill.x == ZERO_LENGTH ) continue; // Output hole shapes: @@ -1024,12 +1026,13 @@ void PCB_BASE_FRAME::PlotDrillMark( PLOTTER* aPlotter, if( PtPad->m_DrillShape == PAD_OVAL ) { - diam = PtPad->m_Drill; + diam.x = TO_LEGACY_LU( PtPad->m_Drill.x ); + diam.y = TO_LEGACY_LU( PtPad->m_Drill.y ); aPlotter->flash_pad_oval( pos, diam, PtPad->m_Orient, aTraceMode ); } else { - diam.x = aSmallDrillShape ? SMALL_DRILL : PtPad->m_Drill.x; + diam.x = aSmallDrillShape ? SMALL_DRILL : TO_LEGACY_LU( PtPad->m_Drill.x ); aPlotter->flash_pad_circle( pos, diam.x, aTraceMode ); } } diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 5887f5bd76..47b31915e6 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -351,16 +351,18 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, continue; // Manage hole according to the print drill option - wxSize drill_tmp = pt_pad->m_Drill; + wxSize drill_tmp; + drill_tmp.x = TO_LEGACY_LU( pt_pad->m_Drill.x ); + drill_tmp.y = TO_LEGACY_LU( pt_pad->m_Drill.y ); switch ( aDrillShapeOpt ) { case PRINT_PARAMETERS::NO_DRILL_SHAPE: - pt_pad->m_Drill = wxSize(0,0); + pt_pad->m_Drill = VECTOR_PCB(ZERO_LENGTH, ZERO_LENGTH); //wxSize(0,0); break; case PRINT_PARAMETERS::SMALL_DRILL_SHAPE: - pt_pad->m_Drill.x = MIN(SMALL_DRILL,pt_pad->m_Drill.x); - pt_pad->m_Drill.y = MIN(SMALL_DRILL,pt_pad->m_Drill.y); + pt_pad->m_Drill.x = MIN(FROM_LEGACY_LU( SMALL_DRILL ),pt_pad->m_Drill.x ); + pt_pad->m_Drill.y = MIN(FROM_LEGACY_LU( SMALL_DRILL ),pt_pad->m_Drill.y ); break; case PRINT_PARAMETERS::FULL_DRILL_SHAPE: // Do nothing @@ -368,7 +370,8 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule, } pt_pad->Draw( aPanel, aDC, aDraw_mode ); - pt_pad->m_Drill = drill_tmp; + pt_pad->m_Drill.x = FROM_LEGACY_LU( drill_tmp.x ); + pt_pad->m_Drill.y = FROM_LEGACY_LU( drill_tmp.y ); } /* Print footprint graphic shapes */ diff --git a/pcbnew/solve.cpp b/pcbnew/solve.cpp index ca8429f7df..7c96855321 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 = pt_cur_ch->m_PadStart->m_Size.x / 2; - int dy = pt_cur_ch->m_PadStart->m_Size.y / 2; + int dx = TO_LEGACY_LU( pt_cur_ch->m_PadStart->m_Size.x / 2 ); + int dy = TO_LEGACY_LU( pt_cur_ch->m_PadStart->m_Size.y / 2 ); int px = pt_cur_ch->m_PadStart->GetPosition().x; int py = pt_cur_ch->m_PadStart->GetPosition().y; @@ -479,8 +479,8 @@ static int Autoroute_One_Track( PCB_EDIT_FRAME* pcbframe, + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.x; cY = ( Board.m_GridRouting * row_target ) + pcbframe->GetBoard()->m_BoundaryBox.m_Pos.y; - dx = pt_cur_ch->m_PadEnd->m_Size.x / 2; - dy = pt_cur_ch->m_PadEnd->m_Size.y / 2; + dx = TO_LEGACY_LU( pt_cur_ch->m_PadEnd->m_Size.x / 2 ); + dy = TO_LEGACY_LU( pt_cur_ch->m_PadEnd->m_Size.y / 2 ); px = pt_cur_ch->m_PadEnd->GetPosition().x; py = pt_cur_ch->m_PadEnd->GetPosition().y; diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index a7749cc53b..c0e6e336f3 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -321,11 +321,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) POINT dsnOffset; - if( aPad->m_Offset.x || aPad->m_Offset.y ) + if( aPad->m_Offset.x != ZERO_LENGTH || aPad->m_Offset.y != ZERO_LENGTH ) { - char offsetTxt[64]; + char offsetTxt[64]; /// @BUG !!!Unsafe - wxPoint offset( aPad->m_Offset.x, aPad->m_Offset.y ); + wxPoint offset( TO_LEGACY_LU( aPad->m_Offset.x ), TO_LEGACY_LU( aPad->m_Offset.y ) ); dsnOffset = mapPt( offset ); @@ -341,7 +341,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) default: case PAD_CIRCLE: { - double diameter = scale(aPad->m_Size.x); + double diameter = scale( TO_LEGACY_LU( aPad->m_Size.x ) ); for( int ndx=0; ndxm_Size.x) ); + uniqifier.c_str(), scale(TO_LEGACY_LU( aPad->m_Size.x ) ) ); name[ sizeof(name)-1 ] = 0; padstack->SetPadstackId( name ); @@ -366,8 +366,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) case PAD_RECT: { - double dx = scale( aPad->m_Size.x ) / 2.0; - double dy = scale( aPad->m_Size.y ) / 2.0; + double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 2.0; + double dy = scale( TO_LEGACY_LU( aPad->m_Size.y ) ) / 2.0; POINT lowerLeft( -dx, -dy ); POINT upperRight( dx, dy ); @@ -388,7 +388,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) } snprintf( name, sizeof(name), "Rect%sPad_%.6gx%.6g_mil", - uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y) ); + uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( aPad->m_Size.y ) ) ); name[ sizeof(name)-1 ] = 0; padstack->SetPadstackId( name ); @@ -397,8 +397,8 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) case PAD_OVAL: { - double dx = scale( aPad->m_Size.x ) / 2.0; - double dy = scale( aPad->m_Size.y ) / 2.0; + double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 2.0; + double dy = scale( TO_LEGACY_LU( aPad->m_Size.y ) ) / 2.0; double dr = dx - dy; double radius; POINT start; @@ -436,7 +436,7 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) } snprintf( name, sizeof(name), "Oval%sPad_%.6gx%.6g_mil", - uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y) ); + uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( aPad->m_Size.y ) ) ); name[ sizeof(name)-1 ] = 0; padstack->SetPadstackId( name ); @@ -445,11 +445,11 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) case PAD_TRAPEZOID: { - double dx = scale( aPad->m_Size.x ) / 2.0; - double dy = scale( aPad->m_Size.y ) / 2.0; + double dx = scale( TO_LEGACY_LU( aPad->m_Size.x ) ) / 2.0; + double dy = scale( TO_LEGACY_LU( aPad->m_Size.y ) ) / 2.0; - double ddx = scale( aPad->m_DeltaSize.x ) / 2.0; - double ddy = scale( aPad->m_DeltaSize.y ) / 2.0; + double ddx = scale( TO_LEGACY_LU( aPad->m_DeltaSize.x ) ) / 2.0; + double ddy = scale( TO_LEGACY_LU( aPad->m_DeltaSize.y ) ) / 2.0; // see class_pad_draw_functions.cpp which draws the trapezoid pad POINT lowerLeft( -dx - ddy, -dy - ddx ); @@ -479,15 +479,15 @@ PADSTACK* SPECCTRA_DB::makePADSTACK( BOARD* aBoard, D_PAD* aPad ) polygon->AppendPoint( lowerRight ); } - D(printf( "m_DeltaSize: %d,%d\n", aPad->m_DeltaSize.x, aPad->m_DeltaSize.y );) + D(printf( "m_DeltaSize: %d,%d\n", TO_LEGACY_LU( aPad->m_DeltaSize.x ), TO_LEGACY_LU( aPad->m_DeltaSize.y ) );) // this string _must_ be unique for a given physical shape snprintf( name, sizeof(name), "Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_mil", - uniqifier.c_str(), scale(aPad->m_Size.x), scale(aPad->m_Size.y), - aPad->m_DeltaSize.x < 0 ? 'n' : 'p', - abs( scale( aPad->m_DeltaSize.x )), - aPad->m_DeltaSize.y < 0 ? 'n' : 'p', - abs( scale( aPad->m_DeltaSize.y )) + uniqifier.c_str(), scale( TO_LEGACY_LU( aPad->m_Size.x ) ), scale( TO_LEGACY_LU( aPad->m_Size.y ) ), + aPad->m_DeltaSize.x < ZERO_LENGTH ? 'n' : 'p', + abs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.x ) )), + aPad->m_DeltaSize.y < ZERO_LENGTH ? 'n' : 'p', + abs( scale( TO_LEGACY_LU( aPad->m_DeltaSize.y ) )) ); name[ sizeof(name)-1 ] = 0; @@ -527,7 +527,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule ) // see if this pad is a through hole with no copper on its perimeter if( isRoundKeepout( pad ) ) { - double diameter = scale( pad->m_Drill.x ); + double diameter = scale( TO_LEGACY_LU( pad->m_Drill.x ) ); POINT vertex = mapPt( pad->m_Pos0 ); int layerCount = aBoard->GetCopperLayerCount(); 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 459d67885b..e05d95a8e2 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 == 0) && (pad->m_Drill.y == 0) ) + if( (pad->m_Drill.x == ZERO_LENGTH) && (pad->m_Drill.y == ZERO_LENGTH) ) continue; // Use a dummy pad to calculate a hole shape that have the same dimension as diff --git a/pcbnew/zones_convert_to_polygons_aux_functions.cpp b/pcbnew/zones_convert_to_polygons_aux_functions.cpp index e23707786f..a63945c26d 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 = ( pad->m_Size.x / 2 ) + aZone->m_ThermalReliefGapValue; - endpoint.y = ( pad->m_Size.y / 2 ) + aZone->m_ThermalReliefGapValue; + endpoint.x = ( TO_LEGACY_LU( pad->m_Size.x / 2 ) ) + aZone->m_ThermalReliefGapValue; + endpoint.y = ( TO_LEGACY_LU( pad->m_Size.y / 2 ) ) + aZone->m_ThermalReliefGapValue; int copperThickness = aZone->m_ThermalReliefCopperBridgeValue - aZone->m_ZoneMinThickness; if( copperThickness < 0 ) copperThickness = 0; - startpoint.x = min( pad->m_Size.x, copperThickness ); - startpoint.y = min( pad->m_Size.y, copperThickness ); + startpoint.x = min( TO_LEGACY_LU( pad->m_Size.x ), copperThickness ); + startpoint.y = min( TO_LEGACY_LU( pad->m_Size.y ), copperThickness ); startpoint.x /= 2; startpoint.y /= 2;