From 814f65934fccf6dc583a496d361f4bd925b0fdee Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 10 Oct 2025 15:06:13 +0100 Subject: [PATCH] Improvements to DRC marker clearance paths. Reverts most of the fix for 9778. Highlighting multiple markers creates confusion in both the status bar and how the associated clearance paths are shown. Also adds more clearance path graphics to make the need for a fix to 9778 somewhat less acute. Also makes clearance graphics scale with marker. --- common/advanced_config.cpp | 2 - include/advanced_config.h | 9 - libs/kimath/src/geometry/shape_arc.cpp | 15 ++ .../src/geometry/shape_nearest_points.cpp | 13 +- pcbnew/CMakeLists.txt | 1 - pcbnew/dialogs/dialog_drc.cpp | 30 +-- pcbnew/drc/drc_cache_generator.h | 6 +- pcbnew/drc/drc_engine.cpp | 4 +- pcbnew/drc/drc_engine.h | 6 +- .../drc/drc_interactive_courtyard_clearance.h | 6 +- pcbnew/drc/drc_test_provider.cpp | 54 ++++- pcbnew/drc/drc_test_provider.h | 22 +- .../drc/drc_test_provider_annular_width.cpp | 217 ++++++++---------- .../drc/drc_test_provider_clearance_base.cpp | 99 -------- pcbnew/drc/drc_test_provider_clearance_base.h | 59 ----- .../drc_test_provider_connection_width.cpp | 10 +- .../drc_test_provider_copper_clearance.cpp | 135 ++++++----- .../drc_test_provider_courtyard_clearance.cpp | 26 +-- pcbnew/drc/drc_test_provider_creepage.cpp | 20 +- .../drc/drc_test_provider_edge_clearance.cpp | 18 +- pcbnew/drc/drc_test_provider_hole_size.cpp | 56 +++-- pcbnew/drc/drc_test_provider_hole_to_hole.cpp | 25 +- .../drc_test_provider_physical_clearance.cpp | 85 ++++--- .../drc/drc_test_provider_silk_clearance.cpp | 7 +- pcbnew/drc/drc_test_provider_solder_mask.cpp | 2 +- pcbnew/pcb_draw_panel_gal.cpp | 9 +- pcbnew/pcb_marker.cpp | 64 +++++- pcbnew/pcb_marker.h | 15 +- pcbnew/pcb_painter.cpp | 3 +- pcbnew/pcbnew_jobs_handler.cpp | 4 +- .../scripting/pcbnew_scripting_helpers.cpp | 2 +- pcbnew/tools/drc_tool.cpp | 6 +- .../drc/test_custom_rule_severities.cpp | 2 +- .../pcbnew/drc/test_drc_component_classes.cpp | 2 +- qa/tests/pcbnew/drc/test_drc_copper_conn.cpp | 2 +- .../pcbnew/drc/test_drc_copper_graphics.cpp | 2 +- .../pcbnew/drc/test_drc_copper_sliver.cpp | 2 +- .../pcbnew/drc/test_drc_courtyard_invalid.cpp | 2 +- .../pcbnew/drc/test_drc_courtyard_overlap.cpp | 2 +- .../drc/test_drc_incorrect_text_mirror.cpp | 2 +- qa/tests/pcbnew/drc/test_drc_lengths.cpp | 2 +- .../pcbnew/drc/test_drc_multi_netclasses.cpp | 2 +- qa/tests/pcbnew/drc/test_drc_orientation.cpp | 2 +- qa/tests/pcbnew/drc/test_drc_regressions.cpp | 4 +- qa/tests/pcbnew/drc/test_drc_skew.cpp | 2 +- .../pcbnew/drc/test_drc_starved_thermal.cpp | 2 +- qa/tests/pcbnew/drc/test_drc_via_dangling.cpp | 2 +- .../pcbnew/drc/test_solder_mask_bridging.cpp | 2 +- qa/tests/pcbnew/test_tracks_cleaner.cpp | 2 +- qa/tests/pcbnew/test_zone_filler.cpp | 6 +- qa/tools/drc_proto/drc_proto.cpp | 2 +- 51 files changed, 512 insertions(+), 562 deletions(-) delete mode 100644 pcbnew/drc/drc_test_provider_clearance_base.cpp delete mode 100644 pcbnew/drc/drc_test_provider_clearance_base.h diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index c3cfe86100..ba01fccae3 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -319,8 +319,6 @@ ADVANCED_CFG::ADVANCED_CFG() m_MaximumThreads = 0; - m_MinimumMarkerSeparationDistance = 0.15; - m_NetInspectorBulkUpdateOptimisationThreshold = 100; m_ExcludeFromSimulationLineWidth = 25; diff --git a/include/advanced_config.h b/include/advanced_config.h index a18639ac34..e2cc252dec 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -786,15 +786,6 @@ public: */ int m_MaximumThreads; - /** - * When finding overlapped marker a minium distance (in mm) between two DRC markers required - * to mark it as overlapped - * - * Setting name: "MinimumMarkerSeparationDistance" - * Default value: 0.15 - */ - double m_MinimumMarkerSeparationDistance; - /** * When updating the net inspector, it either recalculates all nets or iterates through items * one-by-one. This value controls the threshold at which all nets are recalculated rather than diff --git a/libs/kimath/src/geometry/shape_arc.cpp b/libs/kimath/src/geometry/shape_arc.cpp index f7b443a563..d09c2d7970 100644 --- a/libs/kimath/src/geometry/shape_arc.cpp +++ b/libs/kimath/src/geometry/shape_arc.cpp @@ -564,6 +564,10 @@ bool SHAPE_ARC::NearestPoints( const SEG& aSeg, VECTOR2I& aPtA, VECTOR2I& aPtB, } } + // Adjust point A by half the arc width towards point B + VECTOR2I dir = ( aPtB - aPtA ).Resize( GetWidth() / 2 ); + aPtA += dir; + return true; } @@ -625,6 +629,10 @@ bool SHAPE_ARC::NearestPoints( const SHAPE_RECT& aRect, VECTOR2I& aPtA, VECTOR2I } } + // Adjust point A by half the arc-width towards point B + VECTOR2I dir = ( aPtB - aPtA ).Resize( GetWidth() / 2 ); + aPtA += dir; + return true; } @@ -762,6 +770,13 @@ bool SHAPE_ARC::NearestPoints( const SHAPE_ARC& aArc, VECTOR2I& aPtA, VECTOR2I& } } + // Adjust point A by half the arc-width towards point B + VECTOR2I dir = ( aPtB - aPtA ).Resize( GetWidth() / 2 ); + aPtA += dir; + // Adjust point B by half the other arc-width towards point A + dir = ( aPtA - aPtB ).Resize( aArc.GetWidth() / 2 ); + aPtB += dir; + return true; } diff --git a/libs/kimath/src/geometry/shape_nearest_points.cpp b/libs/kimath/src/geometry/shape_nearest_points.cpp index 1e8c3e3534..ff5e4e0c4b 100644 --- a/libs/kimath/src/geometry/shape_nearest_points.cpp +++ b/libs/kimath/src/geometry/shape_nearest_points.cpp @@ -63,9 +63,8 @@ static bool NearestPoints( const SHAPE_CIRCLE& aA, const SHAPE_CIRCLE& aB, else { // Points lie on line between centers - VECTOR2I dir = delta.Resize( 1 ); - aPtA = aA.GetCenter() + dir.Resize( aA.GetRadius() ); - aPtB = aB.GetCenter() - dir.Resize( aB.GetRadius() ); + aPtA = aA.GetCenter() + delta.Resize( aA.GetRadius() ); + aPtB = aB.GetCenter() - delta.Resize( aB.GetRadius() ); } return true; @@ -450,7 +449,13 @@ static bool NearestPoints( const SHAPE_ARC& aArc, const SHAPE_RECT& aRect, VECTO static bool NearestPoints( const SHAPE_ARC& aArc, const SHAPE_SEGMENT& aSeg, VECTOR2I& aPtA, VECTOR2I& aPtB ) { int64_t distSq; - return aArc.NearestPoints( aSeg.GetSeg(), aPtA, aPtB, distSq ); + bool retVal = aArc.NearestPoints( aSeg.GetSeg(), aPtA, aPtB, distSq ); + + // Adjust point B by half the seg width towards point A + VECTOR2I dir = ( aPtA - aPtB ).Resize( aSeg.GetWidth() / 2 ); + aPtB += dir; + + return retVal; } static bool NearestPoints( const SHAPE_ARC& aArcA, const SHAPE_ARC& aArcB, VECTOR2I& aPtA, VECTOR2I& aPtB ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index afe598f832..2de0cb4add 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -274,7 +274,6 @@ set( PCBNEW_DRC_SRCS drc/drc_test_provider.cpp drc/drc_test_provider_annular_width.cpp drc/drc_test_provider_disallow.cpp - drc/drc_test_provider_clearance_base.cpp drc/drc_test_provider_creepage.cpp drc/drc_test_provider_connectivity.cpp drc/drc_test_provider_connection_width.cpp diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 8e1bd1cabe..929ca39727 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -56,7 +56,6 @@ #include #include #include -#include // wxWidgets spends *far* too long calcuating column widths (most of it, believe it or // not, in repeatedly creating/destroying a wxDC to do the measurement in). @@ -491,17 +490,6 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent ) } }; - auto isOverlapping = - []( BOARD_ITEM* aSelectedMarkerItem, BOARD_ITEM* aUnSelectedMarkerItem ) -> bool - { - VECTOR2D selectedItemPos = aSelectedMarkerItem->GetPosition() / PCB_IU_PER_MM; - VECTOR2D unSelectedItemPos = aUnSelectedMarkerItem->GetPosition() / PCB_IU_PER_MM; - double dist = selectedItemPos.Distance( unSelectedItemPos ); - double minimumMarkerSeparationDistance = ADVANCED_CFG::GetCfg().m_MinimumMarkerSeparationDistance; - - return dist <= minimumMarkerSeparationDistance; - }; - if( !node ) { // list is being freed; don't do anything with null ptrs @@ -668,23 +656,7 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent ) } else { - if( item->Type() == PCB_MARKER_T ) - { - std::vector items; - - for( BOARD_ITEM* boardMarkerItem : board->Markers() ) - { - if( item->m_Uuid != boardMarkerItem->m_Uuid && isOverlapping( item, boardMarkerItem ) ) - items.push_back( boardMarkerItem ); - } - - items.push_back( item ); - m_frame->FocusOnItems( items, principalLayer, m_scroll_on_crossprobe ); - } - else - { - m_frame->FocusOnItem( item, principalLayer, m_scroll_on_crossprobe ); - } + m_frame->FocusOnItem( item, principalLayer, m_scroll_on_crossprobe ); } aEvent.Skip(); diff --git a/pcbnew/drc/drc_cache_generator.h b/pcbnew/drc/drc_cache_generator.h index 8fbd451edb..9888013de2 100644 --- a/pcbnew/drc/drc_cache_generator.h +++ b/pcbnew/drc/drc_cache_generator.h @@ -26,14 +26,14 @@ #pragma once -#include +#include -class DRC_CACHE_GENERATOR : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_CACHE_GENERATOR : public DRC_TEST_PROVIDER { public: DRC_CACHE_GENERATOR() : - DRC_TEST_PROVIDER_CLEARANCE_BASE() + DRC_TEST_PROVIDER() {} virtual ~DRC_CACHE_GENERATOR() = default; diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 6a830833c2..5fed91caa7 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -1796,7 +1796,7 @@ bool DRC_ENGINE::IsErrorLimitExceeded( int error_code ) void DRC_ENGINE::ReportViolation( const std::shared_ptr& aItem, const VECTOR2I& aPos, - int aMarkerLayer, const std::vector& aShapes ) + int aMarkerLayer, const std::function& aPathGenerator ) { static std::mutex globalLock; @@ -1805,7 +1805,7 @@ void DRC_ENGINE::ReportViolation( const std::shared_ptr& aItem, const if( m_violationHandler ) { std::lock_guard guard( globalLock ); - m_violationHandler( aItem, aPos, aMarkerLayer, aShapes ); + m_violationHandler( aItem, aPos, aMarkerLayer, aPathGenerator ); } if( m_logReporter ) diff --git a/pcbnew/drc/drc_engine.h b/pcbnew/drc/drc_engine.h index 8b5005c240..b1f32188c9 100644 --- a/pcbnew/drc/drc_engine.h +++ b/pcbnew/drc/drc_engine.h @@ -36,7 +36,6 @@ class BOARD_COMMIT; class BOARD_DESIGN_SETTINGS; class DRC_TEST_PROVIDER; -class DRC_TEST_PROVIDER_CLEARANCE_BASE; class DRC_TEST_PROVIDER_CREEPAGE; class PCB_EDIT_FRAME; class DS_PROXY_VIEW_ITEM; @@ -68,7 +67,7 @@ class DRC_CONSTRAINT; typedef std::function& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes )> DRC_VIOLATION_HANDLER; + const std::function& aPathGenerator )> DRC_VIOLATION_HANDLER; /** * Design Rule Checker object that performs all the DRC tests. @@ -83,7 +82,6 @@ typedef std::function& aItem, class DRC_ENGINE : public UNITS_PROVIDER { // They need to change / restore the violation handler - friend class DRC_TEST_PROVIDER_CLEARANCE_BASE; friend class DRC_TEST_PROVIDER_CREEPAGE; public: @@ -176,7 +174,7 @@ public: bool RulesValid() { return m_rulesValid; } void ReportViolation( const std::shared_ptr& aItem, const VECTOR2I& aPos, - int aMarkerLayer, const std::vector& aShapes = {} ); + int aMarkerLayer, const std::function& aPathGenerator = {} ); bool KeepRefreshing( bool aWait = false ); void AdvanceProgress(); diff --git a/pcbnew/drc/drc_interactive_courtyard_clearance.h b/pcbnew/drc/drc_interactive_courtyard_clearance.h index 02555d571d..ffb4e4cbbc 100644 --- a/pcbnew/drc/drc_interactive_courtyard_clearance.h +++ b/pcbnew/drc/drc_interactive_courtyard_clearance.h @@ -25,14 +25,14 @@ #pragma once -#include +#include -class DRC_INTERACTIVE_COURTYARD_CLEARANCE : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_INTERACTIVE_COURTYARD_CLEARANCE : public DRC_TEST_PROVIDER { public: DRC_INTERACTIVE_COURTYARD_CLEARANCE( const std::shared_ptr& aDRCEngine ) : - DRC_TEST_PROVIDER_CLEARANCE_BASE(), + DRC_TEST_PROVIDER(), m_largestCourtyardClearance( 0 ) { m_isRuleDriven = false; diff --git a/pcbnew/drc/drc_test_provider.cpp b/pcbnew/drc/drc_test_provider.cpp index b133cf43f6..0f07e3a8a2 100644 --- a/pcbnew/drc/drc_test_provider.cpp +++ b/pcbnew/drc/drc_test_provider.cpp @@ -45,7 +45,8 @@ DRC_TEST_PROVIDER_REGISTRY::~DRC_TEST_PROVIDER_REGISTRY() DRC_TEST_PROVIDER::DRC_TEST_PROVIDER() : UNITS_PROVIDER( pcbIUScale, EDA_UNITS::MM ), - m_drcEngine( nullptr ) + m_drcEngine( nullptr ), + m_board( nullptr ) { } @@ -73,10 +74,57 @@ const wxString DRC_TEST_PROVIDER::GetName() const { return wxT( "" void DRC_TEST_PROVIDER::reportViolation( std::shared_ptr& item, const VECTOR2I& aMarkerPos, int aMarkerLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { item->SetViolatingTest( this ); - m_drcEngine->ReportViolation( item, aMarkerPos, aMarkerLayer, aShapes ); + m_drcEngine->ReportViolation( item, aMarkerPos, aMarkerLayer, aPathGenerator ); +} + + +void DRC_TEST_PROVIDER::reportTwoPointGeometry( std::shared_ptr& aDrcItem, const VECTOR2I& aMarkerPos, + const VECTOR2I& ptA, const VECTOR2I& ptB, PCB_LAYER_ID aLayer ) +{ + PCB_SHAPE ptAShape( nullptr, SHAPE_T::SEGMENT ); + ptAShape.SetStart( ptA ); + ptAShape.SetEnd( ptB ); + + reportViolation( aDrcItem, aMarkerPos, aLayer, + [&]( PCB_MARKER* aMarker ) + { + aMarker->SetPath( { ptAShape }, ptA, ptB ); + } ); +} + + +void DRC_TEST_PROVIDER::reportTwoShapeGeometry( std::shared_ptr& aDrcItem, const VECTOR2I& aMarkerPos, + const SHAPE* aShape1, const SHAPE* aShape2, PCB_LAYER_ID aLayer, + int aDistance ) +{ + VECTOR2I ptA, ptB; + + if( aDistance == 0 ) + { + reportTwoPointGeometry( aDrcItem, aMarkerPos, aMarkerPos, aMarkerPos, aLayer ); + } + else if( aShape1->NearestPoints( aShape2, ptA, ptB ) ) + { + reportTwoPointGeometry( aDrcItem, aMarkerPos, ptA, ptB, aLayer ); + } + else + { + reportViolation( aDrcItem, aMarkerPos, aLayer ); + } +} + + +void DRC_TEST_PROVIDER::reportTwoItemGeometry( std::shared_ptr& aDrcItem, const VECTOR2I& aMarkerPos, + const BOARD_ITEM* aItem1, const BOARD_ITEM* aItem2, + PCB_LAYER_ID aLayer, int aDistance ) +{ + std::shared_ptr aShape1 = aItem1->GetEffectiveShape( aLayer ); + std::shared_ptr aShape2 = aItem2->GetEffectiveShape( aLayer ); + + reportTwoShapeGeometry( aDrcItem, aMarkerPos, aShape1.get(), aShape2.get(), aLayer, aDistance ); } diff --git a/pcbnew/drc/drc_test_provider.h b/pcbnew/drc/drc_test_provider.h index a337ddd8ba..faa30c0f90 100644 --- a/pcbnew/drc/drc_test_provider.h +++ b/pcbnew/drc/drc_test_provider.h @@ -106,15 +106,28 @@ protected: #define REPORT_AUX( s ) if( getLogReporter() ) getLogReporter()->Report( s, RPT_SEVERITY_INFO ) - virtual void reportViolation( std::shared_ptr& item, const VECTOR2I& aMarkerPos, - int aMarkerLayer, const std::vector& aShapes = {} ); + void reportViolation( std::shared_ptr& item, const VECTOR2I& aMarkerPos, + int aMarkerLayer, + const std::function& aPathGenerator = []( PCB_MARKER* ){} ); + + void reportTwoPointGeometry( std::shared_ptr& aDrcItem, const VECTOR2I& aMarkerPos, + const VECTOR2I& ptA, const VECTOR2I& ptB, PCB_LAYER_ID aLayer ); + + void reportTwoShapeGeometry( std::shared_ptr& aDrcItem, const VECTOR2I& aMarkerPos, + const SHAPE* aShape1, const SHAPE* aShape2, PCB_LAYER_ID aLayer, + int aDistance ); + + void reportTwoItemGeometry( std::shared_ptr& aDrcItem, const VECTOR2I& aMarkerPos, + const BOARD_ITEM* aItem1, const BOARD_ITEM* aItem2, PCB_LAYER_ID aLayer, + int aDistance ); + virtual bool reportProgress( size_t aCount, size_t aSize, size_t aDelta = 1 ); virtual bool reportPhase( const wxString& aStageName ); bool isInvisibleText( const BOARD_ITEM* aItem ) const; - wxString formatMsg( const wxString& aFormatString, const wxString& aSource, double aConstraint, double aActual, - EDA_DATA_TYPE aDataType = EDA_DATA_TYPE::DISTANCE ); + wxString formatMsg( const wxString& aFormatString, const wxString& aSource, double aConstraint, + double aActual, EDA_DATA_TYPE aDataType = EDA_DATA_TYPE::DISTANCE ); wxString formatMsg( const wxString& aFormatString, const wxString& aSource, const EDA_ANGLE& aConstraint, const EDA_ANGLE& aActual ); @@ -124,5 +137,6 @@ protected: protected: DRC_ENGINE* m_drcEngine; + BOARD* m_board; bool m_isRuleDriven = true; }; diff --git a/pcbnew/drc/drc_test_provider_annular_width.cpp b/pcbnew/drc/drc_test_provider_annular_width.cpp index ba7688022a..693d4e2add 100644 --- a/pcbnew/drc/drc_test_provider_annular_width.cpp +++ b/pcbnew/drc/drc_test_provider_annular_width.cpp @@ -129,44 +129,42 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() } }; - auto checkPadAnnularWidth = + auto getPadAnnulusPts = []( PAD* pad, PCB_LAYER_ID aLayer, DRC_CONSTRAINT& constraint, - const std::vector& sameNumPads, - int* aMinAnnularWidth, int* aMaxAnnularWidth ) + const std::vector& sameNumPads, VECTOR2I* ptA, VECTOR2I* ptB ) { - int annularWidth = 0; bool handled = false; if( pad->GetOffset( aLayer ) == VECTOR2I( 0, 0 ) ) { - VECTOR2I padSize = pad->GetSize( aLayer ); + int xDist = KiROUND( ( pad->GetSizeX() - pad->GetDrillSizeX() ) / 2.0 ); + int yDist = KiROUND( ( pad->GetSizeY() - pad->GetDrillSizeY() ) / 2.0 ); + + if( yDist < xDist ) + { + *ptA = pad->GetPosition() - VECTOR2I( 0, pad->GetDrillSizeY() / 2 ); + *ptB = pad->GetPosition() - VECTOR2I( 0, pad->GetSizeY() / 2 ); + } + else + { + *ptA = pad->GetPosition() - VECTOR2I( pad->GetDrillSizeX() / 2, 0 ); + *ptB = pad->GetPosition() - VECTOR2I( pad->GetSizeX() / 2, 0 ); + } + + RotatePoint( *ptA, pad->GetPosition(), pad->GetOrientation() ); + RotatePoint( *ptB, pad->GetPosition(), pad->GetOrientation() ); switch( pad->GetShape( aLayer ) ) { - case PAD_SHAPE::CIRCLE: - annularWidth = ( padSize.x - pad->GetDrillSizeX() ) / 2; - - // If there are more pads with the same number then we'll still need to - // run the more generalised checks below. - handled = sameNumPads.empty(); - + case PAD_SHAPE::CHAMFERED_RECT: + handled = pad->GetChamferRectRatio( aLayer ) <= 0.30; break; - case PAD_SHAPE::CHAMFERED_RECT: - if( pad->GetChamferRectRatio( aLayer ) > 0.30 ) - break; - - KI_FALLTHROUGH; - + case PAD_SHAPE::CIRCLE: case PAD_SHAPE::OVAL: case PAD_SHAPE::RECTANGLE: case PAD_SHAPE::ROUNDRECT: - annularWidth = std::min( padSize.x - pad->GetDrillSizeX(), - padSize.y - pad->GetDrillSizeY() ) / 2; - - // If there are more pads with the same number then we'll still need to - // run the more generalised checks below. - handled = sameNumPads.empty(); + handled = true; break; @@ -175,10 +173,9 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() } } - if( !handled ) + if( !handled || !sameNumPads.empty() ) { // Slow (but general purpose) method. - SEG::ecoord dist_sq; SHAPE_POLY_SET padOutline; std::shared_ptr slot = pad->GetEffectiveHoleShape(); @@ -189,19 +186,15 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() if( !padOutline.Collide( pad->GetPosition() ) ) { // Hole outside pad - annularWidth = 0; + *ptA = pad->GetPosition(); + *ptB = pad->GetPosition(); } else { - // Disable is-inside test in SquaredDistance - padOutline.Outline( 0 ).SetClosed( false ); - - dist_sq = padOutline.SquaredDistanceToSeg( slot->GetSeg() ); - annularWidth = sqrt( dist_sq ) - slot->GetWidth() / 2; + padOutline.NearestPoints( slot.get(), *ptA, *ptB ); } } - else if( constraint.Value().HasMin() - && ( annularWidth < constraint.Value().Min() ) ) + else if( constraint.Value().HasMin() ) { SHAPE_POLY_SET aggregatePadOutline = padOutline; SHAPE_POLY_SET otherPadHoles; @@ -212,8 +205,8 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() for( const PAD* sameNumPad : sameNumPads ) { // Construct the full pad with outline and hole. - sameNumPad->TransformShapeToPolygon( aggregatePadOutline, PADSTACK::ALL_LAYERS, - 0, pad->GetMaxError(), ERROR_OUTSIDE ); + sameNumPad->TransformShapeToPolygon( aggregatePadOutline, aLayer, 0, + pad->GetMaxError(), ERROR_OUTSIDE ); sameNumPad->TransformHoleToPolygon( otherPadHoles, 0, pad->GetMaxError(), ERROR_INSIDE ); @@ -224,22 +217,68 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() if( !aggregatePadOutline.Collide( pad->GetPosition() ) ) { // Hole outside pad - annularWidth = 0; + *ptA = pad->GetPosition(); + *ptB = pad->GetPosition(); } else { - // Disable is-inside test in SquaredDistance - for( int ii = 0; ii < aggregatePadOutline.OutlineCount(); ++ii ) - aggregatePadOutline.Outline( ii ).SetClosed( false ); - - dist_sq = aggregatePadOutline.SquaredDistanceToSeg( slot->GetSeg() ); - annularWidth = sqrt( dist_sq ) - slot->GetWidth() / 2; + aggregatePadOutline.NearestPoints( slot.get(), *ptA, *ptB ); } } } + }; - *aMaxAnnularWidth = std::max( *aMaxAnnularWidth, annularWidth ); - *aMinAnnularWidth = std::min( *aMinAnnularWidth, annularWidth ); + auto checkConstraint = + [&]( DRC_CONSTRAINT& constraint, BOARD_ITEM* item, const VECTOR2I& ptA, const VECTOR2I& ptB, + PCB_LAYER_ID aLayer ) + { + if( constraint.GetSeverity() == RPT_SEVERITY_IGNORE ) + return; + + int v_min = 0; + int v_max = 0; + bool fail_min = false; + bool fail_max = false; + int width = ( ptA - ptB ).EuclideanNorm(); + + if( constraint.Value().HasMin() ) + { + v_min = constraint.Value().Min(); + fail_min = width < v_min; + } + + if( constraint.Value().HasMax() ) + { + v_max = constraint.Value().Max(); + fail_max = width > v_max; + } + + if( fail_min || fail_max ) + { + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_ANNULAR_WIDTH ); + wxString msg; + + if( fail_min ) + { + msg = formatMsg( _( "(%s min annular width %s; actual %s)" ), + constraint.GetName(), + v_min, + width ); + } + + if( fail_max ) + { + msg = formatMsg( _( "(%s max annular width %s; actual %s)" ), + constraint.GetName(), + v_max, + width ); + } + + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( item ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoPointGeometry( drcItem, item->GetPosition(), ptA, ptB, aLayer ); + } }; auto checkAnnularWidth = @@ -248,34 +287,22 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() if( m_drcEngine->IsErrorLimitExceeded( DRCE_ANNULAR_WIDTH ) ) return false; - auto constraint = m_drcEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, item, nullptr, - UNDEFINED_LAYER ); - - int minAnnularWidth = INT_MAX; - int maxAnnularWidth = 0; - int v_min = 0; - int v_max = 0; - bool fail_min = false; - bool fail_max = false; - - switch( item->Type() ) - { - case PCB_VIA_T: + if( item->Type() == PCB_VIA_T ) { PCB_VIA* via = static_cast( item ); - int drill = via->GetDrillValue(); via->Padstack().ForEachUniqueLayer( [&]( PCB_LAYER_ID aLayer ) { - int layerWidth = ( via->GetWidth( aLayer ) - drill ) / 2; - minAnnularWidth = std::min( minAnnularWidth, layerWidth ); - maxAnnularWidth = std::max( maxAnnularWidth, layerWidth ); - } ); - break; - } + auto constraint = m_drcEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, item, + nullptr, aLayer ); - case PCB_PAD_T: + VECTOR2I ptA = via->GetPosition() - VECTOR2I( via->GetDrillValue() / 2, 0 ); + VECTOR2I ptB = via->GetPosition() - VECTOR2I( via->GetWidth( aLayer ) / 2, 0 ); + checkConstraint( constraint, via, ptA, ptB, aLayer ); + } ); + } + else if( item->Type() == PCB_PAD_T ) { PAD* pad = static_cast( item ); @@ -290,58 +317,14 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() pad->Padstack().ForEachUniqueLayer( [&]( PCB_LAYER_ID aLayer ) { - checkPadAnnularWidth( pad, aLayer, constraint, sameNumPads, - &minAnnularWidth, &maxAnnularWidth ); + auto constraint = m_drcEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, item, + nullptr, aLayer ); + + VECTOR2I ptA; + VECTOR2I ptB; + getPadAnnulusPts( pad, aLayer, constraint, sameNumPads, &ptA, &ptB ); + checkConstraint( constraint, pad, ptA, ptB, aLayer ); } ); - - break; - } - - default: - return true; - } - - if( constraint.GetSeverity() == RPT_SEVERITY_IGNORE ) - return true; - - if( constraint.Value().HasMin() ) - { - v_min = constraint.Value().Min(); - fail_min = minAnnularWidth < v_min; - } - - if( constraint.Value().HasMax() ) - { - v_max = constraint.Value().Max(); - fail_max = maxAnnularWidth > v_max; - } - - if( fail_min || fail_max ) - { - std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_ANNULAR_WIDTH ); - wxString msg; - - if( fail_min ) - { - msg = formatMsg( _( "(%s min annular width %s; actual %s)" ), - constraint.GetName(), - v_min, - minAnnularWidth ); - } - - if( fail_max ) - { - msg = formatMsg( _( "(%s max annular width %s; actual %s)" ), - constraint.GetName(), - v_max, - maxAnnularWidth ); - } - - drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); - drcItem->SetItems( item ); - drcItem->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drcItem, item->GetPosition(), item->GetLayer() ); } return true; diff --git a/pcbnew/drc/drc_test_provider_clearance_base.cpp b/pcbnew/drc/drc_test_provider_clearance_base.cpp deleted file mode 100644 index 7e5170c274..0000000000 --- a/pcbnew/drc/drc_test_provider_clearance_base.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com - * Copyright The 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 - * 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 - */ - -#include -#include - - -std::vector DRC_TEST_PROVIDER_CLEARANCE_BASE::GetShapes( const std::vector& aShapes, - const VECTOR2I& aStart, const VECTOR2I& aEnd, - int aLength ) -{ - STROKE_PARAMS hairline( 1.0 ); // Segments of width 1.0 will get drawn as lines by PCB_PAINTER - std::vector shortestPathShapes; - - // Add the path - for( PCB_SHAPE shape : aShapes ) - { - shape.SetStroke( hairline ); - shortestPathShapes.push_back( std::move( shape ) ); - } - - // Draw perpendicular begin/end stops - if( shortestPathShapes.size() > 0 ) - { - VECTOR2I V1 = shortestPathShapes[0].GetStart() - shortestPathShapes[0].GetEnd(); - VECTOR2I V2 = shortestPathShapes.back().GetStart() - shortestPathShapes.back().GetEnd(); - V1 = V1.Perpendicular().Resize( std::max( aLength / 24, pcbIUScale.mmToIU( 0.05 ) ) ); - V2 = V2.Perpendicular().Resize( std::max( aLength / 24, pcbIUScale.mmToIU( 0.05 ) ) ); - - PCB_SHAPE s( nullptr, SHAPE_T::SEGMENT ); - s.SetStroke( hairline ); - - s.SetStart( aStart + V1 ); - s.SetEnd( aStart - V1 ); - shortestPathShapes.push_back( s ); - - s.SetStart( aEnd + V2 ); - s.SetEnd( aEnd - V2 ); - shortestPathShapes.push_back( s ); - } - - // Add shaded areas - for( PCB_SHAPE shape : aShapes ) - { - shape.SetWidth( std::max( aLength / 10, pcbIUScale.mmToIU( 0.2 ) ) ); - shortestPathShapes.push_back( std::move( shape ) ); - } - - return shortestPathShapes; -} - - -void DRC_TEST_PROVIDER_CLEARANCE_BASE::ReportAndShowPathCuToCu( std::shared_ptr& aDrce, - const VECTOR2I& aMarkerPos, - int aMarkerLayer, - const BOARD_ITEM* aItem1, - const BOARD_ITEM* aItem2, - PCB_LAYER_ID layer, int aDistance ) -{ - std::shared_ptr aShape1 = aItem1->GetEffectiveShape( layer ); - std::shared_ptr aShape2 = aItem2->GetEffectiveShape( layer ); - - VECTOR2I ptA, ptB; - - // Don't try showing graphics if we don't have a GUI instance - if( wxApp::GetGUIInstance() && aShape1->NearestPoints( aShape2.get(), ptA, ptB ) ) - { - PCB_SHAPE ptAShape( nullptr, SHAPE_T::SEGMENT ); - ptAShape.SetStart( ptA ); - ptAShape.SetEnd( ptB ); - reportViolation( aDrce, aMarkerPos, aMarkerLayer, GetShapes( { ptAShape }, ptA, ptB, aDistance ) ); - } - else - { - reportViolation( aDrce, aMarkerPos, aMarkerLayer ); - } -} diff --git a/pcbnew/drc/drc_test_provider_clearance_base.h b/pcbnew/drc/drc_test_provider_clearance_base.h deleted file mode 100644 index 0fe7e27719..0000000000 --- a/pcbnew/drc/drc_test_provider_clearance_base.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2004-2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com - * Copyright The 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 - * 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 - */ - - -#pragma once - -#include -#include -#include -#include -#include - -class BOARD; - - -class DRC_TEST_PROVIDER_CLEARANCE_BASE : public DRC_TEST_PROVIDER -{ -public: - DRC_TEST_PROVIDER_CLEARANCE_BASE () : - DRC_TEST_PROVIDER(), - m_board( nullptr ), - m_boardOutlineValid( false ) - {} - - virtual ~DRC_TEST_PROVIDER_CLEARANCE_BASE() = default; - -protected: - BOARD* m_board; - bool m_boardOutlineValid; - - void ReportAndShowPathCuToCu( std::shared_ptr& aDrce, const VECTOR2I& aMarkerPos, - int aMarkerLayer, const BOARD_ITEM* aItem1, - const BOARD_ITEM* aItem2, PCB_LAYER_ID layer, int aDistance ); - - std::vector GetShapes( const std::vector& aShapes, const VECTOR2I& aStart, - const VECTOR2I& aEnd, int aLength ); -}; diff --git a/pcbnew/drc/drc_test_provider_connection_width.cpp b/pcbnew/drc/drc_test_provider_connection_width.cpp index 81ead78780..14afb75035 100644 --- a/pcbnew/drc/drc_test_provider_connection_width.cpp +++ b/pcbnew/drc/drc_test_provider_connection_width.cpp @@ -444,7 +444,7 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run() if( c.Value().Min() == aMinWidth ) { - auto drce = DRC_ITEM::Create( DRCE_CONNECTION_WIDTH ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CONNECTION_WIDTH ); wxString msg; msg = formatMsg( _( "(%s minimum connection width %s; actual %s)" ), @@ -454,13 +454,13 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run() msg += wxS( " " ) + layerDesc( aLayer ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetViolatingRule( c.GetParentRule() ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetViolatingRule( c.GetParentRule() ); for( BOARD_ITEM* item : contributingItems ) - drce->AddItem( item ); + drcItem->AddItem( item ); - reportViolation( drce, location, aLayer ); + reportTwoPointGeometry( drcItem, location, span.A, span.B, aLayer ); } } } diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index a09b67b034..ed6cc203e6 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -57,11 +57,11 @@ - DRCE_SHORTING_ITEMS */ -class DRC_TEST_PROVIDER_COPPER_CLEARANCE : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_TEST_PROVIDER_COPPER_CLEARANCE : public DRC_TEST_PROVIDER { public: DRC_TEST_PROVIDER_COPPER_CLEARANCE () : - DRC_TEST_PROVIDER_CLEARANCE_BASE(), + DRC_TEST_PROVIDER(), m_drcEpsilon( 0 ) {} @@ -245,9 +245,7 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testSingleLayerItemAgainstItem( BOARD_I std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_TRACKS_CROSSING ); drcItem->SetItems( item, other ); drcItem->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drcItem, *intersection, layer ); - + reportTwoPointGeometry( drcItem, *intersection, *intersection, *intersection, layer ); return false; } } @@ -261,17 +259,16 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testSingleLayerItemAgainstItem( BOARD_I } else if( actual == 0 && otherNet && testShorting ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); wxString msg; msg.Printf( _( "(nets %s and %s)" ), net ? net->GetNetname() : _( "" ), otherNet ? otherNet->GetNetname() : _( "" ) ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( item, other ); - - reportViolation( drce, pos, layer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( item, other ); + reportTwoPointGeometry( drcItem, pos, pos, pos, layer ); has_error = true; if( !m_drcEngine->GetReportAllTrackErrors() ) @@ -279,17 +276,16 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testSingleLayerItemAgainstItem( BOARD_I } else if( testClearance ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( item, other ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - ReportAndShowPathCuToCu( drce, pos, layer, item, other, layer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( item, other ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoShapeGeometry( drcItem, pos, itemShape, otherShape, layer, actual ); has_error = true; if( !m_drcEngine->GetReportAllTrackErrors() ) @@ -333,18 +329,17 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testSingleLayerItemAgainstItem( BOARD_I if( a_shape[ii]->Collide( holeShape.get(), std::max( 0, clearance - m_drcEpsilon ), &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); wxString msg = formatMsg( clearance ? _( "(%s clearance %s; actual %s)" ) : _( "(%s clearance %s; actual < 0)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( a[ii], b[ii] ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - ReportAndShowPathCuToCu( drce, pos, layer, a[ii], b[ii], layer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( a[ii], b[ii] ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoShapeGeometry( drcItem, pos, a_shape[ii], holeShape.get(), layer, actual ); return false; } } @@ -451,16 +446,16 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem, if( zoneTree->QueryColliding( itemBBox, itemShape.get(), aLayer, std::max( 0, clearance - m_drcEpsilon ), &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, aZone ); - drce->SetViolatingRule( constraint.GetParentRule() ); - ReportAndShowPathCuToCu( drce, pos, aLayer, aItem, aZone, aLayer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, aZone ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoItemGeometry( drcItem, pos, aItem, aZone, aLayer, actual ); } } @@ -489,16 +484,18 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem, std::max( 0, clearance - m_drcEpsilon ), &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, aZone ); - drce->SetViolatingRule( constraint.GetParentRule() ); - ReportAndShowPathCuToCu( drce, pos, aLayer, aItem, aZone, aLayer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, aZone ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + + std::shared_ptr zoneShape = aZone->GetEffectiveShape( aLayer ); + reportTwoShapeGeometry( drcItem, pos, holeShape.get(), zoneShape.get(), aLayer, actual ); } } } @@ -560,29 +557,29 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testKnockoutTextAgainstZone( BOARD_ITEM if( zoneTree->QueryColliding( itemBBox, itemShape.get(), layer, std::max( 0, clearance - m_drcEpsilon ), &actual, &pos ) ) { - std::shared_ptr drce; + std::shared_ptr drcItem; wxString msg; if( testShorts && actual == 0 && *aInheritedNet ) { - drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); + drcItem = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); msg.Printf( _( "(nets %s and %s)" ), ( *aInheritedNet )->GetNetname(), aZone->GetNetname() ); } else { - drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); } - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aText, aZone ); - drce->SetViolatingRule( constraint.GetParentRule() ); - ReportAndShowPathCuToCu( drce, pos, layer, aText, aZone, layer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aText, aZone ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoItemGeometry( drcItem, pos, aText, aZone, layer, actual ); } } } @@ -827,17 +824,16 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa return true; } - std::shared_ptr drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); wxString msg; msg.Printf( _( "(nets %s and %s)" ), pad->GetNetname(), otherPad->GetNetname() ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( pad, otherPad ); - - reportViolation( drce, otherPad->GetPosition(), aLayer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( pad, otherPad ); + reportViolation( drcItem, otherPad->GetPosition(), aLayer ); has_error = true; } @@ -860,30 +856,29 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa } else if( actual == 0 && padNet && otherNet && testShorting ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_SHORTING_ITEMS ); wxString msg = wxString::Format( _( "(nets %s and %s)" ), pad->GetNetname(), otherCItem->GetNetname() ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( pad, other ); - - reportViolation( drce, pos, aLayer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( pad, other ); + reportTwoPointGeometry( drcItem, pos, pos, pos, aLayer ); has_error = true; testHoles = false; // No need for multiple violations } else if( testClearance ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( pad, other ); - drce->SetViolatingRule( constraint.GetParentRule() ); - ReportAndShowPathCuToCu( drce, pos, aLayer, pad, other, aLayer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( pad, other ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoItemGeometry( drcItem, pos, pad, other, aLayer, actual ); has_error = true; testHoles = false; // No need for multiple violations } @@ -896,16 +891,16 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa { if( shape->Collide( otherShape, sub_e( clearance ), &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( item, otherItem ); - drce->SetViolatingRule( constraint.GetParentRule() ); - ReportAndShowPathCuToCu( drce, pos, aLayer, item, otherItem, aLayer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( item, otherItem ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoShapeGeometry( drcItem, pos, shape, otherShape, aLayer, actual ); has_error = true; testHoles = false; // No need for multiple violations } @@ -1216,28 +1211,28 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones() [this]( ZONE* zoneA, ZONE* zoneB, VECTOR2I& pt, int actual, const DRC_CONSTRAINT& constraint, PCB_LAYER_ID layer ) -> void { - std::shared_ptr drce; + std::shared_ptr drcItem; if( constraint.IsNull() ) { - drce = DRC_ITEM::Create( DRCE_ZONES_INTERSECT ); + drcItem = DRC_ITEM::Create( DRCE_ZONES_INTERSECT ); wxString msg = _( "(intersecting zones must have distinct priorities)" ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( zoneA, zoneB ); - reportViolation( drce, pt, layer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( zoneA, zoneB ); + reportViolation( drcItem, pt, layer ); } else { - drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), constraint.GetValue().Min(), std::max( actual, 0 ) ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( zoneA, zoneB ); - drce->SetViolatingRule( constraint.GetParentRule() ); - ReportAndShowPathCuToCu( drce, pt, layer, zoneA, zoneB, layer, actual ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( zoneA, zoneB ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoItemGeometry( drcItem, pt, zoneA, zoneB, layer, actual ); } }; diff --git a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp index 566eee27c4..44c32ca1c1 100644 --- a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include /* @@ -39,11 +39,11 @@ - DRCE_NPTH_IN_COURTYARD, */ -class DRC_TEST_PROVIDER_COURTYARD_CLEARANCE : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_TEST_PROVIDER_COURTYARD_CLEARANCE : public DRC_TEST_PROVIDER { public: DRC_TEST_PROVIDER_COURTYARD_CLEARANCE () : - DRC_TEST_PROVIDER_CLEARANCE_BASE(), + DRC_TEST_PROVIDER(), m_largestCourtyardClearance( 0 ) { m_isRuleDriven = false; @@ -227,7 +227,7 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() { if( frontA.Collide( &frontB, clearance, &actual, &pos ) ) { - auto drce = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS ); if( clearance > 0 ) { @@ -236,12 +236,12 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); } - drce->SetViolatingRule( constraint.GetParentRule() ); - drce->SetItems( fpA, fpB ); - reportViolation( drce, pos, F_CrtYd ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + drcItem->SetItems( fpA, fpB ); + reportTwoShapeGeometry( drcItem, pos, &frontA, &frontB, F_CrtYd, actual ); } } } @@ -259,7 +259,7 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() { if( backA.Collide( &backB, clearance, &actual, &pos ) ) { - auto drce = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_OVERLAPPING_FOOTPRINTS ); if( clearance > 0 ) { @@ -268,12 +268,12 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); } - drce->SetViolatingRule( constraint.GetParentRule() ); - drce->SetItems( fpA, fpB ); - reportViolation( drce, pos, B_CrtYd ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + drcItem->SetItems( fpA, fpB ); + reportTwoShapeGeometry( drcItem, pos, &backA, &backB, B_CrtYd, actual ); } } } diff --git a/pcbnew/drc/drc_test_provider_creepage.cpp b/pcbnew/drc/drc_test_provider_creepage.cpp index b2968fcc3d..3675741640 100644 --- a/pcbnew/drc/drc_test_provider_creepage.cpp +++ b/pcbnew/drc/drc_test_provider_creepage.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -47,11 +47,11 @@ - DRCE_CREEPAGE */ -class DRC_TEST_PROVIDER_CREEPAGE : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_TEST_PROVIDER_CREEPAGE : public DRC_TEST_PROVIDER { public: DRC_TEST_PROVIDER_CREEPAGE() : - DRC_TEST_PROVIDER_CLEARANCE_BASE() + DRC_TEST_PROVIDER() {} virtual ~DRC_TEST_PROVIDER_CREEPAGE() = default; @@ -172,12 +172,12 @@ int DRC_TEST_PROVIDER_CREEPAGE::testCreepage( CREEPAGE_GRAPH& aGraph, int aNetCo if( !shortestPath.empty() && ( shortestPath.size() >= 4 ) && ( distance - creepageValue < 0 ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CREEPAGE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CREEPAGE ); wxString msg = formatMsg( _( "(%s creepage %s; actual %s)" ), constraint.GetName(), creepageValue, distance ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetViolatingRule( constraint.GetParentRule() ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); std::shared_ptr gc1 = shortestPath[1]; std::shared_ptr gc2 = shortestPath[shortestPath.size() - 2]; @@ -188,7 +188,7 @@ int DRC_TEST_PROVIDER_CREEPAGE::testCreepage( CREEPAGE_GRAPH& aGraph, int aNetCo const BOARD_ITEM* item2 = gc2->n2->m_parent->GetParent(); if( m_reportedPairs.insert( std::make_pair( item1, item2 ) ).second ) - drce->SetItems( item1, item2 ); + drcItem->SetItems( item1, item2 ); else return 1; } @@ -200,7 +200,11 @@ int DRC_TEST_PROVIDER_CREEPAGE::testCreepage( CREEPAGE_GRAPH& aGraph, int aNetCo for( const std::shared_ptr& gc : shortestPath ) gc->GetShapes( path ); - reportViolation( drce, gc1->m_path.a2, aLayer, GetShapes( path, startPoint, endPoint, distance ) ); + reportViolation( drcItem, gc1->m_path.a2, aLayer, + [&]( PCB_MARKER* aMarker ) + { + aMarker->SetPath( path, startPoint, endPoint ); + } ); } return 1; diff --git a/pcbnew/drc/drc_test_provider_edge_clearance.cpp b/pcbnew/drc/drc_test_provider_edge_clearance.cpp index 61b637bd22..580e16828f 100644 --- a/pcbnew/drc/drc_test_provider_edge_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_edge_clearance.cpp @@ -24,12 +24,13 @@ #include #include #include +#include #include #include #include #include #include -#include +#include #include "drc_rtree.h" /* @@ -40,11 +41,11 @@ - DRCE_SILK_EDGE_CLEARANCE */ -class DRC_TEST_PROVIDER_EDGE_CLEARANCE : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_TEST_PROVIDER_EDGE_CLEARANCE : public DRC_TEST_PROVIDER { public: DRC_TEST_PROVIDER_EDGE_CLEARANCE () : - DRC_TEST_PROVIDER_CLEARANCE_BASE(), + DRC_TEST_PROVIDER(), m_largestEdgeClearance( 0 ) {} @@ -99,7 +100,7 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge( BOARD_ITEM* item, SHAPE* } } - std::shared_ptr drce = DRC_ITEM::Create( aErrorCode ); + std::shared_ptr drcItem = DRC_ITEM::Create( aErrorCode ); // Only report clearance info if there is any; otherwise it's just a straight collision if( minClearance > 0 ) @@ -109,13 +110,12 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge( BOARD_ITEM* item, SHAPE* minClearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); } - drce->SetItems( edge->m_Uuid, item->m_Uuid ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drce, pos, Edge_Cuts ); + drcItem->SetItems( edge->m_Uuid, item->m_Uuid ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoItemGeometry( drcItem, pos, edge, item, Edge_Cuts, actual ); if( item->Type() == PCB_TRACE_T || item->Type() == PCB_ARC_T ) return m_drcEngine->GetReportAllTrackErrors(); diff --git a/pcbnew/drc/drc_test_provider_hole_size.cpp b/pcbnew/drc/drc_test_provider_hole_size.cpp index 165d8a7d0c..f5bf15a0c7 100644 --- a/pcbnew/drc/drc_test_provider_hole_size.cpp +++ b/pcbnew/drc/drc_test_provider_hole_size.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include /* Drilled hole size test. scans vias/through-hole pads and checks for min drill sizes @@ -117,23 +117,42 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole( PAD* aPad ) auto constraint = m_drcEngine->EvalRules( HOLE_SIZE_CONSTRAINT, aPad, nullptr, UNDEFINED_LAYER /* holes are not layer-specific */ ); - bool fail_min = false; - bool fail_max = false; - int constraintValue = 0; + bool fail_min = false; + bool fail_max = false; + int constraintValue = 0; + VECTOR2I ptA, ptB; if( constraint.GetSeverity() == RPT_SEVERITY_IGNORE ) return; - if( constraint.Value().HasMin() && holeMinor < constraint.Value().Min() ) - { - fail_min = true; - constraintValue = constraint.Value().Min(); - } - if( constraint.Value().HasMax() && holeMajor > constraint.Value().Max() ) { fail_max = true; constraintValue = constraint.Value().Max(); + + ptA = aPad->GetPosition(); + + if( aPad->GetDrillSizeX() == aPad->GetDrillSizeY() ) + ptB = ptA - VECTOR2I( aPad->GetDrillSize() ).Resize( aPad->GetDrillSizeX() / 2 ); + else if( aPad->GetDrillSizeX() > aPad->GetDrillSizeY() ) + ptB = ptA - VECTOR2I( aPad->GetDrillSizeX() / 2, 0 ); + else + ptB = ptA - VECTOR2I( 0, aPad->GetDrillSizeY() / 2 ); + } + + if( constraint.Value().HasMin() && holeMinor < constraint.Value().Min() ) + { + fail_min = true; + constraintValue = constraint.Value().Min(); + + ptA = aPad->GetPosition(); + + if( aPad->GetDrillSizeX() == aPad->GetDrillSizeY() ) + ptB = ptA - VECTOR2I( aPad->GetDrillSize() ).Resize( aPad->GetDrillSizeX() / 2 ); + else if( aPad->GetDrillSizeX() < aPad->GetDrillSizeY() ) + ptB = ptA - VECTOR2I( aPad->GetDrillSizeX() / 2, 0 ); + else + ptB = ptA - VECTOR2I( 0, aPad->GetDrillSizeY() / 2 ); } if( fail_min || fail_max ) @@ -163,8 +182,7 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole( PAD* aPad ) drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetItems( aPad ); drcItem->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drcItem, aPad->GetPosition(), UNDEFINED_LAYER ); + reportTwoPointGeometry( drcItem, ptA, ptA, ptB, UNDEFINED_LAYER ); } } @@ -193,17 +211,18 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole( PCB_VIA* via, bool aExceedMicro, bool fail_min = false; bool fail_max = false; int constraintValue = 0; + int drill = via->GetDrillValue(); if( constraint.GetSeverity() == RPT_SEVERITY_IGNORE ) return; - if( constraint.Value().HasMin() && via->GetDrillValue() < constraint.Value().Min() ) + if( constraint.Value().HasMin() && drill < constraint.Value().Min() ) { fail_min = true; constraintValue = constraint.Value().Min(); } - if( constraint.Value().HasMax() && via->GetDrillValue() > constraint.Value().Max() ) + if( constraint.Value().HasMax() && drill > constraint.Value().Max() ) { fail_max = true; constraintValue = constraint.Value().Max(); @@ -223,21 +242,24 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole( PCB_VIA* via, bool aExceedMicro, msg = formatMsg( _( "(%s min hole %s; actual %s)" ), constraintName, constraintValue, - via->GetDrillValue() ); + drill ); } else { msg = formatMsg( _( "(%s max hole %s; actual %s)" ), constraintName, constraintValue, - via->GetDrillValue() ); + drill ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetItems( via ); drcItem->SetViolatingRule( constraint.GetParentRule() ); - reportViolation( drcItem, via->GetPosition(), UNDEFINED_LAYER ); + VECTOR2I ptA = via->GetPosition(); + + VECTOR2I ptB = ptA - VECTOR2I( drill, drill ).Resize( drill / 2 ); + reportTwoPointGeometry( drcItem, ptA, ptA, ptB, UNDEFINED_LAYER ); } } diff --git a/pcbnew/drc/drc_test_provider_hole_to_hole.cpp b/pcbnew/drc/drc_test_provider_hole_to_hole.cpp index 99e94130d1..b2a4b21912 100644 --- a/pcbnew/drc/drc_test_provider_hole_to_hole.cpp +++ b/pcbnew/drc/drc_test_provider_hole_to_hole.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include "drc_rtree.h" /* @@ -41,11 +41,11 @@ - DRCE_DRILLED_HOLES_COLOCATED */ -class DRC_TEST_PROVIDER_HOLE_TO_HOLE : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_TEST_PROVIDER_HOLE_TO_HOLE : public DRC_TEST_PROVIDER { public: DRC_TEST_PROVIDER_HOLE_TO_HOLE () : - DRC_TEST_PROVIDER_CLEARANCE_BASE(), + DRC_TEST_PROVIDER(), m_board( nullptr ), m_largestHoleToHoleClearance( 0 ) {} @@ -282,9 +282,10 @@ bool DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole( BOARD_ITEM* aItem, SHA if( aItem->m_Uuid > aOther->m_Uuid ) std::swap( aItem, aOther ); - std::shared_ptr drce = DRC_ITEM::Create( DRCE_DRILLED_HOLES_COLOCATED ); - drce->SetItems( aItem, aOther ); - reportViolation( drce, aHole->GetCenter(), UNDEFINED_LAYER ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_DRILLED_HOLES_COLOCATED ); + drcItem->SetItems( aItem, aOther ); + reportTwoPointGeometry( drcItem, aHole->GetCenter(), aHole->GetCenter(), aHole->GetCenter(), + UNDEFINED_LAYER ); } } else if( reportHole2Hole ) @@ -305,17 +306,17 @@ bool DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole( BOARD_ITEM* aItem, SHA if( aItem->m_Uuid > aOther->m_Uuid ) std::swap( aItem, aOther ); - std::shared_ptr drce = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_DRILLED_HOLES_TOO_CLOSE ); wxString msg = formatMsg( _( "(%s min %s; actual %s)" ), constraint.GetName(), minClearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, aOther ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drce, aHole->GetCenter(), UNDEFINED_LAYER ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, aOther ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoShapeGeometry( drcItem, aHole->GetCenter(), aHole, otherHole.get(), UNDEFINED_LAYER, + actual ); } } diff --git a/pcbnew/drc/drc_test_provider_physical_clearance.cpp b/pcbnew/drc/drc_test_provider_physical_clearance.cpp index 8cfd7cc64d..72db6d9e62 100644 --- a/pcbnew/drc/drc_test_provider_physical_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_physical_clearance.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include /* Physical clearance tests. @@ -45,11 +45,11 @@ - DRCE_PHYSICAL_HOLE_CLEARANCE */ -class DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE : public DRC_TEST_PROVIDER_CLEARANCE_BASE +class DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE : public DRC_TEST_PROVIDER { public: DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE () : - DRC_TEST_PROVIDER_CLEARANCE_BASE() + DRC_TEST_PROVIDER() {} virtual ~DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE() = default; @@ -473,7 +473,7 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain( const SHAPE_LINE_ for( const std::pair& collision : collisions ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); VECTOR2I pt = collision.first; if( FOOTPRINT* parentFP = aParentItem->GetParentFootprint() ) @@ -487,11 +487,11 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain( const SHAPE_LINE_ clearance, collision.second ); - drce->SetErrorMessage( msg ); - drce->SetItems( aParentItem ); - drce->SetViolatingRule( aConstraint.GetParentRule() ); + drcItem->SetErrorMessage( msg ); + drcItem->SetItems( aParentItem ); + drcItem->SetViolatingRule( aConstraint.GetParentRule() ); - reportViolation( drce, pt, aLayer ); + reportViolation( drcItem, pt, aLayer ); } } @@ -530,17 +530,16 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer( ZONE* aZone, PCB_LAYER if( firstOutline->Collide( secondSeg, clearance - epsilon, &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), aConstraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aZone ); - drce->SetViolatingRule( aConstraint.GetParentRule() ); - - reportViolation( drce, pos, aLayer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aZone ); + drcItem->SetViolatingRule( aConstraint.GetParentRule() ); + reportViolation( drcItem, pos, aLayer ); } } @@ -596,17 +595,16 @@ int DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aItem if( aItemShape->Collide( otherShape, clearance, &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, aOther ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drce, pos, aLayer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, aOther ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoShapeGeometry( drcItem, pos, aItemShape, otherShape, aLayer, actual ); ++violations; } } @@ -665,8 +663,7 @@ int DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aItem if( itemHoleShape || otherHoleShape ) { - constraint = m_drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, aOther, aItem, - aLayer ); + constraint = m_drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, aOther, aItem, aLayer ); clearance = constraint.GetValue().Min(); } @@ -674,33 +671,31 @@ int DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aItem { if( itemHoleShape && itemHoleShape->Collide( otherShape, clearance, &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance , actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, aOther ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drce, pos, aLayer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, aOther ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoShapeGeometry( drcItem, pos, itemHoleShape.get(), otherShape, aLayer, actual ); ++violations; } if( otherHoleShape && otherHoleShape->Collide( aItemShape, clearance, &actual, &pos ) ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, aOther ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drce, pos, aLayer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, aOther ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoShapeGeometry( drcItem, pos, otherHoleShape.get(), aItemShape, aLayer, actual ); ++violations; } } @@ -777,17 +772,16 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt if( colliding ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, zone ); - drce->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drce, pos, aLayer ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, zone ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); + reportTwoItemGeometry( drcItem, pos, aItem, zone, aLayer, actual ); } } @@ -824,17 +818,18 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt if( colliding ) { - std::shared_ptr drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); + std::shared_ptr drcItem = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE ); wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), clearance, actual ); - drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); - drce->SetItems( aItem, zone ); - drce->SetViolatingRule( constraint.GetParentRule() ); + drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); + drcItem->SetItems( aItem, zone ); + drcItem->SetViolatingRule( constraint.GetParentRule() ); - reportViolation( drce, pos, aLayer ); + std::shared_ptr zoneShape = zone->GetEffectiveShape( aLayer ); + reportTwoShapeGeometry( drcItem, pos, holeShape.get(), zoneShape.get(), aLayer, actual ); } } } diff --git a/pcbnew/drc/drc_test_provider_silk_clearance.cpp b/pcbnew/drc/drc_test_provider_silk_clearance.cpp index 46b846f0ad..7d43ec60d5 100644 --- a/pcbnew/drc/drc_test_provider_silk_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_silk_clearance.cpp @@ -29,8 +29,9 @@ #include #include #include -#include +#include #include +#include /* Silk to silk clearance test. Check all silkscreen features against each other. @@ -250,9 +251,7 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() drcItem->SetItems( refItem, testItem ); drcItem->SetViolatingRule( constraint.GetParentRule() ); - - reportViolation( drcItem, pos, aLayers.second ); - + reportTwoShapeGeometry( drcItem, pos, refShape, testShape, aLayers.second, actual ); *aCollisionDetected = true; } diff --git a/pcbnew/drc/drc_test_provider_solder_mask.cpp b/pcbnew/drc/drc_test_provider_solder_mask.cpp index 244ef08dfc..baef29f299 100644 --- a/pcbnew/drc/drc_test_provider_solder_mask.cpp +++ b/pcbnew/drc/drc_test_provider_solder_mask.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include /* diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index a4ee8c3691..223e0e707e 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -922,19 +922,16 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps() m_view->SetLayerDisplayOnly( LAYER_RATSNEST ); m_view->SetLayerTarget( LAYER_DRC_ERROR, KIGFX::TARGET_OVERLAY ); - //m_view->SetLayerDisplayOnly( LAYER_DRC_ERROR ); m_view->SetLayerTarget( LAYER_DRC_WARNING, KIGFX::TARGET_OVERLAY ); - //m_view->SetLayerDisplayOnly( LAYER_DRC_WARNING ); m_view->SetLayerTarget( LAYER_DRC_EXCLUSION, KIGFX::TARGET_OVERLAY ); - //m_view->SetLayerDisplayOnly( LAYER_DRC_EXCLUSION ); m_view->SetLayerTarget( LAYER_MARKER_SHADOWS, KIGFX::TARGET_OVERLAY ); m_view->SetLayerDisplayOnly( LAYER_MARKER_SHADOWS ); m_view->SetLayerTarget( LAYER_DRC_SHAPES, KIGFX::TARGET_OVERLAY ); - m_view->SetLayerDisplayOnly( LAYER_DRC_SHAPES ); + m_view->SetLayerDisplayOnly( LAYER_DRC_SHAPES ); // markers can't be selected through shapes m_view->SetLayerTarget( LAYER_DRAWINGSHEET, KIGFX::TARGET_NONCACHED ); - m_view->SetLayerDisplayOnly( LAYER_DRAWINGSHEET ) ; - m_view->SetLayerDisplayOnly( LAYER_GRID ); + m_view->SetLayerDisplayOnly( LAYER_DRAWINGSHEET ) ; // drawing sheet can't be selected + m_view->SetLayerDisplayOnly( LAYER_GRID ); // grid can't be selected for( int i = LAYER_UI_START; i < LAYER_UI_END; ++i ) { diff --git a/pcbnew/pcb_marker.cpp b/pcbnew/pcb_marker.cpp index 8f6bd2d307..322caace87 100644 --- a/pcbnew/pcb_marker.cpp +++ b/pcbnew/pcb_marker.cpp @@ -367,11 +367,73 @@ void PCB_MARKER::SetZoom( double aZoomFactor ) const } +std::vector PCB_MARKER::GetShapes() const +{ + STROKE_PARAMS hairline( 1.0 ); // Segments of width 1.0 will get drawn as lines by PCB_PAINTER + std::vector pathShapes; + + if( m_pathStart == m_pathEnd ) + { + // Add a collision 'X' + const int len = KiROUND( 2.5 * MarkerScale() ); + + PCB_SHAPE s( nullptr, SHAPE_T::SEGMENT ); + s.SetStroke( hairline ); + + s.SetStart( m_pathStart + VECTOR2I( -len, -len ) ); + s.SetEnd( m_pathStart + VECTOR2I( len, len ) ); + pathShapes.push_back( s ); + + s.SetStart( m_pathStart + VECTOR2I( -len, len ) ); + s.SetEnd( m_pathStart + VECTOR2I( len, -len ) ); + pathShapes.push_back( s ); + } + else + { + // Add the path + for( PCB_SHAPE shape : m_pathShapes ) + { + shape.SetStroke( hairline ); + pathShapes.push_back( std::move( shape ) ); + } + + // Draw perpendicular begin/end stops + if( pathShapes.size() > 0 ) + { + VECTOR2I V1 = pathShapes[0].GetStart() - pathShapes[0].GetEnd(); + VECTOR2I V2 = pathShapes.back().GetStart() - pathShapes.back().GetEnd(); + V1 = V1.Perpendicular().Resize( 2.5 * MarkerScale() ); + V2 = V2.Perpendicular().Resize( 2.5 * MarkerScale() ); + + PCB_SHAPE s( nullptr, SHAPE_T::SEGMENT ); + s.SetStroke( hairline ); + + s.SetStart( m_pathStart + V1 ); + s.SetEnd( m_pathStart - V1 ); + pathShapes.push_back( s ); + + s.SetStart( m_pathEnd + V2 ); + s.SetEnd( m_pathEnd - V2 ); + pathShapes.push_back( s ); + } + } + + // Add shaded areas + for( PCB_SHAPE shape : m_pathShapes ) + { + shape.SetWidth( 10 * MarkerScale() ); + pathShapes.push_back( std::move( shape ) ); + } + + return pathShapes; +} + + const BOX2I PCB_MARKER::GetBoundingBox() const { BOX2I box = GetBoundingBoxMarker(); - for( const PCB_SHAPE& s : m_shapes ) + for( const PCB_SHAPE& s : m_pathShapes ) box.Merge( s.GetBoundingBox() ); return box; diff --git a/pcbnew/pcb_marker.h b/pcbnew/pcb_marker.h index 1630ceb06d..4fae4182be 100644 --- a/pcbnew/pcb_marker.h +++ b/pcbnew/pcb_marker.h @@ -150,12 +150,21 @@ public: return wxT( "PCB_MARKER" ); } - std::vector GetShapes() const { return m_shapes; }; - void SetShapes( const std::vector& aShapes ) { m_shapes = aShapes; }; + std::vector GetShapes() const; + + void SetPath( const std::vector& aShapes, const VECTOR2I& aStart, const VECTOR2I& aEnd ) + { + m_pathShapes = aShapes; + m_pathStart = aStart; + m_pathEnd = aEnd; + } protected: KIGFX::COLOR4D getColor() const override; protected: - std::vector m_shapes; // Shown on LAYER_DRC_SHAPES + std::vector m_pathShapes; // Shown on LAYER_DRC_SHAPES + VECTOR2I m_pathStart; + VECTOR2I m_pathEnd; + int m_pathLength; }; diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 8648afe4b0..3c2a279ba9 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -490,6 +490,7 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const BOARD_ITEM* aItem, int aLayer ) con case LAYER_DRC_ERROR: case LAYER_DRC_WARNING: case LAYER_DRC_EXCLUSION: + case LAYER_DRC_SHAPES: isActive = true; break; @@ -3131,7 +3132,7 @@ void PCB_PAINTER::draw( const PCB_MARKER* aMarker, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetStrokeColor( WHITE ); - m_gal->SetLineWidth( pcbIUScale.mmToIU( 0.01 ) ); + m_gal->SetLineWidth( KiROUND( aMarker->MarkerScale() / 2.0 ) ); if( shape.GetShape() == SHAPE_T::SEGMENT ) { diff --git a/pcbnew/pcbnew_jobs_handler.cpp b/pcbnew/pcbnew_jobs_handler.cpp index bf54355db7..37c66fec4c 100644 --- a/pcbnew/pcbnew_jobs_handler.cpp +++ b/pcbnew/pcbnew_jobs_handler.cpp @@ -2249,10 +2249,10 @@ int PCBNEW_JOBS_HANDLER::JobExportDrc( JOB* aJob ) drcEngine->SetProgressReporter( m_progressReporter ); drcEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aLayer ); - marker->SetShapes( aShapes ); + aPathGenerator( marker ); commit.Add( marker ); } ); diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 89d216d972..fc74a13fd9 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -593,7 +593,7 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, engine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2D& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( aItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT || aItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT diff --git a/pcbnew/tools/drc_tool.cpp b/pcbnew/tools/drc_tool.cpp index 465263cb46..818f804a5a 100644 --- a/pcbnew/tools/drc_tool.cpp +++ b/pcbnew/tools/drc_tool.cpp @@ -173,11 +173,11 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aRefillZones m_drcEngine->SetProgressReporter( aProgressReporter ); m_drcEngine->SetViolationHandler( - [&]( const std::shared_ptr& aItem, VECTOR2I aPos, int aLayer, - const std::vector& aShapes ) + [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, + const std::function& aPathGenerator ) { PCB_MARKER* marker = new PCB_MARKER( aItem, aPos, aLayer ); - marker->SetShapes( aShapes ); + aPathGenerator( marker ); commit.Add( marker ); } ); diff --git a/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp b/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp index 5808d0429f..4d8378f42c 100644 --- a/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp +++ b/qa/tests/pcbnew/drc/test_custom_rule_severities.cpp @@ -64,7 +64,7 @@ BOOST_FIXTURE_TEST_CASE( DRCCustomRuleSeverityTest, DRC_REGRESSION_TEST_FIXTURE bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { PCB_MARKER temp( aItem, aPos ); diff --git a/qa/tests/pcbnew/drc/test_drc_component_classes.cpp b/qa/tests/pcbnew/drc/test_drc_component_classes.cpp index 9df6323af6..2ee408eac0 100644 --- a/qa/tests/pcbnew/drc/test_drc_component_classes.cpp +++ b/qa/tests/pcbnew/drc/test_drc_component_classes.cpp @@ -75,7 +75,7 @@ BOOST_FIXTURE_TEST_CASE( DRCComponentClasses, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp b/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp index cd13079d6e..1068e4c7f0 100644 --- a/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp +++ b/qa/tests/pcbnew/drc/test_drc_copper_conn.cpp @@ -81,7 +81,7 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperConn, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp b/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp index 09b59623eb..fa00229950 100644 --- a/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp +++ b/qa/tests/pcbnew/drc/test_drc_copper_graphics.cpp @@ -64,7 +64,7 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperGraphicsTest, DRC_COPPER_GRAPHICS_TEST_FIXTURE bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { PCB_MARKER temp( aItem, aPos ); diff --git a/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp b/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp index 131b3664be..041b609b75 100644 --- a/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp +++ b/qa/tests/pcbnew/drc/test_drc_copper_sliver.cpp @@ -105,7 +105,7 @@ BOOST_DATA_TEST_CASE_F( DRC_REGRESSION_TEST_FIXTURE, DRCCopperSliver, bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp b/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp index eff417c880..75a47eee74 100644 --- a/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp +++ b/qa/tests/pcbnew/drc/test_drc_courtyard_invalid.cpp @@ -305,7 +305,7 @@ void DoCourtyardInvalidTest( const COURTYARD_INVALID_CASE& aCase, drcEngine.SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( aItem->GetErrorCode() == DRCE_OVERLAPPING_FOOTPRINTS || aItem->GetErrorCode() == DRCE_MALFORMED_COURTYARD diff --git a/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp b/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp index 86e3103a6c..a95f96d215 100644 --- a/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp +++ b/qa/tests/pcbnew/drc/test_drc_courtyard_overlap.cpp @@ -461,7 +461,7 @@ static void DoCourtyardOverlapTest( const COURTYARD_OVERLAP_TEST_CASE& aCase, drcEngine.SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( aItem->GetErrorCode() == DRCE_OVERLAPPING_FOOTPRINTS || aItem->GetErrorCode() == DRCE_MALFORMED_COURTYARD diff --git a/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp b/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp index 8b8b93d2f0..389e055bd7 100644 --- a/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp +++ b/qa/tests/pcbnew/drc/test_drc_incorrect_text_mirror.cpp @@ -63,7 +63,7 @@ BOOST_FIXTURE_TEST_CASE( DRCIncorrectTextMirror, DRC_INCORRECT_TEXT_MIRROR_TEST_ bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_lengths.cpp b/qa/tests/pcbnew/drc/test_drc_lengths.cpp index 4b70f84d28..a84242fad6 100644 --- a/qa/tests/pcbnew/drc/test_drc_lengths.cpp +++ b/qa/tests/pcbnew/drc/test_drc_lengths.cpp @@ -77,7 +77,7 @@ BOOST_FIXTURE_TEST_CASE( DRCLengths, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp b/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp index 7510a33171..d2e159476e 100644 --- a/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp +++ b/qa/tests/pcbnew/drc/test_drc_multi_netclasses.cpp @@ -78,7 +78,7 @@ BOOST_FIXTURE_TEST_CASE( DRCMultiNetclasses, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_orientation.cpp b/qa/tests/pcbnew/drc/test_drc_orientation.cpp index 69e21b2832..f68e45c2fb 100644 --- a/qa/tests/pcbnew/drc/test_drc_orientation.cpp +++ b/qa/tests/pcbnew/drc/test_drc_orientation.cpp @@ -78,7 +78,7 @@ BOOST_FIXTURE_TEST_CASE( DRCOrientation, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_regressions.cpp b/qa/tests/pcbnew/drc/test_drc_regressions.cpp index a7b2cac110..a145e78044 100644 --- a/qa/tests/pcbnew/drc/test_drc_regressions.cpp +++ b/qa/tests/pcbnew/drc/test_drc_regressions.cpp @@ -91,7 +91,7 @@ BOOST_FIXTURE_TEST_CASE( DRCFalsePositiveRegressions, DRC_REGRESSION_TEST_FIXTUR bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); @@ -177,7 +177,7 @@ BOOST_FIXTURE_TEST_CASE( DRCFalseNegativeRegressions, DRC_REGRESSION_TEST_FIXTUR bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - std::vector aShapes ) + const std::function& aPathGenerator ) { markers.emplace_back( PCB_MARKER( aItem, aPos ) ); diff --git a/qa/tests/pcbnew/drc/test_drc_skew.cpp b/qa/tests/pcbnew/drc/test_drc_skew.cpp index 91e8b82bd5..c6f77af1e6 100644 --- a/qa/tests/pcbnew/drc/test_drc_skew.cpp +++ b/qa/tests/pcbnew/drc/test_drc_skew.cpp @@ -79,7 +79,7 @@ BOOST_FIXTURE_TEST_CASE( DRCSkew, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_starved_thermal.cpp b/qa/tests/pcbnew/drc/test_drc_starved_thermal.cpp index 09868527a9..564ab17842 100644 --- a/qa/tests/pcbnew/drc/test_drc_starved_thermal.cpp +++ b/qa/tests/pcbnew/drc/test_drc_starved_thermal.cpp @@ -67,7 +67,7 @@ BOOST_FIXTURE_TEST_CASE( DRCStarvedThermal, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( bds.GetSeverity( aItem->GetErrorCode() ) == SEVERITY::RPT_SEVERITY_ERROR ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/drc/test_drc_via_dangling.cpp b/qa/tests/pcbnew/drc/test_drc_via_dangling.cpp index fbf2f59c85..a19f9ef032 100644 --- a/qa/tests/pcbnew/drc/test_drc_via_dangling.cpp +++ b/qa/tests/pcbnew/drc/test_drc_via_dangling.cpp @@ -48,7 +48,7 @@ BOOST_FIXTURE_TEST_CASE( DRCViaDanglingRuleTest, DRC_REGRESSION_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { PCB_MARKER temp( aItem, aPos ); diff --git a/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp b/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp index 836d34a06b..61b1fdb8ae 100644 --- a/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp +++ b/qa/tests/pcbnew/drc/test_solder_mask_bridging.cpp @@ -59,7 +59,7 @@ BOOST_FIXTURE_TEST_CASE( DRCSolderMaskBridgingTest, DRC_SOLDER_MASK_BRIDGING_TES bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { PCB_MARKER temp( aItem, aPos ); diff --git a/qa/tests/pcbnew/test_tracks_cleaner.cpp b/qa/tests/pcbnew/test_tracks_cleaner.cpp index b5fbc8f3c1..54b71bf11f 100644 --- a/qa/tests/pcbnew/test_tracks_cleaner.cpp +++ b/qa/tests/pcbnew/test_tracks_cleaner.cpp @@ -208,7 +208,7 @@ BOOST_DATA_TEST_CASE_F( TRACK_CLEANER_TEST_FIXTURE, TrackCleanerRegressionTests, bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( aItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS ) violations.push_back( *aItem ); diff --git a/qa/tests/pcbnew/test_zone_filler.cpp b/qa/tests/pcbnew/test_zone_filler.cpp index 4deb1d3df4..791e077af3 100644 --- a/qa/tests/pcbnew/test_zone_filler.cpp +++ b/qa/tests/pcbnew/test_zone_filler.cpp @@ -104,7 +104,7 @@ BOOST_FIXTURE_TEST_CASE( BasicZoneFills, ZONE_FILL_TEST_FIXTURE ) bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { if( aItem->GetErrorCode() == DRCE_CLEARANCE ) { @@ -199,7 +199,7 @@ BOOST_DATA_TEST_CASE_F( ZONE_FILL_TEST_FIXTURE, RegressionZoneFillTests, bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - std::vector aShapes ) + const std::function& aPathGenerator ) { if( aItem->GetErrorCode() == DRCE_CLEARANCE ) violations.push_back( *aItem ); @@ -246,7 +246,7 @@ BOOST_DATA_TEST_CASE_F( ZONE_FILL_TEST_FIXTURE, RegressionSliverZoneFillTests, bds.m_DRCEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - std::vector aShapes ) + const std::function& aPathGenerator ) { if( aItem->GetErrorCode() == DRCE_COPPER_SLIVER ) violations.push_back( *aItem ); diff --git a/qa/tools/drc_proto/drc_proto.cpp b/qa/tools/drc_proto/drc_proto.cpp index 50b435b7e8..3ad7348a43 100644 --- a/qa/tools/drc_proto/drc_proto.cpp +++ b/qa/tools/drc_proto/drc_proto.cpp @@ -115,7 +115,7 @@ int runDRCProto( PROJECT_CONTEXT project, std::shared_ptr a drcEngine->SetViolationHandler( [&]( const std::shared_ptr& aItem, const VECTOR2I& aPos, int aLayer, - const std::vector& aShapes ) + const std::function& aPathGenerator ) { // fixme } );