pcbnew: Don't update coords on add

When adding an element to a module, we don't need to update the relative
coordinates.  Doing so can cause changes when writing to file depending
on rotation and position.

Fixes: lp:1810870
* https://bugs.launchpad.net/kicad/+bug/1810870
This commit is contained in:
Seth Hillbrand 2019-01-13 13:20:29 -08:00
parent 9458ae8221
commit 5433423377
5 changed files with 13 additions and 28 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 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
@ -285,27 +285,6 @@ void MODULE::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
}
aBoardItem->SetParent( this );
// Update relative coordinates, it can be done only after there is a parent object assigned
switch( aBoardItem->Type() )
{
case PCB_MODULE_TEXT_T:
static_cast<TEXTE_MODULE*>( aBoardItem )->SetLocalCoord();
break;
case PCB_MODULE_EDGE_T:
static_cast<EDGE_MODULE*>( aBoardItem )->SetLocalCoord();
break;
case PCB_PAD_T:
static_cast<D_PAD*>( aBoardItem )->SetLocalCoord();
break;
default:
// Huh? It should have been filtered out by the previous switch
assert(false);
break;
}
}

View File

@ -680,6 +680,7 @@ public:
///> Set absolute coordinates.
void SetDrawCoord();
//todo: Remove SetLocalCoord along with m_pos
///> Set relative coordinates.
void SetLocalCoord();
@ -788,6 +789,7 @@ private: // Private variable members:
wxString m_name;
// TODO: Remove m_Pos from Pad or make private. View positions calculated from m_Pos0
wxPoint m_Pos; ///< pad Position on board
PAD_SHAPE_T m_padShape; ///< Shape: PAD_SHAPE_CIRCLE, PAD_SHAPE_RECT,

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 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
@ -596,8 +596,9 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
pad->SetSize( wxSize( KiROUND( EuclideanNorm( delta ) ) + width,
width ) );
padPos += module->GetPosition();
// Set the relative position before adjusting the absolute position
pad->SetPos0( padPos );
padPos += module->GetPosition();
pad->SetPosition( padPos );
if( !testFlags( parameters[paramCnt-2], 0x0100, wxT( "square" ) ) )
@ -677,8 +678,10 @@ MODULE* GPCB_FPL_CACHE::parseMODULE( LINE_READER* aLineReader )
}
pad->SetDrillSize( wxSize( drillSize, drillSize ) );
padPos += module->GetPosition();
// Set the relative position before adjusting the absolute position
pad->SetPos0( padPos );
padPos += module->GetPosition();
pad->SetPosition( padPos );
if( pad->GetShape() == PAD_SHAPE_CIRCLE && pad->GetSize().x != pad->GetSize().y )

View File

@ -7,7 +7,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2019 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

View File

@ -127,10 +127,11 @@ void CLIPBOARD_IO::SaveSelection( const SELECTION& aSelected )
pad->SetNetCode( 0, 0 );
}
// Add the pad to the new module before moving to ensure the local coords are correct
partialModule.Add( clone );
// locate the reference point at (0, 0) in the copied items
clone->Move( wxPoint(-refPoint.x, -refPoint.y ) );
partialModule.Add( clone );
}
// Set the new relative internal local coordinates of copied items