KiCad PCB EDA Suite
Loading...
Searching...
No Matches
block_drag_dependents.cpp File Reference
#include "block_drag_dependents.h"
#include <base_units.h>
#include <board.h>
#include <footprint.h>
#include <pcb_shape.h>
#include <constraints/board_constraint_adapter.h>
#include <optional>
#include <set>

Go to the source code of this file.

Functions

BLOCK_DRAG_DEPENDENT_RESULT BlockDragFindDependents (const std::vector< PCB_SHAPE * > &aCandidates, const std::vector< BLOCK_DRAG_ENDPOINT > &aMovedEndpoints, bool aOverrideLocks, std::vector< BLOCK_DRAG_ENDPOINT > &aDependents)
 Find the joined endpoints that have to follow the ones the drag moves.
 

Function Documentation

◆ BlockDragFindDependents()

BLOCK_DRAG_DEPENDENT_RESULT BlockDragFindDependents ( const std::vector< PCB_SHAPE * > & aCandidates,
const std::vector< BLOCK_DRAG_ENDPOINT > & aMovedEndpoints,
bool aOverrideLocks,
std::vector< BLOCK_DRAG_ENDPOINT > & aDependents )

Find the joined endpoints that have to follow the ones the drag moves.

An endpoint follows when it shares a layer with a moved endpoint and sits within 1 micrometre of it, or on Edge.Cuts within the board's outline chaining epsilon. Only ends count, never a point along a shape. When the endpoints gathered around one moved endpoint are not all within tolerance of each other the match is ambiguous, so that endpoint is left alone and the tolerance stays too small to close a gap the user left on purpose.

A shape that moving one end alone would distort follows WHOLE, and its far end starts the search again, so a chain of joined shapes follows as one group. The walk stops at the first shape that stretches, because that shape's far end stays where it is, and each carried shape is reached once.

The caller builds aCandidates from the graphics of the editing scope that the gesture is not moving. That scope also settles footprint children: the board editor passes board drawings, and the footprint editor passes the footprint's own children.

Returns
LOCKED when a shape that would follow, or its parent footprint, is locked and aOverrideLocks is false, with aDependents cleared.

Definition at line 51 of file block_drag_dependents.cpp.

References ConstraintItemIsLocked(), Edge_Cuts, LOCKED, moved, OK, pcbIUScale, VECTOR2< T >::SquaredDistance(), and WHOLE.

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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), 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().