From 058108dd6def23ede2f39ca74c39e12e33b83200 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 1 May 2020 18:44:25 +0100 Subject: [PATCH] There are 3 courtyard DRC checks, not 2. --- pcbnew/CMakeLists.txt | 2 +- pcbnew/drc/drc.cpp | 13 ++--- pcbnew/drc/drc.h | 2 +- ...d_overlap.cpp => drc_courtyard_tester.cpp} | 51 ++++++++++--------- ...tyard_overlap.h => drc_courtyard_tester.h} | 6 +-- qa/pcbnew/drc/test_drc_courtyard_invalid.cpp | 4 +- qa/pcbnew/drc/test_drc_courtyard_overlap.cpp | 4 +- qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp | 6 +-- 8 files changed, 45 insertions(+), 43 deletions(-) rename pcbnew/drc/{courtyard_overlap.cpp => drc_courtyard_tester.cpp} (79%) rename pcbnew/drc/{courtyard_overlap.h => drc_courtyard_tester.h} (89%) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index a3c059f873..80adea70a6 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -229,7 +229,7 @@ set( PCBNEW_MICROWAVE_SRCS ) set( PCBNEW_DRC_SRCS - drc/courtyard_overlap.cpp + drc/drc_courtyard_tester.cpp drc/drc.cpp drc/drc_clearance_test_functions.cpp ) diff --git a/pcbnew/drc/drc.cpp b/pcbnew/drc/drc.cpp index ab8fa5e56e..6567cc886a 100644 --- a/pcbnew/drc/drc.cpp +++ b/pcbnew/drc/drc.cpp @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include DRC::DRC() : @@ -469,9 +469,10 @@ void DRC::RunTests( wxTextCtrl* aMessages ) testCopperTextAndGraphics(); - // find overlapping courtyard ares. + // test courtyards if( !m_pcb->GetDesignSettings().Ignore( DRCE_OVERLAPPING_FOOTPRINTS ) - && !m_pcb->GetDesignSettings().Ignore( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) ) + || !m_pcb->GetDesignSettings().Ignore( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) + || !m_pcb->GetDesignSettings().Ignore( DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT ) ) { if( aMessages ) { @@ -479,7 +480,7 @@ void DRC::RunTests( wxTextCtrl* aMessages ) aMessages->Refresh(); } - doOverlappingCourtyardsDrc(); + doCourtyardsDrc(); } for( DRC_ITEM* footprintItem : m_footprints ) @@ -1604,9 +1605,9 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, D_PAD** aStart, D_PAD** aEnd, int x_li } -void DRC::doOverlappingCourtyardsDrc() +void DRC::doCourtyardsDrc() { - DRC_COURTYARD_OVERLAP drc_overlap( [&]( MARKER_PCB* aMarker ) { addMarkerToPcb( aMarker ); } ); + DRC_COURTYARD_TESTER drc_overlap( [&]( MARKER_PCB* aMarker ) { addMarkerToPcb( aMarker ); } ); drc_overlap.RunDRC( *m_pcb ); } diff --git a/pcbnew/drc/drc.h b/pcbnew/drc/drc.h index b46e9f8280..ce2afb17ea 100644 --- a/pcbnew/drc/drc.h +++ b/pcbnew/drc/drc.h @@ -267,7 +267,7 @@ private: /** * Test for footprint courtyard overlaps. */ - void doOverlappingCourtyardsDrc(); + void doCourtyardsDrc(); //--------------------------------------------------- diff --git a/pcbnew/drc/courtyard_overlap.cpp b/pcbnew/drc/drc_courtyard_tester.cpp similarity index 79% rename from pcbnew/drc/courtyard_overlap.cpp rename to pcbnew/drc/drc_courtyard_tester.cpp index fb3f067fdf..3bdf451f98 100644 --- a/pcbnew/drc/courtyard_overlap.cpp +++ b/pcbnew/drc/drc_courtyard_tester.cpp @@ -1,13 +1,9 @@ -/** - * @file drc_marker_functions.cpp - */ - /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2010 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,7 +24,7 @@ */ -#include +#include #include #include @@ -47,13 +43,13 @@ static const wxChar* DRC_COURTYARD_TRACE = wxT( "KICAD_DRC_COURTYARD" ); -DRC_COURTYARD_OVERLAP::DRC_COURTYARD_OVERLAP( MARKER_HANDLER aMarkerHandler ) : +DRC_COURTYARD_TESTER::DRC_COURTYARD_TESTER( MARKER_HANDLER aMarkerHandler ) : DRC_TEST_PROVIDER( aMarkerHandler ) { } -bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const +bool DRC_COURTYARD_TESTER::RunDRC( BOARD& aBoard ) const { wxLogTrace( DRC_COURTYARD_TRACE, "Running DRC: Courtyard" ); @@ -65,26 +61,31 @@ bool DRC_COURTYARD_OVERLAP::RunDRC( BOARD& aBoard ) const // Update courtyard polygons, and test for missing courtyard definition: for( MODULE* footprint : aBoard.Modules() ) { - bool is_ok = footprint->BuildPolyCourtyard(); - - if( !is_ok && !aBoard.GetDesignSettings().Ignore( DRCE_OVERLAPPING_FOOTPRINTS ) ) + if( footprint->BuildPolyCourtyard() ) { - DRC_ITEM* drcItem = new DRC_ITEM( DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT ); - drcItem->SetItems( footprint ); - HandleMarker( new MARKER_PCB( drcItem, footprint->GetPosition() ) ); - success = false; + if( !aBoard.GetDesignSettings().Ignore( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) ) + { + int outlineCount = footprint->GetPolyCourtyardFront().OutlineCount() + + footprint->GetPolyCourtyardBack().OutlineCount(); + + if( outlineCount == 0 ) + { + DRC_ITEM* drcItem = new DRC_ITEM( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ); + drcItem->SetItems( footprint ); + HandleMarker( new MARKER_PCB( drcItem, footprint->GetPosition() ) ); + success = false; + } + } } - - if( aBoard.GetDesignSettings().Ignore( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ) ) - continue; - - if( footprint->GetPolyCourtyardFront().OutlineCount() == 0 - && footprint->GetPolyCourtyardBack().OutlineCount() == 0 && is_ok ) + else { - DRC_ITEM* drcItem = new DRC_ITEM( DRCE_MISSING_COURTYARD_IN_FOOTPRINT ); - drcItem->SetItems( footprint ); - HandleMarker( new MARKER_PCB( drcItem, footprint->GetPosition() ) ); - success = false; + if( !aBoard.GetDesignSettings().Ignore( DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT ) ) + { + DRC_ITEM* drcItem = new DRC_ITEM( DRCE_MALFORMED_COURTYARD_IN_FOOTPRINT ); + drcItem->SetItems( footprint ); + HandleMarker( new MARKER_PCB( drcItem, footprint->GetPosition() ) ); + success = false; + } } } diff --git a/pcbnew/drc/courtyard_overlap.h b/pcbnew/drc/drc_courtyard_tester.h similarity index 89% rename from pcbnew/drc/courtyard_overlap.h rename to pcbnew/drc/drc_courtyard_tester.h index fe00ce5270..908c9d89ba 100644 --- a/pcbnew/drc/courtyard_overlap.h +++ b/pcbnew/drc/drc_courtyard_tester.h @@ -32,12 +32,12 @@ /** * A class that provides the courtyard-based DRC checks. */ -class DRC_COURTYARD_OVERLAP : public DRC_TEST_PROVIDER +class DRC_COURTYARD_TESTER : public DRC_TEST_PROVIDER { public: - DRC_COURTYARD_OVERLAP( MARKER_HANDLER aMarkerHandler ); + DRC_COURTYARD_TESTER( MARKER_HANDLER aMarkerHandler ); - virtual ~DRC_COURTYARD_OVERLAP() {}; + virtual ~DRC_COURTYARD_TESTER() {}; bool RunDRC( BOARD& aBoard ) const override; }; diff --git a/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp b/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp index 4d62e8f25a..4cbeb2a00a 100644 --- a/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp +++ b/qa/pcbnew/drc/test_drc_courtyard_invalid.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include "../board_test_utils.h" @@ -307,7 +307,7 @@ void DoCourtyardInvalidTest( // list of markers to collect std::vector> markers; - DRC_COURTYARD_OVERLAP drc_overlap( + DRC_COURTYARD_TESTER drc_overlap( [&]( MARKER_PCB* aMarker ) { markers.push_back( std::unique_ptr( aMarker ) ); diff --git a/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp b/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp index 7a2388f306..d6b95f6d90 100644 --- a/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp +++ b/qa/pcbnew/drc/test_drc_courtyard_overlap.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include "../board_test_utils.h" @@ -473,7 +473,7 @@ static void DoCourtyardOverlapTest( // list of markers to collect std::vector> markers; - DRC_COURTYARD_OVERLAP drc_overlap( + DRC_COURTYARD_TESTER drc_overlap( [&]( MARKER_PCB* aMarker ) { markers.push_back( std::unique_ptr( aMarker ) ); diff --git a/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp b/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp index 8487266ac9..a23a7abf36 100644 --- a/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp +++ b/qa/pcbnew_tools/tools/drc_tool/drc_tool.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include @@ -169,7 +169,7 @@ private: std::unique_ptr createDrcProvider( BOARD& aBoard, DRC_TEST_PROVIDER::MARKER_HANDLER aHandler ) override { - return std::make_unique( aHandler ); + return std::make_unique( aHandler ); } }; @@ -206,7 +206,7 @@ private: std::unique_ptr createDrcProvider( BOARD& aBoard, DRC_TEST_PROVIDER::MARKER_HANDLER aHandler ) override { - return std::make_unique( aHandler ); + return std::make_unique( aHandler ); } };