64std::optional<INTERSECTABLE_GEOM> GetBoardIntersectable(
const BOARD_ITEM& aItem )
66 switch( aItem.
Type() )
118std::optional<int64_t> FindSquareDistanceToItem(
const BOARD_ITEM& item,
const VECTOR2I& aPos )
120 std::optional<INTERSECTABLE_GEOM> intersectable = GetBoardIntersectable( item );
121 std::optional<NEARABLE_GEOM> nearable;
189 std::vector<VECTOR2I> referenceOnlyPoints;
193 std::vector<KIGFX::CONSTRUCTION_GEOM::DRAWABLE> constructionDrawables;
201 case SHAPE_T::SEGMENT:
203 if( !aExtensionOnly )
211 constructionDrawables.emplace_back(
213 constructionDrawables.emplace_back(
221 constructionDrawables.emplace_back( shape.
GetStart() );
222 constructionDrawables.emplace_back( shape.
GetEnd() );
225 referenceOnlyPoints.emplace_back( shape.
GetStart() );
226 referenceOnlyPoints.emplace_back( shape.
GetEnd() );
232 if( !aExtensionOnly )
234 constructionDrawables.push_back(
242 constructionDrawables.push_back(
245 constructionDrawables.push_back( shape.
GetCenter() );
251 constructionDrawables.emplace_back( shape.
GetStart() );
252 constructionDrawables.emplace_back( shape.
GetEnd() );
255 referenceOnlyPoints.emplace_back( shape.
GetStart() );
256 referenceOnlyPoints.emplace_back( shape.
GetEnd() );
261 case SHAPE_T::CIRCLE:
262 case SHAPE_T::RECTANGLE:
264 constructionDrawables.push_back( shape.
GetCenter() );
279 std::move( constructionDrawables ),
283 if( referenceOnlyPoints.size() )
290 std::move( constructionItemsBatch ), aIsPersistent );
296 const int c_gridSnapEpsilon_sq = 4;
303 std::vector<VECTOR2I> points;
305 const SEG testSegments[] = {
SEG( aligned, aligned +
VECTOR2( 1, 0 ) ),
310 for(
const SEG& seg : testSegments )
315 points.push_back( *vec );
322 for(
const VECTOR2I& pt : { aSeg.
A, aSeg.
B } )
324 SEG::ecoord d_sq = ( pt - aPoint ).SquaredEuclideanNorm();
326 if( d_sq < min_d_sq )
336 SEG::ecoord d_sq = ( pt - aligned ).SquaredEuclideanNorm();
338 if( d_sq < min_d_sq )
356 std::vector<VECTOR2I> points;
369 SEG::ecoord d_sq = ( pt - aPoint ).SquaredEuclideanNorm();
371 if( d_sq < min_d_sq )
381 SEG::ecoord d_sq = ( pt - aligned ).SquaredEuclideanNorm();
383 if( d_sq < min_d_sq )
401 double minDist = std::numeric_limits<double>::max();
402 ANCHOR* nearestOrigin =
nullptr;
412 hitAny = hitAny && item->
HitTest( aMousePos );
418 double dist = a.Distance( aMousePos );
427 return nearestOrigin ? nearestOrigin->
pos : aMousePos;
432 std::vector<BOARD_ITEM*>& aItems,
438 computeAnchors( aItems, aMousePos,
true, aSelectionFilter,
nullptr,
true );
446 double minDist = std::numeric_limits<double>::max();
450 minDist = nearestOrigin->
Distance( aMousePos );
451 best = nearestOrigin;
456 double dist = nearestCorner->
Distance( aMousePos );
461 best = nearestCorner;
467 double dist = nearestOutline->
Distance( aMousePos );
469 if( minDist > lineSnapMinCornerDistance && dist < minDist )
470 best = nearestOutline;
473 return best ? best->
pos : aMousePos;
481 std::vector<BOARD_ITEM*> item;
486 item.push_back( aReferenceItem );
499 const std::vector<BOARD_ITEM*>& aSkip )
502 const int snapSize = 25;
515 const BOX2I visibilityHorizon =
520 const std::vector<BOARD_ITEM*> visibleItems =
queryVisible( visibilityHorizon, aSkip );
521 computeAnchors( visibleItems, aOrigin,
false,
nullptr, &aLayers,
false );
530 ad->AddAnchor(
anchor.pos );
532 ad->SetNearest( nearest ?
OPT_VECTOR2I{ nearest->
pos } : std::nullopt );
537 std::optional<int> snapDist;
539 snapDist = nearest->
Distance( aOrigin );
546 const auto ptIsReferenceOnly = [&](
const VECTOR2I& aPt )
549 return std::find( referenceOnlyPoints.begin(), referenceOnlyPoints.end(), aPt )
550 != referenceOnlyPoints.end();
553 const auto proposeConstructionForItems = [&](
const std::vector<EDA_ITEM*>& aItems )
557 std::vector<BOARD_ITEM*> items;
570 || ( ( aLayers & boardItem->
GetLayerSet() ).any() ) )
572 items.push_back( boardItem );
582 bool snapValid =
false;
590 aOrigin, nearestGrid, snapDist, snapRange );
605 if( !ptIsReferenceOnly( *snapLineSnap ) )
607 return *snapLineSnap;
613 if( nearest && nearest->
Distance( aOrigin ) <= snapRange )
619 if( ptIsReferenceOnly( nearest->
pos ) )
632 if( !anchorIsConstructed )
634 proposeConstructionForItems( nearest->
items );
637 const auto shouldAcceptAnchor = [&](
const ANCHOR& aAnchor )
640 static const bool haveExtensions =
642 if( !haveExtensions )
652 bool allRealAreInvolved =
655 return allRealAreInvolved;
658 if( shouldAcceptAnchor( *nearest ) )
675 static const bool canActivateByHitTest =
677 if( canActivateByHitTest )
682 const int hoverAccuracy = 0;
685 if( item->
HitTest( aOrigin, hoverAccuracy ) )
687 proposeConstructionForItems( { item } );
705 if( nearestPointOnAnElement
706 && nearestPointOnAnElement->Distance( aOrigin ) <= snapRange )
708 updateSnapPoint( { *nearestPointOnAnElement, POINT_TYPE::PT_ON_ELEMENT } );
713 return *nearestPointOnAnElement;
757 switch( aItem->
Type() )
793 if( !
grid.overrides_enabled )
799 if(
grid.override_connected )
800 idx =
grid.override_connected_idx;
805 if(
grid.override_wires )
806 idx =
grid.override_wires_idx;
811 if(
grid.override_vias )
812 idx =
grid.override_vias_idx;
817 if(
grid.override_text )
818 idx =
grid.override_text_idx;
823 if(
grid.override_graphics )
824 idx =
grid.override_graphics_idx;
832 if( idx >= 0 && idx < (
int)
grid.grids.size() )
839std::vector<BOARD_ITEM*>
842 std::set<BOARD_ITEM*> items;
843 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
851 view->
Query( aArea, selectedItems );
853 for(
const auto& [ viewItem, layer ] : selectedItems )
868 if(
IsPcbLayer( layer ) && parentFP->GetPrivateLayers().test( layer ) )
875 && ( !isHighContrast || activeLayers.count( layer ) )
878 items.insert ( boardItem );
885 items.erase( aItem );
897 return {items.begin(), items.end()};
915 const VECTOR2I& aRefPos,
bool aFrom,
917 const LSET* aMatchLayers,
bool aForDrag )
919 std::vector<PCB_INTERSECTABLE> intersectables;
923 const bool computeIntersections = !aForDrag;
924 const bool computePointsOnElements = !aForDrag;
925 const bool excludeGraphics = aSelectionFilter && !aSelectionFilter->
graphics;
926 const bool excludeTracks = aSelectionFilter && !aSelectionFilter->
tracks;
928 const auto itemIsSnappable = [&](
const BOARD_ITEM& aItem )
934 || ( ( *aMatchLayers & aItem.
GetLayerSet() ).any() );
939 const auto processItem = [&](
BOARD_ITEM& item )
942 if( !itemIsSnappable( item ) )
952 if( computeIntersections || computePointsOnElements )
954 std::optional<INTERSECTABLE_GEOM> intersectableGeom;
957 intersectableGeom = GetBoardIntersectable( item );
961 intersectableGeom = GetBoardIntersectable( item );
964 if( intersectableGeom )
966 intersectables.emplace_back( &item, *intersectableGeom );
973 processItem( *item );
985 constructionItem.Constructions )
988 [&](
const auto& visited )
990 using ItemType = std::decay_t<
decltype( visited )>;
992 if constexpr( std::is_same_v<ItemType, LINE>
993 || std::is_same_v<ItemType, CIRCLE>
994 || std::is_same_v<ItemType, HALF_LINE>
995 || std::is_same_v<ItemType, SHAPE_ARC> )
997 intersectables.emplace_back( involvedItem, visited );
999 else if constexpr( std::is_same_v<ItemType, VECTOR2I> )
1003 POINT_TYPE::PT_NONE );
1016 if( computeIntersections )
1018 for( std::size_t ii = 0; ii < intersectables.size(); ++ii )
1022 for( std::size_t jj = ii + 1; jj < intersectables.size(); ++jj )
1028 if( intersectableA.
Item == intersectableB.
Item )
1031 std::vector<VECTOR2I> intersections;
1034 std::visit( visitor, intersectableB.
Geometry );
1037 for(
const VECTOR2I& intersection : intersections )
1039 std::vector<EDA_ITEM*> items = {
1040 intersectableA.
Item,
1041 intersectableB.
Item,
1044 POINT_TYPE::PT_INTERSECTION );
1053 if( computePointsOnElements )
1060 [&](
const auto& geom )
1065 intersectable.Geometry );
1079 auto checkVisibility =
1085 bool onActiveLayer = !isHighContrast;
1086 bool isLODVisible =
false;
1090 if( !onActiveLayer && activeLayers.count( layer ) )
1091 onActiveLayer =
true;
1094 isLODVisible =
true;
1096 if( onActiveLayer && isLODVisible )
1118 case PAD_SHAPE::CIRCLE:
1129 case PAD_SHAPE::OVAL:
1140 case PAD_SHAPE::RECTANGLE:
1141 case PAD_SHAPE::TRAPEZOID:
1142 case PAD_SHAPE::ROUNDRECT:
1143 case PAD_SHAPE::CHAMFERED_RECT:
1148 if( aPad->
GetShape( aLayer ) == PAD_SHAPE::TRAPEZOID )
1149 trap_delta = aPad->
GetDelta( aLayer ) / 2;
1153 corners.
Append( -half_size.
x - trap_delta.
y, half_size.
y + trap_delta.
x );
1154 corners.
Append( half_size.
x + trap_delta.
y, half_size.
y - trap_delta.
x );
1155 corners.
Append( half_size.
x - trap_delta.
y, -half_size.
y + trap_delta.
x );
1156 corners.
Append( -half_size.
x + trap_delta.
y, -half_size.
y - trap_delta.
x );
1179 if( !outline->IsEmpty() )
1181 for(
const VECTOR2I& pt : outline->Outline( 0 ).CPoints() )
1195 std::vector<TYPED_POINT2I> snap_pts;
1197 if( hole_size.
x == hole_size.
y )
1200 const CIRCLE circle( hole_pos, hole_size.
x / 2 );
1227 case SHAPE_T::CIRCLE:
1229 const int r = ( start - end ).EuclideanNorm();
1234 POINT_TYPE::PT_QUADRANT );
1236 POINT_TYPE::PT_QUADRANT );
1238 POINT_TYPE::PT_QUADRANT );
1240 POINT_TYPE::PT_QUADRANT );
1246 POINT_TYPE::PT_END );
1248 POINT_TYPE::PT_END );
1250 POINT_TYPE::PT_MID );
1252 POINT_TYPE::PT_CENTER );
1255 case SHAPE_T::RECTANGLE:
1259 SEG first( start, point2 );
1260 SEG second( point2, end );
1261 SEG third( end, point3 );
1262 SEG fourth( point3, start );
1268 addAnchor( first.
A, snapFlags, shape, POINT_TYPE::PT_CORNER );
1270 addAnchor( second.
A, snapFlags, shape, POINT_TYPE::PT_CORNER );
1272 addAnchor( third.
A, snapFlags, shape, POINT_TYPE::PT_CORNER );
1274 addAnchor( fourth.
A, snapFlags, shape, POINT_TYPE::PT_CORNER );
1279 case SHAPE_T::SEGMENT:
1283 POINT_TYPE::PT_MID );
1290 std::vector<VECTOR2I> poly;
1303 case SHAPE_T::BEZIER:
1314 switch( aItem->
Type() )
1324 if( aSelectionFilter && !aSelectionFilter->
pads )
1333 if( !checkVisibility(
pad ) )
1336 if( !
pad->GetBoundingBox().Contains( aRefPos ) )
1339 pad->Padstack().ForEachUniqueLayer(
1342 if( activeLayers.count( aLayer ) )
1343 handlePadShape(
pad, aLayer );
1347 if( aFrom && aSelectionFilter && !aSelectionFilter->
footprints )
1359 if( ( center - position ).SquaredEuclideanNorm() >
grid.SquaredEuclideanNorm() )
1368 if( aSelectionFilter && !aSelectionFilter->
pads )
1377 if( checkVisibility( aItem ) )
1381 pad->Padstack().ForEachUniqueLayer(
1384 if( activeLayers.count( aLayer ) )
1385 handlePadShape(
pad, aLayer );
1394 if( aSelectionFilter && !aSelectionFilter->
text )
1403 if( checkVisibility( aItem ) )
1404 handleShape(
static_cast<PCB_SHAPE*
>( aItem ) );
1411 if( aSelectionFilter && !aSelectionFilter->
graphics )
1420 if( checkVisibility( aItem ) )
1421 handleShape(
static_cast<PCB_SHAPE*
>( aItem ) );
1429 if( aSelectionFilter && !aSelectionFilter->
tracks )
1438 if( checkVisibility( aItem ) )
1452 POINT_TYPE::PT_CENTER );
1458 if( aSelectionFilter && !aSelectionFilter->
vias )
1467 if( checkVisibility( aItem ) )
1469 POINT_TYPE::PT_CENTER );
1474 if( aFrom && aSelectionFilter && !aSelectionFilter->
zones )
1477 if( checkVisibility( aItem ) )
1497 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
1500 if( checkVisibility( aItem ) )
1512 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
1515 if( checkVisibility( aItem ) )
1524 for(
int i = 0; i < 2; i++ )
1534 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
1537 if( checkVisibility( aItem ) )
1549 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
1552 if( checkVisibility( aItem ) )
1564 if( aFrom && aSelectionFilter && !aSelectionFilter->
text )
1567 if( checkVisibility( aItem ) )
1575 if( checkVisibility( item ) )
1592 ecoord minDist = std::numeric_limits<ecoord>::max();
1593 std::vector<ANCHOR*> anchorsAtMinDistance;
1599 if( ( aFlags &
anchor.flags ) != aFlags )
1602 if( !anchorsAtMinDistance.empty() &&
anchor.pos == anchorsAtMinDistance.front()->pos )
1605 anchorsAtMinDistance.push_back( &
anchor );
1609 const double dist =
anchor.pos.SquaredDistance( aPos );
1610 if( dist < minDist )
1614 anchorsAtMinDistance.clear();
1615 anchorsAtMinDistance.push_back( &
anchor );
1625 ecoord minDistToItem = std::numeric_limits<ecoord>::max();
1631 ecoord distToNearestItem = std::numeric_limits<ecoord>::max();
1637 std::optional<ecoord> distToThisItem =
1638 FindSquareDistanceToItem(
static_cast<const BOARD_ITEM&
>( *item ), aPos );
1640 if( distToThisItem )
1641 distToNearestItem = std::min( distToNearestItem, *distToThisItem );
1646 distToNearestItem = std::min( distToNearestItem, minDist );
1648 if( distToNearestItem < minDistToItem )
1650 minDistToItem = distToNearestItem;
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual void RunOnDescendants(const std::function< void(BOARD_ITEM *)> &aFunction, int aDepth=0) const
Invoke a function on all descendants.
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
constexpr Vec Centre() const
Represent basic circle geometry with utility geometry functions.
void CancelProposal()
Cancel outstanding proposals for new geometry.
std::vector< CONSTRUCTION_ITEM > CONSTRUCTION_ITEM_BATCH
void ProposeConstructionItems(CONSTRUCTION_ITEM_BATCH aBatch, bool aIsPersistent)
Add a batch of construction items to the helper.
bool InvolvesAllGivenRealItems(const std::vector< EDA_ITEM * > &aItems) const
Check if all 'real' (non-null = constructed) the items in the batch are in the list of items currentl...
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
KICAD_T Type() const
Returns the type of object.
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void DupPolyPointsList(std::vector< VECTOR2I > &aBuffer) const
Duplicate the list of corners in a std::vector<VECTOR2I>
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
VECTOR2I GetArcMid() const
const VECTOR2I & GetTextPos() const
void addAnchor(const VECTOR2I &aPos, int aFlags, EDA_ITEM *aItem, int aPointTypes=POINT_TYPE::PT_NONE)
SNAP_MANAGER & getSnapManager()
void showConstructionGeometry(bool aShow)
VECTOR2D GetVisibleGrid() const
std::optional< ANCHOR > m_snapItem
KIGFX::ANCHOR_DEBUG * enableAndGetAnchorDebug()
Enable the anchor debug if permitted and return it.
KIGFX::SNAP_INDICATOR m_viewSnapPoint
void updateSnapPoint(const TYPED_POINT2I &aPoint)
KIGFX::ORIGIN_VIEWITEM m_viewAxis
std::vector< ANCHOR > m_anchors
View item to draw debug items for anchors.
A color representation with 4 components: red, green, blue, alpha.
COLOR4D WithAlpha(double aAlpha) const
Return a color with the same color, but the given alpha.
std::variant< SEG, LINE, HALF_LINE, CIRCLE, SHAPE_ARC, VECTOR2I > DRAWABLE
const VECTOR2D & GetGridSize() const
Return the grid size.
void SetColor(const KIGFX::COLOR4D &aColor)
void SetStyle(MARKER_STYLE aStyle)
void SetDrawAtZero(bool aDrawFlag)
Set the draw at zero flag.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > GetHighContrastLayers() const
Returns the set of currently high-contrast layers.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
bool GetHighContrast() const
void SetSnapTypes(int aSnapTypes)
Set a mask of point types that this snap item represents.
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Class that represents an oval shape (rectangle with semicircular end caps)
const VECTOR2I & GetDrillSize() const
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
VECTOR2I GetPosition() const override
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
bool HasHole() const override
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
const VECTOR2I & GetMid() const
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
virtual const VECTOR2I & GetEnd() const
For better understanding of the points that make a dimension:
const VECTOR2I & GetCrossbarStart() const
const VECTOR2I & GetCrossbarEnd() const
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
A radial dimension indicates either the radius or diameter of an arc or circle.
std::vector< NEARABLE_GEOM > m_pointOnLineCandidates
~PCB_GRID_HELPER() override
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
BOARD_ITEM * GetSnapped() const
Function GetSnapped If the PCB_GRID_HELPER has highlighted a snap point (target shown),...
VECTOR2D GetGridSize(GRID_HELPER_GRIDS aGrid) const override
Return the size of the specified grid.
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, BOARD_ITEM *aReferenceItem, GRID_HELPER_GRIDS aGrid=GRID_HELPER_GRIDS::GRID_CURRENT)
Chooses the "best" snap anchor around the given point, optionally taking layers from the reference it...
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, std::vector< BOARD_ITEM * > &aItem, GRID_HELPER_GRIDS aGrid=GRID_HELPER_GRIDS::GRID_CURRENT, const PCB_SELECTION_FILTER_OPTIONS *aSelectionFilter=nullptr)
void AddConstructionItems(std::vector< BOARD_ITEM * > aItems, bool aExtensionOnly, bool aIsPersistent)
Add construction geometry for a set of board items.
ANCHOR * nearestAnchor(const VECTOR2I &aPos, int aFlags)
Find the nearest anchor point to the given position with matching flags.
MAGNETIC_SETTINGS * m_magneticSettings
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Gets the coarsest grid that applies to an item.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
VECTOR2I AlignToNearestPad(const VECTOR2I &aMousePos, std::deque< PAD * > &aPads)
virtual VECTOR2I Align(const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
PCB_GRID_HELPER(TOOL_MANAGER *aToolMgr, MAGNETIC_SETTINGS *aMagneticSettings)
void computeAnchors(const std::vector< BOARD_ITEM * > &aItems, const VECTOR2I &aRefPos, bool aFrom, const PCB_SELECTION_FILTER_OPTIONS *aSelectionFilter, const LSET *aLayers, bool aForDrag)
computeAnchors inserts the local anchor points in to the grid helper for the specified container of b...
std::vector< BOARD_ITEM * > queryVisible(const BOX2I &aArea, const std::vector< BOARD_ITEM * > &aSkip) const
A set of BOARD_ITEMs (i.e., without duplicates).
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
VECTOR2I GetPosition() const override
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
ecoord SquaredDistance(const SEG &aSeg) const
VECTOR2I::extended_type ecoord
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
const VECTOR2I & GetP1() const
int IntersectLine(const SEG &aSeg, std::vector< VECTOR2I > *aIpsBuffer) const
Find intersection points between this arc and aSeg, treating aSeg as an infinite line.
const VECTOR2I & GetP0() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Move(const VECTOR2I &aVector) override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
virtual const SEG GetSegment(int aIndex) const override
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
virtual size_t GetSegmentCount() const override
Represent a set of closed polygons.
CONST_ITERATOR CIterateWithHoles(int aOutline) const
A class that manages the geometry of a "snap line".
void SetSnappedAnchor(const VECTOR2I &aAnchorPos)
Inform this manager that an anchor snap has been made.
OPT_VECTOR2I GetNearestSnapLinePoint(const VECTOR2I &aCursor, const VECTOR2I &aNearestGrid, std::optional< int > aDistToNearest, int snapRange) const
If the snap line is active, return the best snap point that is closest to the cursor.
void ClearSnapLine()
Clear the snap line origin and end points.
void SetSnapLineOrigin(const VECTOR2I &aOrigin)
The snap point is a special point that is located at the last point the cursor snapped to.
void SetSnapLineEnd(const OPT_VECTOR2I &aSnapPoint)
Set the end point of the snap line.
A SNAP_MANAGER glues together the snap line manager and construction manager., along with some other ...
SNAP_LINE_MANAGER & GetSnapLineManager()
CONSTRUCTION_MANAGER & GetConstructionManager()
const std::vector< VECTOR2I > & GetReferenceOnlyPoints() const
void SetReferenceOnlyPoints(std::vector< VECTOR2I > aPoints)
Set the reference-only points - these are points that are not snapped to, but can still be used for c...
constexpr extended_type SquaredDistance(const VECTOR2< T > &aVector) const
Compute the squared distance between two vectors.
static constexpr extended_type ECOORD_MAX
VECTOR2_TRAITS< int32_t >::extended_type extended_type
Handle a list of polygons defining a copper zone.
static constexpr EDA_ANGLE ANGLE_90
@ ARC
use RECTANGLE instead of RECT to avoid collision in a Windows header
bool m_ExtensionSnapActivateOnHover
If extension snaps are enabled, 'activate' items on hover, even if not near a snap point.
bool m_EnableExtensionSnaps
Enable snap anchors based on item line extensions.
std::variant< LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, BOX2I > INTERSECTABLE_GEOM
A variant type that can hold any of the supported geometry types for intersection calculations.
bool IsPcbLayer(int aLayer)
Test whether a layer is a valid layer for Pcbnew.
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc)
@ LAYER_ANCHOR
anchor of items having an anchor point (texts, footprints)
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
std::vector< TYPED_POINT2I > GetOvalKeyPoints(const OVAL &aOval, OVAL_KEY_POINT_FLAGS aFlags)
Get a list of interesting points on an oval (rectangle with semicircular end caps)
std::vector< TYPED_POINT2I > GetCircleKeyPoints(const CIRCLE &aCircle, bool aIncludeCenter)
Get key points of an CIRCLE.
unsigned int OVAL_KEY_POINT_FLAGS
@ GEOMETRY
Position or shape has changed.
VECTOR2I GetNearestPoint(const NEARABLE_GEOM &aGeom, const VECTOR2I &aPt)
Get the nearest point on a geometry to a given point.
std::variant< LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, BOX2I, VECTOR2I > NEARABLE_GEOM
A variant type that can hold any of the supported geometry types for nearest point calculations.
Class to handle a set of BOARD_ITEMs.
std::optional< VECTOR2I > OPT_VECTOR2I
VECTOR2I::extended_type ecoord
Utility functions for working with shapes.
Items to be used for the construction of "virtual" anchors, for example, when snapping to a point inv...
std::vector< EDA_ITEM * > items
double Distance(const VECTOR2I &aP) const
A visitor that visits INTERSECTABLE_GEOM variant objects with another (which is held as state: m_othe...
PCB_INTERSECTABLE(BOARD_ITEM *aItem, INTERSECTABLE_GEOM aSeg)
INTERSECTABLE_GEOM Geometry
This file contains data structures that are saved in the project file or project local settings file ...
bool vias
Vias (all types>
bool graphics
Graphic lines, shapes, polygons.
bool footprints
Allow selecting entire footprints.
bool text
Text (free or attached to a footprint)
bool tracks
Copper tracks.
bool dimensions
Dimension items.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D