KiCad PCB EDA Suite
Loading...
Searching...
No Matches
block_drag_displacement.cpp File Reference

Go to the source code of this file.

Functions

static EDIT_POINT * resolveInCollections (const std::vector< EDIT_POINTS * > &aCollections, const PCB_HANDLE_KEY &aKey, EDIT_POINTS **aOwner=nullptr)
 
std::map< PCB_HANDLE_KEY, VECTOR2I > BlockDragMoveOrigins (const std::vector< EDIT_POINTS * > &aCollections, const std::set< PCB_HANDLE_KEY > &aPicked)
 Note every handle the drag will move, and where each one started.
 
bool BlockDragApplyDisplacement (const std::vector< EDIT_POINTS * > &aCollections, const std::map< PCB_HANDLE_KEY, VECTOR2I > &aOrigins, const VECTOR2I &aDelta, const GRID_HELPER &aGrid)
 Put every handle at its starting position plus the drag's offset.
 

Function Documentation

◆ BlockDragApplyDisplacement()

bool BlockDragApplyDisplacement ( const std::vector< EDIT_POINTS * > & aCollections,
const std::map< PCB_HANDLE_KEY, VECTOR2I > & aOrigins,
const VECTOR2I & aDelta,
const GRID_HELPER & aGrid )

Put every handle at its starting position plus the drag's offset.

Each position comes from the stored starting point, so a long drag with many mouse events cannot drift. The offset is already snapped to the grid by the caller. A picked edge's corners are placed like any other handle and the edge is then asked to follow them, which is what holds a zone edge square to its neighbours.

Returns
false when a handle fails to resolve, in which case the caller drops the gesture and puts the original geometry back.

Definition at line 83 of file block_drag_displacement.cpp.

References EDIT_POINT::ApplyRelation(), resolveInCollections(), and EDIT_POINT::SetPosition().

Referenced by BLOCK_DRAG_SESSION::applyFrame(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ BlockDragMoveOrigins()

std::map< PCB_HANDLE_KEY, VECTOR2I > BlockDragMoveOrigins ( const std::vector< EDIT_POINTS * > & aCollections,
const std::set< PCB_HANDLE_KEY > & aPicked )

Note every handle the drag will move, and where each one started.

A picked edge adds itself and its two corners. Each frame places the corners first and then drives the edge, so the edge follows the same rule it would follow if the user dragged it on its own. A corner picked both directly and through an edge is listed once, so it moves once.

Returns
one entry per handle, or an empty map when a picked handle no longer resolves, which means the gesture cannot start.

Definition at line 43 of file block_drag_displacement.cpp.

References EDIT_LINE::GetEnd(), EDIT_LINE::GetOrigin(), EDIT_LINE::GetPosition(), EDIT_POINT::GetPosition(), PCB_HANDLE_KEY::Make(), and resolveInCollections().

Referenced by BLOCK_DRAG_SESSION::Begin(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ resolveInCollections()

static EDIT_POINT * resolveInCollections ( const std::vector< EDIT_POINTS * > & aCollections,
const PCB_HANDLE_KEY & aKey,
EDIT_POINTS ** aOwner = nullptr )
static