KiCad PCB EDA Suite
Loading...
Searching...
No Matches
block_drag_dependents.h File Reference
#include <vector>
#include <math/vector2d.h>

Go to the source code of this file.

Classes

struct  BLOCK_DRAG_ENDPOINT
 One end of a graphic shape, used both for the ends that moved and for the ones found to follow them. More...
 

Enumerations

enum class  BLOCK_DRAG_FOLLOW { STRETCH , WHOLE }
 How a shape follows the endpoint it is joined to. More...
 
enum class  BLOCK_DRAG_DEPENDENT_RESULT { OK , LOCKED }
 

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.
 

Enumeration Type Documentation

◆ BLOCK_DRAG_DEPENDENT_RESULT

enum class BLOCK_DRAG_DEPENDENT_RESULT
strong
Enumerator
OK 
LOCKED 

A shape that would have to follow is locked and Override Locks is off, so the drag has to stop.

Definition at line 55 of file block_drag_dependents.h.

◆ BLOCK_DRAG_FOLLOW

enum class BLOCK_DRAG_FOLLOW
strong

How a shape follows the endpoint it is joined to.

Enumerator
STRETCH 

Only this end moves, so the shape stretches.

The name ENDPOINT is taken by a macro in eda_item_flags.h.

WHOLE 

The whole shape moves, for a shape that moving one end alone would distort.

Its far end travels too, so the chain carries on from there.

Definition at line 32 of file block_drag_dependents.h.

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