64using namespace std::placeholders;
66#include <wx/hyperlink.h>
71#include <dialogs/dialog_tablecell_properties.h>
72#include <dialogs/dialog_table_properties.h>
109 m_selectionTool( nullptr ),
119 m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
125 auto menu = std::make_shared<CONDITIONAL_MENU>( aTool );
128 menu->SetTitle(
_(
"Positioning Tools" ) );
130 auto notMovingCondition = [](
const SELECTION& aSelection )
132 return aSelection.Empty() || !aSelection.Front()->IsMoving();
148 auto menu = std::make_shared<CONDITIONAL_MENU>( aTool );
150 menu->SetTitle(
_(
"Shape Modification" ) );
168 auto hasCornerCondition =
176 auto hasMidpointCondition =
220 auto positioningToolsCondition =
224 subMenu->Evaluate( aSel );
225 return subMenu->GetMenuItemCount() > 0;
228 auto shapeModificationCondition =
232 subMenu->Evaluate( aSel );
233 return subMenu->GetMenuItemCount() > 0;
236 auto propertiesCondition =
239 if( aSel.GetSize() == 0 )
253 if( aSel.GetSize() == 1 )
265 auto inFootprintEditor =
289 auto multipleFootprintsCondition =
292 bool foundFirst =
false;
308 auto noActiveToolCondition =
311 return frame()->ToolStackIsEmpty();
314 auto notMovingCondition =
317 return aSelection.Empty() || !aSelection.Front()->IsMoving();
320 auto noItemsCondition =
321 [ this ](
const SELECTION& aSelections ) ->
bool
323 return frame()->GetBoard() && !
frame()->GetBoard()->IsEmpty();
351 && notMovingCondition );
354 && notMovingCondition
355 && !inFootprintEditor );
357 && notMovingCondition );
379 && !inFootprintEditor );
391 menu.AddSeparator( 100 );
392 menu.AddMenu( shapeModificationSubMenu.get(), shapeModificationCondition, 100 );
393 menu.AddMenu( positioningToolsSubMenu.get(), positioningToolsCondition, 100 );
395 menu.AddSeparator( 150 );
407 menu.AddSeparator( 150 );
423 wxString footprintName;
424 wxArrayString fplist;
429 fplist.Add( fp->GetReference() + wxT(
" ( " ) + fp->GetValue() + wxT(
" )" ) );
439 footprintName.Trim(
true );
440 footprintName.Trim(
false );
442 if( !footprintName.IsEmpty() )
446 if( fp->GetReference().CmpNoCase( footprintName ) == 0 )
546 std::vector<PCB_TRACK*> tracks;
547 std::vector<PCB_TRACK*> vias;
548 std::vector<FOOTPRINT*> footprints;
555 vias.push_back( track );
557 tracks.push_back( track );
568 for( int ii = aCollector.GetCount() - 1; ii >= 0; --ii )
570 if( aCollector[ii]->Type() != PCB_FOOTPRINT_T )
571 aCollector.Remove( ii );
574 else if( tracks.size() || vias.size() )
579 if( aCollector.GetCount() > 1 )
580 sTool->GuessSelectionCandidates( aCollector, aPt );
587 auto connected = []( PCB_TRACK* track, const VECTOR2I& pt )
589 return track->GetStart() == pt || track->GetEnd() == pt;
592 if( tracks.size() == 2 && vias.size() == 0 )
594 if( connected( tracks[0], tracks[1]->GetStart() )
595 || connected( tracks[0], tracks[1]->GetEnd() ) )
597 aCollector.Remove( tracks[1] );
600 else if( tracks.size() == 2 && vias.size() == 1 )
602 if( connected( tracks[0], vias[0]->GetPosition() )
603 && connected( tracks[1], vias[0]->GetPosition() ) )
605 aCollector.Remove( tracks[0] );
606 aCollector.Remove( tracks[1] );
613 if( selection.Empty() )
616 if( selection.Size() == 1 && selection.Front()->Type() ==
PCB_ARC_T )
620 return DragArcTrack( aEvent );
624 invokeInlineRouter( mode );
643 wxString msg = wxString::Format(
_(
"Unable to resize arc tracks of %s or greater." ),
645 frame()->ShowInfoBarError( msg );
658 bool restore_state =
false;
672 tanStart.
A = *tanIntersect;
674 tanEnd.
A = *tanIntersect;
677 std::set<PCB_TRACK*> addedTracks;
679 auto getUniqueTrackAtAnchorCollinear =
685 int allowedDeviation = theArc->
GetWidth();
687 std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
689 for(
int i = 0; i < 3; i++ )
691 itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor,
694 allowedDeviation /= 2;
696 if( itemsOnAnchor.size() == 1 )
702 if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() ==
PCB_TRACE_T )
704 track =
static_cast<PCB_TRACK*
>( itemsOnAnchor.front() );
710 if( trackSeg.
Angle( aCollinearSeg ) > maxTangentDeviation )
727 addedTracks.insert( track );
733 PCB_TRACK* trackOnStart = getUniqueTrackAtAnchorCollinear( theArc->
GetStart(), tanStart);
734 PCB_TRACK* trackOnEnd = getUniqueTrackAtAnchorCollinear( theArc->
GetEnd(), tanEnd );
739 tanStart.
B = trackOnStart->
GetEnd();
745 tanEnd.
B = trackOnEnd->
GetEnd();
749 if( tanIntersect = tanStart.
IntersectLines( tanEnd ); !tanIntersect )
752 auto isTrackStartClosestToArcStart =
755 double trackStartToArcStart = aTrack->GetStart().
Distance( theArc->
GetStart() );
756 double trackEndToArcStart = aTrack->GetEnd().Distance( theArc->
GetStart() );
758 return trackStartToArcStart < trackEndToArcStart;
761 bool isStartTrackOnStartPt = isTrackStartClosestToArcStart( trackOnStart );
762 bool isEndTrackOnStartPt = isTrackStartClosestToArcStart( trackOnEnd );
791 auto getFurthestPointToTanInterstect =
794 if( ( aPointA - *tanIntersect ).EuclideanNorm()
795 > ( aPointB - *tanIntersect ).EuclideanNorm() )
806 VECTOR2I tanStartPoint = getFurthestPointToTanInterstect( tanStart.
A, tanStart.
B );
807 VECTOR2I tanEndPoint = getFurthestPointToTanInterstect( tanEnd.
A, tanEnd.
B );
808 VECTOR2I tempTangentPoint = tanEndPoint;
810 if( getFurthestPointToTanInterstect( tanStartPoint, tanEndPoint ) == tanEndPoint )
811 tempTangentPoint = tanStartPoint;
817 SEG cSegTanStart( maxTanPtStart, *tanIntersect );
818 SEG cSegTanEnd( maxTanPtEnd, *tanIntersect );
819 SEG cSegChord( maxTanPtStart, maxTanPtEnd );
821 int cSegTanStartSide = cSegTanStart.
Side( theArc->
GetMid() );
822 int cSegTanEndSide = cSegTanEnd.
Side( theArc->
GetMid() );
823 int cSegChordSide = cSegChord.
Side( theArc->
GetMid() );
825 bool eatFirstMouseUp =
true;
837 std::vector<VECTOR2I> possiblePoints;
844 for(
const VECTOR2I& candidate : possiblePoints )
846 if( ( candidate -
m_cursor ).SquaredEuclideanNorm()
847 < ( closest -
m_cursor ).SquaredEuclideanNorm() )
876 if( isStartTrackOnStartPt )
879 trackOnStart->
SetEnd( newStart );
881 if( isEndTrackOnStartPt )
884 trackOnEnd->
SetEnd( newEnd );
892 if( evt->IsMotion() || evt->IsDrag(
BUT_LEFT ) )
894 eatFirstMouseUp =
false;
896 else if( evt->IsCancelInteractive() || evt->IsActivate() )
898 restore_state =
true;
903 restore_state =
true;
912 eatFirstMouseUp =
false;
924 if( isStartTrackOnStartPt )
925 newStart = trackOnStart->
GetEnd();
927 if( isEndTrackOnStartPt )
928 newEnd = trackOnEnd->
GetEnd();
933 if( trackOnStart->
GetLength() <= maxLengthIU )
935 if( addedTracks.count( trackOnStart ) )
938 addedTracks.erase( trackOnStart );
943 commit.
Remove( trackOnStart );
949 if( trackOnEnd->
GetLength() <= maxLengthIU )
951 if( addedTracks.count( trackOnEnd ) )
954 addedTracks.erase( trackOnEnd );
959 commit.
Remove( trackOnEnd );
978 commit.
Push(
_(
"Drag Arc Track" ) );
990 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
992 BOARD_ITEM* item = aCollector[ i ];
994 if( !dynamic_cast<PCB_TRACK*>( item ) )
995 aCollector.Remove( item );
1013 if(
via->GetViaType() == VIATYPE::MICROVIA )
1026 via->SetDrill( new_drill );
1034 wxCHECK( track, 0 );
1043 commit.
Push(
_(
"Edit Track Width/Via Size" ) );
1060 static int filletRadius = 0;
1066 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1068 BOARD_ITEM* item = aCollector[i];
1070 if( !dynamic_cast<PCB_TRACK*>( item ) )
1071 aCollector.Remove( item );
1076 if( selection.
Size() < 2 )
1078 frame()->ShowInfoBarMsg(
_(
"At least two straight track segments must be selected." ) );
1094 bool t1Start =
true;
1095 bool t2Start =
true;
1098 std::vector<FILLET_OP> filletOperations;
1099 bool operationPerformedOnAtLeastOne =
false;
1100 bool didOneAttemptFail =
false;
1101 std::set<PCB_TRACK*> processedTracks;
1103 auto processFilletOp =
1104 [&](
PCB_TRACK* aTrack,
bool aStartPoint )
1108 std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
1112 if( itemsOnAnchor.size() > 0
1113 && selection.
Contains( itemsOnAnchor.at( 0 ) )
1119 if( processedTracks.find( trackOther ) == processedTracks.end() )
1121 if( itemsOnAnchor.size() == 1 )
1124 filletOp.t1 = aTrack;
1125 filletOp.t2 = trackOther;
1126 filletOp.t1Start = aStartPoint;
1127 filletOp.t2Start = aTrack->
IsPointOnEnds( filletOp.t2->GetStart() );
1128 filletOperations.push_back( filletOp );
1134 didOneAttemptFail =
true;
1148 processFilletOp( track,
true );
1149 processFilletOp( track,
false );
1151 processedTracks.insert( track );
1157 std::vector<BOARD_ITEM*> itemsToAddToSelection;
1159 for( FILLET_OP filletOp : filletOperations )
1167 if( trackOnStart && trackOnEnd )
1170 if( ( trackOnStart || trackOnEnd ) && track1->
GetLayer() == track2->
GetLayer() )
1178 SHAPE_ARC sArc( t1Seg, t2Seg, filletRadius );
1181 auto setIfPointOnSeg =
1184 VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
1189 aPointToSet.
x = aVecToTest.x;
1190 aPointToSet.
y = aVecToTest.y;
1198 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP0() )
1199 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP0() ) )
1201 didOneAttemptFail =
true;
1205 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP1() )
1206 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP1() ) )
1208 didOneAttemptFail =
true;
1220 itemsToAddToSelection.push_back( tArc );
1225 if( filletOp.t1Start )
1228 track1->
SetEnd( t1newPoint );
1230 if( filletOp.t2Start )
1233 track2->
SetEnd( t2newPoint );
1235 operationPerformedOnAtLeastOne =
true;
1239 commit.
Push(
_(
"Fillet Tracks" ) );
1242 for(
BOARD_ITEM* item : itemsToAddToSelection )
1245 if( !operationPerformedOnAtLeastOne )
1246 frame()->ShowInfoBarMsg(
_(
"Unable to fillet the selected track segments." ) );
1247 else if( didOneAttemptFail )
1248 frame()->ShowInfoBarMsg(
_(
"Some of the track segments could not be filleted." ) );
1264 int& aPersitentRadius )
1269 return std::nullopt;
1273 return aPersitentRadius;
1277static std::optional<DOGBONE_CORNER_ROUTINE::PARAMETERS>
1286 std::vector<WX_MULTI_ENTRY_DIALOG::ENTRY> entries{
1293 _(
"Add slots in acute corners" ),
1295 _(
"Add slots in acute corners to allow access to a cutter of the given radius" ),
1302 return std::nullopt;
1304 std::vector<WX_MULTI_ENTRY_DIALOG::RESULT> results = dlg.
GetValues();
1305 wxCHECK( results.size() == 2, std::nullopt );
1309 s_dogBoneParams.DogboneRadiusIU = std::get<long long int>( results[0] );
1310 s_dogBoneParams.AddSlots = std::get<bool>( results[1] );
1312 catch(
const std::bad_variant_access& )
1315 return std::nullopt;
1318 return s_dogBoneParams;
1334 static CHAMFER_PARAMS params{ default_setback, default_setback };
1337 params.m_chamfer_setback_a );
1340 return std::nullopt;
1342 params.m_chamfer_setback_a = dlg.
GetValue();
1345 params.m_chamfer_setback_b = params.m_chamfer_setback_a;
1356 std::vector<VECTOR2I> pts;
1359 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1361 BOARD_ITEM* item = aCollector[i];
1365 if( !item->IsType( { PCB_SHAPE_LOCATE_SEGMENT_T,
1366 PCB_SHAPE_LOCATE_POLY_T,
1367 PCB_SHAPE_LOCATE_RECT_T } ) )
1369 aCollector.
Remove( item );
1375 std::set<PCB_SHAPE*> lines_to_add;
1376 std::vector<PCB_SHAPE*> items_to_remove;
1380 std::vector<VECTOR2I> pts;
1387 items_to_remove.push_back( graphic );
1390 pts.emplace_back( start );
1391 pts.emplace_back(
VECTOR2I( end.x, start.y ) );
1392 pts.emplace_back( end );
1393 pts.emplace_back(
VECTOR2I( start.x, end.y ) );
1398 items_to_remove.push_back( graphic );
1400 for(
int jj = 0; jj < graphic->
GetPolyShape().VertexCount(); ++jj )
1404 for(
size_t jj = 1; jj < pts.size(); ++jj )
1412 lines_to_add.insert( line );
1415 if( pts.size() > 1 )
1420 line->
SetEnd( pts.front() );
1423 lines_to_add.insert( line );
1431 frame()->ShowInfoBarMsg(
_(
"Exactly two lines must be selected to extend them." ) );
1438 else if( segmentCount < 2 )
1440 frame()->ShowInfoBarMsg(
_(
"A shape with at least two lines must be selected." ) );
1454 selection.Add( item );
1458 for(
PCB_SHAPE* item : items_to_remove )
1460 selection.Remove( item );
1461 commit.Remove( item );
1469 std::vector<BOARD_ITEM*> items_to_select_on_success;
1472 std::vector<BOARD_ITEM*> items_to_deselect_on_success;
1477 auto item_modification_handler =
1483 commit.Modify( &aItem );
1484 items_to_select_on_success.push_back( &aItem );
1488 bool any_items_created = !lines_to_add.empty();
1489 auto item_creation_handler =
1490 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1492 any_items_created =
true;
1493 items_to_select_on_success.push_back( aItem.get() );
1494 commit.Add( aItem.release() );
1497 bool any_items_removed = !items_to_remove.empty();
1498 auto item_removal_handler =
1502 any_items_removed =
true;
1503 items_to_deselect_on_success.push_back( &aItem );
1504 commit.Remove( &aItem );
1509 item_creation_handler, item_modification_handler, item_removal_handler );
1512 std::unique_ptr<PAIRWISE_LINE_ROUTINE> pairwise_line_routine;
1517 std::optional<int> filletRadiusIU =
1520 if( filletRadiusIU.has_value() )
1522 pairwise_line_routine = std::make_unique<LINE_FILLET_ROUTINE>(
1523 frame()->
GetModel(), change_handler, *filletRadiusIU );
1528 std::optional<DOGBONE_CORNER_ROUTINE::PARAMETERS> dogboneParams =
1531 if( dogboneParams.has_value() )
1533 pairwise_line_routine = std::make_unique<DOGBONE_CORNER_ROUTINE>(
1534 frame()->
GetModel(), change_handler, *dogboneParams );
1539 std::optional<CHAMFER_PARAMS> chamfer_params =
GetChamferParams( *frame() );
1541 if( chamfer_params.has_value() )
1543 pairwise_line_routine = std::make_unique<LINE_CHAMFER_ROUTINE>( frame()->
GetModel(),
1550 pairwise_line_routine = std::make_unique<LINE_EXTENSION_ROUTINE>( frame()->
GetModel(),
1554 if( !pairwise_line_routine )
1565 if( ( a->GetFlags() & STRUCT_DELETED ) == 0
1566 && ( b->GetFlags() & STRUCT_DELETED ) == 0 )
1568 PCB_SHAPE* line_a = static_cast<PCB_SHAPE*>( a );
1569 PCB_SHAPE* line_b = static_cast<PCB_SHAPE*>( b );
1571 pairwise_line_routine->ProcessLinePair( *line_a, *line_b );
1576 for(
BOARD_ITEM* item : items_to_select_on_success )
1577 m_selectionTool->AddItemToSel( item,
true );
1580 for(
BOARD_ITEM* item : items_to_deselect_on_success )
1581 m_selectionTool->RemoveItemFromSel( item,
true );
1583 if( any_items_removed )
1586 if( any_items_created )
1592 commit.Push( pairwise_line_routine->GetCommitDescription() );
1594 if(
const std::optional<wxString> msg = pairwise_line_routine->GetStatusMessage() )
1595 frame()->ShowInfoBarMsg( *msg );
1606 std::vector<VECTOR2I> pts;
1609 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1611 BOARD_ITEM* item = aCollector[i];
1613 if( !item->IsType( { PCB_SHAPE_LOCATE_POLY_T, PCB_ZONE_T } ) )
1614 aCollector.
Remove( item );
1616 if(
ZONE* zone = dyn_cast<ZONE*>( item ) )
1618 if( zone->IsTeardropArea() )
1619 aCollector.
Remove( item );
1631 if( dlg.ShowModal() == wxID_CANCEL )
1634 s_toleranceValue = dlg.GetValue();
1636 if( s_toleranceValue <= 0 )
1641 std::vector<PCB_SHAPE*> shapeList;
1647 if(
PCB_SHAPE* shape = dyn_cast<PCB_SHAPE*>( item ) )
1654 if(
ZONE* zone = dyn_cast<ZONE*>( item ) )
1662 commit.Push(
_(
"Simplify Polygons" ) );
1676 std::vector<VECTOR2I> pts;
1679 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1681 BOARD_ITEM* item = aCollector[i];
1685 if( !item->IsType( { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_ARC_T,
1686 PCB_SHAPE_LOCATE_BEZIER_T } ) )
1688 aCollector.
Remove( item );
1700 if( dlg.ShowModal() == wxID_CANCEL )
1703 s_toleranceValue = dlg.GetValue();
1705 if( s_toleranceValue <= 0 )
1710 std::vector<PCB_SHAPE*> shapeList;
1711 std::vector<std::unique_ptr<PCB_SHAPE>> newShapes;
1717 shapeList.push_back( shape );
1724 std::vector<PCB_SHAPE*> items_to_select;
1726 for( std::unique_ptr<PCB_SHAPE>& ptr : newShapes )
1730 commit.Add( shape );
1731 items_to_select.push_back( shape );
1734 commit.Push(
_(
"Heal Shapes" ) );
1737 for(
PCB_SHAPE* item : items_to_select )
1738 m_selectionTool->AddItemToSel( item,
true );
1740 if( items_to_select.size() > 0 )
1756 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1758 BOARD_ITEM* item = aCollector[i];
1760 if( !item->IsType( {
1761 PCB_SHAPE_LOCATE_POLY_T,
1762 PCB_SHAPE_LOCATE_RECT_T,
1765 aCollector.
Remove( item );
1771 const EDA_ITEM*
const last_item = selection.GetLastAddedItem();
1774 std::vector<PCB_SHAPE*> items_to_process;
1778 items_to_process.push_back(
static_cast<PCB_SHAPE*
>( item ) );
1783 if( item == last_item )
1784 std::swap( items_to_process.back(), items_to_process.front() );
1790 auto item_modification_handler =
1796 std::vector<BOARD_ITEM*> items_to_select_on_success;
1798 auto item_creation_handler =
1799 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1801 items_to_select_on_success.push_back( aItem.get() );
1802 commit.
Add( aItem.release() );
1805 auto item_removal_handler =
1813 item_creation_handler, item_modification_handler, item_removal_handler );
1816 std::unique_ptr<POLYGON_BOOLEAN_ROUTINE> boolean_routine;
1819 boolean_routine = std::make_unique<POLYGON_MERGE_ROUTINE>( frame()->
GetModel(),
1824 boolean_routine = std::make_unique<POLYGON_SUBTRACT_ROUTINE>( frame()->
GetModel(),
1829 boolean_routine = std::make_unique<POLYGON_INTERSECT_ROUTINE>( frame()->
GetModel(),
1834 wxASSERT_MSG(
false,
"Could not find a polygon routine for this action" );
1839 for(
PCB_SHAPE* shape : items_to_process )
1840 boolean_routine->ProcessShape( *shape );
1842 boolean_routine->Finalize();
1845 for(
BOARD_ITEM* item : items_to_select_on_success )
1846 m_selectionTool->AddItemToSel( item,
true );
1851 commit.Push( boolean_routine->GetCommitDescription() );
1853 if(
const std::optional<wxString> msg = boolean_routine->GetStatusMessage() )
1854 frame()->ShowInfoBarMsg( *msg );
1876 std::vector<PCB_TABLECELL*> cells;
1926 for(
EDA_ITEM* eda_item : selCopy )
1928 if( !eda_item->IsBOARD_ITEM() )
1955 commit = &localCommit;
1970 if( selection.
Empty() )
1973 std::optional<VECTOR2I> oldRefPt;
1974 bool is_hover = selection.
IsHover();
1996 if( selection.
Empty() )
2013 if(
frame()->GetCanvas()->GetView()->GetGAL()->IsFlippedX() )
2014 rotateAngle = -rotateAngle;
2020 viewBBox.
Merge( item->ViewBBox() );
2029 typedef std::numeric_limits<int> coord_limits;
2034 bool outOfBounds = rotPos.
x < min || rotPos.
x > max || rotPos.
y < min || rotPos.
y > max
2035 || rotEnd.
x < min || rotEnd.
x > max || rotEnd.
y < min || rotEnd.
y > max;
2041 if( !item->IsNew() && !item->IsMoving() )
2044 if( item->IsBOARD_ITEM() )
2048 board_item->
Rotate( refPt, rotateAngle );
2053 if( !localCommit.
Empty() )
2054 localCommit.
Push(
_(
"Rotate" ) );
2086 MIRROR( tmpPt, aMirrorPoint, aFlipDirection );
2126 commit = &localCommit;
2137 if( selection.
Empty() )
2144 ? FLIP_DIRECTION::TOP_BOTTOM
2145 : FLIP_DIRECTION::LEFT_RIGHT;
2147 std::vector<EDA_ITEM*> items;
2153 static_cast<PCB_GROUP*
>( item )->RunOnDescendants(
2156 items.push_back( descendant );
2161 items.push_back( item );
2170 if( !item->IsNew() && !item->IsMoving() )
2174 switch( item->Type() )
2177 static_cast<PCB_SHAPE*
>( item )->
Mirror( mirrorPoint, flipDirection );
2181 static_cast<ZONE*
>( item )->
Mirror( mirrorPoint, flipDirection );
2186 static_cast<PCB_TEXT*
>( item )->
Mirror( mirrorPoint, flipDirection );
2198 mirrorPad( *
static_cast<PAD*
>( item ), mirrorPoint, flipDirection );
2204 static_cast<PCB_TRACK*
>( item )->
Mirror( mirrorPoint, flipDirection );
2217 if( !localCommit.
Empty() )
2218 localCommit.
Push(
_(
"Mirror" ) );
2244 commit = &localCommit;
2253 if( selection.
Empty() )
2271 if( !item->IsNew() && !item->IsMoving() )
2274 setJustify(
static_cast<PCB_TEXT*
>( item ) );
2278 if( !item->IsNew() && !item->IsMoving() )
2285 if( !localCommit.
Empty() )
2288 localCommit.
Push(
_(
"Left Justify" ) );
2290 localCommit.
Push(
_(
"Center Justify" ) );
2292 localCommit.
Push(
_(
"Right Justify" ) );
2319 commit = &localCommit;
2331 if( selection.
Empty() )
2334 std::optional<VECTOR2I> oldRefPt;
2349 if( selection.
GetSize() == 1 )
2353 if( !item || item->
GetShape() != SHAPE_T::RECTANGLE )
2361 if( !item->IsBOARD_ITEM() )
2367 commit->
Modify( boardItem );
2369 boardItem->
Flip( refPt, flipDirection );
2373 if( !localCommit.
Empty() )
2374 localCommit.
Push(
_(
"Change Side / Flip" ) );
2396 std::unordered_set<BOARD_ITEM*>& children )
2400 std::unordered_set<BOARD_ITEM*>& childItems =
static_cast<PCB_GROUP*
>( item )->GetItems();
2404 children.insert( childItem );
2414 auto itr = items.begin();
2416 while( itr != items.end() )
2426 std::unordered_set<BOARD_ITEM*> childItems;
2429 std::for_each( childItems.begin(), childItems.end(),
2430 [&](
auto eraseItem )
2432 items.erase( eraseItem );
2452 std::unordered_set<EDA_ITEM*> rootItems( aItems.
begin(), aItems.
end() );
2455 int itemsDeleted = 0;
2456 int fieldsHidden = 0;
2457 int fieldsAlreadyHidden = 0;
2461 if( !item->IsBOARD_ITEM() )
2470 switch( item->Type() )
2476 wxASSERT( parentFP );
2477 commit.
Modify( parentFP );
2486 fieldsAlreadyHidden++;
2496 commit.
Modify( parentFP );
2497 parentFP->
Delete( board_item );
2502 commit.
Remove( board_item );
2518 commit.
Remove( board_item );
2524 commit.
Modify( board_item );
2525 static_cast<PCB_TABLECELL*
>( board_item )->SetText( wxEmptyString );
2542 commit.
Remove( board_item );
2549 commit.
Modify( parentFP );
2551 parentFP->
Remove( board_item );
2561 if( !aIsCut && aItems.
GetSize() == 1 )
2564 ZONE* zone =
static_cast<ZONE*
>( board_item );
2566 int outlineIdx, holeIdx;
2589 commit.
Remove( board_item );
2594 if( rootItems.size() == 1 )
2611 commit.
Remove( board_item );
2618 wxASSERT_MSG( parentFP ==
nullptr, wxT(
"Try to delete an item living in a footprint" ) );
2619 commit.
Remove( board_item );
2628 if( enteredGroup && enteredGroup->
GetItems().empty() )
2633 commit.
Push(
_(
"Cut" ) );
2635 else if( itemsDeleted == 0 )
2637 if( fieldsHidden == 1 )
2638 commit.
Push(
_(
"Hide Field" ) );
2639 else if( fieldsHidden > 1 )
2640 commit.
Push(
_(
"Hide Fields" ) );
2641 else if( fieldsAlreadyHidden > 0 )
2642 editFrame->
ShowInfoBarError(
_(
"Use the Footprint Properties dialog to remove fields." ) );
2646 commit.
Push(
_(
"Delete" ) );
2657 std::vector<BOARD_ITEM*> lockedItems;
2741 if( selection.
Empty() )
2755 if( ret == wxID_OK )
2763 selCenter += translation;
2765 if( !
frame()->GetPcbNewSettings()->m_Display.m_DisplayInvertYAxis )
2766 rotation = -rotation;
2770 if( !item->IsBOARD_ITEM() )
2775 if( !boardItem->
IsNew() )
2776 commit.
Modify( boardItem );
2779 boardItem->
Move( translation );
2781 switch( rotationAnchor )
2787 boardItem->
Rotate( selCenter, angle );
2790 boardItem->
Rotate(
frame()->GetScreen()->m_LocalOrigin, angle );
2801 commit.
Push(
_(
"Move Exactly" ) );
2803 if( selection.IsHover() )
2836 if( selection.
Empty() )
2852 bool is_hover = selection.
IsHover();
2854 std::vector<BOARD_ITEM*> new_items;
2855 new_items.reserve( selection.
Size() );
2861 if( !item->IsBOARD_ITEM() )
2875 switch( orig_item->
Type() )
2901 new_items.push_back( dupe_item );
2902 commit.
Add( dupe_item );
2920 static_cast<PAD*
>( dupe_item )->SetNumber( padNumber );
2927 new_items.push_back( dupe_item );
2928 commit.
Add( dupe_item );
2937 dupe_item =
static_cast<PCB_GROUP*
>( orig_item )->DeepDuplicate();
2943 new_items.push_back( aItem );
2944 commit.
Add( aItem );
2948 new_items.push_back( dupe_item );
2949 commit.
Add( dupe_item );
2953 wxASSERT_MSG(
false, wxString::Format( wxT(
"Unhandled item type %d" ),
2954 orig_item->
Type() ) );
2964 EDA_ITEMS nItems( new_items.begin(), new_items.end() );
2968 if( !selection.
Empty() )
2970 editFrame->
DisplayToolMsg( wxString::Format(
_(
"Duplicated %d item(s)" ),
2971 (
int) new_items.size() ) );
2975 commit.
Push(
_(
"Duplicate" ) );
2990 const auto incrementableFilter =
2993 for(
int i = aCollector.GetCount() - 1; i >= 0; i-- )
2995 switch( aCollector[i]->Type() )
3001 aCollector.Remove( i );
3008 incrementableFilter,
true );
3010 if( selection.
Empty() )
3023 commit = &localCommit;
3025 const auto modifyItem = [&](
EDA_ITEM& aItem )
3030 commit->
Modify( &aItem );
3035 switch( item->Type() )
3045 if( !
pad.CanHaveNumber() )
3049 std::optional<wxString> newNumber =
3050 incrementer.Increment(
pad.GetNumber(), incParam.
Delta, incParam.
Index );
3055 pad.SetNumber( *newNumber );
3064 std::optional<wxString> newText =
3065 incrementer.Increment(
text.GetText(), incParam.
Delta, incParam.
Index );
3070 text.SetText( *newText );
3080 commit->
Push(
_(
"Increment" ) );
3089 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
3091 if( aCollector[i]->Type() !=
PCB_PAD_T )
3100 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
3111 if( aSelection.
Empty() )
3135 BOX2I nonFieldsBBox;
3139 if( !item->IsType( { PCB_TEXT_T, PCB_FIELD_T } ) )
3140 nonFieldsBBox.
Merge( item->GetBoundingBox() );
3155 const wxString& aCanceledMessage,
VECTOR2I& aReferencePoint )
3159 std::optional<VECTOR2I> pickedPoint;
3167 const auto setPickerLayerSet = [&]()
3172 layerFilter =
LSET( { editFrame.GetActiveLayer() } );
3180 setPickerLayerSet();
3183 [&](
const VECTOR2D& aPoint ) ->
bool
3185 pickedPoint = aPoint;
3187 if( !aSuccessMessage.empty() )
3189 m_statusPopup->SetText( aSuccessMessage );
3190 m_statusPopup->Expire( 800 );
3194 m_statusPopup->Hide();
3209 if( !aCanceledMessage.empty() )
3211 m_statusPopup->SetText( aCanceledMessage );
3212 m_statusPopup->Expire( 800 );
3216 m_statusPopup->Hide();
3221 [&](
const int& aFinalState )
3240 setPickerLayerSet();
3243 evt->SetPassEvent();
3254 aReferencePoint = *pickedPoint;
3256 return pickedPoint.has_value();
3264 getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
3266 "pcbnew.InteractiveEdit.selectReferencePoint",
3267 TOOL_ACTION_SCOPE::AS_GLOBAL );
3269 frame()->PushTool( selectReferencePoint );
3275 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
3277 BOARD_ITEM* item = aCollector[i];
3281 if( ( item->Type() == PCB_FIELD_T || item->Type() == PCB_TEXT_T )
3282 && aCollector.HasItem( item->GetParentFootprint() ) )
3284 aCollector.Remove( item );
3289 aCollector.Remove( item );
3295 aEvent.IsAction( &
ACTIONS::cut ) && !m_isFootprintEditor );
3297 if( !selection.Empty() )
3299 std::vector<BOARD_ITEM*> items;
3303 if( item->IsBOARD_ITEM() )
3304 items.push_back(
static_cast<BOARD_ITEM*
>( item ) );
3311 if( !pickReferencePoint(
_(
"Select reference point for the copy..." ),
3312 _(
"Selection copied" ),
3313 _(
"Copy canceled" ),
3316 frame()->PopTool( selectReferencePoint );
3322 refPoint =
grid.BestDragOrigin( getViewControls()->GetCursorPosition(), items );
3325 selection.SetReferencePoint( refPoint );
3327 io.SetBoard( board() );
3328 io.SaveSelection( selection, m_isFootprintEditor );
3329 frame()->SetStatusText(
_(
"Selection copied" ) );
3332 frame()->PopTool( selectReferencePoint );
3334 if( selection.IsHover() )
3335 m_selectionTool->ClearSelection();
3354 const auto getItemText = [&](
const BOARD_ITEM& aItem ) -> wxString
3356 switch( aItem.Type() )
3368 return text.GetShownText(
true );
3382 for(
int row = 0; row < table.
GetRowCount(); ++row )
3384 for(
int col = 0; col < table.
GetColCount(); ++col )
3406 return wxEmptyString;
3409 wxArrayString itemTexts;
3413 if( item->IsBOARD_ITEM() )
3416 wxString itemText = getItemText( *boardItem );
3418 itemText.Trim(
false ).Trim(
true );
3420 if( !itemText.IsEmpty() )
3422 itemTexts.Add( std::move( itemText ) );
3428 if( !itemTexts.empty() )
3430 SaveClipboard( wxJoin( itemTexts,
'\n',
'\0' ).ToStdString() );
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION decrementPrimary
static TOOL_ACTION pickerSubTool
static TOOL_ACTION unselectAll
static TOOL_ACTION decrementSecondary
static TOOL_ACTION pasteSpecial
static TOOL_ACTION rightJustify
static TOOL_ACTION pageSettings
static TOOL_ACTION incrementSecondary
static TOOL_ACTION duplicate
static TOOL_ACTION incrementPrimary
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION increment
static TOOL_ACTION leftJustify
static TOOL_ACTION copyAsText
static TOOL_ACTION refreshPreview
static TOOL_ACTION selectAll
static TOOL_ACTION centerJustify
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual 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) override
Add a change of the item aItem of type aChangeType to the change list.
virtual void Revert() override
Revert the commit by restoring the modified items state.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
int GetCurrentViaSize() const
const VECTOR2I & GetAuxOrigin()
int GetCurrentTrackWidth() const
int GetCurrentViaDrill() const
virtual void Delete(BOARD_ITEM *aItem)
Removes an item from the container and deletes it.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetLocked(bool aLocked)
PCB_GROUP * GetParentGroup() const
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Rotate this object.
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool IsLocked() const
BOARD_ITEM_CONTAINER * GetParent() const
virtual void RunOnDescendants(const std::function< void(BOARD_ITEM *)> &aFunction, int aDepth=0) const
Invoke a function on all descendants.
virtual void Normalize()
Perform any normalization required after a user rotate and/or flip.
virtual void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Flip this object, i.e.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
const FOOTPRINTS & Footprints() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
constexpr const Vec & GetPosition() const
constexpr const Vec GetEnd() 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 bool IsValid() const
Represent basic circle geometry with utility geometry functions.
VECTOR2I Center
Public to make access simpler.
int Radius
Public to make access simpler.
CIRCLE & ConstructFromTanTanPt(const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
Construct this circle such that it is tangent to the given segments and passes through the given poin...
VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute the point on the circumference of the circle that is the closest to aP.
int GetCount() const
Return the number of objects in the list.
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
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)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
@ TABLECELL_PROPS_EDIT_TABLE
enum TABLECELL_PROPS_RETVALUE GetReturnValue()
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const VECTOR2I &aPosition)
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void DisplayToolMsg(const wxString &msg) override
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetStatusPopup(wxWindow *aPopup)
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetWidth(int aWidth)
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual bool IsVisible() const
virtual void SetVisible(bool aVisible)
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
static const TOOL_EVENT UnselectedEvent
Used when the right click button is pressed, or when the select tool is in effect.
static const std::vector< KICAD_T > DraggableItems
A scan list for items that can be dragged.
A handler that is based on a set of callbacks provided by the user of the ITEM_MODIFICATION_ROUTINE.
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 VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool IsBOARD_ITEM() const
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...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
A collection of nets and the parameters used to route or test these nets.
int GetuViaDiameter() const
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
const VECTOR2I & GetDelta(PCB_LAYER_ID aLayer) const
VECTOR2I GetPosition() const override
void SetDelta(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
void FlipPrimitives(FLIP_DIRECTION aFlipDirection)
Flip (mirror) the primitives left to right or top to bottom, around the anchor position in custom pad...
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
void SetOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
void SetPosition(const VECTOR2I &aPos) override
const VECTOR2I & GetOffset(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
static TOOL_ACTION drag45Degree
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
static TOOL_ACTION changeTrackWidth
Update selected tracks & vias to the current track & via dimensions.
static TOOL_ACTION unrouteSelected
Removes all tracks from the selected items to the first pad.
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION updateFootprint
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
static TOOL_ACTION pointEditorMoveMidpoint
static TOOL_ACTION getAndPlace
Find an item and start moving.
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION editFpInFpEditor
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION moveWithReference
move with a reference point
static TOOL_ACTION swap
Swapping of selected items.
static TOOL_ACTION moveExact
Activation of the exact move tool.
static TOOL_ACTION intersectPolygons
Intersection of multiple polygons.
static TOOL_ACTION pointEditorMoveCorner
static TOOL_ACTION genRemove
static TOOL_ACTION selectConnection
Select tracks between junctions or expands an existing selection to pads or the entire connection.
static TOOL_ACTION assignNetClass
static TOOL_ACTION packAndMoveFootprints
Pack and start moving selected footprints.
static TOOL_ACTION copyWithReference
copy command with manual reference point selection
static TOOL_ACTION healShapes
Connect selected shapes, possibly extending or cutting them, or adding extra geometry.
static TOOL_ACTION dragFreeAngle
static TOOL_ACTION positionRelativeInteractively
static TOOL_ACTION inspectClearance
static TOOL_ACTION updateLocalRatsnest
static TOOL_ACTION updateFootprints
static TOOL_ACTION deleteFull
static TOOL_ACTION moveIndividually
move items one-by-one
static TOOL_ACTION changeFootprints
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
static TOOL_ACTION chamferLines
Chamfer (i.e. adds a straight line) all selected straight lines by a user defined setback.
static TOOL_ACTION dogboneCorners
Add "dogbone" corners to selected lines to allow routing with a cutter radius.
static TOOL_ACTION filletTracks
Fillet (i.e. adds an arc tangent to) all selected straight tracks by a user defined radius.
static TOOL_ACTION simplifyPolygons
Simplify polygon outlines.
static TOOL_ACTION footprintProperties
static TOOL_ACTION filletLines
Fillet (i.e. adds an arc tangent to) all selected straight lines by a user defined radius.
static TOOL_ACTION changeFootprint
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
static TOOL_ACTION positionRelative
static TOOL_ACTION move
move or drag an item
static TOOL_ACTION mirrorV
static TOOL_ACTION mergePolygons
Merge multiple polygons into a single polygon.
static TOOL_ACTION subtractPolygons
Subtract polygons from other polygons.
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static TOOL_ACTION flip
Flipping of selected objects.
static TOOL_ACTION extendLines
Extend selected lines to meet at a point.
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
virtual double GetLength() const override
Return the length of the arc track.
void SetMid(const VECTOR2I &aMid)
EDA_ANGLE GetAngle() const
const VECTOR2I & GetMid() const
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Common, abstract interface for edit frames.
virtual void OnEditItemRequest(BOARD_ITEM *aItem)
Install the corresponding dialog editor for the given item.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
The main frame for Pcbnew.
static const TOOL_EVENT & SnappingModeChangedByKeyEvent()
Hotkey feedback.
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
Tool that displays edit points allowing to modify items by dragging the points.
BOX2I GetBoundingBox() const override
int GetWidth() const override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
PCB_TABLECELL * GetCell(int aRow, int aCol) const
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
void SetHasSolderMask(bool aVal)
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
void SetEnd(const VECTOR2I &aEnd)
bool HasSolderMask() const
void SetStart(const VECTOR2I &aStart)
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
std::optional< int > GetLocalSolderMaskMargin() const
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Return STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if point if near (dist = m...
virtual void SetWidth(int aWidth)
virtual int GetWidth() const
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
bool ApproxCollinear(const SEG &aSeg, int aDistanceThreshold=1) const
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
SEG PerpendicularSeg(const VECTOR2I &aP) const
Compute a segment perpendicular to this one, passing through point aP.
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
EDA_ANGLE Angle(const SEG &aOther) const
Determine the smallest angle between two segments.
static SELECTION_CONDITION HasTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if among the selected items there is at least one of a given types.
static SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
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.
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
VECTOR2I GetReferencePoint() const
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
virtual unsigned int GetSize() const override
Return the number of stored items.
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
int Size() const
Returns the number of selected parts.
std::deque< EDA_ITEM * > & Items()
void ClearReferencePoint()
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
size_t CountType(KICAD_T aType) const
bool Contains(EDA_ITEM *aItem) const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
void SimplifyOutlines(int aMaxError=0)
Simplifies the lines in the polyset.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
Heuristically increment a string's n'th part from the right.
void SetSkipIOSQXZ(bool aSkip)
If a alphabetic part is found, skip the letters I, O, S, Q, X, Z.
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
A dialog like WX_UNIT_ENTRY_DIALOG, but with multiple entries.
std::vector< RESULT > GetValues() const
Returns the values in the order they were added.
An extension of WX_TEXT_ENTRY_DIALOG that uses UNIT_BINDER to request a dimension (e....
int GetValue()
Return the value in internal units.
Handle a list of polygons defining a copper zone.
bool UnFill()
Removes the zone filling.
bool HitTestCutout(const VECTOR2I &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Test if the given point is contained within a cutout of the zone.
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
@ ROTATE_AROUND_USER_ORIGIN
@ ROTATE_AROUND_SEL_CENTER
@ ROTATE_AROUND_AUX_ORIGIN
@ ROTATE_AROUND_ITEM_ANCHOR
static constexpr EDA_ANGLE ANGLE_180
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
#define IS_NEW
New item, just created.
#define STRUCT_DELETED
flag indication structures to be erased
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
void ConnectBoardShapes(std::vector< PCB_SHAPE * > &aShapeList, std::vector< std::unique_ptr< PCB_SHAPE > > &aNewShapes, int aChainingEpsilon)
Connects shapes to each other, making continious contours (adjacent shapes will have a common vertex)...
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_SCHEMATIC_DRAWINGSHEET
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
KICOMMON_API wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Create an S3DMODEL representation of aNode (raw data, no transforms).
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
Class to handle a set of BOARD_ITEMs.
std::optional< VECTOR2I > OPT_VECTOR2I
Parameters that define a simple chamfer operation.
constexpr int mmToIU(double mm) const
const VECTOR2I CalcArcMid(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true)
Return the middle point of an arc, half-way between aStart and aEnd.
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_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_SHAPE_LOCATE_SEGMENT_T
@ PCB_SHAPE_LOCATE_RECT_T
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_SHAPE_LOCATE_BEZIER_T
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_SHAPE_LOCATE_POLY_T
@ 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_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I