KiCad PCB EDA Suite
Loading...
Searching...
No Matches
constraint_builder.h File Reference
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <vector>
#include <math/vector2d.h>
#include <geometry/eda_angle.h>
#include <constraints/pcb_constraint.h>

Go to the source code of this file.

Classes

struct  CONSTRAINT_ANCHOR_POINT
 A selectable feature of a shape (a segment endpoint, arc centre, ...) and its location. More...
 
struct  DIMENSION_ENDPOINT_BINDING
 One of a dimension feature points bound coincident to an object anchor by draw time auto constrain dimAnchor is the dimension START or END target is the anchor it binds to. More...
 

Enumerations

enum class  DIM_VALUE_MODE : int { DRIVEN , DRIVING , ARBITRARY }
 Mode a value bearing dimension value is in Driven mirrors measured geometry Driving forces geometry to the entered length Arbitrary shows custom text. More...
 

Functions

EDA_ANGLE MeasureCornerAngle (const SEG &aA, const SEG &aB)
 The corner angle between two segments, in the closed range [0, 180] degrees.
 
bool ConstraintPolygonIsModelable (const PCB_SHAPE *aShape)
 True when polygon has one non empty hole free arc free outline making it solver eligible Shared by adapter ingestion and anchor enumeration so picker matches solver.
 
std::vector< CONSTRAINT_ANCHOR_POINTConstraintShapeAnchors (const PCB_SHAPE *aShape)
 Enumerate a shape constraint anchors with positions segment and arc endpoints arc centre circle centre rectangle and polygon vertices empty list if none Shared by anchor picking and the endpoint selection overlay so both agree what is bindable.
 
std::optional< CONSTRAINT_ANCHOR_POINTConstraintShapeVertex (const PCB_SHAPE *aShape, int aIndex)
 VERTEX anchor at ordinal aIndex of a rectangle or eligible polygon or std::nullopt if the shape has no such vertex bad ordinal arc bearing polygon or wrong shape kind.
 
std::vector< PCB_SHAPE * > CollectConstraintShapes (BOARD *aBoard)
 Every PCB_SHAPE on the board (drawings plus footprint graphics) – the candidates constraints can reference.
 
std::vector< BOARD_ITEM * > CollectConstrainableItems (BOARD *aBoard)
 Every constrainable item on the board – shapes plus dimensions – for board-wide anchor picking.
 
std::optional< CONSTRAINT_MEMBERNearestAnchorAmong (const std::vector< PCB_SHAPE * > &aShapes, const VECTOR2I &aPos, double aMaxDist)
 The {shape, anchor} member nearest aPos within aMaxDist among aShapes, or std::nullopt.
 
std::unique_ptr< PCB_CONSTRAINTBuildConstraintFromItems (BOARD_ITEM *aParent, PCB_CONSTRAINT_TYPE aType, const std::vector< BOARD_ITEM * > &aItems)
 Build a constraint of aType from a set of selected board items, or nullptr if the selection does not fit the type (wrong count or kind of items).
 
std::optional< CONSTRAINT_MEMBERNearestConstraintAnchor (BOARD *aBoard, const VECTOR2I &aPos, double aMaxDist, const std::vector< CONSTRAINT_MEMBER > &aExclude={})
 Find the constrainable-item anchor (a shape's segment/arc endpoint or centre, or a dimension's feature point) nearest aPos within aMaxDist, for point-anchored constraint authoring (coincident, midpoint, ...).
 
BOARD_ITEMResolveConstrainableItem (BOARD *aBoard, const KIID &aId)
 The board item a constraint may reference: a PCB_SHAPE or a dimension, or nullptr for anything else (or a deleted item).
 
std::vector< DIMENSION_ENDPOINT_BINDINGSelectDimensionEndpointBindings (BOARD *aBoard, const KIID &aDimension, const VECTOR2I &aStart, const std::optional< VECTOR2I > &aEnd, double aMaxDist)
 Choose the coincident bindings a freshly drawn dimension endpoints should take so it tracks the geometry it measures.
 
std::vector< CONSTRAINT_ANCHOR_POINTConstraintItemAnchors (const BOARD_ITEM *aItem)
 The constraint anchors an item exposes.
 
