Reduce tiny fp errors that can be introduced when updating footprints
Moving by the cursor position (double) and then back to the integer coordinate position sometimes added tiny tiny tiny shifts in the coordinate.
(cherry picked from commit dad49d5dba)
Co-authored-by: Mark Roszko <[email protected]>
This commit is contained in:
@@ -269,12 +269,12 @@ public:
|
||||
FOOTPRINT* CreateNewFootprint( wxString aFootprintName, const wxString& aLibName );
|
||||
|
||||
/**
|
||||
* Place \a aFootprint at the current cursor position and updates footprint coordinates
|
||||
* Place \a aFootprint at the current cursor position (or provided one) and updates footprint coordinates
|
||||
* with the new position.
|
||||
*
|
||||
* @param aRecreateRatsnest A bool true redraws the footprint ratsnest.
|
||||
*/
|
||||
void PlaceFootprint( FOOTPRINT* aFootprint, bool aRecreateRatsnest = true );
|
||||
void PlaceFootprint( FOOTPRINT* aFootprint, bool aRecreateRatsnest = true, std::optional<VECTOR2I> aPosition = std::nullopt );
|
||||
|
||||
void ShowPadPropertiesDialog( PAD* aPad );
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ static FOOTPRINT* s_FootprintInitialCopy = nullptr; // Copy of footprint for
|
||||
static PICKED_ITEMS_LIST s_PickedList; // A pick-list to save initial footprint
|
||||
// and dragged tracks
|
||||
|
||||
void PCB_BASE_FRAME::PlaceFootprint( FOOTPRINT* aFootprint, bool aRecreateRatsnest )
|
||||
void PCB_BASE_FRAME::PlaceFootprint( FOOTPRINT* aFootprint, bool aRecreateRatsnest, std::optional<VECTOR2I> aPosition )
|
||||
{
|
||||
if( aFootprint == nullptr )
|
||||
return;
|
||||
@@ -423,7 +423,11 @@ void PCB_BASE_FRAME::PlaceFootprint( FOOTPRINT* aFootprint, bool aRecreateRatsne
|
||||
s_PickedList.ClearItemsList();
|
||||
}
|
||||
|
||||
aFootprint->SetPosition( GetCanvas()->GetViewControls()->GetCursorPosition() );
|
||||
if( aPosition.has_value() )
|
||||
aFootprint->SetPosition( aPosition.value() );
|
||||
else
|
||||
aFootprint->SetPosition( GetCanvas()->GetViewControls()->GetCursorPosition() );
|
||||
|
||||
aFootprint->ClearFlags();
|
||||
|
||||
delete s_FootprintInitialCopy;
|
||||
|
||||
@@ -2361,11 +2361,7 @@ void PCB_EDIT_FRAME::ExchangeFootprint( FOOTPRINT* aExisting, FOOTPRINT* aNew,
|
||||
|
||||
aNew->SetParent( GetBoard() );
|
||||
|
||||
PlaceFootprint( aNew, false );
|
||||
|
||||
// PlaceFootprint will move the footprint to the cursor position, which we don't want. Copy
|
||||
// the original position across.
|
||||
aNew->SetPosition( aExisting->GetPosition() );
|
||||
PlaceFootprint( aNew, false, aExisting->GetPosition() );
|
||||
|
||||
if( aNew->GetLayer() != aExisting->GetLayer() )
|
||||
aNew->Flip( aNew->GetPosition(), GetPcbNewSettings()->m_FlipDirection );
|
||||
|
||||
Reference in New Issue
Block a user