7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 19:03:45 +00:00

DRC and flipped footprints: better fix than ugly commit 6bc51781

The sorting function used by DRC now also normalize segments.
This commit is contained in:
jean-pierre charras 2024-09-04 09:48:38 +02:00
parent 3e5ca2ee7a
commit 43ea0d0adb
2 changed files with 16 additions and 29 deletions

View File

@ -2329,36 +2329,8 @@ void FOOTPRINT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
// Reverse mirror footprint graphics and texts.
for( BOARD_ITEM* item : m_drawings )
{
item->Flip( m_pos, false );
#if 1
// This code is expected to be temporary: a better but more complex fix should
// be in drc_test_library_parity.cpp
// Before commit 513d659c (master) or 55fafe34 (8.0 branch)
// ( (28 08 2024: Fix incorrect flip for graphic segments)
// segments ends were swapped (for an obscure reason) creating an issue for
// segments living on a board.
// They are now not flipped, but it has a side effect for footprints, especially
// in DRC test for library parity, any footprint flipped before this commit does
// not match library.
// so to avoid this issue, swap the ends of segments, like before.
// This is ugly fix, until the DRC test can handle swapped and not swapped ends
if( item->Type() == PCB_SHAPE_T )
{
PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
if( shape->GetShape() == SHAPE_T::SEGMENT )
{
VECTOR2I start = shape->GetStart();
VECTOR2I end = shape->GetEnd();
shape->SetStart( end );
shape->SetEnd( start );
}
}
#endif
}
// Now rotate 180 deg if required
if( aFlipLeftRight )
Rotate( aCentre, ANGLE_180 );

View File

@ -466,7 +466,22 @@ void PCB_SHAPE::Scale( double aScale )
void PCB_SHAPE::Normalize()
{
if( m_shape == SHAPE_T::RECTANGLE )
if( m_shape == SHAPE_T::SEGMENT )
{
// we want start point the top left point and end point the bottom right
// (more easy to compare 2 segments: we are seeing them as equivalent if
// they have the same end points, not necessary the same order)
VECTOR2I start = GetStart();
VECTOR2I end = GetEnd();
if( ( start.x > end.x )
|| ( start.x == end.x && start.y < end.y ) )
{
SetStart( end );
SetEnd( start );
}
}
else if( m_shape == SHAPE_T::RECTANGLE )
{
VECTOR2I start = GetStart();
VECTOR2I end = GetEnd();