2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file drc_stuff.h
|
|
|
|
*/
|
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2007-11-27 01:34:35 +00:00
|
|
|
*
|
2016-09-08 18:17:37 +00:00
|
|
|
* Copyright (C) 2007-2016 Dick Hollenbeck, dick@softplc.com
|
2018-02-10 20:17:11 +00:00
|
|
|
* Copyright (C) 2017-2018 KiCad Developers, see change_log.txt for contributors.
|
2007-11-27 01:34:35 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#ifndef DRC_H
|
|
|
|
#define DRC_H
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
#include <vector>
|
2016-06-29 15:09:55 +00:00
|
|
|
#include <memory>
|
2018-08-27 13:50:50 +00:00
|
|
|
#include <geometry/seg.h>
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
#define OK_DRC 0
|
|
|
|
#define BAD_DRC 1
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2018-01-06 23:37:24 +00:00
|
|
|
// DRC error codes could be defined by an enum.
|
|
|
|
// however a #define is used because error code value is displayed in DRC messages,
|
|
|
|
// and using #define that shows each numerical value helps for debug.
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/// DRC error codes:
|
2010-09-18 08:29:40 +00:00
|
|
|
#define DRCE_ 1 // not used yet
|
2017-03-22 15:47:15 +00:00
|
|
|
#define DRCE_UNCONNECTED_ITEMS 2 ///< items are unconnected
|
2010-09-18 08:29:40 +00:00
|
|
|
#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
|
2013-09-11 15:30:21 +00:00
|
|
|
#define DRCE_TRACK_ENDS1 8 ///< 2 parallel track segments too close: fine start point test
|
|
|
|
#define DRCE_TRACK_ENDS2 9 ///< 2 parallel track segments too close: fine start point test
|
|
|
|
#define DRCE_TRACK_ENDS3 10 ///< 2 parallel track segments too close: fine end point test
|
|
|
|
#define DRCE_TRACK_ENDS4 11 ///< 2 parallel track segments too close: fine end point test
|
|
|
|
#define DRCE_TRACK_SEGMENTS_TOO_CLOSE 12 ///< 2 parallel track segments too close: segm ends between segref ends
|
2010-09-18 08:29:40 +00:00
|
|
|
#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)
|
2018-08-27 17:34:28 +00:00
|
|
|
#define DRCE_ZONES_INTERSECT 22 ///< copper area outlines intersect
|
|
|
|
#define DRCE_ZONES_TOO_CLOSE 23 ///< copper area outlines are too close
|
2015-01-22 12:06:34 +00:00
|
|
|
#define DRCE_SUSPICIOUS_NET_FOR_ZONE_OUTLINE 24 ///< copper area has a net but no pads in nets, which is suspicious
|
2010-09-18 08:29:40 +00:00
|
|
|
#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
|
2016-08-25 01:16:27 +00:00
|
|
|
#define DRCE_TOO_SMALL_VIA_DRILL 30 ///< Too small via drill
|
|
|
|
#define DRCE_TOO_SMALL_MICROVIA_DRILL 31 ///< Too small micro via drill
|
|
|
|
#define DRCE_NETCLASS_TRACKWIDTH 32 ///< netclass has TrackWidth < board.m_designSettings->m_TrackMinWidth
|
|
|
|
#define DRCE_NETCLASS_CLEARANCE 33 ///< netclass has Clearance < board.m_designSettings->m_TrackClearance
|
|
|
|
#define DRCE_NETCLASS_VIASIZE 34 ///< netclass has ViaSize < board.m_designSettings->m_ViasMinSize
|
|
|
|
#define DRCE_NETCLASS_VIADRILLSIZE 35 ///< netclass has ViaDrillSize < board.m_designSettings->m_ViasMinDrill
|
|
|
|
#define DRCE_NETCLASS_uVIASIZE 36 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinSize
|
|
|
|
#define DRCE_NETCLASS_uVIADRILLSIZE 37 ///< netclass has ViaSize < board.m_designSettings->m_MicroViasMinDrill
|
|
|
|
#define DRCE_VIA_INSIDE_KEEPOUT 38 ///< Via in inside a keepout area
|
|
|
|
#define DRCE_TRACK_INSIDE_KEEPOUT 39 ///< Track in inside a keepout area
|
|
|
|
#define DRCE_PAD_INSIDE_KEEPOUT 40 ///< Pad in inside a keepout area
|
2018-08-27 13:50:50 +00:00
|
|
|
#define DRCE_TRACK_NEAR_COPPER 41 ///< track & copper graphic collide or are too close
|
|
|
|
#define DRCE_VIA_NEAR_COPPER 42 ///< via and copper graphic collide or are too close
|
|
|
|
#define DRCE_PAD_NEAR_COPPER 43 ///< pad and copper graphic collide or are too close
|
|
|
|
#define DRCE_TRACK_NEAR_ZONE 44 ///< track & zone collide or are too close together
|
|
|
|
#define DRCE_OVERLAPPING_FOOTPRINTS 45 ///< footprint courtyards overlap
|
|
|
|
#define DRCE_MISSING_COURTYARD_IN_FOOTPRINT 46 ///< footprint has no courtyard defined
|
|
|
|
#define DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT 47 ///< footprint has a courtyard but malformed
|
2018-01-06 23:37:24 +00:00
|
|
|
///< (not convertible to a closed polygon with holes)
|
2018-08-27 13:50:50 +00:00
|
|
|
#define DRCE_MICRO_VIA_NOT_ALLOWED 48 ///< micro vias are not allowed
|
|
|
|
#define DRCE_BURIED_VIA_NOT_ALLOWED 49 ///< buried vias are not allowed
|
|
|
|
#define DRCE_DISABLED_LAYER_ITEM 50 ///< item on a disabled layer
|
|
|
|
#define DRCE_DRILLED_HOLES_TOO_CLOSE 51 ///< overlapping drilled holes break drill bits
|
2007-11-27 01:34:35 +00:00
|
|
|
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_PANEL;
|
2011-09-23 13:57:12 +00:00
|
|
|
class PCB_EDIT_FRAME;
|
2009-06-18 13:30:52 +00:00
|
|
|
class DIALOG_DRC_CONTROL;
|
2011-09-23 13:57:12 +00:00
|
|
|
class BOARD_ITEM;
|
|
|
|
class BOARD;
|
|
|
|
class D_PAD;
|
|
|
|
class ZONE_CONTAINER;
|
|
|
|
class TRACK;
|
|
|
|
class MARKER_PCB;
|
|
|
|
class DRC_ITEM;
|
|
|
|
class NETCLASS;
|
2018-08-23 22:41:57 +00:00
|
|
|
class EDA_TEXT;
|
2018-08-27 13:50:50 +00:00
|
|
|
class DRAWSEGMENT;
|
|
|
|
class wxWindow;
|
|
|
|
class wxString;
|
|
|
|
class wxTextCtrl;
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Provide an abstract interface of a DRC_ITEM* list manager. The details
|
2007-12-03 05:14:51 +00:00
|
|
|
* of the actual list architecture are hidden from the caller. Any class
|
|
|
|
* that implements this interface can then be used by a DRCLISTBOX class without
|
|
|
|
* it knowing the actual architecture of the list.
|
|
|
|
*/
|
|
|
|
class DRC_ITEM_LIST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function DeleteAllItems
|
|
|
|
* removes and deletes all the items in the list.
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
virtual void DeleteAllItems() = 0;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
/**
|
|
|
|
* Function GetItem
|
|
|
|
* retrieves a DRC_ITEM by pointer. The actual item remains owned by the
|
|
|
|
* list container.
|
|
|
|
* @param aIndex The 0 based index into the list of the desired item.
|
|
|
|
* @return const DRC_ITEM* - the desired item or NULL if aIndex is out of range.
|
|
|
|
*/
|
2008-01-12 20:31:56 +00:00
|
|
|
virtual const DRC_ITEM* GetItem( int aIndex ) = 0;
|
2007-12-03 05:14:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function DeleteAllItems
|
|
|
|
* removes and deletes desired item from the list.
|
2008-01-12 20:31:56 +00:00
|
|
|
* @param aIndex The 0 based index into the list of the desired item which
|
2007-12-03 05:14:51 +00:00
|
|
|
* is to be deleted.
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
virtual void DeleteItem( int aIndex ) = 0;
|
2007-12-03 05:14:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetCount
|
|
|
|
* returns the number of items in the list.
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
virtual int GetCount() = 0;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
|
|
|
virtual ~DRC_ITEM_LIST() { }
|
2007-12-03 05:14:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
typedef std::vector<DRC_ITEM*> DRC_LIST;
|
2007-12-04 18:23:38 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Design Rule Checker object that performs all the DRC tests. The output of
|
2007-12-01 03:42:52 +00:00
|
|
|
* the checking goes to the BOARD file in the form of two MARKER lists. Those
|
|
|
|
* two lists are displayable in the drc dialog box. And they can optionally
|
|
|
|
* be sent to a text file on disk.
|
|
|
|
* This class is given access to the windows and the BOARD
|
|
|
|
* that it needs via its constructor or public access functions.
|
2008-01-12 20:31:56 +00:00
|
|
|
*/
|
2007-12-01 03:42:52 +00:00
|
|
|
class DRC
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2009-06-18 13:30:52 +00:00
|
|
|
friend class DIALOG_DRC_CONTROL;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
private:
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
// protected or private functions() are lowercase first character.
|
2008-01-12 20:31:56 +00:00
|
|
|
bool m_doPad2PadTest;
|
|
|
|
bool m_doUnconnectedTest;
|
|
|
|
bool m_doZonesTest;
|
2012-07-13 18:55:29 +00:00
|
|
|
bool m_doKeepoutTest;
|
2008-01-12 20:31:56 +00:00
|
|
|
bool m_doCreateRptFile;
|
2018-02-10 20:17:11 +00:00
|
|
|
bool m_refillZones;
|
2018-03-20 02:54:16 +00:00
|
|
|
bool m_reportAllTrackErrors;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
|
|
|
wxString m_rptFilename;
|
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
MARKER_PCB* m_currentMarker;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
/**
|
|
|
|
* in legacy canvas, when creating a track, the drc test must only display the
|
|
|
|
* error message, and do not create a DRC marker.
|
|
|
|
* if m_drcInLegacyRoutingMode it true only the message will be displayed
|
|
|
|
* m_drcInLegacyRoutingMode = false is the normal Drc mode
|
|
|
|
*/
|
|
|
|
bool m_drcInLegacyRoutingMode;
|
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
/* 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
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
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) )
|
2010-09-18 08:29:40 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
*/
|
2013-05-05 07:17:48 +00:00
|
|
|
double m_segmAngle; // Ref segm orientation in 0,1 degre
|
2011-09-23 13:57:12 +00:00
|
|
|
int m_segmLength; // length of the reference segment
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
/* variables used in checkLine to test DRC segm to segm:
|
2012-07-13 18:55:29 +00:00
|
|
|
* define the area relative to the ref segment that does not contains any other segment
|
2010-09-18 08:29:40 +00:00
|
|
|
*/
|
2010-09-19 17:44:46 +00:00
|
|
|
int m_xcliplo;
|
|
|
|
int m_ycliplo;
|
|
|
|
int m_xcliphi;
|
|
|
|
int m_ycliphi;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2016-07-27 12:53:45 +00:00
|
|
|
PCB_EDIT_FRAME* m_pcbEditorFrame; ///< The pcb frame editor which owns the board
|
2010-09-18 08:29:40 +00:00
|
|
|
BOARD* m_pcb;
|
2016-04-15 18:15:22 +00:00
|
|
|
DIALOG_DRC_CONTROL* m_drcDialog;
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2016-07-27 12:53:45 +00:00
|
|
|
DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs
|
2008-01-12 20:31:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Update needed pointers from the one pointer which is known not to change.
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
void updatePointers();
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
/**
|
2018-08-27 13:50:50 +00:00
|
|
|
* Function newMarker
|
|
|
|
* Creates a marker on a track, via or pad.
|
2018-02-10 20:17:11 +00:00
|
|
|
*
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param aTrack/aPad The reference item.
|
2018-08-27 13:50:50 +00:00
|
|
|
* @param aConflitItem Another item on the board which is in conflict with the
|
|
|
|
* reference item.
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param aErrorCode An ID for the particular type of error that is being reported.
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2018-08-27 13:50:50 +00:00
|
|
|
MARKER_PCB* newMarker( TRACK* aTrack, BOARD_ITEM* aConflitItem, const SEG& aConflictSeg,
|
|
|
|
int aErrorCode );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
MARKER_PCB* newMarker( TRACK* aTrack, ZONE_CONTAINER* aConflictZone, int aErrorCode );
|
|
|
|
|
|
|
|
MARKER_PCB* newMarker( D_PAD* aPad, BOARD_ITEM* aConflictItem, int aErrorCode );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2008-01-20 19:55:22 +00:00
|
|
|
/**
|
2018-08-27 13:50:50 +00:00
|
|
|
* Function newMarker
|
|
|
|
* Creates a marker at a given location.
|
2018-02-10 20:17:11 +00:00
|
|
|
*
|
2018-01-28 09:35:33 +00:00
|
|
|
* @param aItem The reference item.
|
|
|
|
* @param aPos Usually the position of the item, but could be more specific for a zone.
|
|
|
|
* @param aErrorCode An ID for the particular type of error that is being reported.
|
|
|
|
*/
|
2018-08-27 13:50:50 +00:00
|
|
|
MARKER_PCB* newMarker( const wxPoint& aPos, BOARD_ITEM* aItem, int aErrorCode );
|
2018-01-28 09:35:33 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
MARKER_PCB* newMarker( const wxPoint& aPos, BOARD_ITEM* aItem, BOARD_ITEM* bItem,
|
|
|
|
int aErrorCode );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
/**
|
2018-08-27 13:50:50 +00:00
|
|
|
* Create a MARKER which will report on a generic problem with the board which is
|
2009-09-10 15:22:26 +00:00
|
|
|
* not geographically locatable.
|
|
|
|
*/
|
2018-08-27 13:50:50 +00:00
|
|
|
MARKER_PCB* newMarker( int aErrorCode, const wxString& aMessage );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2017-03-03 15:04:58 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Adds a DRC marker to the PCB through the COMMIT mechanism.
|
2017-03-03 15:04:58 +00:00
|
|
|
*/
|
2017-03-03 19:26:18 +00:00
|
|
|
void addMarkerToPcb( MARKER_PCB* aMarker );
|
2011-06-09 13:30:46 +00:00
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
//-----<categorical group tests>-----------------------------------------
|
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Go through each NETCLASS and verifies that its clearance, via size, track width, and
|
|
|
|
* track clearance are larger than those in board.m_designSettings.
|
2009-09-10 15:22:26 +00:00
|
|
|
* This is necessary because the actual DRC checks are run against the NETCLASS
|
|
|
|
* limits, so in order enforce global limits, we first check the NETCLASSes against
|
|
|
|
* the global limits.
|
|
|
|
* @return bool - true if succes, else false but only after
|
|
|
|
* reporting _all_ NETCLASS violations.
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
bool testNetClasses();
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Perform the DRC on all tracks.
|
|
|
|
*
|
|
|
|
* This test can take a while, a progress bar can be displayed
|
2015-07-08 07:33:11 +00:00
|
|
|
* @param aActiveWindow = the active window ued as parent for the progress bar
|
|
|
|
* @param aShowProgressBar = true to show a progress bar
|
2011-11-11 07:00:51 +00:00
|
|
|
* (Note: it is shown only if there are many tracks)
|
2011-11-10 08:21:11 +00:00
|
|
|
*/
|
2015-07-08 07:33:11 +00:00
|
|
|
void testTracks( wxWindow * aActiveWindow, bool aShowProgressBar );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
void testPad2Pad();
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2018-04-14 14:58:01 +00:00
|
|
|
void testDrilledHoles();
|
|
|
|
|
2011-09-23 13:57:12 +00:00
|
|
|
void testUnconnected();
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2011-11-10 08:21:11 +00:00
|
|
|
void testZones();
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
void testKeepoutAreas();
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2018-08-23 22:41:57 +00:00
|
|
|
// aTextItem is type BOARD_ITEM* to accept either TEXTE_PCB or TEXTE_MODULE
|
2018-08-27 13:50:50 +00:00
|
|
|
void testCopperTextItem( BOARD_ITEM* aTextItem );
|
|
|
|
|
|
|
|
void testCopperDrawItem( DRAWSEGMENT* aDrawing );
|
2018-08-23 22:41:57 +00:00
|
|
|
|
2018-08-27 13:50:50 +00:00
|
|
|
void testCopperTextAndGraphics();
|
2014-08-13 15:47:02 +00:00
|
|
|
|
2018-07-04 08:23:40 +00:00
|
|
|
///> Tests for items placed on disabled layers (causing false connections).
|
|
|
|
void testDisabledLayers();
|
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
//-----<single "item" tests>-----------------------------------------
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
bool doNetClass( const std::shared_ptr<NETCLASS>& aNetClass, wxString& msg );
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Test the clearance between aRefPad and other pads.
|
|
|
|
*
|
2007-12-01 03:42:52 +00:00
|
|
|
* The pad list must be sorted by x coordinate.
|
2018-02-10 20:17:11 +00:00
|
|
|
*
|
2018-05-16 07:20:04 +00:00
|
|
|
* @param aRefPad is the pad to test
|
|
|
|
* @param aStart is the first pad of the list to test against aRefPad
|
|
|
|
* @param aEnd is the end of the list and is not included
|
|
|
|
* @param x_limit is used to stop the test
|
|
|
|
* (i.e. when the current pad pos X in list exceeds this limit, because the list
|
|
|
|
* is sorted by X coordinate)
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
bool doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_limit );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Test the current segment.
|
|
|
|
*
|
2007-12-01 03:42:52 +00:00
|
|
|
* @param aRefSeg The segment to test
|
2018-05-16 07:20:04 +00:00
|
|
|
* @param aStart the first item of track list to test against (usually BOARD::m_Track)
|
2008-12-04 04:28:11 +00:00
|
|
|
* @param doPads true if should do pads test
|
2018-02-10 20:17:11 +00:00
|
|
|
* @return bool - true if no problems, else false and m_currentMarker is
|
2007-12-01 03:42:52 +00:00
|
|
|
* filled in with the problem information.
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
bool doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool doPads = true );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2012-07-13 18:55:29 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Test the current segment or via.
|
|
|
|
*
|
2012-07-13 18:55:29 +00:00
|
|
|
* @param aRefSeg The segment to test
|
2018-02-10 20:17:11 +00:00
|
|
|
* @return bool - true if no problems, else false and m_currentMarker is
|
2012-07-13 18:55:29 +00:00
|
|
|
* filled in with the problem information.
|
|
|
|
*/
|
|
|
|
bool doTrackKeepoutDrc( TRACK* aRefSeg );
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2008-02-23 04:54:06 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Test a segment in ZONE_CONTAINER * aArea:
|
2008-02-23 04:54:06 +00:00
|
|
|
* Test Edge inside other areas
|
|
|
|
* Test Edge too close other areas
|
2018-02-10 20:17:11 +00:00
|
|
|
*
|
2008-02-23 04:54:06 +00:00
|
|
|
* @param aArea The current area.
|
|
|
|
* @param aCornerIndex The first corner of the segment to test.
|
|
|
|
* @return bool - false if DRC error or true if OK
|
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
bool doEdgeZoneDrc( ZONE_CONTAINER* aArea, int aCornerIndex );
|
2008-01-20 19:55:22 +00:00
|
|
|
|
2017-03-16 17:09:33 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Test for footprint courtyard overlaps.
|
|
|
|
*
|
2017-03-16 17:09:33 +00:00
|
|
|
* @return bool - false if DRC error or true if OK
|
|
|
|
*/
|
|
|
|
bool doFootprintOverlappingDrc();
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
//-----<single tests>----------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param aRefPad The reference pad to check
|
|
|
|
* @param aPad Another pad to check against
|
2010-09-18 17:55:08 +00:00
|
|
|
* @return bool - true if clearance between aRefPad and aPad is >= dist_min, else false
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
bool checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Check the distance from a pad to segment. This function uses several
|
2007-12-01 03:42:52 +00:00
|
|
|
* instance variable not passed in:
|
2010-09-18 17:55:08 +00:00
|
|
|
* m_segmLength = length of the segment being tested
|
|
|
|
* m_segmAngle = angle of the segment with the X axis;
|
|
|
|
* m_segmEnd = end coordinate of the segment
|
|
|
|
* m_padToTestPos = position of pad relative to the origin of segment
|
|
|
|
* @param aPad Is the pad involved in the check
|
|
|
|
* @param aSegmentWidth width of the segment to test
|
|
|
|
* @param aMinDist Is the minimum clearance needed
|
2007-12-01 03:42:52 +00:00
|
|
|
*
|
2010-09-18 17:55:08 +00:00
|
|
|
* @return true distance >= dist_min,
|
|
|
|
* false if distance < dist_min
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2011-09-23 13:57:12 +00:00
|
|
|
bool checkClearanceSegmToPad( const D_PAD* aPad, int aSegmentWidth, int aMinDist );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
|
|
|
|
/**
|
2016-04-06 18:15:49 +00:00
|
|
|
* Check the distance from a point to a segment.
|
2018-02-10 20:17:11 +00:00
|
|
|
*
|
2016-04-06 18:15:49 +00:00
|
|
|
* The segment is expected starting at 0,0, and on the X axis
|
2010-09-19 17:44:46 +00:00
|
|
|
* (used to test DRC between a segment and a round pad, via or round end of a track
|
|
|
|
* @param aCentre The coordinate of the circle's center
|
|
|
|
* @param aRadius A "keep out" radius centered over the circle
|
2016-04-06 18:15:49 +00:00
|
|
|
* @param aLength The length of the segment (i.e. coordinate of end, because it is on
|
2011-09-23 13:57:12 +00:00
|
|
|
* the X axis)
|
2007-12-01 03:42:52 +00:00
|
|
|
* @return bool - true if distance >= radius, else
|
2010-09-19 17:44:46 +00:00
|
|
|
* false when distance < aRadius
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2010-09-19 17:44:46 +00:00
|
|
|
static bool checkMarginToCircle( wxPoint aCentre, int aRadius, int aLength );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/**
|
|
|
|
* Function checkLine
|
2011-09-23 13:57:12 +00:00
|
|
|
* (helper function used in drc calculations to see if one track is in contact with
|
|
|
|
* another track).
|
2010-09-19 17:44:46 +00:00
|
|
|
* Test if a line intersects a bounding box (a rectangle)
|
|
|
|
* The rectangle is defined by m_xcliplo, m_ycliplo and m_xcliphi, m_ycliphi
|
|
|
|
* return true if the line from aSegStart to aSegEnd is outside the bounding box
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2010-09-19 17:44:46 +00:00
|
|
|
bool checkLine( wxPoint aSegStart, wxPoint aSegEnd );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
//-----</single tests>---------------------------------------------
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
public:
|
2011-03-01 19:26:17 +00:00
|
|
|
DRC( PCB_EDIT_FRAME* aPcbWindow );
|
2007-11-27 22:49:35 +00:00
|
|
|
|
2007-12-04 18:23:38 +00:00
|
|
|
~DRC();
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/**
|
2018-04-14 14:58:01 +00:00
|
|
|
* Function Drc
|
2007-12-01 03:42:52 +00:00
|
|
|
* tests the current segment and returns the result and displays the error
|
|
|
|
* in the status panel only if one exists.
|
2018-06-04 08:44:25 +00:00
|
|
|
* No marker created or added to the board. Must be used only during track
|
|
|
|
* creation in legacy canvas
|
2007-12-01 03:42:52 +00:00
|
|
|
* @param aRefSeg The current segment to test.
|
|
|
|
* @param aList The track list to test (usually m_Pcb->m_Track)
|
|
|
|
* @return int - BAD_DRC (1) if DRC error or OK_DRC (0) if OK
|
|
|
|
*/
|
2018-06-04 08:44:25 +00:00
|
|
|
int DrcOnCreatingTrack( TRACK* aRefSeg, TRACK* aList );
|
2007-11-27 22:49:35 +00:00
|
|
|
|
2008-02-23 04:54:06 +00:00
|
|
|
/**
|
2018-04-14 14:58:01 +00:00
|
|
|
* Function Drc
|
2011-09-23 13:57:12 +00:00
|
|
|
* tests the outline segment starting at CornerIndex and returns the result and displays
|
|
|
|
* the error in the status panel only if one exists.
|
2008-02-23 04:54:06 +00:00
|
|
|
* Test Edge inside other areas
|
|
|
|
* Test Edge too close other areas
|
2018-06-04 08:44:25 +00:00
|
|
|
* No marker created or added to the board. Must be used only during zone
|
|
|
|
* creation in legacy canvas
|
|
|
|
* @param aArea The area parent which contains the corner.
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aCornerIndex The starting point of the segment to test.
|
2008-02-23 04:54:06 +00:00
|
|
|
* @return int - BAD_DRC (1) if DRC error or OK_DRC (0) if OK
|
|
|
|
*/
|
2018-06-04 08:44:25 +00:00
|
|
|
int DrcOnCreatingZone( ZONE_CONTAINER* aArea, int aCornerIndex );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2018-06-04 08:44:25 +00:00
|
|
|
/**
|
2017-12-08 10:25:13 +00:00
|
|
|
* Tests whether distance between zones complies with the DRC rules.
|
|
|
|
*
|
|
|
|
* @param aZone: zone to compare with other zones, or if NULL then
|
|
|
|
* all zones are compared to all others.
|
2018-06-04 08:44:25 +00:00
|
|
|
* @param aCreateMarkers: if true create DRC markers.
|
|
|
|
* False: do not create markers. only fing drc errors
|
2017-12-08 10:25:13 +00:00
|
|
|
* @return Errors count
|
|
|
|
*/
|
|
|
|
int TestZoneToZoneOutline( ZONE_CONTAINER* aZone, bool aCreateMarkers );
|
2010-09-18 08:29:40 +00:00
|
|
|
|
2007-12-01 03:42:52 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Open a dialog and prompts the user, then if a test run button is
|
2007-12-03 05:14:51 +00:00
|
|
|
* clicked, runs the test(s) and creates the MARKERS. The dialog is only
|
|
|
|
* created if it is not already in existence.
|
2018-02-10 20:17:11 +00:00
|
|
|
*
|
2016-07-27 12:53:45 +00:00
|
|
|
* @param aParent is the parent window for wxWidgets. Usually the PCB editor frame
|
2018-04-08 10:28:59 +00:00
|
|
|
* but can be another dialog
|
2016-07-28 12:07:35 +00:00
|
|
|
* if aParent == NULL (default), the parent will be the PCB editor frame
|
|
|
|
* and the dialog will be not modal (just float on parent
|
|
|
|
* if aParent is specified, the dialog will be modal.
|
2018-04-08 10:28:59 +00:00
|
|
|
* The modal mode is mandatory if the dialog is created from another dialog, not
|
2016-07-28 12:07:35 +00:00
|
|
|
* from the PCB editor frame
|
2007-12-01 03:42:52 +00:00
|
|
|
*/
|
2016-07-28 12:07:35 +00:00
|
|
|
void ShowDRCDialog( wxWindow* aParent = NULL );
|
2007-12-03 05:14:51 +00:00
|
|
|
|
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Deletes this ui dialog box and zeros out its pointer to remember
|
2007-12-04 18:23:38 +00:00
|
|
|
* the state of the dialog's existence.
|
2018-02-10 20:17:11 +00:00
|
|
|
*
|
2007-12-04 18:23:38 +00:00
|
|
|
* @param aReason Indication of which button was clicked to cause the destruction.
|
2018-02-10 20:17:11 +00:00
|
|
|
* if aReason == wxID_OK, design parameters values which can be entered from the dialog
|
|
|
|
* will bbe saved in design parameters list
|
2007-12-03 05:14:51 +00:00
|
|
|
*/
|
2016-07-28 12:07:35 +00:00
|
|
|
void DestroyDRCDialog( int aReason );
|
2008-01-12 20:31:56 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2007-11-27 01:34:35 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Save all the UI or test settings and may be called before running the tests.
|
|
|
|
*
|
2007-11-27 01:34:35 +00:00
|
|
|
* @param aPad2PadTest Tells whether to test pad to pad distances.
|
|
|
|
* @param aUnconnectedTest Tells whether to list unconnected pads.
|
|
|
|
* @param aZonesTest Tells whether to test zones.
|
2018-02-10 20:17:11 +00:00
|
|
|
* @param aRefillZones Refill zones before performing DRC.
|
2012-09-12 17:28:55 +00:00
|
|
|
* @param aKeepoutTest Tells whether to test keepout areas.
|
2018-03-20 02:54:16 +00:00
|
|
|
* @param aReportAllTrackErrors Tells whether or not to stop checking track connections after the first error.
|
2007-12-01 03:42:52 +00:00
|
|
|
* @param aReportName A string telling the disk file report name entered.
|
2008-01-12 20:31:56 +00:00
|
|
|
* @param aSaveReport A boolean telling whether to generate disk file report.
|
2007-11-27 01:34:35 +00:00
|
|
|
*/
|
2008-01-12 20:31:56 +00:00
|
|
|
void SetSettings( bool aPad2PadTest, bool aUnconnectedTest,
|
2018-02-10 20:17:11 +00:00
|
|
|
bool aZonesTest, bool aKeepoutTest, bool aRefillZones,
|
2018-03-20 02:54:16 +00:00
|
|
|
bool aReportAllTrackErrors,
|
2012-07-13 18:55:29 +00:00
|
|
|
const wxString& aReportName, bool aSaveReport )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2017-03-16 17:09:33 +00:00
|
|
|
m_doPad2PadTest = aPad2PadTest;
|
|
|
|
m_doUnconnectedTest = aUnconnectedTest;
|
|
|
|
m_doZonesTest = aZonesTest;
|
|
|
|
m_doKeepoutTest = aKeepoutTest;
|
|
|
|
m_rptFilename = aReportName;
|
|
|
|
m_doCreateRptFile = aSaveReport;
|
2018-02-10 20:17:11 +00:00
|
|
|
m_refillZones = aRefillZones;
|
2018-06-04 08:44:25 +00:00
|
|
|
m_drcInLegacyRoutingMode = false;
|
2018-03-20 02:54:16 +00:00
|
|
|
m_reportAllTrackErrors = aReportAllTrackErrors;
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2010-09-18 08:29:40 +00:00
|
|
|
|
2007-12-01 05:37:44 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Run all the tests specified with a previous call to
|
2007-12-01 05:37:44 +00:00
|
|
|
* SetSettings()
|
2009-06-27 06:26:41 +00:00
|
|
|
* @param aMessages = a wxTextControl where to display some activity messages. Can be NULL
|
2007-12-01 05:37:44 +00:00
|
|
|
*/
|
2010-09-18 08:29:40 +00:00
|
|
|
void RunTests( wxTextCtrl* aMessages = NULL );
|
2007-12-01 03:42:52 +00:00
|
|
|
|
2007-12-03 05:14:51 +00:00
|
|
|
/**
|
2018-02-10 20:17:11 +00:00
|
|
|
* Gather a list of all the unconnected pads and shows them in the
|
2007-12-03 05:14:51 +00:00
|
|
|
* dialog, and optionally prints a report of such.
|
|
|
|
*/
|
2010-09-18 08:29:40 +00:00
|
|
|
void ListUnconnectedPads();
|
2011-06-09 13:30:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return a pointer to the current marker (last created marker
|
|
|
|
*/
|
|
|
|
MARKER_PCB* GetCurrentMarker( )
|
|
|
|
{
|
|
|
|
return m_currentMarker;
|
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
#endif // DRC_H
|