diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 67a739ad60..c025c02039 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -334,10 +334,17 @@ void D_PAD::BuildEffectiveShapes() const add( poly ); } - // Bounding radius + // Bounding box and radius // m_effectiveBoundingRadius = calcBoundingRadius(); + for( const std::shared_ptr& shape : m_effectiveShapes ) + { + BOX2I r = shape->BBox(); + m_effectiveBoundingBox.Merge( EDA_RECT( (wxPoint) r.GetOrigin(), + wxSize( r.GetWidth(), r.GetHeight() ) ) ); + } + // Hole shape // wxSize half_size = m_Drill / 2; @@ -357,15 +364,10 @@ void D_PAD::BuildEffectiveShapes() const const EDA_RECT D_PAD::GetBoundingBox() const { - EDA_RECT bbox; + if( m_shapesDirty ) + BuildEffectiveShapes(); - for( const std::shared_ptr& shape : GetEffectiveShapes() ) - { - BOX2I r = shape->BBox(); - bbox.Merge( EDA_RECT( (wxPoint) r.GetOrigin(), wxSize( r.GetWidth(), r.GetHeight() ) ) ); - } - - return bbox; + return m_effectiveBoundingBox; } @@ -1098,14 +1100,14 @@ unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const // Netnames will be shown only if zoom is appropriate if( IsNetnameLayer( aLayer ) ) { - int divisor = GetBoundingRadius(); + int divisor = std::min( GetBoundingBox().GetWidth(), GetBoundingBox().GetHeight() ); // Pad sizes can be zero briefly when someone is typing a number like "0.5" // in the pad properties dialog if( divisor == 0 ) return HIDE; - return ( Millimeter2iu( 10 ) / divisor ); + return ( Millimeter2iu( 5 ) / divisor ); } // Other layers are shown without any conditions diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 7793dad838..f04dbb9a09 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -620,6 +620,7 @@ private: mutable bool m_shapesDirty; mutable int m_effectiveBoundingRadius; + mutable EDA_RECT m_effectiveBoundingBox; mutable std::vector> m_effectiveShapes; mutable std::shared_ptr m_effectiveHoleShape; diff --git a/pcbnew/drc/drc_clearance_test_functions.cpp b/pcbnew/drc/drc_clearance_test_functions.cpp index b0ca0ae029..20c5e19bf5 100644 --- a/pcbnew/drc/drc_clearance_test_functions.cpp +++ b/pcbnew/drc/drc_clearance_test_functions.cpp @@ -24,77 +24,16 @@ */ #include -#include #include -#include #include #include -#include #include -#include #include #include #include #include #include -#include -#include // for KiROUND #include -#include - - -/** - * compare 2 convex polygons and return true if distance > aDist (if no error DRC) - * i.e if for each edge of the first polygon distance from each edge of the other polygon - * is >= aDist - */ -bool poly2polyDRC( wxPoint* aTref, int aTrefCount, wxPoint* aTtest, int aTtestCount, - int aAllowedDist, int* actualDist ) -{ - /* Test if one polygon is contained in the other and thus the polygon overlap. - * This case is not covered by the following check if one polygone is - * completely contained in the other (because edges don't intersect)! - */ - if( TestPointInsidePolygon( aTref, aTrefCount, aTtest[0] ) ) - { - *actualDist = 0; - return false; - } - - if( TestPointInsidePolygon( aTtest, aTtestCount, aTref[0] ) ) - { - *actualDist = 0; - return false; - } - - for( int ii = 0, jj = aTrefCount - 1; ii < aTrefCount; jj = ii, ii++ ) - { - // for all edges in aTref - for( int kk = 0, ll = aTtestCount - 1; kk < aTtestCount; ll = kk, kk++ ) - { - // for all edges in aTtest - double d; - int intersect = TestForIntersectionOfStraightLineSegments( - aTref[ii].x, aTref[ii].y, aTref[jj].x, aTref[jj].y, - aTtest[kk].x, aTtest[kk].y, aTtest[ll].x, aTtest[ll].y, - nullptr, nullptr, &d ); - - if( intersect ) - { - *actualDist = 0; - return false; - } - - if( d < aAllowedDist ) - { - *actualDist = KiROUND( d ); - return false; - } - } - } - - return true; -} /*