KiCad PCB EDA Suite
Loading...
Searching...
No Matches
footprint_utils.cpp File Reference
#include "footprint_utils.h"
#include <core/mirror.h>
#include <trigo.h>
#include <footprint.h>
#include <item_realignment.h>
#include <pad.h>

Go to the source code of this file.

Functions

bool ComputeFootprintShift (const FOOTPRINT &aExisting, const FOOTPRINT &aNew, VECTOR2I &aShift, EDA_ANGLE &aAngleShift)
 Compute position and angle shift between two footprints.
 

Function Documentation

◆ ComputeFootprintShift()

bool ComputeFootprintShift ( const FOOTPRINT & aExisting,
const FOOTPRINT & aNew,
VECTOR2I & aShift,
EDA_ANGLE & aAngleShift )

Compute position and angle shift between two footprints.

This will only happen when the new footprint has a different origin or has been rotated compared to the existing footprint. Most of the time, this returns a null shift.

The shift is computed based on pad positions and assumes that there are at least two non-coincident pads with unique numbers that are the same in both footprints.

Pad positions are compared on the side of the existing footprint. A footprint on the back of the board stores its pads mirrored in its library frame, so if the new footprint is on the other side (and will be flipped onto the existing footprint's side when it is exchanged in), its pad positions are mirrored to match before the shift is computed.

Definition at line 30 of file footprint_utils.cpp.

References ANGLE_0, FOOTPRINT::GetOrientation(), GetRotated(), ORTHO_ITEM_REALIGNER::GetTransform(), FOOTPRINT::IsFlipped(), MIRROR(), pad, and result.

Referenced by BOARD::ExchangeFootprint(), and FP_REALIGNMENT_TEST_FIXTURE::ExecuteTestCase().