std::optional< VECTOR2IConstraintAnchorPosition (BOARD *aBoard, const CONSTRAINT_MEMBER &aMember)
 Current location of a constraint member's anchor (its shape's START/END/CENTER, or a dimension's feature point), or std::nullopt if the referenced item is gone or exposes no such anchor.
 
double InitialConstraintValue (PCB_CONSTRAINT_TYPE aType, double aMeasured, const std::map< PCB_CONSTRAINT_TYPE, double > &aRemembered)
 Value a freshly authored constraint dialog should open with.
 
std::optional< KIIDNearestConstrainedShape (const std::vector< PCB_SHAPE * > &aCandidates, const VECTOR2I &aPos, int aMaxDist)
 The candidate shape whose outline aPos hits within aMaxDist, or std::nullopt.
 
std::optional< KIIDSelectRadialDimensionTarget (BOARD *aBoard, const KIID &aDimension, const VECTOR2I &aCenter, const VECTOR2I &aRim, double aMaxDist)
 Single circle or arc a radial dimension binds to or std::nullopt.
 
bool DimensionEndpointsBound (BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
 True when both of aDimension measured endpoints are bound to anchors that still resolve a coincident per endpoint for aligned or orthogonal or a centre and rim pair for radial the pair the draw time auto constrain authors A stale or deleted target does not count so the Driving mode this predicate gates degrades rather than drive a dimension whose link to the geometry is broken.
 
bool DimensionHasValueMode (const PCB_DIMENSION_BASE *aDimension)
 True for dimension types with a measured value aligned orthogonal or radial offering the Driven Driving or Arbitrary mode Centre and leader marks have none.
 
PCB_CONSTRAINTFindDimensionLengthConstraint (BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
 Self FIXED_LENGTH constraint whose members are exactly aDimension START and END or nullptr the driving length constraint the value mode owns Scans board level and footprint parented constraints since SetDimensionValueMode parents to the owning dimension footprint not necessarily the first.
 
bool DimensionCanDrive (BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
 True when Driving mode may be offered for aDimension needs both endpoints bound via DimensionEndpointsBound or an existing driving length so removed bindings never silently drop it.
 
DIM_VALUE_MODE DimensionValueMode (BOARD *aBoard, const PCB_DIMENSION_BASE *aDimension)
 The value mode aDimension is in, derived from state: a self driving length means Driving, else enabled override text means Arbitrary, else the default Driven (the value mirrors the measured geometry).
 
PCB_CONSTRAINTSetDimensionValueMode (BOARD *aBoard, PCB_DIMENSION_BASE *aDimension, DIM_VALUE_MODE aMode, std::optional< int > aDrivingLengthIU, const std::optional< wxString > &aOverrideText, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::function< void(BOARD_ITEM *)> &aStageAdd, const std::function< void(BOARD_ITEM *)> &aBeforeRemove)
 Apply a value mode transition to aDimension Driving creates or updates the driving length with aDrivingLengthIU Driven and Arbitrary drop any driving length Arbitrary also sets the override text from aOverrideText when provided.
 
void RemapPolygonVertexMembers (BOARD *aBoard, const KIID &aPoly, int aChangedIndex, int aDelta, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::function< void(BOARD_ITEM *)> &aBeforeRemove)
 Repoint persisted VERTEX constraint members after an outline edit of polygon aPoly inserts or removes a vertex at ordinal aChangedIndex Members at or past that point shift by aDelta so each keeps naming the corner it was authored on.
 

Enumeration Type Documentation

◆ DIM_VALUE_MODE

enum class DIM_VALUE_MODE : int
strong

Mode a value bearing dimension value is in Driven mirrors measured geometry Driving forces geometry to the entered length Arbitrary shows custom text.

Enumerator
DRIVEN 
DRIVING 
ARBITRARY 

Definition at line 225 of file constraint_builder.h.

Function Documentation

◆ BuildConstraintFromItems()

std::unique_ptr< PCB_CONSTRAINT > BuildConstraintFromItems ( BOARD_ITEM * aParent,
PCB_CONSTRAINT_TYPE aType,
const std::vector< BOARD_ITEM * > & aItems )

Build a constraint of aType from a set of selected board items, or nullptr if the selection does not fit the type (wrong count or kind of items).

The authoring tool works on whole selected shapes, so every member uses the WHOLE anchor. For the fixed-length / fixed-radius families the driving value is measured from the current geometry, so the constraint pins the shape at its present size until the user edits the value.

This is split out from the tool so the selection-to-constraint logic is unit-testable without the interactive tool framework.

Definition at line 129 of file constraint_builder.cpp.

References ANGULAR_DIMENSION, ARC_ANGLE, EDA_ANGLE::AsDegrees(), COLLINEAR, CONCENTRIC, EQUAL_LENGTH, EQUAL_RADIUS, FIXED_LENGTH, FIXED_RADIUS, EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), HORIZONTAL, MeasureCornerAngle(), PARALLEL, PERPENDICULAR, TANGENT, VERTICAL, and WHOLE.

Referenced by CONSTRAINT_EDIT_TOOL::AddConstraint(), 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 CONSTRAINT_EDIT_TOOL::pickShapeConstraint().

◆ CollectConstrainableItems()

std::vector< BOARD_ITEM * > CollectConstrainableItems ( BOARD * aBoard)

Every constrainable item on the board – shapes plus dimensions – for board-wide anchor picking.

Definition at line 404 of file constraint_builder.cpp.

References BOARD::Drawings(), BOARD::Footprints(), and PCB_SHAPE_T.

Referenced by NearestConstraintAnchor(), and SelectDimensionEndpointBindings().

◆ CollectConstraintShapes()

std::vector< PCB_SHAPE * > CollectConstraintShapes ( BOARD * aBoard)

Every PCB_SHAPE on the board (drawings plus footprint graphics) – the candidates constraints can reference.

Shared by the anchor and segment hit-tests so the board walk lives in one place.

Definition at line 378 of file constraint_builder.cpp.

References BOARD::Drawings(), and BOARD::Footprints().

Referenced by SelectRadialDimensionTarget().

◆ ConstraintAnchorPosition()

std::optional< VECTOR2I > ConstraintAnchorPosition ( BOARD * aBoard,
const CONSTRAINT_MEMBER & aMember )

◆ ConstraintItemAnchors()

std::vector< CONSTRAINT_ANCHOR_POINT > ConstraintItemAnchors ( const BOARD_ITEM * aItem)

The constraint anchors an item exposes.

Delegates to ConstraintShapeAnchors for a shape; for a dimension it returns the measured feature points (START/END for aligned/orthogonal/radial, START only for leader/center – their other point is a control point, not a feature).

Definition at line 602 of file constraint_builder.cpp.

References ConstraintShapeAnchors(), END, PCB_DIM_ALIGNED_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_SHAPE_T, START, and EDA_ITEM::Type().

Referenced by BOOST_AUTO_TEST_CASE(), ConstraintAnchorPosition(), NearestConstraintAnchor(), CONSTRAINT_OVERLAY::render(), and SelectDimensionEndpointBindings().

◆ ConstraintPolygonIsModelable()

bool ConstraintPolygonIsModelable ( const PCB_SHAPE * aShape)

True when polygon has one non empty hole free arc free outline making it solver eligible Shared by adapter ingestion and anchor enumeration so picker matches solver.

Definition at line 321 of file constraint_builder.cpp.

References SHAPE_LINE_CHAIN::ArcCount(), SHAPE_POLY_SET::COutline(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetShape(), SHAPE_POLY_SET::HoleCount(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), and POLY.

Referenced by BOARD_CONSTRAINT_ADAPTER::Build(), ConstraintShapeAnchors(), and PCB_POINT_EDITOR::updateItem().

◆ ConstraintShapeAnchors()

◆ ConstraintShapeVertex()

std::optional< CONSTRAINT_ANCHOR_POINT > ConstraintShapeVertex ( const PCB_SHAPE * aShape,
int aIndex )

VERTEX anchor at ordinal aIndex of a rectangle or eligible polygon or std::nullopt if the shape has no such vertex bad ordinal arc bearing polygon or wrong shape kind.

Point editor identifies a dragged corner or vertex by ordinal Returned position is the authoritative solve target since a clamped drag can overshoot it so never match the cursor

Definition at line 337 of file constraint_builder.cpp.

References ConstraintShapeAnchors(), EDA_SHAPE::GetShape(), POLY, and RECTANGLE.

Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and PCB_POINT_EDITOR::updateItem().

◆ DimensionCanDrive()

bool DimensionCanDrive ( BOARD * aBoard,
const PCB_DIMENSION_BASE * aDimension )

True when Driving mode may be offered for aDimension needs both endpoints bound via DimensionEndpointsBound or an existing driving length so removed bindings never silently drop it.

Definition at line 886 of file constraint_builder.cpp.

References DimensionEndpointsBound(), DimensionHasValueMode(), FindDimensionLengthConstraint(), and PCB_CONSTRAINT::IsDriving().

Referenced by BOOST_AUTO_TEST_CASE(), DIALOG_DIMENSION_PROPERTIES::buildValueModeChoice(), DIMENSION_DESC::DIMENSION_DESC(), and SetDimensionValueMode().

◆ DimensionEndpointsBound()

bool DimensionEndpointsBound ( BOARD * aBoard,
const PCB_DIMENSION_BASE * aDimension )

True when both of aDimension measured endpoints are bound to anchors that still resolve a coincident per endpoint for aligned or orthogonal or a centre and rim pair for radial the pair the draw time auto constrain authors A stale or deleted target does not count so the Driving mode this predicate gates degrades rather than drive a dimension whose link to the geometry is broken.

Definition at line 730 of file constraint_builder.cpp.

References CENTER, COINCIDENT, ConstraintAnchorPosition(), BOARD::Constraints(), END, BOARD::Footprints(), PCB_CONSTRAINT::GetConstraintType(), PCB_CONSTRAINT::GetMembers(), CONSTRAINT_MEMBER::m_anchor, CONSTRAINT_MEMBER::m_item, EDA_ITEM::m_Uuid, PCB_DIM_RADIAL_T, POINT_ON_LINE, ResolveConstrainableItem(), START, EDA_ITEM::Type(), and WHOLE.

Referenced by 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 DimensionCanDrive().

◆ DimensionHasValueMode()

bool DimensionHasValueMode ( const PCB_DIMENSION_BASE * aDimension)

True for dimension types with a measured value aligned orthogonal or radial offering the Driven Driving or Arbitrary mode Centre and leader marks have none.

Definition at line 827 of file constraint_builder.cpp.

References PCB_DIM_ALIGNED_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, and EDA_ITEM::Type().

Referenced by BOOST_AUTO_TEST_CASE(), DIMENSION_DESC::DIMENSION_DESC(), DimensionCanDrive(), and SetDimensionValueMode().

◆ DimensionValueMode()

DIM_VALUE_MODE DimensionValueMode ( BOARD * aBoard,
const PCB_DIMENSION_BASE * aDimension )

The value mode aDimension is in, derived from state: a self driving length means Driving, else enabled override text means Arbitrary, else the default Driven (the value mirrors the measured geometry).

Definition at line 900 of file constraint_builder.cpp.

References ARBITRARY, DRIVEN, DRIVING, FindDimensionLengthConstraint(), PCB_DIMENSION_BASE::GetOverrideTextEnabled(), and PCB_CONSTRAINT::IsDriving().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCB_DIMENSION_BASE::GetValueMode(), and DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow().

◆ FindDimensionLengthConstraint()

PCB_CONSTRAINT * FindDimensionLengthConstraint ( BOARD * aBoard,
const PCB_DIMENSION_BASE * aDimension )

Self FIXED_LENGTH constraint whose members are exactly aDimension START and END or nullptr the driving length constraint the value mode owns Scans board level and footprint parented constraints since SetDimensionValueMode parents to the owning dimension footprint not necessarily the first.

Definition at line 845 of file constraint_builder.cpp.

References BOARD::Constraints(), END, FIXED_LENGTH, BOARD::Footprints(), EDA_ITEM::m_Uuid, and START.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), DimensionCanDrive(), DimensionValueMode(), PCB_DIMENSION_BASE::GetValueFieldText(), SetDimensionValueMode(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), and PCB_PROPERTIES_PANEL::valueChanged().

◆ InitialConstraintValue()

double InitialConstraintValue ( PCB_CONSTRAINT_TYPE aType,
double aMeasured,
const std::map< PCB_CONSTRAINT_TYPE, double > & aRemembered )

Value a freshly authored constraint dialog should open with.

Defaults to the geometry the tool just measured Once the user types a value for a type this session that value sticks for future same type constraints instead of the new measurement Keyed by type so length and angle values never mix

Definition at line 652 of file constraint_builder.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and CONSTRAINT_EDIT_TOOL::commitConstraint().

◆ MeasureCornerAngle()

EDA_ANGLE MeasureCornerAngle ( const SEG & aA,
const SEG & aB )

The corner angle between two segments, in the closed range [0, 180] degrees.

The vertex is the nearest pair of endpoints (one per segment); the angle is measured between the two rays running from that vertex toward each segment's other endpoint. Defining both rays "away from the vertex" makes the value invariant to each segment's stored START/END order and to member order, and it reads the obtuse/acute corner the user sees (a 120 degree corner stays 120, not 60). Nearest-endpoint pairing avoids SEG::IntersectLines, so near-parallel segments stay stable.

Definition at line 98 of file constraint_builder.cpp.

References SEG::A, SEG::Angle(), SEG::B, and vA.

Referenced by BOARD_CONSTRAINT_ADAPTER::ApplyReferenceValues(), and BuildConstraintFromItems().

◆ NearestAnchorAmong()

std::optional< CONSTRAINT_MEMBER > NearestAnchorAmong ( const std::vector< PCB_SHAPE * > & aShapes,
const VECTOR2I & aPos,
double aMaxDist )

The {shape, anchor} member nearest aPos within aMaxDist among aShapes, or std::nullopt.

Shared hit-test kernel for board-wide anchor picking and the selection-scoped endpoint overlay.

Definition at line 354 of file constraint_builder.cpp.

References ConstraintShapeAnchors(), and result.

◆ NearestConstrainedShape()

std::optional< KIID > NearestConstrainedShape ( const std::vector< PCB_SHAPE * > & aCandidates,
const VECTOR2I & aPos,
int aMaxDist )

The candidate shape whose outline aPos hits within aMaxDist, or std::nullopt.

Pure over an explicit candidate set (the caller passes the constrained shapes), so hovering an unconstrained shape lying closer is ignored, and the helper stays unit-testable without the tool.

Definition at line 661 of file constraint_builder.cpp.

References PCB_SHAPE::HitTest().

Referenced by BOOST_AUTO_TEST_CASE(), and CONSTRAINT_EDIT_TOOL::onHoverMotion().

◆ NearestConstraintAnchor()

std::optional< CONSTRAINT_MEMBER > NearestConstraintAnchor ( BOARD * aBoard,
const VECTOR2I & aPos,
double aMaxDist,
const std::vector< CONSTRAINT_MEMBER > & aExclude = {} )

Find the constrainable-item anchor (a shape's segment/arc endpoint or centre, or a dimension's feature point) nearest aPos within aMaxDist, for point-anchored constraint authoring (coincident, midpoint, ...).

Anchors in aExclude are skipped by member identity (item KIID plus anchor), so the previously picked handle is passed over and the next-nearest is returned. Two distinct shapes whose endpoints coincide in space stay separately pickable, since only the exact handle is excluded.

Returns
the {item, anchor} member, or std::nullopt if no anchor is close enough.

Definition at line 430 of file constraint_builder.cpp.

References CollectConstrainableItems(), ConstraintItemAnchors(), alg::contains(), and result.

Referenced by CONSTRAINT_EDIT_TOOL::AddPointConstraint(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CONSTRAINT_EDIT_TOOL::pickLinearConstraint(), and SelectDimensionEndpointBindings().

◆ RemapPolygonVertexMembers()

void RemapPolygonVertexMembers ( BOARD * aBoard,
const KIID & aPoly,
int aChangedIndex,
int aDelta,
const std::function< void(BOARD_ITEM *)> & aBeforeModify,
const std::function< void(BOARD_ITEM *)> & aBeforeRemove )

Repoint persisted VERTEX constraint members after an outline edit of polygon aPoly inserts or removes a vertex at ordinal aChangedIndex Members at or past that point shift by aDelta so each keeps naming the corner it was authored on.

A member on the removed vertex itself cannot be repaired since every solver form is fixed arity so its whole constraint retires through aBeforeRemove a constraint about to be reindexed is staged through aBeforeModify first Callers pass the geometry commit Modify and Remove so undo restores outline indices and retired constraints together across board and footprints mirroring DimensionEndpointsBound

Definition at line 976 of file constraint_builder.cpp.

References BOARD::Constraints(), BOARD::Footprints(), and VERTEX.

Referenced by PCB_POINT_EDITOR::addCorner(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), PCB_POINT_EDITOR::chamferCorner(), and PCB_POINT_EDITOR::removeCorner().

◆ ResolveConstrainableItem()

BOARD_ITEM * ResolveConstrainableItem ( BOARD * aBoard,
const KIID & aId )

The board item a constraint may reference: a PCB_SHAPE or a dimension, or nullptr for anything else (or a deleted item).

Constraints bind these two families; everything else is unconstrainable.

Definition at line 589 of file constraint_builder.cpp.

References PCB_SHAPE_T, BOARD::ResolveItem(), and EDA_ITEM::Type().

Referenced by buildShapeConstraintMap(), ConstraintAnchorPosition(), and DimensionEndpointsBound().

◆ SelectDimensionEndpointBindings()

std::vector< DIMENSION_ENDPOINT_BINDING > SelectDimensionEndpointBindings ( BOARD * aBoard,
const KIID & aDimension,
const VECTOR2I & aStart,
const std::optional< VECTOR2I > & aEnd,
double aMaxDist )

Choose the coincident bindings a freshly drawn dimension endpoints should take so it tracks the geometry it measures.

Prefers one object near both endpoints binding START and END to it else binds each endpoint to its own nearest anchor independently possibly on different objects and partial binding is fine Excludes the dimension own anchors aEnd is std::nullopt for a leader or centre mark which binds only START

Definition at line 462 of file constraint_builder.cpp.

References CollectConstrainableItems(), ConstraintItemAnchors(), END, EDA_ITEM::m_Uuid, NearestConstraintAnchor(), and START.

Referenced by bindDimensionEndpoints(), 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().

◆ SelectRadialDimensionTarget()

std::optional< KIID > SelectRadialDimensionTarget ( BOARD * aBoard,
const KIID & aDimension,
const VECTOR2I & aCenter,
const VECTOR2I & aRim,
double aMaxDist )

Single circle or arc a radial dimension binds to or std::nullopt.

Auto constrains only when aCenter and aRim both land on the same object centre and circumference within aMaxDist Caller then binds centre coincident and rim point on circle when no single circle or arc plays both roles nothing is bound

Definition at line 674 of file constraint_builder.cpp.

References std::abs(), ARC, CENTER, CollectConstraintShapes(), ConstraintShapeAnchors(), and KiROUND().

Referenced by bindDimensionEndpoints(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ SetDimensionValueMode()

PCB_CONSTRAINT * SetDimensionValueMode ( BOARD * aBoard,
PCB_DIMENSION_BASE * aDimension,
DIM_VALUE_MODE aMode,
std::optional< int > aDrivingLengthIU,
const std::optional< wxString > & aOverrideText,
const std::function< void(BOARD_ITEM *)> & aBeforeModify,
const std::function< void(BOARD_ITEM *)> & aStageAdd,
const std::function< void(BOARD_ITEM *)> & aBeforeRemove )

Apply a value mode transition to aDimension Driving creates or updates the driving length with aDrivingLengthIU Driven and Arbitrary drop any driving length Arbitrary also sets the override text from aOverrideText when provided.

A Driving transition rejects leaving the board untouched when DimensionCanDrive fails or the length is absent or not positive so an unbound dimension never grows a constraint its geometry cannot follow

Callers pass their commit staging operations aBeforeModify runs before an item changes aStageAdd receives a fresh constraint to join the board and aBeforeRemove receives one to retire unedited

Returns
the live driving constraint for the caller to re solve once it joins the board or nullptr when the transition leaves no driving length

Definition at line 914 of file constraint_builder.cpp.

References ARBITRARY, DimensionCanDrive(), DimensionHasValueMode(), DRIVING, END, FindDimensionLengthConstraint(), FIXED_LENGTH, BOARD_ITEM::GetParentFootprint(), EDA_ITEM::m_Uuid, PCB_CONSTRAINT::SetDriving(), PCB_DIMENSION_BASE::SetOverrideText(), PCB_DIMENSION_BASE::SetOverrideTextEnabled(), PCB_CONSTRAINT::SetValue(), START, and PCB_DIMENSION_BASE::Update().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), DIALOG_DIMENSION_PROPERTIES::stageValueModeConstraint(), and PCB_PROPERTIES_PANEL::valueChanged().