27using namespace std::placeholders;
91 if( aDirection.
x != 0 || aDirection.
y != 0 )
92 aDirections.push_back( aDirection );
97 std::vector<VECTOR2I> directions;
102 switch( aRelation->
Kind() )
158 if( !aShape || !aPoints || !aEditedPoint )
166 if( position == aShape->
GetStart() )
169 if( position == aShape->
GetEnd() )
183 if( aEditedPoint == &aPoints->
Point( i ) )
187 for(
unsigned i = 0; i < aPoints->
LinesSize() && i < 4; ++i )
189 if( aEditedPoint == &aPoints->
Line( i ) )
195 for(
unsigned i = 0; i < aPoints->
PointsSize(); ++i )
197 if( aEditedPoint == &aPoints->
Point( i ) )
201 for(
unsigned i = 0; i < aPoints->
LinesSize(); ++i )
203 if( aEditedPoint == &aPoints->
Line( i ) )
267 wxArrayString strings;
289 return wxT(
"RECT_RADIUS_TEXT_ITEM" );
325 if( aPoints.
SwapX() )
326 std::swap( topLeft.
x, botRight.
x );
328 if( aPoints.
SwapY() )
329 std::swap( topLeft.
y, botRight.
y );
391 PinEditedCorner( aEditedPoint, aPoints, topLeft, topRight, botLeft, botRight,
392 { 0, 0 }, { 0, 0 }, aMinSize );
400 setLeft( topLeft.
x );
401 setRight( botRight.
x );
402 setBottom( botRight.
y );
407 aRectangle.
Move( moveVector );
411 int width =
std::abs( botRight.
x - topLeft.
x );
412 int height =
std::abs( botRight.
y - topLeft.
y );
413 int maxRadius = std::min( width, height ) / 2;
415 x = std::clamp( x, botRight.
x - maxRadius, botRight.
x );
427 setLeft( topLeft.
x );
432 setBottom( botRight.
y );
437 setRight( botRight.
x );
440 for(
unsigned i = 0; i < aPoints.
LinesSize(); ++i )
458 if( aPoints.
SwapX() )
459 std::swap( topLeft.
x, botRight.
x );
461 if( aPoints.
SwapY() )
462 std::swap( topLeft.
y, botRight.
y );
489 std::vector<EDA_ITEM*>& aUpdatedItems )
override
511 const VECTOR2I& aMinSize = { 0, 0 } )
521 aTopLeft.
x = std::min( aTopLeft.
x, aHole.x - aHoleSize.
x / 2 - minWidth );
522 aTopLeft.
y = std::min( aTopLeft.
y, aHole.y - aHoleSize.
y / 2 - minHeight );
527 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
528 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
532 aTopRight.
y = aTopLeft.
y;
533 aBotLeft.
x = aTopLeft.
x;
540 aTopRight.
x = std::max( aTopRight.
x, aHole.x + aHoleSize.
x / 2 + minWidth );
541 aTopRight.
y = std::min( aTopRight.
y, aHole.y - aHoleSize.
y / 2 - minHeight );
546 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + minWidth );
547 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - minHeight );
551 aTopLeft.
y = aTopRight.
y;
552 aBotRight.
x = aTopRight.
x;
559 aBotLeft.
x = std::min( aBotLeft.
x, aHole.x - aHoleSize.
x / 2 - minWidth );
560 aBotLeft.
y = std::max( aBotLeft.
y, aHole.y + aHoleSize.
y / 2 + minHeight );
565 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - minWidth );
566 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + minHeight );
570 aBotRight.
y = aBotLeft.
y;
571 aTopLeft.
x = aBotLeft.
x;
578 aBotRight.
x = std::max( aBotRight.
x, aHole.x + aHoleSize.
x / 2 + minWidth );
579 aBotRight.
y = std::max( aBotRight.
y, aHole.y + aHoleSize.
y / 2 + minHeight );
584 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
585 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
589 aBotLeft.
y = aBotRight.
y;
590 aTopRight.
x = aBotRight.
x;
594 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
598 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
602 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
606 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
638 std::vector<EDA_ITEM*>& aUpdatedItems )
override
667 std::vector<EDA_ITEM*>& aUpdatedItems )
override
705 auto set45Constraint =
734 std::vector<EDA_ITEM*>& aUpdatedItems )
override
783 wxFAIL_MSG( wxT(
"MakePoints: unhandled PCB_GRID_TYPE" ) );
814 wxFAIL_MSG( wxT(
"UpdatePoints: unhandled PCB_GRID_TYPE" ) );
820 std::vector<EDA_ITEM*>& aUpdatedItems )
override
837 const double dragAngle = std::atan2( worldOff.
y, worldOff.
x );
838 const int newRadius = std::max( 1,
KiROUND( std::hypot( worldOff.
x, worldOff.
y ) ) );
839 const double orientOld =
m_gridItem.GetOrientation().AsRadians();
840 const double phiMaxOld =
m_gridItem.GetPhiExtent().AsRadians();
845 const auto wrap2pi = [](
double a )
849 while( a >= 2 *
M_PI )
858 const double newOrient = -dragAngle;
859 const double newPhiMax = wrap2pi( phiMaxOld - orientOld - dragAngle );
867 const double newPhiMax = wrap2pi( dragAngle + orientOld );
874 const double newOrient = phiMaxOld / 2.0 - dragAngle;
886 const int newHalfX = std::max( 1,
std::abs( local.
x ) );
887 const int newHalfY = std::max( 1,
std::abs( local.
y ) );
896 wxFAIL_MSG( wxT(
"UpdateItem: unhandled PCB_GRID_TYPE" ) );
919 const int sx = ( aX == 0 ) ? -1 : +1;
920 const int sy = ( aY == 0 ) ? -1 : +1;
928 const double phi =
m_gridItem.GetPhiExtent().AsRadians();
935 const double phi =
m_gridItem.GetPhiExtent().AsRadians() / 2.0;
969 std::vector<EDA_ITEM*>& aUpdatedItems )
override
975 aUpdatedItems.push_back( &
table );
981 int colWidth =
m_cell.GetRectangleWidth();
983 for(
int ii = 0; ii <
m_cell.GetColSpan() - 1; ++ii )
984 colWidth -=
table.GetColWidth(
m_cell.GetColumn() + ii );
992 int rowHeight =
m_cell.GetRectangleHeight();
994 for(
int ii = 0; ii <
m_cell.GetRowSpan() - 1; ++ii )
995 rowHeight -=
table.GetRowHeight(
m_cell.GetRow() + ii );
1008 std::vector<VECTOR2I> corners =
m_cell.GetCorners();
1010 return aPoint ==
COL_WIDTH ? ( corners[1] + corners[2] ) / 2 : ( corners[2] + corners[3] ) / 2;
1043 if(
m_pad.IsLocked() )
1058 if( !
m_pad.GetOrientation().IsCardinal() )
1061 if(
m_pad.GetOrientation().IsVertical() )
1062 std::swap( halfSize.
x, halfSize.
y );
1065 aPoints.
AddPoint( shapePos - halfSize );
1067 aPoints.
AddPoint( shapePos + halfSize );
1087 int target =
locked ? 0 : 1;
1095 else if( target == 1 )
1097 shapePos.
x += halfSize.
x;
1110 int target =
locked || !
m_pad.GetOrientation().IsCardinal() ? 0 : 4;
1117 else if( target == 4 )
1119 if(
m_pad.GetOrientation().IsVertical() )
1120 std::swap( halfSize.
x, halfSize.
y );
1124 shapePos.
y - halfSize.
y ) );
1127 shapePos.
y + halfSize.
y ) );
1141 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1168 botLeft, botRight, holeCenter, holeSize );
1171 || (
m_pad.GetDrillSize().x &&
m_pad.GetDrillSize().y ) )
1181 dist[0] =
center.x - topLeft.
x;
1182 dist[1] =
center.y - topLeft.
y;
1183 dist[2] = botRight.
x -
center.x;
1184 dist[3] = botRight.
y -
center.y;
1188 dist[0] =
center.x - botLeft.
x;
1189 dist[1] =
center.y - topRight.
y;
1190 dist[2] = topRight.
x -
center.x;
1191 dist[3] = botLeft.
y -
center.y;
1194 VECTOR2I padSize( dist[0] + dist[2], dist[1] + dist[3] );
1195 VECTOR2I deltaOffset( padSize.
x / 2 - dist[2], padSize.
y / 2 - dist[3] );
1197 if(
m_pad.GetOrientation().IsVertical() )
1198 std::swap( padSize.
x, padSize.
y );
1217 bottom = botRight.
y;
1229 if(
m_pad.GetOrientation().IsVertical() )
1230 std::swap( padSize.
x, padSize.
y );
1272 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1296 m_oldCrossBar(
SEG{ aDimension.GetCrossbarStart(), aDimension.GetCrossbarEnd() } )
1319 const VECTOR2I newProject = newCrossBar.LineProject( newTextPos );
1321 const VECTOR2I oldProjectedOffset =
1323 const VECTOR2I newProjectedOffset = newProject - newCrossBar.NearestPoint( newProject );
1325 const bool textWasLeftOf = oldProjectedOffset.
x < 0
1326 || ( oldProjectedOffset.
x == 0 && oldProjectedOffset.
y > 0 );
1327 const bool textIsLeftOf = newProjectedOffset.
x < 0
1328 || ( newProjectedOffset.
x == 0 && newProjectedOffset.
y > 0 );
1330 if( textWasLeftOf != textIsLeftOf )
1350 const EDA_ANGLE rotation = oldAngle - newAngle;
1363 rotTextOffsetFromCbCenter,
1364 newCrossBar.Center() );
1370 return newCbRefPt + rotTextOffsetFromCbEnd;
1383 const VECTOR2I newProjected = newCrossBar.A + ( newCrossBar.B - newCrossBar.A ) * oldRatio;
1384 return newProjected + rotCbNormalToText;
1439 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1476 if( featureLine.
Cross( crossBar ) > 0 )
1488 if( featureLine.
Cross( crossBar ) > 0 )
1555 if( !bounds.
Contains( cursorPos ) )
1578 m_dimension.SetHeight( vert ? featureLine.
x : featureLine.
y );
1633 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1650 return std::nullopt;
1696 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1748 return std::nullopt;
1787 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1847 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1871 if( item->Type() == PCB_SHAPE_T )
1873 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
1874 m_shapes.push_back( shape );
1875 m_originalWidths[shape] = static_cast<double>( shape->GetWidth() );
1881 const std::optional<VECTOR2I>& aPinned ) :
1929 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1954 shape->Move(
delta );
1959 aUpdatedItems.push_back( shape );
2005 const double MIN_ARM_RATIO = 0.1;
2011 double floor =
static_cast<double>( diagonal.
SquaredEuclideanNorm() ) * MIN_ARM_RATIO * MIN_ARM_RATIO;
2022 scale =
static_cast<double>( oldArm.
Dot( newArm ) ) / span;
2026 double sx =
static_cast<double>( br.
x - tl.
x ) /
static_cast<double>( oldBox.
GetWidth() );
2027 double sy =
static_cast<double>( br.
y - tl.
y ) /
static_cast<double>( oldBox.
GetHeight() );
2029 scale = ( sx + sy ) / 2.0;
2043 shape->Move( -origin );
2044 shape->Scale(
scale );
2045 shape->Move( origin );
2049 shapeIt->second = shapeIt->second *
scale;
2050 shape->SetWidth(
KiROUND( shapeIt->second ) );
2054 shape->SetWidth(
KiROUND( shape->GetWidth() *
scale ) );
2057 aUpdatedItems.push_back( shape );
2073 bbox.
Merge( shape->GetBoundingBox() );
2166 const auto type = aItem.
Type();
2185 double angleRad = aAngleDeg *
M_PI / 180.0;
2188 double chord = (
next - prev ).EuclideanNorm();
2189 double sinA = sin( angleRad );
2191 if( chord == 0.0 || fabs( sinA ) < 1e-9 )
2194 double radius = chord / ( 2.0 * sinA );
2199 double h_sq =
radius *
radius - ( chord * chord ) / 4.0;
2200 double h = h_sq > 0.0 ? sqrt( h_sq ) : 0.0;
2224 return d1 < d2 ? p1 : p2;
2233 wxASSERT_MSG(
m_selectionTool, wxT(
"pcbnew.InteractiveSelection tool is not available" ) );
2235 const auto arcIsEdited =
2236 [](
const SELECTION& aSelection ) ->
bool
2238 const EDA_ITEM* item = aSelection.Front();
2255 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
2264 bool rejected =
false;
2279 std::unique_ptr<POINT_EDIT_BEHAVIOR> behavior;
2281 switch( aItem->
Type() )
2286 behavior = std::make_unique<REFERENCE_IMAGE_POINT_EDIT_BEHAVIOR>( refImage.
GetReferenceImage(),
2293 behavior = std::make_unique<BARCODE_POINT_EDIT_BEHAVIOR>( barcode );
2299 behavior = std::make_unique<GRID_POINT_EDIT_BEHAVIOR>(
grid );
2305 behavior = std::make_unique<TEXTBOX_POINT_EDIT_BEHAVIOR>( textbox );
2314 case SHAPE_T::SEGMENT: behavior = std::make_unique<EDA_SEGMENT_POINT_EDIT_BEHAVIOR>( *shape );
break;
2316 case SHAPE_T::RECTANGLE: behavior = std::make_unique<RECTANGLE_POINT_EDIT_BEHAVIOR>( *shape );
break;
2323 case SHAPE_T::CIRCLE: behavior = std::make_unique<EDA_CIRCLE_POINT_EDIT_BEHAVIOR>( *shape );
break;
2325 case SHAPE_T::POLY: behavior = std::make_unique<EDA_POLYGON_POINT_EDIT_BEHAVIOR>( *shape );
break;
2328 behavior = std::make_unique<EDA_BEZIER_POINT_EDIT_BEHAVIOR>( *shape, shape->
GetMaxError() );
2332 case SHAPE_T::ELLIPSE_ARC: behavior = std::make_unique<EDA_ELLIPSE_POINT_EDIT_BEHAVIOR>( *shape );
break;
2344 bool shapesOnly =
true;
2357 std::unique_ptr<SHAPE_GROUP_POINT_EDIT_BEHAVIOR> groupBehavior =
2358 std::make_unique<SHAPE_GROUP_POINT_EDIT_BEHAVIOR>( *
group );
2360 behavior = std::move( groupBehavior );
2376 behavior = std::make_unique<PCB_TABLECELL_POINT_EDIT_BEHAVIOR>( *cell );
2393 behavior = std::make_unique<PAD_POINT_EDIT_BEHAVIOR>(
pad, activeLayer );
2400 ZONE& zone =
static_cast<ZONE&
>( *aItem );
2401 behavior = std::make_unique<ZONE_POINT_EDIT_BEHAVIOR>( zone );
2410 behavior = std::make_unique<GENERATOR_POLY_POINT_EDIT_BEHAVIOR>( *generator );
2416 behavior = std::make_unique<GENERATOR_POINT_EDIT_BEHAVIOR>( *generator );
2425 behavior = std::make_unique<ALIGNED_DIMENSION_POINT_EDIT_BEHAVIOR>( dimension );
2432 behavior = std::make_unique<DIM_CENTER_POINT_EDIT_BEHAVIOR>( dimension );
2439 behavior = std::make_unique<DIM_RADIAL_POINT_EDIT_BEHAVIOR>( dimension );
2446 behavior = std::make_unique<DIM_LEADER_POINT_EDIT_BEHAVIOR>( dimension );
2450 default: aRejected =
true;
break;
2478 std::vector<BOARD_ITEM*> items;
2480 for(
EDA_ITEM* selItem : aSelection )
2482 if( selItem->IsBOARD_ITEM() )
2483 items.push_back(
static_cast<BOARD_ITEM*
>( selItem ) );
2499 bool rejected =
false;
2500 std::unique_ptr<POINT_EDIT_BEHAVIOR> behavior =
makeBehavior( item, rejected );
2506 entry.
behavior = std::move( behavior );
2507 entry.
points = std::make_shared<EDIT_POINTS>( item );
2522 if(
view->HasItem( entry.points.get() ) )
2523 view->Remove( entry.points.get() );
2546 std::vector<EDIT_POINTS*> collections;
2549 collections.push_back( entry.points.get() );
2617 for(
unsigned ii = 0; ii < points->PointsSize(); ++ii )
2618 points->Point( ii ).SetSelected(
false );
2620 for(
unsigned ii = 0; ii < points->LinesSize(); ++ii )
2621 points->Line( ii ).SetSelected(
false );
2630 resolved = it->Resolve( *points );
2666 if( !entry.behavior->UpdatePoints( *entry.points ) )
2670 if(
getView()->HasItem( entry.points.get() ) )
2673 entry.points = std::make_shared<EDIT_POINTS>( parent );
2674 entry.points->SetLineStateVisible(
true );
2675 entry.behavior->MakePoints( *entry.points );
2699 owner = entry.points.get();
2814 for(
int ii = 0; list[ii]; ++ii )
2832 void SetPoly(
const SHAPE_LINE_CHAIN& aPoly ) { m_poly = aPoly; }
2833 SHAPE_LINE_CHAIN& GetPoly() {
return m_poly; }
2835 const BOX2I ViewBBox()
const override {
return m_poly.BBox(); }
2838 void drawPreviewShape( KIGFX::VIEW* aView )
const override
2840 if( m_poly.PointCount() < 2 )
2843 KIGFX::GAL& gal = *aView->
GetGAL();
2855 SHAPE_LINE_CHAIN m_poly;
2864 std::set<KIID> known;
2869 known.insert( item->m_Uuid );
2874 item->RunOnChildren( [&](
BOARD_ITEM* aChild )
2876 known.insert( aChild->
m_Uuid );
2884 if( known.insert( aItem->m_Uuid ).second )
2886 aItems.push_back( aItem );
2899 bool touches =
false;
2903 if( known.count( member.m_item ) )
2915 if( known.count( member.m_item ) )
2928 include( footprint );
2941 return wxString::Format(
_(
"The move violates DRC. (%s to commit anyway.)" ),
3035 bool revert(
bool aPushed );
3038 void endDrag(
bool aKeepPicks );
3048 void showBand( HANDLE_PICK_AREA& aArea );
3049 void hideBand( HANDLE_PICK_AREA& aArea );
3078 std::vector<std::pair<EDIT_POINTS*, POINT_EDIT_BEHAVIOR*>>
m_targets;
3136 m_editor.getView()->ClearPreview();
3143 shape->UpdateHatching();
3149 if(
m_editor.getView()->HasItem( display.get() ) )
3150 m_editor.getView()->Remove( display.get() );
3155 neighbor->ClearBrightened();
3156 m_editor.getView()->Update( neighbor );
3162 m_editor.m_editedPoint->SetActive(
false );
3168 if( routerTool && routerTool->
Router() )
3186 m_editor.getView()->Hide( item,
false );
3188 if( item->IsSelected() )
3189 m_editor.getView()->Hide( item,
true );
3210 m_editor.m_blockDragAbort =
nullptr;
3211 m_grid.SetPointEditProfile(
true );
3212 m_editor.getViewControls()->ForceCursorPosition(
false );
3213 m_editor.getViewControls()->SetAutoPan(
false );
3214 m_editor.frame()->UndoRedoBlock(
false );
3273 bool hasMovedPoint =
false;
3275 for(
const auto& [key, origin] :
m_origins )
3277 if( key.Parent() == parent->
m_Uuid )
3279 hasMovedPoint =
true;
3284 if( !hasMovedPoint )
3289 if( candidate ==
m_editor.m_editPoints.get() )
3291 behavior =
m_editor.m_editorBehavior.get();
3297 if( entry.
points.get() == candidate )
3308 m_targets.push_back( { candidate, behavior } );
3319 std::vector<EDA_ITEM*>& aUpdated )
3324 for(
auto& [targetPoints, behavior] :
m_targets )
3327 aUpdated.push_back( parent );
3329 for(
const auto& [key, origin] :
m_origins )
3331 if( key.Parent() != parent->
m_Uuid )
3336 behavior->UpdateItem( *
moved, *targetPoints,
m_commit, aUpdated );
3341 if( behavior->UpdateItemAppliesAllPoints() )
3349 if( frameStep !=
VECTOR2I( 0, 0 ) )
3353 rigidItem->Move( frameStep );
3354 aUpdated.push_back( rigidItem );
3382 aUpdated.push_back( dep.
shape );
3393 std::vector<std::pair<CONSTRAINT_MEMBER, VECTOR2I>> pins;
3397 std::vector<CONSTRAINT_ANCHOR_POINT> anchors;
3403 if( shape != anchorShape )
3406 anchorShape = shape;
3411 if(
anchor.anchor == member.m_anchor &&
anchor.index == member.m_index )
3413 pins.emplace_back( member,
anchor.pos );
3419 std::vector<PCB_SHAPE*> solverMoved;
3421 auto stageNeighbor = [&](
BOARD_ITEM* aItem )
3428 aUpdated.push_back( aItem );
3437 for(
PCB_SHAPE* neighbor : solverMoved )
3439 aUpdated.push_back( neighbor );
3443 if( !neighbor->IsMoving() && !neighbor->IsBrightened() )
3445 neighbor->SetBrightened();
3467 grabCollection = candidate;
3481 std::set<PCB_HANDLE_KEY> priorPicks =
m_editor.m_pickedHandles;
3482 bool grabPicked =
m_editor.m_pickedHandles.count( *grabKey ) > 0;
3485 auto restorePicks = [&]() ->
bool
3487 m_editor.setPickedHandles( priorPicks );
3491 auto refuse = [&](
const wxString& aMessage ) ->
bool
3493 m_editor.frame()->ShowInfoBarError( aMessage );
3498 if( aPressInFlight )
3501 return restorePicks();
3504 if( grabCollection ==
m_editor.m_editPoints.get() )
3508 if( !grabPicked ||
m_editor.m_pickedHandles.size() < 2 )
3511 else if( !grabPicked )
3514 std::set<PCB_HANDLE_KEY> picked =
m_editor.m_pickedHandles;
3517 m_editor.setPickedHandles( std::move( picked ) );
3522 m_editor.m_selectionTool->StopDisambiguation();
3525 std::vector<BOARD_ITEM*> routerItems;
3533 return refuse( wxString::Format(
_(
"%s cannot be dragged." ),
3538 routerItems.push_back( selectedItem );
3544 return restorePicks();
3546 bool overrideLocksNow =
m_editFrame->GetOverrideLocks();
3548 for(
auto& [targetPoints, behavior] :
m_targets )
3553 return refuse( wxString::Format(
_(
"%s is locked. Enable 'Override locks' to move it." ),
3562 std::unordered_set<const BOARD_ITEM*> blockParticipants;
3564 for(
auto& [targetPoints, behavior] :
m_targets )
3565 blockParticipants.insert(
static_cast<BOARD_ITEM*
>( targetPoints->GetParent() ) );
3570 if( blockParticipants.count( selectedItem ) )
3575 return refuse( wxString::Format(
_(
"%s is locked. Enable 'Override locks' to move it." ),
3579 blockParticipants.insert( selectedItem );
3596 std::vector<BLOCK_DRAG_ENDPOINT> movedEndpoints;
3598 for(
auto& [targetPoints, behavior] :
m_targets )
3605 for(
const auto& [key, origin] :
m_origins )
3607 if( key.Parent() != shape->
m_Uuid || key.IsLine() )
3610 if( key.Index() == 0 || key.Index() == 1 )
3611 movedEndpoints.push_back( { shape, key.Index() == 0, origin } );
3633 if( !movedEndpoints.empty() )
3643 if( blockParticipants.count( aItem ) )
3653 for(
BOARD_ITEM* drawing : footprint->GraphicalItems() )
3654 addCandidate( drawing );
3660 addCandidate( drawing );
3666 return refuse(
_(
"A locked connected item prevents the drag. Enable 'Override locks' to move it." ) );
3672 bool padOfCarriedFootprint =
false;
3675 if( !routerItems.empty() )
3682 return refuse(
_(
"The router is busy." ) );
3695 std::set<PAD*> independentPads;
3696 std::unordered_set<FOOTPRINT*> carriedFootprints;
3701 carriedFootprints.insert(
static_cast<FOOTPRINT*
>( routerItem ) );
3715 routerSet.
Add( solid );
3721 routerSet.
Add( solid );
3730 routerSet.
Add( solid );
3739 PAD*
pad =
static_cast<PAD*
>( routerItem );
3741 if( carriedFootprints.count(
pad->GetParentFootprint() ) )
3743 padOfCarriedFootprint =
true;
3749 if( !
m_editor.frame()->GetPcbNewSettings()->m_AllowFreePads )
3751 return refuse( wxString::Format(
_(
"%s cannot be dragged." ),
3752 pad->GetItemDescription(
m_editor.frame(),
false ) ) );
3758 return refuse( wxString::Format(
_(
"%s cannot be dragged." ),
3759 pad->GetItemDescription(
m_editor.frame(),
false ) ) );
3763 independentPads.insert(
pad );
3768 if( pnsItems.empty() )
3770 return refuse( wxString::Format(
_(
"%s cannot be dragged." ),
3771 routerItem->GetItemDescription(
m_editor.frame(),
false ) ) );
3775 routerSet.
Add( pnsItem );
3788 routerSet.
Add( pnsItem );
3792 if( routerSet.
Size() > 0 )
3799 return refuse(
_(
"The copper in the selection cannot be dragged." ) );
3807 std::set<KIID> blockAnchoredCopper;
3811 const std::vector<PNS::LINE>& held = blockDragger->AnchoredLines();
3815 m_editor.frame()->ShowInfoBarWarning( wxString::Format(
3816 wxPLURAL(
"%zu selected arc cannot move because both ends are fixed.",
3817 "%zu selected arcs cannot move because both ends are fixed.", held.size() ),
3826 blockAnchoredCopper.insert( parent->m_Uuid );
3843 if( blockAnchoredCopper.count( routerItem->m_Uuid ) )
3846 m_editor.getView()->Hide( routerItem,
true,
true );
3865 for(
auto& [targetPoints, behavior] :
m_targets )
3888 std::shared_ptr<EDIT_POINTS> display = std::make_shared<EDIT_POINTS>( dep.shape );
3889 display->AddPoint( dep.position );
3890 display->Point( 0 ).SetDependent();
3891 m_editor.getView()->Add( display.get() );
3901 shape->UpdateHatching();
3908 std::vector<BOARD_ITEM*> validationScope =
m_moving;
3915 std::vector<BOARD_ITEM*> blockConstrainedItems;
3916 std::unordered_set<const BOARD_ITEM*> seeded;
3918 auto seedConstrained = [&](
BOARD_ITEM* aItem )
3924 blockConstrainedItems.push_back( aItem );
3927 for(
auto& [targetPoints, behavior] :
m_targets )
3934 for(
const auto& [key, origin] :
m_origins )
3936 if( key.Parent() != shape->
m_Uuid )
3939 EDIT_POINT* picked = key.Resolve( *targetPoints );
3944 if( std::optional<CONSTRAINT_MEMBER> member =
3951 seedConstrained( shape );
3956 std::unordered_set<BOARD_ITEM*> walked;
3960 if( !aItem || !walked.insert( aItem ).second )
3964 seedConstrained( aItem );
3969 carryWhole( rigidItem );
3976 carryWhole( dep.shape );
3984 seedConstrained( dep.shape );
3987 if( !blockConstrainedItems.empty() )
4004 if( !
m_editor.m_isFootprintEditor )
4011 if( moving->GetParentFootprint() )
4018 m_grid.SetPointEditProfile(
false );
4019 m_editor.frame()->UndoRedoBlock(
true );
4020 m_editor.getViewControls()->SetAutoPan(
true );
4025 m_editor.m_blockDragAbort = [
this]()
4035 if( !
m_editor.blockAnchorEditingEnabled() )
4040 if( modifiers != 0 && modifiers !=
MD_SHIFT )
4043 bool anyPickable =
false;
4053 for(
unsigned ii = 0; ii < candidate->PointsSize(); ++ii )
4076 if(
m_editor.getView()->GetGAL()->GetClearColor().Distance( color ) < 0.5 )
4086 m_editor.m_selectionTool->StopDisambiguation();
4090 aArea.SetStrokeColor( color.
WithAlpha( 0.9 ) );
4091 aArea.SetFillColor( color.
WithAlpha( 0.15 ) );
4093 m_editor.getView()->SetVisible( &aArea,
true );
4094 m_editor.getViewControls()->SetAutoPan(
true );
4100 m_editor.getViewControls()->SetAutoPan(
false );
4101 m_editor.getView()->SetVisible( &aArea,
false );
4102 m_editor.getView()->Remove( &aArea );
4109 HANDLE_PICK_AREA area;
4115 bool finished =
false;
4116 bool exitLoop =
false;
4124 if( lassoEvt->IsCancelInteractive() )
4126 lassoEvt->SetPassEvent(
false );
4129 else if( lassoEvt->IsActivate() )
4132 exitLoop = !lassoEvt->IsMoveTool();
4143 points.
Append( lassoEvt->Position() );
4149 lassoEvt->SetPassEvent(
false );
4167 area.SetPoly( points );
4168 area.GetPoly().Append(
m_editor.m_toolMgr->GetMousePosition() );
4176 std::set<PCB_HANDLE_KEY> picked =
m_editor.m_pickedHandles;
4179 m_editor.setPickedHandles( std::move( picked ) );
4195 bool released =
false;
4196 bool exitLoop =
false;
4198 HANDLE_PICK_AREA area;
4205 if( boxEvt->IsCancelInteractive() )
4207 boxEvt->SetPassEvent(
false );
4210 else if( boxEvt->IsActivate() )
4212 exitLoop = !boxEvt->IsMoveTool();
4220 else if( boxEvt->IsDrag(
BUT_LEFT ) )
4222 end = boxEvt->Position();
4226 else if( boxEvt->IsMouseUp(
BUT_LEFT ) )
4242 std::set<PCB_HANDLE_KEY> picked =
m_editor.m_pickedHandles;
4245 m_editor.setPickedHandles( std::move( picked ) );
4275 for(
const auto& [key, origin] :
m_origins )
4289 if( policy->GetMode() != edgeMode )
4290 policy->SetMode( edgeMode );
4297 std::vector<EDA_ITEM*> updatedItems;
4306 m_editor.frame()->ShowInfoBarError(
_(
"The move would break a geometric constraint." ) );
4310 m_grid.ClearSnapFeedback();
4331 for(
EDA_ITEM* updatedItem : updatedItems )
4332 m_editor.getView()->Update( updatedItem );
4346 bool dragStatus =
true;
4352 m_editor.getView()->ClearPreview();
4354 if( !allowed && dragger && dragger->GetForceMarkObstaclesMode( &dragStatus ) && !dragStatus )
4360 statusItem->
SetMessage(
_(
"The move violates DRC." ) );
4363 m_editor.getView()->AddToPreview( statusItem );
4377 m_editor.frame()->ShowInfoBarError( aMessage );
4391 m_editor.m_selectionTool->StopDisambiguation();
4403 auto originResolves = [&](
const std::pair<const PCB_HANDLE_KEY, VECTOR2I>& aOrigin )
4406 [&](
const auto& aTarget )
4408 return aOrigin.first.Resolve( *aTarget.first ) !=
nullptr;
4423 for(
auto& [targetPoints, behavior] :
m_targets )
4424 behavior->FinalizeItem( *targetPoints,
m_commit );
4428 std::vector<ZONE*> zonesToFill;
4430 auto appendFillZone = [&](
EDA_ITEM* aItem )
4437 if( !
static_cast<ZONE*
>( aItem )->GetIsRuleArea() )
4438 zonesToFill.push_back(
static_cast<ZONE*
>( aItem ) );
4442 if( !
m_editor.m_isFootprintEditor )
4444 for(
auto& [targetPoints, behavior] :
m_targets )
4445 appendFillZone( targetPoints->GetParent() );
4448 appendFillZone( rigidItem );
4451 bool routerSessionOk =
true;
4452 bool routerStatusOk =
true;
4461 routerSessionOk =
false;
4463 routerStatusOk =
true;
4471 ?
_(
"The move would break a zone outline." )
4472 :
_(
"The move would break the board outline." ) ) )
4477 else if( !routerSessionOk || ( !routerStatusOk && !forceCommit ) )
4488 label =
_(
"Drag block" );
4490 label =
m_origins.size() > 1 ?
_(
"Move Points" ) :
_(
"Move Point" );
4498 bool routerCommitted =
true;
4503 routerCommitted =
false;
4513 if( !routerCommitted )
4527 if( filler.
Fill( zonesToFill ) )
4529 m_editor.board()->OnZonesFilled( zonesToFill );
4532 zoneFillerTool->RegenerateDirtyGenerators( fillCommit );
4540 m_editor.frame()->ShowInfoBarError(
_(
"Zone fill failed, the move was undone." ) );
4555 bool regenerated =
false;
4629 if( selItem->GetEditFlags() || !selItem->IsBOARD_ITEM() )
4641 if( !item || ( item->
IsLocked() && !overrideLocks && !blockHandlesPossible ) )
4649 grid.SetPointEditProfile(
true );
4653 std::vector<std::unique_ptr<BOARD_ITEM>> clones;
4660 std::vector<PCB_SHAPE*> shapes;
4661 std::set<KIID> shapeIds;
4662 bool allShapes =
true;
4663 bool anyLocked =
false;
4670 shapes.push_back( shape );
4671 shapeIds.insert( shape->
m_Uuid );
4682 std::vector<VECTOR2I> pinned;
4684 if( allShapes && shapes.size() > 1 )
4688 if( allShapes && shapes.size() > 1 && ( !anyLocked || overrideLocks ) && pinned.size() < 2 )
4690 std::optional<VECTOR2I>
pin;
4692 if( !pinned.empty() )
4693 pin = pinned.front();
4695 std::unique_ptr<SHAPE_GROUP_POINT_EDIT_BEHAVIOR> groupBehavior =
4696 std::make_unique<SHAPE_GROUP_POINT_EDIT_BEHAVIOR>( std::move( shapes ), item,
pin );
4739 bool inDrag =
false;
4740 bool isConstrained =
false;
4741 bool haveSnapLineDirections =
false;
4743 auto updateSnapLineDirections = [&]()
4745 std::vector<VECTOR2I> directions;
4759 if( directions.empty() )
4761 grid.SetSnapLineDirections( {} );
4762 grid.SetSnapLineEnd( std::nullopt );
4763 haveSnapLineDirections =
false;
4769 grid.SetSnapLineDirections( directions );
4770 grid.SetSnapLineOrigin( origin );
4771 grid.SetSnapLineEnd( std::nullopt );
4772 haveSnapLineDirections =
true;
4778 auto installFeasibilityCallback = [&]()
4780 grid.SetFeasibilityCallback( {} );
4787 grid.SetFeasibilityCallback(
4788 [session](
const SNAP_SOURCE_CONTEXT& aContext,
const std::vector<SNAP_CANDIDATE>& aCandidates )
4790 return session->ResolveCandidates( aContext, aCandidates );
4801 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
4802 installFeasibilityCallback();
4862 evt->SetPassEvent();
4868 block.
Begin( evt->DragOrigin(),
true );
4903 evt->SetPassEvent();
4910 frame()->UndoRedoBlock(
true );
4925 if( std::optional<CONSTRAINT_MEMBER> member =
4933 installFeasibilityCallback();
4942 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
4958 shape->UpdateHatching();
4963 clones.emplace_back( clone );
4964 grid.AddConstructionItems( { clone },
false, true );
4966 updateSnapLineDirections();
4970 bool ctrlHeld = evt->Modifier(
MD_CTRL );
4974 if( isConstrained != need_constraint )
4977 isConstrained = need_constraint;
4978 updateSnapLineDirections();
4981 if( need_constraint )
4989 grid.SetAngleRestriction( std::nullopt, 0.0 );
4996 bool isPoly =
false;
4998 switch( item->
Type() )
5021 if( policy->
GetMode() != targetMode )
5022 policy->
SetMode( targetMode );
5040 if(
grid.GetUseGrid() )
5045 bool snappedAlongPerp =
false;
5067 double step = std::hypot( gridSize.
x * perpUnit.
x,
5068 gridSize.
y * perpUnit.
y );
5072 double offset =
VECTOR2D( pos - origCenter ).
Dot( perpUnit );
5073 double snapped = std::round( offset / step ) * step;
5076 snappedAlongPerp =
true;
5081 if( !snappedAlongPerp )
5084 grid.ResolveSnap( pos, {},
grid.GetItemGrid( item ), { item } )
5091 -
grid.ResolveSnap( last, {},
grid.GetItemGrid( item ), { item } )
5094 if( abs(
delta.x ) >
grid.GetGrid().x / 2 )
5095 pos.
x = last.
x + deltaGrid.
x;
5099 if( abs(
delta.y ) >
grid.GetGrid().y / 2 )
5100 pos.
y = last.
y + deltaGrid.
y;
5122 bool isFreePolygon =
5130 if( idx != wxNOT_FOUND )
5133 int nextIdx = ( idx + 1 ) %
m_editPoints->PointsSize();
5136 SEG segA( pos, prev );
5139 double snapAng = 45.0 * std::round( ang / 45.0 );
5141 if(
std::abs( ang - snapAng ) < 2.0 )
5148 grid.ResolveSnap( snapped, {},
grid.GetItemGrid( item ), { item } )
5152 snapped =
std::abs( griddedAng - snapAng ) < 2.0 ? gridded : pos;
5155 if( snapped != pos )
5166 bool constraintSnapped =
false;
5167 std::vector<VECTOR2I> stationarySelfPoints;
5168 std::vector<SEG> stationarySelfSegments;
5176 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
5183 && &point != &editedLine->
GetEnd() ) ) )
5185 stationarySelfPoints.push_back( point.
GetPosition() );
5189 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
5193 if( &stationaryLine != editedLine
5200 && &stationaryLine.
GetEnd() != &editedLine->
GetEnd() ) ) )
5202 stationarySelfSegments.emplace_back(
5215 int opposite = ( editedIndex + 2 ) % 4;
5216 stationarySelfPoints.push_back(
m_editPoints->Point( opposite ).GetPosition() );
5220 for(
unsigned i = 0; i <
m_editPoints->LinesSize() && i < 4; ++i )
5235 constexpr int arcStart = 0;
5236 constexpr int arcMid = 1;
5237 constexpr int arcEnd = 2;
5238 constexpr int arcCenter = 3;
5242 if( editedIndex != arcStart )
5243 stationarySelfPoints.push_back(
m_editPoints->Point( arcStart ).GetPosition() );
5245 if( editedIndex != arcEnd )
5246 stationarySelfPoints.push_back(
m_editPoints->Point( arcEnd ).GetPosition() );
5248 else if( editedIndex == arcStart || editedIndex == arcMid || editedIndex == arcEnd )
5250 stationarySelfPoints.push_back(
m_editPoints->Point( arcCenter ).GetPosition() );
5255 grid.SetStationarySelfGeometry( std::move( stationarySelfPoints ),
5256 std::move( stationarySelfSegments ) );
5262 grid.ResolveSnap( pos, snapLayers,
grid.GetItemGrid( item ), { item } )
5264 constraintSnapped =
true;
5270 constraintSnapped =
true;
5275 if(
grid.GetSnap() && !snapLayers.empty() )
5279 grid.ResolveSnap( constrainedPos, snapLayers,
grid.GetItemGrid( item ),
5284 if( snapPos != constrainedPos )
5290 if( projectedPos != snapPos )
5298 grid.ResolveSnap( pos, snapLayers,
grid.GetItemGrid( item ), { item } )
5306 if( haveSnapLineDirections )
5309 grid.SetSnapLineOrigin( snapOrigin );
5311 if( constraintSnapped )
5314 grid.SetSnapLineEnd( std::nullopt );
5349 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
5362 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
5380 updateSnapLineDirections();
5397 commit.
Push(
_(
"Resize Table Cells" ) );
5401 commit.
Push(
_(
"Move Point" ) );
5407 shape->UpdateHatching();
5412 frame()->UndoRedoBlock(
false );
5413 updateSnapLineDirections();
5419 bool accumulate = evt->Modifier(
MD_SHIFT ) != 0;
5420 bool consumed =
pickHandleAt( evt->Position(), accumulate );
5438 evt->SetPassEvent();
5441 else if( evt->IsCancelInteractive() || evt->IsActivate() )
5445 if( block.
Cancel( *evt ) )
5461 shape->UpdateHatching();
5466 frame()->UndoRedoBlock(
false );
5467 updateSnapLineDirections();
5476 if( evt->IsCancel() && evt->GetCommandId() == (
int) WXK_ESCAPE )
5477 evt->SetPassEvent(
false );
5483 if( evt->IsActivate() && !evt->IsMoveTool() )
5516 evt->SetPassEvent();
5527 shape->UpdateHatching();
5560 grid.SetSnapLineDirections( {} );
5582 title =
_(
"Move Midpoint to Location" );
5583 msg =
_(
"Move Midpoint" );
5587 title =
_(
"Move Corner to Location" );
5588 msg =
_(
"Move Corner" );
5613 std::vector<EDA_ITEM*> updatedItems = { item };
5629 std::vector<PCB_SHAPE*> modified;
5634 aCommit.Modify( aNeighbor );
5638 updatedItems.push_back( neighbor );
5646 std::optional<CONSTRAINT_MEMBER> member;
5647 std::optional<std::pair<CONSTRAINT_MEMBER, VECTOR2I>> coDragged;
5685 if( !member.has_value() )
5687 for(
unsigned i = 0; i <
m_editPoints->LinesSize() && i < 4; ++i )
5706 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
5722 if( !member.has_value() )
5724 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
5749 std::vector<PCB_SHAPE*> modified;
5753 auto stageNeighbor = [&](
BOARD_ITEM* aItem )
5758 updatedItems.push_back( aItem );
5761 if( member.has_value() )
5775 false, {}, coDragged );
5780 false,
false, {}, coDragged );
5797 updatedItems.push_back( neighbor );
5802 switch( item->
Type() )
5813 if(
pad->IsEntered() )
5820 textBox->ClearRenderCache();
5848 for(
EDA_ITEM* updatedItem : updatedItems )
5851 frame()->SetMsgPanel( item );
5873 int editedIndex = -1;
5874 bool editingLine =
false;
5879 for(
unsigned ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
5889 if( editedIndex == -1 )
5891 for(
unsigned ii = 0; ii <
m_editPoints->LinesSize(); ++ii )
5919 if( editedIndex >= 0 )
5921 if( editingLine && editedIndex < (
int)
m_editPoints->LinesSize() )
5923 else if( !editingLine && editedIndex < (
int)
m_editPoints->PointsSize() )
5954 if(
frame()->ToolStackIsEmpty() )
5957 controls->ForceCursorPosition(
false );
5968 bool isPoly =
false;
5972 switch( parent->
Type() )
5989 if( line && isPoly )
6013 if( line && isPoly )
6048 auto vertexIdx = it.GetIndex();
6051 return std::make_pair(
true, vertexIdx );
6069 switch( item->
Type() )
6072 polyset =
static_cast<ZONE*
>( item )->Outline();
6077 polyset = &
static_cast<PCB_SHAPE*
>( item )->GetPolyShape();
6130 unsigned int nearestIdx = 0;
6131 unsigned int nextNearestIdx = 0;
6132 unsigned int nearestDist = INT_MAX;
6133 unsigned int firstPointInContour = 0;
6138 ZONE* zone =
static_cast<ZONE*
>( item );
6139 zoneOutline = zone->
Outline();
6158 for( ; iterator; iterator++, curr_idx++ )
6160 int jj = curr_idx+1;
6164 jj = firstPointInContour;
6165 firstPointInContour = curr_idx+1;
6168 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
6175 nearestIdx = curr_idx;
6176 nextNearestIdx = jj;
6183 SEG nearestSide( sideOrigin, sideEnd );
6188 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
6189 nearestPoint = ( sideOrigin + sideEnd ) / 2;
6191 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
6195 if( graphicItem && nextNearestIdx < (
unsigned) zoneOutline->
COutline( 0 ).
PointCount() )
6198 [&](
BOARD_ITEM* aConstraint ) { commit.Modify( aConstraint ); },
6199 [&](
BOARD_ITEM* aConstraint ) { commit.Remove( aConstraint ); } );
6203 static_cast<ZONE*
>( item )->HatchBorder();
6205 commit.
Push(
_(
"Add Zone Corner" ) );
6207 else if( graphicItem )
6213 commit.
Modify( graphicItem );
6219 graphicItem->
SetEnd( nearestPoint );
6224 newSegment->
SetStart( nearestPoint );
6227 commit.
Add( newSegment );
6228 commit.
Push(
_(
"Split Segment" ) );
6233 commit.
Modify( graphicItem );
6239 graphicItem->
SetEnd( nearestPoint );
6248 commit.
Add( newArc );
6249 commit.
Push(
_(
"Split Arc" ) );
6277 ZONE* zone =
static_cast<ZONE*
>( item );
6298 const auto& vertexIdx = vertex.second;
6299 auto& outline =
polygon->Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
6301 if( outline.PointCount() > 3 )
6305 polygon->RemoveVertex( vertexIdx );
6312 [&](
BOARD_ITEM* aConstraint ) { commit.Modify( aConstraint ); },
6313 [&](
BOARD_ITEM* aConstraint ) { commit.Remove( aConstraint ); } );
6319 if( vertexIdx.m_contour > 0 )
6323 polygon->RemoveContour( vertexIdx.m_contour );
6335 commit.
Push(
_(
"Remove Zone Corner" ) );
6337 commit.
Push(
_(
"Remove Polygon Corner" ) );
6340 static_cast<ZONE*
>( item )->HatchBorder();
6363 ZONE* zone =
static_cast<ZONE*
>( item );
6384 unsigned int nearestIdx = 0;
6385 unsigned int nearestDist = INT_MAX;
6393 for( ; iterator; iterator++, curr_idx++ )
6395 unsigned int distance =
polygon->CVertex( curr_idx ).Distance( cursorPos );
6400 nearestIdx = curr_idx;
6404 int prevIdx, nextIdx;
6405 if(
polygon->GetNeighbourIndexes( nearestIdx, &prevIdx, &nextIdx ) )
6412 setback = std::min( setback, (
int) ( segA.Length() * 0.25 ) );
6413 setback = std::min( setback, (
int) ( segB.Length() * 0.25 ) );
6417 std::optional<CHAMFER_RESULT> chamferResult =
ComputeChamferPoints( segA, segB, chamferParams );
6419 if( chamferResult && chamferResult->m_updated_seg_a && chamferResult->m_updated_seg_b )
6422 polygon->RemoveVertex( nearestIdx );
6425 polygon->InsertVertex( nearestIdx, chamferResult->m_updated_seg_b->B );
6426 polygon->InsertVertex( nearestIdx, chamferResult->m_updated_seg_a->B );
6432 auto modify = [&](
BOARD_ITEM* aConstraint ) { commit.
Modify( aConstraint ); };
6433 auto remove = [&](
BOARD_ITEM* aConstraint ) { commit.
Remove( aConstraint ); };
6444 commit.
Push(
_(
"Break Zone Corner" ) );
6446 commit.
Push(
_(
"Break Polygon Corner" ) );
6449 static_cast<ZONE*
>( item )->HatchBorder();
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_ENDPOINTS_OR_START_DIRECTION
Whe editing endpoints, the other end remains in place.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
When editing endpoints, the angle and radius are adjusted.
constexpr EDA_IU_SCALE pcbIUScale
bool BlockDragIsConstraintMember(const BOARD_ITEM &aItem)
True when the item belongs to any geometric constraint on its board or inside one of its footprints.
BLOCK_DRAG_CAPABILITY BlockDragCapability(const BOARD_ITEM &aItem)
Classify one board item for a block drag.
std::vector< BOARD_ITEM * > BlockDragExpandSelection(const std::vector< BOARD_ITEM * > &aSelection)
Replace group containers with their members, through nested groups, and drop duplicates.
bool BlockDragAnchorEditingEnabled(const PCB_BASE_FRAME *aFrame)
Whether the user has turned on editing anchor points on a multi-selection.
BLOCK_DRAG_CAPABILITY
How one selected item takes part in a block drag.
@ UNSUPPORTED
Stops the drag with a message before anything moves.
@ DEFORMABLE
Shows handles, and reshapes as the user drags the ones they picked.
@ ROUTER
Moves with the block through the router, which repairs the copper at the edge of the block.
BLOCK_DRAG_DEPENDENT_RESULT BlockDragFindDependents(const std::vector< PCB_SHAPE * > &aCandidates, const std::vector< BLOCK_DRAG_ENDPOINT > &aMovedEndpoints, bool aOverrideLocks, std::vector< BLOCK_DRAG_ENDPOINT > &aDependents)
Find the joined endpoints that have to follow the ones the drag moves.
@ LOCKED
A shape that would have to follow is locked and Override Locks is off, so the drag has to stop.
@ WHOLE
The whole shape moves, for a shape that moving one end alone would distort.
bool BlockDragApplyDisplacement(const std::vector< EDIT_POINTS * > &aCollections, const std::map< PCB_HANDLE_KEY, VECTOR2I > &aOrigins, const VECTOR2I &aDelta, const GRID_HELPER &aGrid)
Put every handle at its starting position plus the drag's offset.
std::map< PCB_HANDLE_KEY, VECTOR2I > BlockDragMoveOrigins(const std::vector< EDIT_POINTS * > &aCollections, const std::set< PCB_HANDLE_KEY > &aPicked)
Note every handle the drag will move, and where each one started.
SHAPE_LINE_CHAIN BlockDragPickRect(const VECTOR2I &aFirst, const VECTOR2I &aSecond)
The closed rectangle a box pick covers, built from two opposite corners.
bool BlockDragHandlePickable(const EDIT_POINTS &aCollection, const EDIT_POINT &aPoint)
True when the user is allowed to pick this handle.
void BlockDragApplyPick(std::set< PCB_HANDLE_KEY > &aPicked, const PCB_HANDLE_KEY &aKey, bool aAccumulate)
Add one clicked handle to the picked set.
void BlockDragLassoPick(const std::vector< EDIT_POINTS * > &aCollections, const SHAPE_LINE_CHAIN &aLasso, bool aAccumulate, std::set< PCB_HANDLE_KEY > &aPicked)
Add the handles a lasso surrounds to the picked set.
BLOCK_DRAG_VALIDATION_RESULT
@ INVALID_ZONE
A zone that came along lost its valid outline.
std::vector< VECTOR2I > ConstraintPinnedPositions(BOARD *aBoard, const std::set< KIID > &aItems)
The distinct board positions that fixed positions pin on aItems.
void ReSolveAfterShapeResize(BOARD *aBoard, PCB_SHAPE *aShape, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Re-solve after a resize, e.g. a circle radius edit. Holds aShape fixed so its neighbors adjust.
bool BoardHasConstraints(BOARD *aBoard)
True if aBoard resolves at least one geometric constraint (see CollectResolvedConstraints()).
CONSTRAINT_DIAGNOSIS SolveCluster(BOARD *aBoard, const CONSTRAINT_MEMBER &aDragged, const VECTOR2I &aCursor, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify, bool aIncludeDragged, bool aStabilize, const std::set< KIID > &aEdited, const std::optional< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > &aCoDragged, const std::set< KIID > &aFixedShapes, bool aHoldDraggedRigid)
Gather the cluster of shapes transitively constrained with the dragged shape, solve with the dragged ...
bool ReSolveShapeClustersHoldingEdited(BOARD *aBoard, const std::vector< PCB_SHAPE * > &aEditedShapes, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Re-solve clusters whose new geometry is authoritative holding every edited shape fully fixed so only ...
bool ConstraintItemIsLocked(const BOARD_ITEM *aItem)
True when the solver must treat aItem as immovable, either locked itself or living inside a locked fo...
CONSTRAINT_BLOCK_RESULT
How a block edit solve turned out.
@ REFUSED
No arrangement fits the pinned points, and the geometry is untouched.
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION gridFastCycle
static TOOL_ACTION toggleGrid
static TOOL_ACTION zoomRedraw
static TOOL_ACTION gridFast1
static TOOL_ACTION gridPrev
static TOOL_ACTION cursorLeft
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION togglePolarCoords
static TOOL_ACTION zoomIn
static TOOL_ACTION cursorLeftFast
static TOOL_ACTION cycleArcEditMode
static TOOL_ACTION gridPreset
static TOOL_ACTION cursorDown
static TOOL_ACTION zoomOut
static TOOL_ACTION pointEditorArcKeepCenter
static TOOL_ACTION cursorRightFast
static TOOL_ACTION deleteLastPoint
static TOOL_ACTION toggleCursor
static TOOL_ACTION pointEditorArcKeepRadius
static TOOL_ACTION zoomCenter
static TOOL_ACTION panDown
static TOOL_ACTION cursorDblClick
static TOOL_ACTION cursorDownFast
static TOOL_ACTION reselectItem
static TOOL_ACTION cursorUpFast
static TOOL_ACTION panLeft
static TOOL_ACTION updateMenu
static TOOL_ACTION activatePointEditor
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION zoomFitObjects
static TOOL_ACTION zoomInCenter
static TOOL_ACTION panRight
static TOOL_ACTION gridFast2
static TOOL_ACTION cursorUp
Cursor control with keyboard.
static TOOL_ACTION refreshPreview
static TOOL_ACTION toggleGridOverrides
static TOOL_ACTION finishInteractive
static TOOL_ACTION gridNext
static TOOL_ACTION cursorRight
static TOOL_ACTION pointEditorArcKeepEndpoint
PCB_DIM_ALIGNED & m_dimension
void updateOrthogonalDimension(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints)
Update orthogonal dimension points.
ALIGNED_DIMENSION_POINT_EDIT_BEHAVIOR(PCB_DIM_ALIGNED &aDimension)
void updateAlignedDimension(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints)
Update non-orthogonal dimension points.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
BARCODE_POINT_EDIT_BEHAVIOR(PCB_BARCODE &aBarcode)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_SHAPE makeDummyRect()
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool collectTargets()
Pair every collection that holds a moved point with its behavior.
KIGFX::COLOR4D bandColor() const
Band colour for the area picks, kept clear of the canvas colour.
PCB_POINT_EDITOR & m_editor
bool KeyboardDrag() const
Whether this drag runs from the keyboard, so motion moves it and a click places it.
void releaseState()
Put the view, the flags and the router back, and drop the gesture's state.
bool Refused() const
Whether the last start was refused, in which case the gesture has already said why.
bool IsActive() const
Whether a drag is running.
bool runLasso(const TOOL_EVENT &aEvent)
Pick handles with a lasso, the way the object lasso works.
std::vector< BOARD_ITEM * > m_moving
Everything that moves with the cursor, kept out of the snap targets so the block cannot chase its own...
std::vector< std::shared_ptr< EDIT_POINTS > > m_dependentDisplays
bool m_keyboardDrag
Started with D, so motion moves it and a click places it.
std::set< KIID > m_constraintTranslated
bool m_refused
The last start was declined and said why itself.
BOARD_ITEM * m_refParent
The grabbed handle's snapping context, taken once at the start.
bool runBox(const TOOL_EVENT &aEvent)
Pick handles with a box, which finishes on release like normal box selection.
SNAP_CONSTRAINT_TYPE m_snapConstraint
bool m_pressConsumed
The rest of a swallowed button press is still to be ignored.
FRAME_RESULT applyFrame(const VECTOR2I &aDelta, std::vector< EDA_ITEM * > &aUpdated)
Write one frame.
std::optional< BLOCK_DRAG_VALIDATION > m_validation
The baseline the zone and board outline checks compare the released geometry against.
bool m_active
A drag is running.
void hideBand(HANDLE_PICK_AREA &aArea)
bool Begin(const VECTOR2I &aOrigin, bool aPressInFlight)
Start a drag from the handle at aOrigin.
FRAME_RESULT
How one frame of the gesture turned out.
@ LOST_IDENTITY
A picked handle has gone, so the gesture has to stop.
@ CONSTRAINED
A constraint blocks this frame, and the board is untouched.
@ APPLIED
The frame's geometry went onto the board.
bool ApplyCursor(const TOOL_EVENT &aEvent)
Place one frame of the drag. True when the editor has to leave its loop.
std::vector< BLOCK_DRAG_ENDPOINT > m_dependents
Unselected ends that sit on a moved joint and follow it, with the handle drawn at each one.
bool m_routerActive
A router drag session is carrying the block's copper.
bool RunAreaPick(const TOOL_EVENT &aEvent)
Run the lasso or the box, whichever the selection mode asks for.
bool m_revertRestarts
Undo will hand out fresh objects, so the editor has to start again from the live selection.
std::optional< BOARD_CONSTRAINT_BLOCK_SESSION > m_constraintSession
std::map< PCB_HANDLE_KEY, VECTOR2I > m_origins
Where each picked handle stood when the gesture began.
void endDrag(bool aKeepPicks)
End the gesture and rebuild the handles.
std::vector< std::pair< PCB_SHAPE *, CONSTRAINT_MEMBER > > m_constraintAnchors
What the solve holds fixed: the anchors the gesture placed itself, and the items it carried whole,...
std::set< PCB_SHAPE * > m_solverBrightened
Neighbours the solve pulled along, brightened so the user can see what moved with the block.
BLOCK_DRAG_SESSION(PCB_POINT_EDITOR &aEditor, PCB_BASE_EDIT_FRAME *aEditFrame, PCB_GRID_HELPER &aGrid, BOARD_COMMIT &aCommit)
bool m_constraintWarned
Said once, not per frame.
VECTOR2I m_appliedDelta
The last offset written to the board, which is what a refused frame is undone with.
bool revert(bool aPushed)
Undo the gesture.
void ClearPressConsumed()
bool Release(const TOOL_EVENT &aEvent)
Finish the drag and push what it changed. True when the editor has to leave its loop.
std::vector< std::pair< EDIT_POINTS *, POINT_EDIT_BEHAVIOR * > > m_targets
Each collection holding a picked handle, with the behavior that rebuilds its item.
bool refuseRelease(const wxString &aMessage)
Say why the release was refused and put the board back, keeping the picks so the user can try again f...
std::vector< KIID > m_overlayHidden
Copper whose selection overlay is hidden while the router preview stands in for it,...
GRID_HELPER_GRIDS m_refGrid
void Abort()
Undo a drag that is still running, for the exits that miss the release and cancel paths.
bool Cancel(TOOL_EVENT &aEvent)
Undo the drag, keeping the picks. True when the editor has to leave its loop.
PCB_BASE_EDIT_FRAME * m_editFrame
std::vector< BOARD_ITEM * > m_rigidItems
Selected items with no picked handle, which travel whole as they would under the move tool.
bool AreaPickStarts(const TOOL_EVENT &aEvent)
Whether a drag starting on empty canvas should pick handles by area.
void showBand(HANDLE_PICK_AREA &aArea)
Put the pick band on the view and take the cursor for it, and take it off again.
bool PressConsumed() const
Whether the rest of a swallowed button press is still to be ignored.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE) override
Add a change of the item aItem of type aChangeType to the change list.
void Revert() override
Revert the commit by restoring the modified items state.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const
Create a copy of this BOARD_ITEM.
bool IsLocked() const override
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
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.
BOARD_ITEM * ResolveItem(const KIID &aID, bool aAllowNullptrReturn=false) const
constexpr void SetMaximum()
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr const Vec GetEnd() const
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
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 coord_type GetBottom() const
Represent a set of changes (additions, deletions or modifications) of a data model (e....
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Class to help update the text position of a dimension when the crossbar changes.
DIM_ALIGNED_TEXT_UPDATER(PCB_DIM_ALIGNED &aDimension)
VECTOR2I getDimensionNewTextPosition()
PCB_DIM_ALIGNED & m_dimension
const VECTOR2I m_originalTextPos
void UpdateTextAfterChange()
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_DIM_CENTER & m_dimension
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
DIM_CENTER_POINT_EDIT_BEHAVIOR(PCB_DIM_CENTER &aDimension)
DIM_LEADER_POINT_EDIT_BEHAVIOR(PCB_DIM_LEADER &aDimension)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_DIM_LEADER & m_dimension
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
DIM_RADIAL_POINT_EDIT_BEHAVIOR(PCB_DIM_RADIAL &aDimension)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
PCB_DIM_RADIAL & m_dimension
bool IsType(FRAME_T aType) const
bool GetOverrideLocks() const
A base class for most all the KiCad significant classes used in schematics and boards.
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const
Return a user-visible description string of this item.
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
virtual VECTOR2I GetTopLeft() const
SHAPE_POLY_SET & GetPolyShape()
virtual VECTOR2I GetBotRight() const
virtual void SetBottom(int val)
virtual void SetTop(int val)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
virtual void SetLeft(int val)
virtual void SetRight(int val)
int GetCornerRadius() const
VECTOR2I GetArcMid() const
EDA_TABLECELL_POINT_EDIT_BEHAVIOR(EDA_SHAPE &aCell)
Represent a line connecting two EDIT_POINTs.
POLYGON_EDGE_DRAG_POLICY * GetDragPolicy() const
void SetRelation(std::unique_ptr< EDIT_RELATION > aRelation)
Set a relation for an EDIT_LINE.
EDIT_POINT & GetEnd()
Return the end EDIT_POINT.
EDIT_POINT & GetOrigin()
Return the origin EDIT_POINT.
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
unsigned int PointsSize() const
Return number of stored EDIT_POINTs.
void AddPoint(const EDIT_POINT &aPoint)
Add an EDIT_POINT.
void SetSwapY(bool aSwap)
void Clear()
Clear all stored EDIT_POINTs and EDIT_LINEs.
EDIT_LINE & Line(unsigned int aIndex)
void AddIndicatorLine(EDIT_POINT &aOrigin, EDIT_POINT &aEnd)
Adds an EDIT_LINE that is shown as an indicator, rather than an editable line (no center point drag,...
void SetLineStateVisible(bool aShow)
void SetSwapX(bool aSwap)
EDA_ITEM * GetParent() const
Return parent of the EDIT_POINTS.
unsigned int LinesSize() const
Return number of stored EDIT_LINEs.
EDIT_POINT & Point(unsigned int aIndex)
void AddLine(const EDIT_LINE &aLine)
Adds an EDIT_LINE.
Represent a single point that can be used for modifying items.
void SetDrivesWholeShape(bool aDrives=true)
SNAP_CONSTRAINT_TYPE GetSnapConstraint() const
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
void SetSnapConstraint(SNAP_CONSTRAINT_TYPE aConstraint)
void SetSelected(bool aSelected=true)
int GetX() const
Return X coordinate of an EDIT_POINT.
void SetRelation(std::unique_ptr< EDIT_RELATION > aRelation)
Set a relation for an EDIT_POINT.
void SetActive(bool aActive=true)
void SetDrawCircle(bool aDrawCircle=true)
static std::unique_ptr< EDIT_RELATION > Angle90(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > Angle45(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > PerpendicularTranslation(const EDIT_LINE &aLine)
const VECTOR2I & Direction() const
static std::unique_ptr< EDIT_RELATION > PointOnLine(const EDIT_POINT &aConstrained, const EDIT_POINT &aReference)
EDIT_RELATION_KIND Kind() const
static const TOOL_EVENT InhibitSelectionEditing
Used to inform tools that the selection should temporarily be non-editable.
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected item had a property changed (except movement)
static const TOOL_EVENT UninhibitSelectionEditing
static const TOOL_EVENT PointSelectedEvent
static const TOOL_EVENT SelectedItemsMoved
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT UnselectedEvent
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
PCB_GENERATOR & m_generator
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
GENERATOR_POINT_EDIT_BEHAVIOR(PCB_GENERATOR &aGenerator)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_GENERATOR_POLY & m_gen
GENERATOR_POLY_POINT_EDIT_BEHAVIOR(PCB_GENERATOR_POLY &aGen)
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
VECTOR2I toLocal(const VECTOR2I &aWorld) const
VECTOR2I radiusEndLocal() const
VECTOR2I arcEndLocal() const
GRID_POINT_EDIT_BEHAVIOR(PCB_GRID_ITEM &aGridItem)
VECTOR2I arcMidLocal() const
VECTOR2I cornerLocal(int aX, int aY) const
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
VECTOR2I toWorld(const VECTOR2I &aLocal) const
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
PCB_GRID_ITEM & m_gridItem
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 & Invert()
Makes the color inverted, alpha remains the same.
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
SIMPLE_OVERLAY_ITEM is class that represents a visual area drawn on a canvas, used to temporarily dem...
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
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.
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.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static constexpr PCB_LAYER_ID TEMP_ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
PAD_POINT_EDIT_BEHAVIOR(PAD &aPad, PCB_LAYER_ID aLayer)
ARC_EDIT_MODE m_ArcEditMode
static TOOL_ACTION drag45Degree
static TOOL_ACTION layerChanged
static TOOL_ACTION pointEditorMoveMidpoint
static TOOL_ACTION genFinishEdit
static TOOL_ACTION genStartEdit
static TOOL_ACTION pointEditorMoveCorner
static TOOL_ACTION genCancelEdit
static TOOL_ACTION dragFreeAngle
static TOOL_ACTION genUpdateEdit
static TOOL_ACTION pointEditorChamferCorner
static TOOL_ACTION pointEditorRemoveCorner
static TOOL_ACTION pointEditorAddCorner
Common, abstract interface for edit frames.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
A geometric constraint between board items (issue #2329).
For better understanding of the points that make a dimension:
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
void SetOrientation(DIR aOrientation)
Set the orientation of the dimension line (so, perpendicular to the feature lines).
DIR GetOrientation() const
A radial dimension indicates either the radius or diameter of an arc or circle.
virtual wxString GetCommitMessage() const =0
virtual void EditStart(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit)=0
bool IsDirty() const
Dirty flag system to for determining if generator output is not up to date It is up to each generator...
virtual bool Update(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit)=0
virtual void EditFinish(GENERATOR_TOOL *aTool, BOARD *aBoard, BOARD_COMMIT *aCommit)=0
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > GetBoardItems() const
static std::optional< PCB_HANDLE_KEY > Make(const EDIT_POINTS &aPoints, const EDIT_POINT *aPoint)
Build the key for a handle in a collection.
Tool that displays edit points allowing to modify items by dragging the points.
friend class BLOCK_DRAG_SESSION
int changeArcEditMode(const TOOL_EVENT &aEvent)
Change the edit method for arcs.
void updateBlockHandlePoints()
Move those handles back onto their items after the geometry changed.
bool CanRemoveCorner(const SELECTION &aSelection)
Condition to display "Remove Corner" context menu entry.
void updateItem(BOARD_COMMIT &aCommit)
Update item's points with edit points.
void setPickedHandles(std::set< PCB_HANDLE_KEY > aPicked)
Replace the picked set and repaint the handles to match it.
VECTOR2I m_stickyDisplacement
void updateBlockHandleHover(const VECTOR2I &aPosition)
Highlight the handle under the cursor, if there is one.
int OnSelectionChange(const TOOL_EVENT &aEvent)
Change selection event handler.
void applyPickedFlags()
Paint the picked handles, dropping keys whose handle has gone.
void setAltConstraint(bool aEnabled)
Set up an alternative constraint (typically enabled upon a modifier key being pressed).
static const unsigned int COORDS_PADDING
bool HasBlockHandle() const
True when the cursor sits on a handle the user can pick.
EDIT_POINT * m_hoveredPoint
bool blockAnchorEditingEnabled() const
Whether the user has turned on anchor point handles for multi-selections.
int addCorner(const TOOL_EVENT &aEvent)
EDIT_POINTS * m_blockHoveredOwner
bool HasPoint()
Indicate the cursor is over an edit point.
EDIT_POINT m_original
Original pos for the current drag point.
static bool CanChamferCorner(const EDA_ITEM &aItem)
Check if a corner of the given item can be chamfered (zones, polys only).
EDIT_POINT get45DegConstrainer() const
Return a point that should be used as a constrainer for 45 degrees mode.
int modifiedSelection(const TOOL_EVENT &aEvent)
EDIT_POINT * m_blockHoveredPoint
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
std::unique_ptr< POINT_EDIT_BEHAVIOR > makeBehavior(EDA_ITEM *aItem, bool &aRejected)
Create the point edit behavior for an item.
void clearPickedHandles()
Unpick everything and redraw.
std::unique_ptr< POINT_EDIT_BEHAVIOR > m_editorBehavior
int removeCorner(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
std::shared_ptr< BOARD_CONSTRAINT_DRAG_SESSION > m_constraintDragSession
std::unique_ptr< EDIT_RELATION > m_altConstraint
RECT_RADIUS_TEXT_ITEM * m_radiusHelper
std::set< PCB_HANDLE_KEY > m_pickedHandles
int bboxHandleInflation() const
Gap to leave between the scaling box handles and the shapes' own handles, in board units for the curr...
std::vector< BLOCK_HANDLE_ENTRY > m_blockHandles
int movePoint(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
static bool CanAddCorner(const EDA_ITEM &aItem)
Check if a corner can be added to the given item (zones, polys, segments, arcs).
void setEditedPoint(EDIT_POINT *aPoint)
Set the current point being edited. NULL means none.
bool pickHandleAt(const VECTOR2I &aPosition, bool aAccumulate)
Pick the handle under aPosition. Returns false when there is no handle to pick.
EDIT_POINT m_altConstrainer
bool isModified(const EDIT_POINT &aPoint) const
Return true if aPoint is the currently modified point.
std::vector< EDIT_POINTS * > pickableCollections()
The handle collections the user can pick from.
ARC_EDIT_MODE m_arcEditMode
std::unique_ptr< KIGFX::PREVIEW::ANGLE_ITEM > m_angleItem
EDIT_POINT * m_editedPoint
void updateEditedPoint(const TOOL_EVENT &aEvent)
Update which point is being edited.
int getEditedPointIndex() const
void updatePoints()
Update edit points with item's points.
int chamferCorner(const TOOL_EVENT &aEvent)
void clearBlockHandles()
Take those handles off the view and throw them away.
std::vector< BOARD_ITEM * > m_expandedSelection
void setTransitions() override
Set up handlers for various events.
std::shared_ptr< EDIT_POINTS > m_editPoints
std::shared_ptr< EDIT_POINTS > makePoints(EDA_ITEM *aItem)
void buildBlockHandles(const PCB_SELECTION &aSelection)
Build the handles shown for every reshapeable item in a multi-selection or group.
std::function< void()> m_blockDragAbort
PCB_SELECTION_TOOL * m_selectionTool
Object to handle a bitmap image that can be inserted in a PCB.
REFERENCE_IMAGE & GetReferenceImage()
void SetCornerRadius(int aCornerRadius) override
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void SetEnd(const VECTOR2I &aEnd) override
bool IsProxyItem() const override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetStart(const VECTOR2I &aStart) override
VECTOR2I unturned(const VECTOR2I &aPoint) const
VECTOR2I edgeMidpoint(TABLECELL_POINTS aPoint) const
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_TABLECELL_POINT_EDIT_BEHAVIOR(PCB_TABLECELL &aCell)
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
virtual bool GetForceMarkObstaclesMode(bool *aDragStatus) const =0
void Add(const LINE &aLine)
Base class for PNS router board items.
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Keep the router "world" - i.e.
std::vector< ITEM * > FindItemsByParent(const BOARD_ITEM *aParent)
ROUTING_SETTINGS & Settings()
bool RoutingInProgress() const
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish, bool aForceCommit)
bool Move(const VECTOR2I &aP, ITEM *aItem)
bool AllowDRCViolations() const
void SetBoard(BOARD *aBoard)
void SetView(KIGFX::VIEW *aView)
void SetIndependentPads(const std::set< PAD * > &aPads)
Pads that move on their own. A moved pad otherwise carries its footprint.
void SetCommitFlags(int aCommitFlags)
A helper class interface to manage the edit points for a single item.
virtual void MakePoints(EDIT_POINTS &aPoints)=0
Construct the initial set of edit points for the item and append to the given list.
static bool isModified(const EDIT_POINT &aEditedPoint, const EDIT_POINT &aPoint)
Checks if two points are the same instance - which means the point is being edited.
void SetMode(POLYGON_LINE_MODE aMode)
POLYGON_LINE_MODE GetMode() const
const VECTOR2I & GetOriginalCenter() const
const VECTOR2I & GetPerpVector() const
static void UpdateOutlineFromPoints(SHAPE_POLY_SET &aOutline, const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints)
Update the polygon outline with the new positions of the edit points.
static void UpdatePointsFromOutline(const SHAPE_POLY_SET &aOutline, EDIT_POINTS &aPoints)
Update the edit points with the current polygon outline.
POLYGON_POINT_EDIT_BEHAVIOR(SHAPE_POLY_SET &aPolygon)
static void BuildForPolyOutline(EDIT_POINTS &aPoints, const SHAPE_POLY_SET &aOutline)
Build the edit points for the given polygon outline.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
static void RemoveNullSegmentsIfPolygonSurvives(SHAPE_POLY_SET &aOutline)
Remove the zero length segments left by an edit, unless that would strip the outline down to somethin...
static void UpdateItem(SCH_SHAPE &aRect, const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, const VECTOR2I &aMinSize={ 0, 0 })
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
static void UpdateItem(PCB_SHAPE &aRectangle, const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, const VECTOR2I &aMinSize={ 0, 0 })
static void UpdatePoints(SCH_SHAPE &aRect, EDIT_POINTS &aPoints)
static void PinEditedCorner(const EDIT_POINT &aEditedPoint, const EDIT_POINTS &aPoints, int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight)
Update the coordinates of 4 corners of a rectangle, according to constraints and the moved corner.
static void PinEditedCorner(const EDIT_POINT &aEditedPoint, const EDIT_POINTS &aEditPoints, VECTOR2I &aTopLeft, VECTOR2I &aTopRight, VECTOR2I &aBotLeft, VECTOR2I &aBotRight, const VECTOR2I &aHole={ 0, 0 }, const VECTOR2I &aHoleSize={ 0, 0 }, const VECTOR2I &aMinSize={ 0, 0 })
Update the coordinates of 4 corners of a rectangle, according to constraints and the moved corner.
static void MakePoints(SCH_SHAPE &aRect, EDIT_POINTS &aPoints)
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
static void MakePoints(const PCB_SHAPE &aRectangle, EDIT_POINTS &aPoints)
Standard rectangle points construction utility (other shapes may use this as well)
static void UpdatePoints(const PCB_SHAPE &aRectangle, EDIT_POINTS &aPoints)
RECTANGLE_POINT_EDIT_BEHAVIOR(PCB_SHAPE &aRectangle)
const EDA_IU_SCALE & m_iuScale
wxString GetClass() const override
Return the class name.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void Set(int aRadius, const VECTOR2I &aCorner, const VECTOR2I &aQuadrant, EDA_UNITS aUnits)
RECT_RADIUS_TEXT_ITEM(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
void SetMessage(const wxString &aStatus)
void SetHint(const wxString &aHint)
void SetPosition(const VECTOR2I &aPos) override
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
EDA_ANGLE Angle(const SEG &aOther) const
Determine the smallest angle between two segments.
Class that groups generic conditions for selected items.
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
int Size() const
Returns the number of selected parts.
VECTOR2I NearestPoint(const VECTOR2I &aP) const
const VECTOR2I & GetP1() const
void SetInflation(int aInflation)
std::optional< VECTOR2I > m_pinned
const std::vector< PCB_SHAPE * > & GetShapes() const
SHAPE_GROUP_POINT_EDIT_BEHAVIOR(PCB_GROUP &aGroup)
BOARD_ITEM * GetParent() const
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
std::unordered_map< PCB_SHAPE *, double > m_originalWidths
std::vector< PCB_SHAPE * > m_shapes
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
SHAPE_GROUP_POINT_EDIT_BEHAVIOR(std::vector< PCB_SHAPE * > aShapes, BOARD_ITEM *aParent, const std::optional< VECTOR2I > &aPinned)
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
BOX2I getBoundingBox() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
virtual size_t GetPointCount() const override
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
void Remove(int aStartIndex, int aEndIndex)
Remove the range of points [start_index, end_index] from the line chain.
bool IsEndContour() const
Represent a set of closed polygons.
ITERATOR_TEMPLATE< VECTOR2I > ITERATOR
ITERATOR IterateWithHoles(int aOutline)
void InsertVertex(int aGlobalIndex, const VECTOR2I &aNewVertex)
Adds a vertex in the globally indexed position aGlobalIndex.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Return an object to iterate through the points of the polygons between aFirst and aLast.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
A textbox is edited as a rectnagle when it is orthogonally aligned.
TEXTBOX_POINT_EDIT_BEHAVIOR(PCB_TEXTBOX &aTextbox)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
EDA_UNITS GetUserUnits() const
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
VECTOR2I GetValue()
Return the value in internal units.
bool Fill(const std::vector< ZONE * > &aZones, bool aCheck=false, wxWindow *aParent=nullptr)
Fills the given list of zones.
void FinalizeItem(EDIT_POINTS &aPoints, COMMIT &aCommit) override
Finalize the edit operation.
bool UpdateItemAppliesAllPoints() const override
Whether UpdateItem() writes every point back, so one call applies all of them.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
ZONE_POINT_EDIT_BEHAVIOR(ZONE &aZone)
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
Handle a list of polygons defining a copper zone.
void SetNeedRefill(bool aNeedRefill)
SHAPE_POLY_SET * Outline()
This file is part of the common library.
bool IsConstrainableItem(const BOARD_ITEM *aItem)
True when aItem is one ResolveConstrainableItem() accepts: a PCB_SHAPE, a dimension or a pad.
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...
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 n...
std::vector< CONSTRAINT_ANCHOR_POINT > ConstraintShapeAnchors(const PCB_SHAPE *aShape)
Enumerate a shape constraint anchors with positions segment and arc endpoints arc centre circle centr...
bool ConstraintPolygonIsModelable(const PCB_SHAPE *aShape)
True when polygon has one non empty hole free arc free outline making it solver eligible Shared by ad...
std::vector< PCB_CONSTRAINT * > CollectResolvedConstraints(const BOARD *aBoard)
The constraints the editor resolves on aBoard.
std::optional< CHAMFER_RESULT > ComputeChamferPoints(const SEG &aSegA, const SEG &aSegB, const CHAMFER_PARAMS &aChamferParams)
Compute the chamfer points for a given line pair and chamfer parameters.
static constexpr double MIN_SCALE
const int minSize
Push and Shove router track width and via size dialog.
#define IS_MOVING
Item being moved.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
a few functions useful in geometry calculations.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamp a vector to values that can be negated, respecting numeric limits of coordinates data type with...
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_GP_OVERLAY
General purpose overlay.
@ LAYER_AUX_ITEMS
Auxiliary items (guides, rule, etc).
@ LAYER_SELECT_OVERLAY
Selected items overlay.
PCB_LAYER_ID
A quick note on layer IDs:
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
bool PointProjectsOntoSegment(const VECTOR2I &aPoint, const SEG &aSeg)
Determine if a point projects onto a segment.
double GetLengthRatioFromStart(const VECTOR2I &aPoint, const SEG &aSeg)
Get the ratio of the vector to a point from the segment's start, compared to the segment's length.
const VECTOR2I & GetNearestEndpoint(const SEG &aSeg, const VECTOR2I &aPoint)
Get the nearest end of a segment to a point.
bool PointIsInDirection(const VECTOR2< T > &aPoint, const VECTOR2< T > &aDirection, const VECTOR2< T > &aFrom)
void DrawTextNextToCursor(KIGFX::VIEW *aView, const VECTOR2D &aCursorPos, const VECTOR2D &aTextQuadrant, const wxArrayString &aStrings, bool aDrawingDropShadows)
Draw strings next to the cursor.
wxString DimensionLabel(const wxString &prefix, double aVal, const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, bool aIncludeUnits=true)
Get a formatted string showing a dimension to a sane precision with an optional prefix and unit suffi...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
BARCODE class definition.
CONSTRAINT_ANCHOR
Which feature of a referenced board item participates in a constraint.
@ VERTEX
An indexed rectangle corner or polygon outline vertex; pairs with CONSTRAINT_MEMBER::m_index.
@ START
First endpoint of a segment or arc.
@ END
Second endpoint of a segment or arc.
@ CENTER
Center of an arc or circle.
@ MANUAL
Text placement is manually set by the user.
#define STATUS_ITEMS_ONLY
Class to handle a set of BOARD_ITEMs.
static VECTOR2I snapCorner(const VECTOR2I &aPrev, const VECTOR2I &aNext, const VECTOR2I &aGuess, double aAngleDeg)
static const TOOL_ACTION *const blockDragNavigationActions[]
static std::optional< CONSTRAINT_MEMBER > constraintMemberForEditPoint(PCB_SHAPE *aShape, EDIT_POINTS *aPoints, EDIT_POINT *aEditedPoint)
static bool blockDragAllowsCommand(const TOOL_EVENT &aEvent)
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
static const TOOL_ACTION *const blockDragSafeActions[]
static std::vector< VECTOR2I > getConstraintDirections(EDIT_RELATION *aRelation)
TEXTBOX_POINT_COUNT
Text boxes have different point counts depending on their orientation.
static void blockDragAppendConstraintCoMembers(BOARD *aBoard, std::vector< BOARD_ITEM * > &aItems)
static void appendDirection(std::vector< VECTOR2I > &aDirections, const VECTOR2I &aDirection)
static void blockDragPassNavigation(TOOL_EVENT *aEvent)
static wxString blockDragDrcRefusal()
The release refuses a DRC violation unless the user forces it, and says so the same way wherever it i...
ARC_EDIT_MODE IncrementArcEditMode(ARC_EDIT_MODE aMode)
#define CHECK_POINT_COUNT(aPoints, aExpected)
#define CHECK_POINT_COUNT_GE(aPoints, aExpected)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
std::optional< VECTOR2I > OPT_VECTOR2I
std::vector< FAB_LAYER_COLOR > dummy
One end of a graphic shape, used both for the ends that moved and for the ones found to follow them.
Parameters that define a simple chamfer operation.
A selectable feature of a shape (a segment endpoint, arc centre, ...) and its location.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
std::unique_ptr< POINT_EDIT_BEHAVIOR > behavior
std::shared_ptr< EDIT_POINTS > points
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
KIBIS top(path, &reporter)
static std::vector< int > candidates(const SEGMENT_INDEX &aIndex, const SEG &aQuery, int aPadding)
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
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.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ 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_GENERATOR_T
class PCB_GENERATOR, generator on a 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_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ NOT_USED
the 3d code uses this value
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ 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_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
Supplemental functions for working with vectors and simple objects that interact with vectors.
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)
static PIECE polygon(std::vector< VIA_CROSS_SECTION_GEOMETRY::POINT > aPoints, bool aMixed=false)