diff --git a/common/drawpanel.cpp b/common/drawpanel.cpp index ead41b6a77..8f61bbca7f 100644 --- a/common/drawpanel.cpp +++ b/common/drawpanel.cpp @@ -866,7 +866,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC ) wxMemoryDC tmpDC; wxBitmap tmpBM( 1, screenSize.y ); tmpDC.SelectObject( tmpBM ); - GRSetColorPen( &tmpDC, WHITE/*g_DrawBgColor*/ ); + GRSetColorPen( &tmpDC, g_DrawBgColor ); tmpDC.DrawLine( 0, 0, 0, screenSize.y-1 ); // init background GRSetColorPen( &tmpDC, m_Parent->GetGridColor() ); for( jj = 0; ; jj++ ) // draw grid points diff --git a/kicad/minizip/CMakeLists.txt b/kicad/minizip/CMakeLists.txt index a8516c90f0..398836d159 100644 --- a/kicad/minizip/CMakeLists.txt +++ b/kicad/minizip/CMakeLists.txt @@ -8,8 +8,10 @@ else(ZLIB_FOUND) # include files are in ${wxWidgets_ROOT_DIR}/src/zlib # and the corresponding library is libwxzlib-.a (like libwxzlib-2.8.a) # and we try to use it - find_path(ZLIB_INCLUDE_DIR zlib.h PATHS ${wxWidgets_ROOT_DIR}/src/zlib/ DOC "location of zlib include files") - set(ZLIB_LIBRARIES ${wxWidgets_ROOT_DIR}/lib/libwxzlib-2.8.a) + # Unfortunately, we have no way to know exactlty the path of zlib.h becuase this file + # is in wxWidgets sources, not in wxWidgets include path. + find_path(ZLIB_INCLUDE_DIR PATHS ${wxWidgets_ROOT_DIR}/../src/zlib/ ${wxWidgets_ROOT_DIR}/src/zlib/ DOC "location of zlib include files") + find_file(ZLIB_LIBRARIES NAMES ${wxWidgets_LIB_DIR}/libwxzlib-2.8.a ZLIB_LIBRARIES NAMES ${wxWidgets_LIB_DIR}/libwxzlib-2.9.a libwxzlib.a PATHS ${wxWidgets_ROOT_DIR}/lib/ PATH_SUFFIXES gcc_dll DOC "location of wxzlib library file") endif(ZLIB_FOUND) include_directories(${CMAKE_CURRENT_SOURCE_DIR} diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 54f3bc5d57..872796f24d 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -869,10 +869,13 @@ void BOARD::DisplayInfo( WinEDA_DrawFrame* frame ) frame->ClearMsgPanel(); int viasCount = 0; + int trackSegmentsCount = 0; for( BOARD_ITEM* item = m_Track; item; item = item->Next() ) { if( item->Type() == TYPE_VIA ) viasCount++; + else + trackSegmentsCount++; } txt.Printf( wxT( "%d" ), GetPadsCount() ); @@ -881,6 +884,9 @@ void BOARD::DisplayInfo( WinEDA_DrawFrame* frame ) txt.Printf( wxT( "%d" ), viasCount ); frame->AppendMsgPanel( _( "Vias" ), txt, DARKGREEN ); + txt.Printf( wxT( "%d" ), trackSegmentsCount ); + frame->AppendMsgPanel( _( "trackSegm" ), txt, DARKGREEN ); + txt.Printf( wxT( "%d" ), GetNodesCount() ); frame->AppendMsgPanel( _( "Nodes" ), txt, DARKCYAN ); diff --git a/pcbnew/class_drc_item.cpp b/pcbnew/class_drc_item.cpp index 22ecade9aa..d6ce7921fc 100644 --- a/pcbnew/class_drc_item.cpp +++ b/pcbnew/class_drc_item.cpp @@ -30,6 +30,7 @@ #include "common.h" #include "pcbnew.h" +#include "drc_stuff.h" wxString DRC_ITEM::GetErrorText() const { diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index 09346cf49e..81cf24f304 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -6,8 +6,7 @@ #define CLASS_MARKER_PCB_H #include "base_struct.h" - -#include "drc_stuff.h" +#include "class_marker_base.h" class MARKER_PCB : public BOARD_ITEM, public MARKER_BASE { diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index a7d524e309..929e436449 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -42,7 +42,6 @@ #include "protos.h" #include "drc_stuff.h" - #include "dialog_drc.h" @@ -108,12 +107,7 @@ DRC::DRC( WinEDA_PcbFrame* aPcbWindow ) // m_rptFilename set to empty by its constructor - m_currentMarker = 0; - - m_spotcx = 0; - m_spotcy = 0; - m_finx = 0; - m_finy = 0; + m_currentMarker = NULL; m_segmAngle = 0; m_segmLength = 0; @@ -539,6 +533,8 @@ void DRC::testZones( bool adoTestFillSegments ) if( !adoTestFillSegments ) return; + // m_pcb->m_Zone is fully obsolete. Keep this test for compatibility + // with old designs. Will be removed on day for( zoneSeg = m_pcb->m_Zone; zoneSeg && zoneSeg->Next(); zoneSeg = zoneSeg->Next() ) { // Test zoneSeg with other zone segments and with all pads @@ -705,13 +701,13 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) NETCLASS* netclass = aRefSeg->GetNetClass(); - // Origine sur le PCB des axes du repere centre sur - // l'origine du segment de reference - int org_X = aRefSeg->m_Start.x; - int org_Y = aRefSeg->m_Start.y; + /* In order to make some calculations more easier or faster, + * pads and tracks coordinates will be made relative to the reference segment origin + */ + wxPoint origin = aRefSeg->m_Start; // origin will be the origin of other coordinates - m_finx = dx = aRefSeg->m_End.x - org_X; - m_finy = dy = aRefSeg->m_End.y - org_Y; + m_segmEnd.x = dx = aRefSeg->m_End.x - origin.x; + m_segmEnd.y = dy = aRefSeg->m_End.y - origin.y; layerMask = aRefSeg->ReturnMaskLayer(); net_code_ref = aRefSeg->GetNet(); @@ -834,8 +830,8 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) pseudo_pad.m_Orient = pad->m_Orient; pseudo_pad.ComputeRayon(); // compute the radius - m_spotcx = pseudo_pad.GetPosition().x - org_X; - m_spotcy = pseudo_pad.GetPosition().y - org_Y; + m_padToTestPos.x = pseudo_pad.GetPosition().x - origin.x; + m_padToTestPos.y = pseudo_pad.GetPosition().y - origin.y; if( !checkClearanceSegmToPad( &pseudo_pad, refsegm_half_width, netclass->GetClearance() ) ) @@ -856,8 +852,8 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) // DRC for the pad shape_pos = pad->ReturnShapePos(); - m_spotcx = shape_pos.x - org_X; - m_spotcy = shape_pos.y - org_Y; + m_padToTestPos.x = shape_pos.x - origin.x; + m_padToTestPos.y = shape_pos.y - origin.y; if( !checkClearanceSegmToPad( pad, refsegm_half_width, aRefSeg->GetClearance( pad ) ) ) { @@ -899,21 +895,17 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) // If the reference segment is a via, we test it here if( aRefSeg->Type() == TYPE_VIA ) { - int orgx, orgy; // origine du repere d'axe X = segment a comparer int angle = 0; // angle du segment a tester; - orgx = track->m_Start.x; - orgy = track->m_Start.y; + dx = track->m_End.x - track->m_Start.x; + dy = track->m_End.y - track->m_Start.y; - dx = track->m_End.x - orgx; - dy = track->m_End.y - orgy; - - x0 = aRefSeg->m_Start.x - orgx; - y0 = aRefSeg->m_Start.y - orgy; + x0 = aRefSeg->m_Start.x - track->m_Start.x; + y0 = aRefSeg->m_Start.y - track->m_Start.y; if( track->Type() == TYPE_VIA ) { - // Test distance between two vias + // Test distance between two vias, i.e. two circles, trivial case if( (int) hypot( x0, y0 ) < w_dist ) { m_currentMarker = fillMarker( aRefSeg, track, @@ -944,11 +936,11 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) * the segment to test in the new axis : the new X axis is the * reference segment. We must translate and rotate the segment to test */ - x0 = track->m_Start.x - org_X; - y0 = track->m_Start.y - org_Y; + x0 = track->m_Start.x - origin.x; + y0 = track->m_Start.y - origin.y; - xf = track->m_End.x - org_X; - yf = track->m_End.y - org_Y; + xf = track->m_End.x - origin.x; + yf = track->m_End.y - origin.y; RotatePoint( &x0, &y0, m_segmAngle ); RotatePoint( &xf, &yf, m_segmAngle ); @@ -1262,8 +1254,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) goto exit; /* Here, pads are near and DRC depend on the pad shapes - * We must compare distance using a fine shape analysis */ - + * We must compare distance using a fine shape analysis + * Because a circle or oval shape is the easier shape to test, try to have + * aRefPad shape type = PAD_CIRCLE or PAD_OVAL. Swap aRefPad and aPad if needed + */ bool swap_pads; swap_pads = false; if( (aRefPad->m_PadShape != PAD_CIRCLE) && (aPad->m_PadShape == PAD_CIRCLE) ) @@ -1280,7 +1274,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) /* Because pad exchange, aRefPad shape is PAD_CIRCLE or PAD_OVAL, * if one of the 2 pads was a PAD_CIRCLE or PAD_OVAL. * Therefore, if aRefPad is a PAD_RECT or a PAD_TRAPEZOID, - * the other pad is also a PAD_RECT or a PAD_TRAPEZOID + * aPad is also a PAD_RECT or a PAD_TRAPEZOID */ switch( aRefPad->m_PadShape ) { @@ -1288,16 +1282,16 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) m_segmLength = 0; m_segmAngle = 0; - m_finx = m_finy = 0; + m_segmEnd.x = m_segmEnd.y = 0; - m_spotcx = rel_pos.x; - m_spotcy = rel_pos.y; + m_padToTestPos.x = rel_pos.x; + m_padToTestPos.y = rel_pos.y; diag = checkClearanceSegmToPad( aPad, aRefPad->m_Rayon, dist_min ); break; case PAD_RECT: - RotatePoint( &rel_pos.x, &rel_pos.y, aRefPad->m_Orient ); + RotatePoint( &rel_pos, aRefPad->m_Orient ); // pad_angle = pad orient relative to the aRefPad orient pad_angle = aRefPad->m_Orient + aPad->m_Orient; @@ -1309,8 +1303,7 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) // 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 if( ( (aRefPad->m_Orient == 0) || (aRefPad->m_Orient == 900) - || (aRefPad->m_Orient == 1800) - || (aRefPad->m_Orient == 2700) ) + || (aRefPad->m_Orient == 1800) || (aRefPad->m_Orient == 2700) ) && ( (aPad->m_Orient == 0) || (aPad->m_Orient == 900) || (aPad->m_Orient == 1800) || (aPad->m_Orient == 2700) ) ) { @@ -1394,7 +1387,6 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) &x, &y, &d ); - ; if( intersect || (d< dist_min) ) { diag = false; @@ -1436,11 +1428,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad ) RotatePoint( &segstart, m_segmAngle ); // True start point coordinate of the equivalent segment // move pad position relative to the segment origin - m_spotcx = rel_pos.x - segstart.x; - m_spotcy = rel_pos.y - segstart.y; + m_padToTestPos = rel_pos - segstart; // Calculate segment end - m_finx = -2 * segstart.x; - m_finy = -2 * segstart.y; // end of segment coordinate + m_segmEnd.x = -2 * segstart.x; + m_segmEnd.y = -2 * segstart.y; // end of segment coordinate diag = checkClearanceSegmToPad( aPad, segm_width / 2, dist_min ); break; } @@ -1459,41 +1450,40 @@ exit: // the only way out (hopefully) for simpler debugging bool DRC::checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int aMinDist ) { - int p_dimx; - int p_dimy; // half the dimension of the pad + wxSize padHalfsize; // half the dimension of the pad int orient; int x0, y0, xf, yf; int seuil; int deltay; seuil = w_segm + aMinDist; - p_dimx = pad_to_test->m_Size.x >> 1; - p_dimy = pad_to_test->m_Size.y >> 1; + padHalfsize.x = pad_to_test->m_Size.x >> 1; + padHalfsize.y = pad_to_test->m_Size.y >> 1; if( pad_to_test->m_PadShape == PAD_CIRCLE ) { /* calcul des coord centre du pad dans le repere axe X confondu * avec le segment en tst */ - RotatePoint( &m_spotcx, &m_spotcy, m_segmAngle ); - return checkMarginToCircle( m_spotcx, m_spotcy, seuil + p_dimx, m_segmLength ); + RotatePoint( &m_padToTestPos.x, &m_padToTestPos.y, m_segmAngle ); + return checkMarginToCircle( m_padToTestPos.x, m_padToTestPos.y, seuil + padHalfsize.x, m_segmLength ); } else { /* calcul de la "surface de securite" du pad de reference */ - m_xcliplo = m_spotcx - seuil - p_dimx; - m_ycliplo = m_spotcy - seuil - p_dimy; - m_xcliphi = m_spotcx + seuil + p_dimx; - m_ycliphi = m_spotcy + seuil + p_dimy; + m_xcliplo = m_padToTestPos.x - seuil - padHalfsize.x; + m_ycliplo = m_padToTestPos.y - seuil - padHalfsize.y; + m_xcliphi = m_padToTestPos.x + seuil + padHalfsize.x; + m_ycliphi = m_padToTestPos.y + seuil + padHalfsize.y; x0 = y0 = 0; - xf = m_finx; - yf = m_finy; + xf = m_segmEnd.x; + yf = m_segmEnd.y; orient = pad_to_test->m_Orient; - RotatePoint( &x0, &y0, m_spotcx, m_spotcy, -orient ); - RotatePoint( &xf, &yf, m_spotcx, m_spotcy, -orient ); + RotatePoint( &x0, &y0, m_padToTestPos.x, m_padToTestPos.y, -orient ); + RotatePoint( &xf, &yf, m_padToTestPos.x, m_padToTestPos.y, -orient ); if( checkLine( x0, y0, xf, yf ) ) return true; @@ -1507,51 +1497,51 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int aMi case PAD_OVAL: /* test de la pastille ovale ramenee au type ovale vertical */ - if( p_dimx > p_dimy ) + if( padHalfsize.x > padHalfsize.y ) { - EXCHG( p_dimx, p_dimy ); + EXCHG( padHalfsize.x, padHalfsize.y ); orient += 900; if( orient >= 3600 ) orient -= 3600; } - deltay = p_dimy - p_dimx; + deltay = padHalfsize.y - padHalfsize.x; - /* ici: p_dimx = rayon, + /* ici: padHalfsize.x = rayon, * delta = dist centre cercles a centre pad */ /* Test du rectangle separant les 2 demi cercles */ - m_xcliplo = m_spotcx - seuil - p_dimx; - m_ycliplo = m_spotcy - w_segm - deltay; - m_xcliphi = m_spotcx + seuil + p_dimx; - m_ycliphi = m_spotcy + w_segm + deltay; + m_xcliplo = m_padToTestPos.x - seuil - padHalfsize.x; + m_ycliplo = m_padToTestPos.y - w_segm - deltay; + m_xcliphi = m_padToTestPos.x + seuil + padHalfsize.x; + m_ycliphi = m_padToTestPos.y + w_segm + deltay; if( !checkLine( x0, y0, xf, yf ) ) return false; /* test des 2 cercles */ - x0 = m_spotcx; /* x0,y0 = centre du cercle superieur du pad ovale */ - y0 = m_spotcy + deltay; - RotatePoint( &x0, &y0, m_spotcx, m_spotcy, orient ); + x0 = m_padToTestPos.x; /* x0,y0 = centre du cercle superieur du pad ovale */ + y0 = m_padToTestPos.y + deltay; + RotatePoint( &x0, &y0, m_padToTestPos.x, m_padToTestPos.y, orient ); RotatePoint( &x0, &y0, m_segmAngle ); - if( !checkMarginToCircle( x0, y0, p_dimx + seuil, m_segmLength ) ) + if( !checkMarginToCircle( x0, y0, padHalfsize.x + seuil, m_segmLength ) ) return false; - x0 = m_spotcx; /* x0,y0 = centre du cercle inferieur du pad ovale */ - y0 = m_spotcy - deltay; - RotatePoint( &x0, &y0, m_spotcx, m_spotcy, orient ); + x0 = m_padToTestPos.x; /* x0,y0 = centre du cercle inferieur du pad ovale */ + y0 = m_padToTestPos.y - deltay; + RotatePoint( &x0, &y0, m_padToTestPos.x, m_padToTestPos.y, orient ); RotatePoint( &x0, &y0, m_segmAngle ); - if( !checkMarginToCircle( x0, y0, p_dimx + seuil, m_segmLength ) ) + if( !checkMarginToCircle( x0, y0, padHalfsize.x + seuil, m_segmLength ) ) return false; break; case PAD_RECT: /* 2 rectangle + 4 1/4 cercles a tester */ /* Test du rectangle dimx + seuil, dimy */ - m_xcliplo = m_spotcx - p_dimx - seuil; - m_ycliplo = m_spotcy - p_dimy; - m_xcliphi = m_spotcx + p_dimx + seuil; - m_ycliphi = m_spotcy + p_dimy; + m_xcliplo = m_padToTestPos.x - padHalfsize.x - seuil; + m_ycliplo = m_padToTestPos.y - padHalfsize.y; + m_xcliphi = m_padToTestPos.x + padHalfsize.x + seuil; + m_ycliphi = m_padToTestPos.y + padHalfsize.y; if( !checkLine( x0, y0, xf, yf ) ) { @@ -1559,10 +1549,10 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int aMi } /* Test du rectangle dimx , dimy + seuil */ - m_xcliplo = m_spotcx - p_dimx; - m_ycliplo = m_spotcy - p_dimy - seuil; - m_xcliphi = m_spotcx + p_dimx; - m_ycliphi = m_spotcy + p_dimy + seuil; + m_xcliplo = m_padToTestPos.x - padHalfsize.x; + m_ycliplo = m_padToTestPos.y - padHalfsize.y - seuil; + m_xcliphi = m_padToTestPos.x + padHalfsize.x; + m_ycliphi = m_padToTestPos.y + padHalfsize.y + seuil; if( !checkLine( x0, y0, xf, yf ) ) { @@ -1571,9 +1561,9 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int aMi /* test des 4 cercles ( surface d'solation autour des sommets */ /* test du coin sup. gauche du pad */ - x0 = m_spotcx - p_dimx; - y0 = m_spotcy - p_dimy; - RotatePoint( &x0, &y0, m_spotcx, m_spotcy, orient ); + x0 = m_padToTestPos.x - padHalfsize.x; + y0 = m_padToTestPos.y - padHalfsize.y; + RotatePoint( &x0, &y0, m_padToTestPos.x, m_padToTestPos.y, orient ); RotatePoint( &x0, &y0, m_segmAngle ); if( !checkMarginToCircle( x0, y0, seuil, m_segmLength ) ) { @@ -1581,9 +1571,9 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int aMi } /* test du coin sup. droit du pad */ - x0 = m_spotcx + p_dimx; - y0 = m_spotcy - p_dimy; - RotatePoint( &x0, &y0, m_spotcx, m_spotcy, orient ); + x0 = m_padToTestPos.x + padHalfsize.x; + y0 = m_padToTestPos.y - padHalfsize.y; + RotatePoint( &x0, &y0, m_padToTestPos.x, m_padToTestPos.y, orient ); RotatePoint( &x0, &y0, m_segmAngle ); if( !checkMarginToCircle( x0, y0, seuil, m_segmLength ) ) { @@ -1591,9 +1581,9 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int aMi } /* test du coin inf. gauche du pad */ - x0 = m_spotcx - p_dimx; - y0 = m_spotcy + p_dimy; - RotatePoint( &x0, &y0, m_spotcx, m_spotcy, orient ); + x0 = m_padToTestPos.x - padHalfsize.x; + y0 = m_padToTestPos.y + padHalfsize.y; + RotatePoint( &x0, &y0, m_padToTestPos.x, m_padToTestPos.y, orient ); RotatePoint( &x0, &y0, m_segmAngle ); if( !checkMarginToCircle( x0, y0, seuil, m_segmLength ) ) { @@ -1601,9 +1591,9 @@ bool DRC::checkClearanceSegmToPad( const D_PAD* pad_to_test, int w_segm, int aMi } /* test du coin inf. droit du pad */ - x0 = m_spotcx + p_dimx; - y0 = m_spotcy + p_dimy; - RotatePoint( &x0, &y0, m_spotcx, m_spotcy, orient ); + x0 = m_padToTestPos.x + padHalfsize.x; + y0 = m_padToTestPos.y + padHalfsize.y; + RotatePoint( &x0, &y0, m_padToTestPos.x, m_padToTestPos.y, orient ); RotatePoint( &x0, &y0, m_segmAngle ); if( !checkMarginToCircle( x0, y0, seuil, m_segmLength ) ) { diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h index aeddc268d8..c7f679de83 100644 --- a/pcbnew/drc_stuff.h +++ b/pcbnew/drc_stuff.h @@ -27,49 +27,49 @@ #include "fctsys.h" -#include "class_marker_base.h" +#include "class_marker_pcb.h" -#define OK_DRC 0 -#define BAD_DRC 1 +#define OK_DRC 0 +#define BAD_DRC 1 /// DRC error codes: -#define DRCE_ 1 // not used yet -#define DRCE_UNCONNECTED_PADS 2 ///< pads are unconnected -#define DRCE_TRACK_NEAR_THROUGH_HOLE 3 ///< thru hole is too close to track -#define DRCE_TRACK_NEAR_PAD 4 ///< pad too close to track -#define DRCE_TRACK_NEAR_VIA 5 ///< track too close to via -#define DRCE_VIA_NEAR_VIA 6 ///< via too close to via -#define DRCE_VIA_NEAR_TRACK 7 ///< via too close to track -#define DRCE_TRACK_ENDS1 8 ///< @todo say what this problem is -#define DRCE_TRACK_ENDS2 9 ///< @todo say what this problem is -#define DRCE_TRACK_ENDS3 10 ///< @todo say what this problem is -#define DRCE_TRACK_ENDS4 11 ///< @todo say what this problem is -#define DRCE_TRACK_UNKNOWN1 12 ///< @todo check source code and change this comment -#define DRCE_TRACKS_CROSSING 13 ///< tracks are crossing -#define DRCE_ENDS_PROBLEM1 14 ///< track ends are too close -#define DRCE_ENDS_PROBLEM2 15 ///< track ends are too close -#define DRCE_ENDS_PROBLEM3 16 ///< track ends are too close -#define DRCE_ENDS_PROBLEM4 17 ///< track ends are too close -#define DRCE_ENDS_PROBLEM5 18 ///< track ends are too close -#define DRCE_PAD_NEAR_PAD1 19 ///< pad too close to pad -#define DRCE_VIA_HOLE_BIGGER 20 ///< via's hole is bigger than its diameter -#define DRCE_MICRO_VIA_INCORRECT_LAYER_PAIR 21 ///< micro via's layer pair incorrect (layers must be adjacent) -#define COPPERAREA_INSIDE_COPPERAREA 22 ///< copper area outlines intersect -#define COPPERAREA_CLOSE_TO_COPPERAREA 23 ///< copper area outlines are too close -#define DRCE_NON_EXISTANT_NET_FOR_ZONE_OUTLINE 24 ///< copper area outline has an incorrect netcode due to a netname not found -#define DRCE_HOLE_NEAR_PAD 25 ///< hole too close to pad -#define DRCE_HOLE_NEAR_TRACK 26 ///< hole too close to track -#define DRCE_TOO_SMALL_TRACK_WIDTH 27 ///< Too small track width -#define DRCE_TOO_SMALL_VIA 28 ///< Too small via size -#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_ViaDrill -#define DRCE_NETCLASS_uVIASIZE 34 -#define DRCE_NETCLASS_uVIADRILLSIZE 35 +#define DRCE_ 1 // not used yet +#define DRCE_UNCONNECTED_PADS 2 ///< pads are unconnected +#define DRCE_TRACK_NEAR_THROUGH_HOLE 3 ///< thru hole is too close to track +#define DRCE_TRACK_NEAR_PAD 4 ///< pad too close to track +#define DRCE_TRACK_NEAR_VIA 5 ///< track too close to via +#define DRCE_VIA_NEAR_VIA 6 ///< via too close to via +#define DRCE_VIA_NEAR_TRACK 7 ///< via too close to track +#define DRCE_TRACK_ENDS1 8 ///< @todo say what this problem is +#define DRCE_TRACK_ENDS2 9 ///< @todo say what this problem is +#define DRCE_TRACK_ENDS3 10 ///< @todo say what this problem is +#define DRCE_TRACK_ENDS4 11 ///< @todo say what this problem is +#define DRCE_TRACK_UNKNOWN1 12 ///< @todo check source code and change this comment +#define DRCE_TRACKS_CROSSING 13 ///< tracks are crossing +#define DRCE_ENDS_PROBLEM1 14 ///< track ends are too close +#define DRCE_ENDS_PROBLEM2 15 ///< track ends are too close +#define DRCE_ENDS_PROBLEM3 16 ///< track ends are too close +#define DRCE_ENDS_PROBLEM4 17 ///< track ends are too close +#define DRCE_ENDS_PROBLEM5 18 ///< track ends are too close +#define DRCE_PAD_NEAR_PAD1 19 ///< pad too close to pad +#define DRCE_VIA_HOLE_BIGGER 20 ///< via's hole is bigger than its diameter +#define DRCE_MICRO_VIA_INCORRECT_LAYER_PAIR 21 ///< micro via's layer pair incorrect (layers must be adjacent) +#define COPPERAREA_INSIDE_COPPERAREA 22 ///< copper area outlines intersect +#define COPPERAREA_CLOSE_TO_COPPERAREA 23 ///< copper area outlines are too close +#define DRCE_NON_EXISTANT_NET_FOR_ZONE_OUTLINE 24 ///< copper area outline has an incorrect netcode due to a netname not found +#define DRCE_HOLE_NEAR_PAD 25 ///< hole too close to pad +#define DRCE_HOLE_NEAR_TRACK 26 ///< hole too close to track +#define DRCE_TOO_SMALL_TRACK_WIDTH 27 ///< Too small track width +#define DRCE_TOO_SMALL_VIA 28 ///< Too small via size +#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 class WinEDA_DrawPanel; @@ -121,7 +121,7 @@ public: }; -typedef std::vector DRC_LIST; +typedef std::vector DRC_LIST; /** @@ -150,29 +150,40 @@ private: // int m_errorCount; - MARKER_PCB* m_currentMarker; + MARKER_PCB* m_currentMarker; - bool m_aboartDRC; - bool m_drcInProgress; - int m_spotcx; - int m_spotcy; - int m_finx; - int m_finy; // coord relatives de l'extremite du segm de reference + bool m_aboartDRC; + bool m_drcInProgress; - int m_segmAngle; // angle d'inclinaison du segment de reference en 0,1 degre - int m_segmLength; // length of the reference segment + /* In DRC functions, many calculations are using coordinates relative + * to the position of the segment under test (segm to segm DRC, segm to pad DRC + * Next variables store coordinates relative to the start point of this segment + */ + wxPoint m_padToTestPos; // Position of the pad to compare in drc test segm to pad or pad to pad + wxPoint m_segmEnd; // End point of the reference segment (start point = (0,0) ) - int m_xcliplo; - int m_ycliplo; - int m_xcliphi; - int m_ycliphi; // coord de la surface de securite du segment a comparer + /* Some functions are comparing the ref segm to pads or others segments using + * coordinates relative to the ref segment considered as the X axis + * so we store the ref segment length (the end point relative to these axis) + * and the segment orientation (used to rotate other coordinates) + */ + int m_segmAngle; // Ref segm orientation in 0,1 degre + int m_segmLength; // length of the reference segment - WinEDA_PcbFrame* m_mainWindow; - WinEDA_DrawPanel* m_drawPanel; - BOARD* m_pcb; - DIALOG_DRC_CONTROL* m_ui; + /* variables used in checkLine to test DRC segm to segm: + * define the area relative to the ref segment that does not contains anu other segment + */ + int m_xcliplo; + int m_ycliplo; + int m_xcliphi; + int m_ycliphi; - DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs + WinEDA_PcbFrame* m_mainWindow; + WinEDA_DrawPanel* m_drawPanel; + BOARD* m_pcb; + DIALOG_DRC_CONTROL* m_ui; + + DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs /** @@ -180,7 +191,7 @@ private: * is a private helper function used to update needed pointers from the * one pointer which is known not to change, m_mainWindow. */ - void updatePointers(); + void updatePointers(); /** @@ -201,7 +212,7 @@ private: MARKER_PCB* fillMarker( D_PAD* aPad, D_PAD* bPad, int aErrorCode, MARKER_PCB* fillMe ); - MARKER_PCB* fillMarker( ZONE_CONTAINER * aArea, int aErrorCode, MARKER_PCB* fillMe ); + MARKER_PCB* fillMarker( ZONE_CONTAINER* aArea, int aErrorCode, MARKER_PCB* fillMe ); /** * Function fillMarker @@ -215,7 +226,10 @@ private: * @param fillMe A MARKER_PCB* which is to be filled in, or NULL if one is to * first be allocated, then filled. */ - MARKER_PCB* fillMarker( const ZONE_CONTAINER * aArea, const wxPoint & aPos, int aErrorCode, MARKER_PCB* fillMe ); + MARKER_PCB* fillMarker( const ZONE_CONTAINER* aArea, + const wxPoint& aPos, + int aErrorCode, + MARKER_PCB* fillMe ); /** * Function fillMarker @@ -236,20 +250,20 @@ private: * @return bool - true if succes, else false but only after * reporting _all_ NETCLASS violations. */ - bool testNetClasses(); + bool testNetClasses(); - void testTracks(); + void testTracks(); - void testPad2Pad(); + void testPad2Pad(); - void testUnconnected(); + void testUnconnected(); - void testZones(bool adoTestFillSegments); + void testZones( bool adoTestFillSegments ); //---------------------------------------------- - bool doNetClass( NETCLASS* aNetClass, wxString& msg ); + bool doNetClass( NETCLASS* aNetClass, wxString& msg ); /** * Function doPadToPadsDrc @@ -260,8 +274,8 @@ private: * @param aEnd Marks the end of the list and is not included * @param x_limit is used to stop the test (when the any pad's X coord exceeds this) */ - bool doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, - LISTE_PAD* aEnd, int x_limit ); + bool doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, + LISTE_PAD* aEnd, int x_limit ); /** * Function DoTrackDrc @@ -272,7 +286,7 @@ private: * @return bool - true if no poblems, else false and m_currentMarker is * filled in with the problem information. */ - bool doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool doPads = true ); + bool doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool doPads = true ); /** @@ -284,7 +298,7 @@ private: * @param aCornerIndex The first corner of the segment to test. * @return bool - false if DRC error or true if OK */ - bool doEdgeZoneDrc( ZONE_CONTAINER * aArea, int aCornerIndex ); + bool doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex ); //--------------------------------------------------- @@ -368,7 +382,7 @@ public: * @param CornerIndex The starting point of the segment to test. * @return int - BAD_DRC (1) if DRC error or OK_DRC (0) if OK */ - int Drc( ZONE_CONTAINER * aArea, int CornerIndex ); + int Drc( ZONE_CONTAINER* aArea, int CornerIndex ); /** * Function DrcBlind @@ -385,13 +399,14 @@ public: return doTrackDrc( aRefSeg, aList ) ? OK_DRC : BAD_DRC; } + /** * Function ShowDialog * opens a dialog and prompts the user, then if a test run button is * clicked, runs the test(s) and creates the MARKERS. The dialog is only * created if it is not already in existence. */ - void ShowDialog(); + void ShowDialog(); /** * Function DestroyDialog @@ -399,7 +414,7 @@ public: * the state of the dialog's existence. * @param aReason Indication of which button was clicked to cause the destruction. */ - void DestroyDialog( int aReason ); + void DestroyDialog( int aReason ); /** @@ -421,20 +436,21 @@ public: m_doCreateRptFile = aSaveReport; } + /** * Function RunTests * will actually run all the tests specified with a previous call to * SetSettings() * @param aMessages = a wxTextControl where to display some activity messages. Can be NULL */ - void RunTests(wxTextCtrl * aMessages = NULL); + void RunTests( wxTextCtrl* aMessages = NULL ); /** * Function ListUnconnectedPad * gathers a list of all the unconnected pads and shows them in the * dialog, and optionally prints a report of such. */ - void ListUnconnectedPads(); + void ListUnconnectedPads(); }; diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index 0a4be03a43..e69927f5a4 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -11,6 +11,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" +#include "drc_stuff.h" #include "protos.h" diff --git a/pcbnew/editrack-part2.cpp b/pcbnew/editrack-part2.cpp index 1d2d2b3916..3ab32f5b5b 100644 --- a/pcbnew/editrack-part2.cpp +++ b/pcbnew/editrack-part2.cpp @@ -10,6 +10,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "class_board_design_settings.h" +#include "drc_stuff.h" #include "protos.h" diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 2acc0e9459..3906be994c 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -11,6 +11,7 @@ #include "pcbnew.h" #include "wxPcbStruct.h" #include "trigo.h" +#include "drc_stuff.h" #include "drag.h" #include "pcbnew_id.h" @@ -274,7 +275,7 @@ static void Show_Drag_Track_Segment_With_Cte_Slope( WinEDA_DrawPanel* panel, { // Get the segment connected to the start point if( ii >= 0 ) - tSegmentToStart = g_DragSegmentList[ii].m_Segm; + tSegmentToStart = g_DragSegmentList[ii].m_Segm; } } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 8b12139f26..b4102e7a22 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -15,6 +15,7 @@ #include "pcbnew_id.h" #include "protos.h" #include "zones_functions_for_undo_redo.h" +#include "drc_stuff.h" bool s_Verbose = false; // false if zone outline diags must not be shown diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index f9f5eead61..a1461b6aa1 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -11,11 +11,11 @@ #include "common.h" #include "confirm.h" #include "pcbnew.h" +#include "drc_stuff.h" -bool bDontShowSelfIntersectionArcsWarning; -bool bDontShowSelfIntersectionWarning; -bool bDontShowIntersectionArcsWarning; -bool bDontShowIntersectionWarning; +static bool bDontShowSelfIntersectionArcsWarning; +static bool bDontShowSelfIntersectionWarning; +static bool bDontShowIntersectionArcsWarning; /** Function AddArea