27#include <unordered_set>
79std::optional<int64_t> FindSquareDistanceToItem(
const BOARD_ITEM& item,
const VECTOR2I& aPos )
82 std::optional<NEARABLE_GEOM> nearable;
88 [&](
const auto& geom )
180 auto constructionItemsBatch = std::make_unique<CONSTRUCTION_MANAGER::CONSTRUCTION_ITEM_BATCH>();
182 std::vector<VECTOR2I> referenceOnlyPoints;
186 std::vector<KIGFX::CONSTRUCTION_GEOM::DRAWABLE> constructionDrawables;
188 switch( item->
Type() )
198 if( !aExtensionOnly )
214 constructionDrawables.emplace_back( shape.
GetStart() );
215 constructionDrawables.emplace_back( shape.
GetEnd() );
218 referenceOnlyPoints.emplace_back( shape.
GetStart() );
219 referenceOnlyPoints.emplace_back( shape.
GetEnd() );
225 if( !aExtensionOnly )
236 constructionDrawables.push_back( shape.
GetCenter() );
242 constructionDrawables.emplace_back( shape.
GetStart() );
243 constructionDrawables.emplace_back( shape.
GetEnd() );
246 referenceOnlyPoints.emplace_back( shape.
GetStart() );
247 referenceOnlyPoints.emplace_back( shape.
GetEnd() );
255 constructionDrawables.push_back( shape.
GetCenter() );
275 constructionDrawables.push_back( refImg.
GetPosition() );
281 constructionDrawables.push_back( seg );
295 std::vector<CONSTRUCTION_MANAGER::CONSTRUCTION_ITEM::DRAWABLE_ENTRY> drawableEntries;
296 drawableEntries.reserve( constructionDrawables.size() );
297 for(
auto&
drawable : constructionDrawables )
299 drawableEntries.emplace_back(
306 std::move( drawableEntries ),
310 if( referenceOnlyPoints.size() )
334 return SnapToGrid( active, aPoint );
340 const int snapSize = 25;
341 double snapScreen =
m_toolMgr->GetView()->ToWorld( snapSize );
353 if( !
grid->Affects().cursor )
356 if(
grid->IsSelected() )
369 const SEG::ecoord dist = ( candidate - aPoint ).SquaredEuclideanNorm();
371 if( dist < bestDist )
384 const int c_gridSnapEpsilon_sq = 4;
391 std::vector<VECTOR2I> points;
393 const SEG testSegments[] = {
SEG( aligned, aligned +
VECTOR2( 1, 0 ) ),
398 for(
const SEG& seg : testSegments )
403 points.push_back( *vec );
410 for(
const VECTOR2I& pt : { aSeg.
A, aSeg.
B } )
412 SEG::ecoord d_sq = ( pt - aPoint ).SquaredEuclideanNorm();
414 if( d_sq < min_d_sq )
424 SEG::ecoord d_sq = ( pt - aligned ).SquaredEuclideanNorm();
426 if( d_sq < min_d_sq )
444 std::vector<VECTOR2I> points;
457 SEG::ecoord d_sq = ( pt - aPoint ).SquaredEuclideanNorm();
459 if( d_sq < min_d_sq )
469 SEG::ecoord d_sq = ( pt - aligned ).SquaredEuclideanNorm();
471 if( d_sq < min_d_sq )
484 wxLogTrace(
traceSnap,
"SnapToPad: mouse pos (%d, %d), pads count: %zu", aMousePos.
x, aMousePos.
y, aPads.size() );
489 if( item->
HitTest( aMousePos ) )
493 double minDist = std::numeric_limits<double>::max();
494 ANCHOR* nearestOrigin =
nullptr;
501 double dist = a.Distance( aMousePos );
510 return nearestOrigin ? nearestOrigin->
pos : aMousePos;
546 return static_cast<const FOOTPRINT&
>( aItem ).GetBoundingBox(
false );
580 return applyOverride();
587 settings = cfg->m_SnapInference;
591 settings = cfg->m_SnapInference;
597 settings = cfg->m_SnapInference;
600 return applyOverride();
608 wxLogTrace(
traceSnap,
"BestDragOrigin: mouse pos (%d, %d), items count: %zu", aMousePos.
x, aMousePos.
y,
612 computeAnchors( aItems, aMousePos,
true, aSelectionFilter,
nullptr,
true );
614 double lineSnapMinCornerDistance =
m_toolMgr->GetView()->ToWorld( 50 );
620 double minDist = std::numeric_limits<double>::max();
624 minDist = nearestOrigin->
Distance( aMousePos );
625 best = nearestOrigin;
627 wxLogTrace(
traceSnap,
" nearest origin winning at (%d, %d), distance=%f", nearestOrigin->
pos.
x,
628 nearestOrigin->
pos.
y, minDist );
633 double dist = nearestCorner->
Distance( aMousePos );
638 best = nearestCorner;
640 wxLogTrace(
traceSnap,
" nearest corner winning at (%d, %d), distance=%f", nearestCorner->
pos.
x,
641 nearestCorner->
pos.
y, dist );
647 double dist = nearestOutline->
Distance( aMousePos );
649 if( minDist > lineSnapMinCornerDistance && dist < minDist )
651 best = nearestOutline;
653 wxLogTrace(
traceSnap,
" nearest outline winning at (%d, %d), distance=%f", nearestOutline->
pos.
x,
654 nearestOutline->
pos.
y, dist );
662 std::optional<BOX2I> movingBounds;
676 && std::any_of( best->
items.begin(), best->
items.end(),
679 return aItem && aItem->Type() == PCB_PAD_T;
689 wxLogTrace(
traceSnap,
" have best: %s, returning (%d, %d)", best ?
"yes" :
"no", ret.
x, ret.
y );
697 std::vector<BOARD_ITEM*> item;
702 item.push_back( aReferenceItem );
707 layers =
LSET( { frame->GetActiveLayer() } );
714 return ResolveSnap( aOrigin, layers, aGrid, item );
719 const std::vector<BOARD_ITEM*>& aSkip,
720 std::optional<VECTOR2I> aMovingReferencePoint )
722 wxLogTrace(
traceSnap,
"ResolveSnap: origin (%d, %d), enableSnap=%d, enableGrid=%d, enableSnapLine=%d", aOrigin.
x,
726 const double snapScale = ranges.
scale;
727 const int snapRange = ranges.
range;
731 const bool constructionEnabled =
734 if( !constructionEnabled )
738 const BOX2I visibilityHorizon =
743 const std::vector<BOARD_ITEM*> visibleItems =
queryVisible( { visibilityHorizon }, aSkip );
744 computeAnchors( visibleItems, aOrigin,
false,
nullptr, &aLayers,
false );
767 if( aSkip.size() == 1 && aSkip.front() )
771 std::optional<std::pair<VECTOR2I, VECTOR2I>> endpoints;
792 endpoints->first.SquaredDistance( aOrigin ) > endpoints->second.SquaredDistance( aOrigin )
802 const bool geometryEnabled =
816 if( inferenceEnabled )
818 const auto eligibleInferenceTarget = [&](
BOARD_ITEM* aItem )
825 switch( aItem->Type() )
838 if( !eligibleInferenceTarget( item ) )
841 if( !geometryEnabled )
850 static_cast<int>( item->
Type() ), 0 },
851 std::move( *geometry ),
857 std::vector<BOARD_ITEM*> layoutItems;
866 BOX2I verticalStrip =
869 BOX2I horizontalStrip =
872 verticalStrip = verticalStrip.
Intersect( viewport );
873 horizontalStrip = horizontalStrip.
Intersect( viewport );
874 std::vector<BOARD_ITEM*> visibleLayoutItems =
queryVisible( { verticalStrip, horizontalStrip }, aSkip );
882 if( footprint && !insideFootprint )
883 layoutItems.push_back( footprint );
885 layoutItems.push_back( item );
888 std::sort( layoutItems.begin(), layoutItems.end(), std::less<>() );
889 layoutItems.erase( std::unique( layoutItems.begin(), layoutItems.end() ), layoutItems.end() );
893 std::unordered_set<BOARD_ITEM*> moving( aSkip.begin(), aSkip.end() );
900 moving.insert( parent );
908 if( !eligibleInferenceTarget( item ) || moving.count( item ) )
911 std::optional<SNAP_TARGET_ID> parent;
917 static_cast<int>( item->
Type() ), 0 },
919 std::move( parent ) } );
922 size_t padCenters = 0;
924 const auto addPadCenter = [&](
PAD* aPad )
926 if( !eligibleInferenceTarget( aPad ) || moving.count( aPad ) )
929 std::optional<SNAP_TARGET_ID> parent;
936 std::move( parent ) } );
944 addPadCenter(
static_cast<PAD*
>( item ) );
953 wxLogTrace( wxT(
"KICAD_SNAP_RESOLVER" ),
"layout targets=%zu pad-centers=%zu", layoutItems.size(),
958 enum class PRESENTATION_KIND
967 PRESENTATION_KIND kind;
968 std::optional<ANCHOR>
anchor;
969 bool proposeConstruction =
false;
983 frame.
candidates.push_back( std::move( candidate ) );
989 frame.
candidates.push_back( std::move( candidate ) );
994 std::vector<SNAP_CANDIDATE> alignment = inferenceProvider.
CollectAlignment( context, snapRange );
995 std::vector<SNAP_CANDIDATE> spacing = inferenceProvider.
CollectEqualSpacing( context, snapRange );
997 wxLogTrace( wxT(
"KICAD_SNAP_RESOLVER" ),
"layout candidates alignment=%zu spacing=%zu", alignment.size(),
1001 frame.
candidates.push_back( std::move( candidate ) );
1004 frame.
candidates.push_back( std::move( candidate ) );
1009 const int snapIn = ranges.
in;
1010 const int snapOut = ranges.
out;
1012 wxLogTrace(
traceSnap,
" snapRange=%d, snapIn=%d, snapOut=%d", snapRange, snapIn, snapOut );
1013 wxLogTrace(
traceSnap,
" visibleItems count=%zu, anchors count=%zu", visibleItems.size(),
m_anchors.size() );
1014 wxLogTrace(
traceSnap,
" nearest anchor: %s at (%d, %d), distance=%f", nearest ?
"found" :
"none",
1015 nearest ? nearest->
pos.
x : 0, nearest ? nearest->
pos.
y : 0,
1016 nearest ? nearest->
Distance( aOrigin ) : -1.0 );
1017 wxLogTrace(
traceSnap,
" nearestGrid: (%d, %d)", nearestGrid.
x, nearestGrid.
y );
1024 ad->AddAnchor(
anchor.pos );
1026 ad->SetNearest( nearest ?
OPT_VECTOR2I{ nearest->
pos } : std::nullopt );
1031 std::optional<int> snapDist;
1034 snapDist = nearest->
Distance( aOrigin );
1038 int existingDist =
m_snapItem->Distance( aOrigin );
1039 if( !snapDist || existingDist < *snapDist )
1040 snapDist = existingDist;
1043 wxLogTrace(
traceSnap,
" snapDist: %s (value=%d)", snapDist ?
"set" :
"none", snapDist ? *snapDist : -1 );
1051 const auto ptIsReferenceOnly = [&](
const VECTOR2I& aPt )
1054 return std::find( referenceOnlyPoints.begin(), referenceOnlyPoints.end(), aPt ) != referenceOnlyPoints.end();
1057 const auto proposeConstructionForItems = [&](
const std::vector<EDA_ITEM*>& aItems )
1061 std::vector<BOARD_ITEM*> items;
1077 items.push_back( boardItem );
1083 if( constructionEnabled )
1087 const auto anchorId = [&](
const ANCHOR& aAnchor )
1089 std::vector<SNAP_TARGET_ID> targets;
1091 for(
const EDA_ITEM* item : aAnchor.items )
1101 if( targets.empty() )
1104 targets.push_back( pointId.
target );
1108 const auto addAnchorCandidate = [&](
const ANCHOR& aAnchor,
bool aRetained )
1124 aAnchor.
pos, aAnchor.
Distance( aOrigin ) / snapScale ) );
1126 id, PRESENTATION{ PRESENTATION_KIND::ANCHOR_MARKER, aAnchor, !aRetained && !constructed } );
1133 const bool nearestCaptured = nearest && nearest->
Distance( aOrigin ) <= snapIn;
1134 bool keepConstructionProposal =
false;
1135 bool allowHoverActivation =
false;
1139 wxLogTrace(
traceSnap,
" Snap enabled, checking snap options..." );
1140 allowHoverActivation = !nearestCaptured;
1144 wxLogTrace(
traceSnap,
" Checking snap lines..." );
1149 if( !snapLineSnap && constructionEnabled )
1151 std::optional<VECTOR2I> constructionSnap =
1154 if( constructionSnap )
1155 snapLineSnap = *constructionSnap;
1158 if( snapLineSnap &&
m_skipPoint != *snapLineSnap )
1160 wxLogTrace(
traceSnap,
" Snap line found at (%d, %d)", snapLineSnap->x, snapLineSnap->y );
1162 if( !nearestCaptured )
1164 if( !ptIsReferenceOnly( *snapLineSnap ) )
1169 *snapLineSnap, snapLineSnap->Distance( aOrigin ) / snapScale ) );
1170 frame.
presentation.emplace(
id, PRESENTATION{ PRESENTATION_KIND::GUIDE, std::nullopt,
false } );
1174 wxLogTrace(
traceSnap,
" Snap line point is reference-only, continuing..." );
1175 keepConstructionProposal =
true;
1185 wxLogTrace(
traceSnap,
" Checking existing m_snapItem, dist=%d (snapOut=%d)", dist, snapOut );
1187 if( dist <= snapOut && !ptIsReferenceOnly(
m_snapItem->pos ) )
1189 if( nearest && ptIsReferenceOnly( nearest->
pos ) && nearest->
Distance( aOrigin ) <= snapRange )
1196 if( nearestCaptured )
1198 wxLogTrace(
traceSnap,
" Nearest anchor within snapIn range" );
1200 if( ptIsReferenceOnly( nearest->
pos ) )
1202 wxLogTrace(
traceSnap,
" Nearest anchor is reference-only, setting snap line origin" );
1204 keepConstructionProposal =
true;
1208 addAnchorCandidate( *nearest,
false );
1214 wxLogTrace(
traceSnap,
" Grid disabled, checking point-on-element snap..." );
1218 if( nearestPointOnAnElement && nearestPointOnAnElement->Distance( aOrigin ) <= snapRange )
1223 *nearestPointOnAnElement, nearestPointOnAnElement->Distance( aOrigin ) / snapScale ) );
1225 PRESENTATION{ PRESENTATION_KIND::POINT_ON_ELEMENT, std::nullopt,
false } );
1241 return m_suppressedSnapSubtypes.contains( aCandidate.subtype );
1251 bool suppressHoverActivation =
false;
1255 const PRESENTATION& presentation = output.
presentation->payload;
1256 keepConstructionProposal =
true;
1258 if( presentation.kind == PRESENTATION_KIND::ANCHOR_MARKER && presentation.anchor )
1260 suppressHoverActivation =
true;
1265 if( presentation.proposeConstruction )
1266 proposeConstructionForItems(
m_snapItem->items );
1268 else if( presentation.kind == PRESENTATION_KIND::GUIDE )
1270 suppressHoverActivation =
true;
1275 else if( presentation.kind == PRESENTATION_KIND::POINT_ON_ELEMENT )
1289 if( constructionEnabled && canActivateByHitTest && allowHoverActivation && !suppressHoverActivation )
1293 if( item->
HitTest( aOrigin, 0 ) )
1295 proposeConstructionForItems( { item } );
1296 keepConstructionProposal =
true;
1302 if( !keepConstructionProposal )
1338 switch( aItem->
Type() )
1375 if( !
grid.overrides_enabled )
1381 if(
grid.override_connected )
1382 idx =
grid.override_connected_idx;
1387 if(
grid.override_wires )
1388 idx =
grid.override_wires_idx;
1393 if(
grid.override_vias )
1394 idx =
grid.override_vias_idx;
1399 if(
grid.override_text )
1400 idx =
grid.override_text_idx;
1405 if(
grid.override_graphics )
1406 idx =
grid.override_graphics_idx;
1414 if( idx >= 0 && idx < (
int)
grid.grids.size() )
1422 const std::vector<BOARD_ITEM*>& aSkip )
const
1424 std::vector<BOARD_ITEM*> items;
1425 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> visibleItems;
1435 for(
const BOX2I& area : aAreas )
1437 if( area.GetWidth() > 0 && area.GetHeight() > 0 )
1438 view->
Query( area, visibleItems );
1441 for(
const auto& [viewItem, layer] : visibleItems )
1443 if( !viewItem->IsBOARD_ITEM() )
1448 if( inFootprintEditor )
1459 if(
IsPcbLayer( layer ) && parentFP->GetPrivateLayers().test( layer ) )
1465 if( view->
IsVisible( boardItem ) && ( !isHighContrast || activeLayers.count( layer ) )
1468 items.push_back( boardItem );
1472 std::sort( items.begin(), items.end(), std::less<>() );
1473 items.erase( std::unique( items.begin(), items.end() ), items.end() );
1475 std::unordered_set<BOARD_ITEM*> skippedItems;
1482 skippedItems.insert( item );
1486 skippedItems.insert( aChild );
1491 items.erase( std::remove_if( items.begin(), items.end(),
1494 return skippedItems.contains( aItem );
1520 std::vector<PCB_INTERSECTABLE> intersectables;
1521 intersectables.reserve( aItems.size() );
1525 const bool computeIntersections = !aForDrag;
1526 const bool computePointsOnElements = !aForDrag;
1527 const bool excludeGraphics = aSelectionFilter && !aSelectionFilter->
graphics;
1528 const bool excludeTracks = aSelectionFilter && !aSelectionFilter->
tracks;
1530 const auto itemIsSnappable =
1540 const auto processItem =
1544 if( !itemIsSnappable( item ) )
1552 if( computeIntersections || computePointsOnElements )
1554 std::optional<INTERSECTABLE_GEOM> intersectableGeom;
1556 if( !excludeGraphics
1566 if( intersectableGeom )
1567 intersectables.emplace_back( &item, *intersectableGeom );
1573 processItem( *item );
1585 [&](
const auto& visited )
1587 using ItemType = std::decay_t<
decltype( visited )>;
1589 if constexpr( std::is_same_v<ItemType, LINE>
1590 || std::is_same_v<ItemType, CIRCLE>
1591 || std::is_same_v<ItemType, HALF_LINE>
1592 || std::is_same_v<ItemType, SHAPE_ARC> )
1594 intersectables.emplace_back( involvedItem, visited );
1596 else if constexpr( std::is_same_v<ItemType, VECTOR2I> )
1612 if( computeIntersections )
1614 for( std::size_t ii = 0; ii < intersectables.size(); ++ii )
1618 for( std::size_t jj = ii + 1; jj < intersectables.size(); ++jj )
1624 if( intersectableA.
Item == intersectableB.
Item )
1627 std::vector<VECTOR2I> intersections;
1630 std::visit( visitor, intersectableB.
Geometry );
1633 for(
const VECTOR2I& intersection : intersections )
1635 std::vector<EDA_ITEM*> items = {
1636 intersectableA.
Item,
1637 intersectableB.
Item,
1650 if( computePointsOnElements )
1657 [&](
const auto& geom )
1662 intersectable.Geometry );
1674 switch( aPadStack.
Mode() )
1684 switch( aPadstackUniqueLayer )
1689 return aPadstackUniqueLayer == aRealLayer;
1694 wxFAIL_MSG( wxString::Format(
"Unexpected padstack unique layer %d in FRONT_INNER_BACK mode",
1695 aPadstackUniqueLayer ) );
1703 return aRealLayer == aPadstackUniqueLayer;
1714 std::vector<ANCHOR_SPEC> anchors;
1741 const auto checkVisibility =
1748 bool onActiveLayer = !isHighContrast;
1749 bool isLODVisible =
false;
1753 if( !onActiveLayer && activeLayers.count( layer ) )
1754 onActiveLayer =
true;
1757 isLODVisible =
true;
1759 if( onActiveLayer && isLODVisible )
1772 auto handlePadShape =
1811 trap_delta = aPad->
GetDelta( aLayer ) / 2;
1815 corners.
Append( -half_size.
x - trap_delta.
y, half_size.
y + trap_delta.
x );
1816 corners.
Append( half_size.
x + trap_delta.
y, half_size.
y - trap_delta.
x );
1817 corners.
Append( half_size.
x - trap_delta.
y, -half_size.
y + trap_delta.
x );
1818 corners.
Append( -half_size.
x + trap_delta.
y, -half_size.
y - trap_delta.
x );
1841 if( !outline->IsEmpty() )
1843 for(
const VECTOR2I& pt : outline->Outline( 0 ).CPoints() )
1857 std::vector<TYPED_POINT2I> snap_pts;
1859 if( hole_size.
x == hole_size.
y )
1882 const auto addRectPoints =
1889 const SEG second( topRight, aBox.
GetEnd() );
1890 const SEG third( aBox.
GetEnd(), bottomLeft );
1907 const auto handleShape =
1910 VECTOR2I start = shape->GetStart();
1913 switch( shape->GetShape() )
1917 const int r = ( start -
end ).EuclideanNorm();
1951 for(
const VECTOR2I& p : shape->GetPolyPoints() )
1964 int majorR = shape->GetEllipseMajorRadius();
1965 int minorR = shape->GetEllipseMinorRadius();
1966 EDA_ANGLE rot = shape->GetEllipseRotation();
1997 switch( aItem->
Type() )
2002 bool footprintVisible = checkVisibility( footprint );
2008 if( aSelectionFilter && !aSelectionFilter->
pads )
2017 if( !checkVisibility(
pad ) )
2020 if( !
pad->GetBoundingBox().Contains( aRefPos ) )
2023 pad->Padstack().ForEachUniqueLayer(
2028 activeHighContrastPrimaryLayer ) )
2030 handlePadShape(
pad, aLayer );
2038 if( aSelectionFilter && !aSelectionFilter->
points )
2041 if( !checkVisibility( pt ) )
2052 if( !footprintVisible && !aFrom )
2055 if( aFrom && aSelectionFilter && !aSelectionFilter->
footprints )
2074 if( (
center - position ).SquaredEuclideanNorm() >
grid.SquaredEuclideanNorm() )
2083 if( aSelectionFilter && !aSelectionFilter->
pads )
2092 if( checkVisibility( aItem ) )
2096 pad->Padstack().ForEachUniqueLayer(
2101 activeHighContrastPrimaryLayer ) )
2103 handlePadShape(
pad, aLayer );
2113 if( aSelectionFilter && !aSelectionFilter->
text )
2122 if( checkVisibility( aItem ) )
2123 handleShape(
static_cast<PCB_SHAPE*
>( aItem ) );
2131 if( aSelectionFilter && !aSelectionFilter->
text )
2140 if( checkVisibility( aItem ) )
2145 VECTOR2I topLeft =
table->GetCell( 0, 0 )->GetCornersInSequence( drawAngle )[0];
2147 table->GetCell(
table->GetRowCount() - 1, 0 )->GetCornersInSequence( drawAngle )[3];
2148 VECTOR2I topRight =
table->GetCell( 0,
table->GetColCount() - 1 )->GetCornersInSequence( drawAngle )[1];
2150 ->GetCornersInSequence( drawAngle )[2];
2165 if( aSelectionFilter && !aSelectionFilter->
graphics )
2173 if( checkVisibility( aItem ) )
2195 if( aSelectionFilter && !aSelectionFilter->
graphics )
2204 if( checkVisibility( aItem ) )
2205 handleShape(
static_cast<PCB_SHAPE*
>( aItem ) );
2213 if( aSelectionFilter && !aSelectionFilter->
tracks )
2222 if( checkVisibility( aItem ) )
2234 addAnchor( spec.pos, spec.flags, arc, spec.pointType );
2259 const auto pushHandle = [&](
VECTOR2I aLocal )
2285 if( aSelectionFilter && !aSelectionFilter->
points )
2288 if( checkVisibility( aItem ) )
2296 if( aSelectionFilter && !aSelectionFilter->
vias )
2305 if( checkVisibility( aItem ) )
2311 if( aFrom && aSelectionFilter && !aSelectionFilter->
zones )
2314 if( checkVisibility( aItem ) )
2334 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
2337 if( checkVisibility( aItem ) )
2349 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
2352 if( checkVisibility( aItem ) )
2361 for(
int i = 0; i < 2; i++ )
2371 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
2374 if( checkVisibility( aItem ) )
2386 if( aFrom && aSelectionFilter && !aSelectionFilter->
dimensions )
2389 if( checkVisibility( aItem ) )
2401 if( aFrom && aSelectionFilter && !aSelectionFilter->
text )
2404 if( checkVisibility( aItem ) )
2410 if( aFrom && aSelectionFilter && !aSelectionFilter->
otherItems )
2413 if( checkVisibility( aItem ) )
2419 addRectPoints( bbox, *barcode );
2427 if( checkVisibility( item ) )
2434 if( aFrom && aSelectionFilter && !aSelectionFilter->
graphics )
2437 if( checkVisibility( aItem ) )
2443 addRectPoints( bbox, *
image );
2465 ecoord minDist = std::numeric_limits<ecoord>::max();
2466 std::vector<ANCHOR*> anchorsAtMinDistance;
2472 if( ( aFlags &
anchor.flags ) != aFlags )
2475 if( !anchorsAtMinDistance.empty() &&
anchor.pos == anchorsAtMinDistance.front()->pos )
2478 anchorsAtMinDistance.push_back( &
anchor );
2482 const double dist =
anchor.pos.SquaredDistance( aPos );
2484 if( dist < minDist )
2488 anchorsAtMinDistance.clear();
2489 anchorsAtMinDistance.push_back( &
anchor );
2503 auto noRealItemsInAnchorAreInvolved =
2504 [&](
ANCHOR* aAnchor ) ->
bool
2509 if( !haveExtensions )
2517 if( !anchorIsConstructed )
2521 return !allRealAreInvolved;
2525 std::erase_if( anchorsAtMinDistance, noRealItemsInAnchorAreInvolved );
2532 ecoord minDistToItem = std::numeric_limits<ecoord>::max();
2538 ecoord distToNearestItem = std::numeric_limits<ecoord>::max();
2545 std::optional<ecoord> distToThisItem =
2546 FindSquareDistanceToItem(
static_cast<const BOARD_ITEM&
>( *item ), aPos );
2548 if( distToThisItem )
2549 distToNearestItem = std::min( distToNearestItem, *distToThisItem );
2554 distToNearestItem = std::min( distToNearestItem, minDist );
2556 if( distToNearestItem < minDistToItem )
2558 minDistToItem = distToNearestItem;
constexpr EDA_IU_SCALE pcbIUScale
std::optional< INTERSECTABLE_GEOM > BoardItemIntersectable(const BOARD_ITEM &aItem)
The kimath primitive a board item is made of.
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 RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
BOARD_ITEM_CONTAINER * GetParent() const
Information pertinent to a Pcbnew printed circuit board.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
const DRAWINGS & Drawings() const
constexpr BOX2< Vec > Intersect(const BOX2< Vec > &aRect)
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
static constexpr BOX2< VECTOR2I > ByCorners(const VECTOR2I &aCorner1, const VECTOR2I &aCorner2)
constexpr const Vec GetEnd() const
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr const Vec GetCenter() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr void Offset(coord_type dx, coord_type dy)
constexpr coord_type GetBottom() const
Represent basic circle geometry with utility geometry functions.
void ProposeConstructionItems(std::unique_ptr< CONSTRUCTION_ITEM_BATCH > aBatch, bool aIsPersistent)
Add a batch of construction items to the helper.
void CancelProposal()
Cancel outstanding proposals for new geometry.
void Clear()
Clear all construction items.
std::vector< CONSTRUCTION_ITEM > CONSTRUCTION_ITEM_BATCH
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
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
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 & GetEllipseCenter() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
VECTOR2I GetArcMid() const
void retainAcceptedSnaps(const SNAP_RESULT &aResult)
Record which snaps the resolver accepted so they can be re-biased on the next resolve,...
std::optional< VECTOR2I > SnapToConstructionLines(const VECTOR2I &aPoint, const VECTOR2I &aNearestGrid, const VECTOR2D &aGrid, double aSnapRange) const
void addAnchor(const VECTOR2I &aPos, int aFlags, EDA_ITEM *aItem, int aPointTypes=POINT_TYPE::PT_NONE)
SNAP_MANAGER & getSnapManager()
SNAP_RANGES computeSnapRanges(bool aClampToVisibleGrid) const
Compute the snap thresholds.
void emitAngleBranchCandidates(std::vector< SNAP_CANDIDATE > &aCandidates, const VECTOR2I &aOrigin, double aSnapScale) const
Emit the angle-restriction snap candidates (the two branches bracketing the cursor angle) into the cu...
void showConstructionGeometry(bool aShow)
SNAP_RESOLVER::FEASIBILITY_CALLBACK m_feasibilityCallback
std::vector< SEG > m_stationarySelfSegments
VECTOR2D GetVisibleGrid() const
SNAP_RESOLVER::TRACE_CALLBACK snapTraceCallback(const SNAP_SOURCE_CONTEXT &aContext) const
VECTOR2I GetOrigin() const
bool canUseGrid() const
Check whether it is possible to use the grid – this depends both on local grid helper settings and gl...
std::optional< SNAP_STABLE_ID > m_retainedAngleBranch
std::optional< ANCHOR > m_snapItem
SNAP_REFERENCE_PREFERENCE m_layoutReferencePreference
KIGFX::ANCHOR_DEBUG * enableAndGetAnchorDebug()
Enable the anchor debug if permitted and return it.
KIGFX::SNAP_INDICATOR m_viewSnapPoint
virtual VECTOR2I Align(const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const
void updateSnapPoint(const TYPED_POINT2I &aPoint)
KIGFX::ORIGIN_VIEWITEM m_viewAxis
std::vector< SNAP_STABLE_ID > m_stickySnapIds
void setLayoutReference(const VECTOR2I &aPoint, const std::optional< BOX2I > &aBounds, bool aAnchorPoint)
Record the classified drag reference and trace it.
void emitSelfAndGridCandidates(std::vector< SNAP_CANDIDATE > &aCandidates, const SNAP_SOURCE_CONTEXT &aContext, const VECTOR2I &aOrigin, const VECTOR2I &aNearestGrid, double aSnapScale, int aSnapRange, bool aUseGrid) const
Emit the point editor's unchanged self-geometry and the independent grid axes.
void applySnapResultGuides(const SNAP_RESULT &aResult)
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.
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
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.
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
bool GetHighContrast() const
bool IsBOARD_ITEM() const
virtual double ViewGetLOD(int aLayer, const 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.
void SyncLayerVisibilityCache()
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 const LSET & AllLayersMask()
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
@ NORMAL
Shape is the same on all layers.
@ CUSTOM
Shapes can be defined on arbitrary layers.
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
static constexpr PCB_LAYER_ID INNER_LAYERS
! The layer identifier to use for "inner layers" on top/inner/bottom padstacks
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
VECTOR2I GetPosition() const override
VECTOR2I GetDrillSize() const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
VECTOR2I GetSize(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 & GetMid() const
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
const SHAPE_POLY_SET & GetSymbolPoly() const
Access the cached polygon for the barcode symbol only (no text, no margins/knockout).
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual VECTOR2I GetEnd() const
virtual VECTOR2I GetStart() const
The dimension's origin is the first feature point for the dimension.
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.
Turns on drill symbols at the holes, for one layer.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
const VECTOR2I & GetOffset() const
std::vector< NEARABLE_GEOM > m_pointOnLineCandidates
void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aRemovedItem) override
std::vector< BOARD_ITEM * > queryVisible(std::initializer_list< BOX2I > aAreas, const std::vector< BOARD_ITEM * > &aSkip) const
static std::vector< ANCHOR_SPEC > GetArcAnchors(const PCB_ARC &aArc, bool aFrom)
Return the snap/drag anchor points that a track arc contributes.
SNAP_RESULT ResolveSnap(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...
SNAP_INFERENCE_SETTINGS snapInferenceSettings() const
Snap inference settings for whichever editor owns this helper.
~PCB_GRID_HELPER() override
VECTOR2I Align(const VECTOR2I &aPoint, GRID_HELPER_GRIDS aGrid) const override
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
VECTOR2I SnapToPad(const VECTOR2I &aMousePos, std::deque< PAD * > &aPads)
void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
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 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)
bool editingInsideFootprint() const
True when the footprint's own contents are the layout objects.
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.
static BOX2I layoutBounds(const BOARD_ITEM &aItem)
MAGNETIC_SETTINGS * m_magneticSettings
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Get the coarsest grid that applies to an item.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
bool m_constructionGeometryEnabled
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::set< SNAP_CANDIDATE_SUBTYPE > m_suppressedSnapSubtypes
EDA_ANGLE GetPhiExtent() const
VECTOR2I GetExtent() const
VECTOR2I GetPosition() const override
GRID_GEOMETRY AsGridGeometry() const
Project this grid into a GRID_GEOMETRY (doubles, radians) for shared math.
EDA_ANGLE GetOrientation() const
int GetRadiusExtent() const
PCB_GRID_TYPE GetGridItemType() const
A set of BOARD_ITEMs (i.e., without duplicates).
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Object to handle a bitmap image that can be inserted in a PCB.
REFERENCE_IMAGE & GetReferenceImage()
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
VECTOR2I GetTextPos() const override
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
VECTOR2I GetTransformOriginOffset() const
Get the center of scaling, etc, relative to the image center (GetPosition()).
VECTOR2I GetPosition() const
BOX2I GetBoundingBox() const
ecoord SquaredDistance(const SEG &aSeg) const
VECTOR2I::extended_type ecoord
static SEG::ecoord Square(int a)
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
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
static SHAPE_SEGMENT BySizeAndCenter(const VECTOR2I &aSize, const VECTOR2I &aCenter, const EDA_ANGLE &aRotation)
std::vector< SNAP_CANDIDATE > CollectObjectGeometry(const SNAP_SOURCE_CONTEXT &aContext, int aRadius) const
std::vector< SNAP_CANDIDATE > CollectEqualSpacing(const SNAP_SOURCE_CONTEXT &aContext, int aRadius) const
void AddBounds(SNAP_OBJECT_BOUNDS aBounds)
std::vector< SNAP_CANDIDATE > CollectTangentNormal(const SNAP_SOURCE_CONTEXT &aContext, int aRadius, bool aTangentEnabled, bool aNormalEnabled) const
void AddPath(SNAP_OBJECT_PATH aPath)
void AddAlignmentPoint(SNAP_ALIGNMENT_POINT aPoint)
std::vector< SNAP_CANDIDATE > CollectAlignment(const SNAP_SOURCE_CONTEXT &aContext, int aRadius) const
OPT_VECTOR2I GetNearestSnapLinePoint(const VECTOR2I &aCursor, const VECTOR2I &aNearestGrid, std::optional< int > aDistToNearest, int snapRange, const VECTOR2D &aGridSize=VECTOR2D(0, 0), const VECTOR2I &aGridOrigin=VECTOR2I(0, 0)) const
If the snap line is active, return the best snap point that is closest to the cursor.
void SetSnappedAnchor(const VECTOR2I &aAnchorPos)
Inform this manager that an anchor snap has been made.
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...
void SetDimensionBrackets(std::vector< SEG > aBrackets)
Define a general 2D-vector/point.
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.
A type-safe container of any type.
static constexpr EDA_ANGLE ANGLE_90
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
SNAP_TARGET_ID SnapTargetId(const KIID &aId)
The snap identity of a document item.
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.
const wxChar *const traceSnap
Flag to enable snap/grid helper debug tracing.
std::variant< LINE, HALF_LINE, SEG, CIRCLE, SHAPE_ARC, SHAPE_ELLIPSE, 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.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc).
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
@ LAYER_SUBGRIDS
Routing/placement subgrids (PCB_GRID_ITEM) visibility and color.
bool IsInnerCopperLayer(int aLayerId)
Test whether a layer is an inner (In1_Cu to In30_Cu) copper layer.
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 > GetCircleKeyPoints(const CIRCLE &aCircle, bool aIncludeCenter)
Get key points of an CIRCLE.
std::vector< TYPED_POINT2I > GetOvalKeyPoints(const SHAPE_SEGMENT &aOval, OVAL_KEY_POINT_FLAGS aFlags)
Get a list of interesting points on an oval (rectangle with semicircular end caps)
std::array< SEG, 4 > BoxToSegs(const BOX2I &aBox)
Decompose a BOX2 into four segments.
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, SHAPE_ELLIPSE, BOX2I, VECTOR2I > NEARABLE_GEOM
A variant type that can hold any of the supported geometry types for nearest point calculations.
BARCODE class definition.
static bool PadstackUniqueLayerAppliesToLayer(const PADSTACK &aPadStack, PCB_LAYER_ID aPadstackUniqueLayer, const PCB_LAYER_ID aRealLayer)
PCB_GRID_ITEM * FindActiveGridAt(const BOARD &aBoard, const VECTOR2I &aPos, PCB_GRID_ROLE aRole)
Pick the grid item active for aRole at aPos.
Class to handle a set of BOARD_ITEMs.
@ PT_INTERSECTION
The point is an intersection of two (or more) items.
@ PT_CENTER
The point is the center of something.
@ PT_CORNER
The point is a corner of a polygon, rectangle, etc (you may want to infer PT_END from this)
@ PT_NONE
No specific point type.
@ PT_QUADRANT
The point is on a quadrant of a circle (N, E, S, W points).
@ PT_END
The point is at the end of a segment, arc, etc.
@ PT_MID
The point is at the middle of a segment, arc, etc.
@ PT_ON_ELEMENT
The point is somewhere on another element, but not some specific point.
std::optional< VECTOR2I > OPT_VECTOR2I
VECTOR2I::extended_type ecoord
Utility functions for working with shapes.
SNAP_FRAME_OUTPUT< Payload > ResolveSnapFrame(SNAP_FRAME_INPUT< Payload > aInput)
SNAP_STABLE_ID MakePointSnapId(SNAP_ID_KIND aKind, const VECTOR2I &aPoint, int aFeatureIndex=0)
SNAP_STABLE_ID MakeCompositeSnapId(SNAP_ID_KIND aKind, const std::vector< SNAP_TARGET_ID > &aTargets, int aFeatureIndex=0)
SNAP_STABLE_ID MakeDerivedSnapId(SNAP_ID_KIND aKind, const SNAP_STABLE_ID &aSource, int aFeatureIndex=0, int aSolutionBranch=0)
Items to be used for the construction of "virtual" anchors, for example, when snapping to a point inv...
VECTOR2D Snap(const VECTOR2D &aPoint) const
Snap a point to the nearest on-grid position.
std::vector< EDA_ITEM * > items
Items that are associated with this anchor (can be more than one, e.g.
double Distance(const VECTOR2I &aP) const
World-space snap thresholds derived from the screen-space snap radius.
int range
Snap radius, optionally clamped to the visible grid.
int in
Distance at which a candidate is picked up.
double scale
SNAP_SCREEN_RADIUS in world units.
int out
Distance at which a held candidate is released.
double rankingHysteresis
Resolver ranking stickiness, as a fraction of the radius.
A visitor that visits INTERSECTABLE_GEOM variant objects with another (which is held as state: m_othe...
A single anchor point contributed by an item, before it is registered with the helper.
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 otherItems
Anything not fitting one of the above categories.
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.
static SNAP_CANDIDATE Point(SNAP_STABLE_ID aId, SNAP_PRIORITY_TIER aPriority, SNAP_CANDIDATE_SUBTYPE aSubtype, const VECTOR2I &aPoint, double aResidual)
std::optional< SNAP_FRAME_PRESENTATION< Payload > > presentation
bool constructionExtensions
bool alignmentDistribution
std::optional< VECTOR2I > stationarySourceLeg
std::optional< BOX2I > movingBounds
std::optional< VECTOR2I > movingReferencePoint
std::optional< SNAP_STABLE_ID > movingItem
std::vector< SNAP_STABLE_ID > stationarySelfFeatures
SNAP_EDITOR_PROFILE profile
SNAP_REFERENCE_PREFERENCE referencePreference
SHAPE_CIRCLE circle(c.m_circle_center, c.m_circle_radius)
wxString result
Test unit parsing edge cases and error handling.
wxLogTrace helper definitions.
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_DRILL_MAP_T
class PCB_DRILL_MAP, drill symbols drawn at the holes
@ 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_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_GRID_ITEM_T
a subgrid placed on a board
@ 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_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
@ 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
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D