79using namespace std::placeholders;
81#include <wx/hyperlink.h>
108 ZONE* zone =
static_cast<ZONE*
>( aItem );
121 if( aSelection.
GetSize() != 1 )
177 else if( item->IsType( EDIT_TOOL::MirrorableItems ) )
207 std::shared_ptr<CONDITIONAL_MENU> menu = std::make_shared<CONDITIONAL_MENU>( aEditTool );
210 menu->SetUntranslatedTitle(
_HKI(
"Mirror / Rotate" ) );
212 bool isBoardEditor = aEditTool && aEditTool->
IsBoardEditor();
215 [isBoardEditor](
const SELECTION& aSelection )
235 std::shared_ptr<CONDITIONAL_MENU> menu = std::make_shared<CONDITIONAL_MENU>( aTool );
238 menu->SetUntranslatedTitle(
_HKI(
"Routing" ) );
240 auto notMovingCondition =
243 return aSelection.Empty() || !aSelection.Front()->IsMoving();
248 && notMovingCondition;
265 std::shared_ptr<CONDITIONAL_MENU> menu = std::make_shared<CONDITIONAL_MENU>( aTool );
268 menu->SetUntranslatedTitle(
_HKI(
"Position" ) );
270 auto notMovingCondition =
273 return aSelection.Empty() || !aSelection.Front()->IsMoving();
287 std::shared_ptr<CONDITIONAL_MENU> menu = std::make_shared<CONDITIONAL_MENU>( aTool );
289 menu->SetUntranslatedTitle(
_HKI(
"Shape Modification" ) );
304 auto hasCornerCondition =
312 auto hasMidpointCondition =
320 auto canAddCornerCondition =
323 const EDA_ITEM* item = aSelection.Front();
328 auto canChamferCornerCondition =
331 const EDA_ITEM* item = aSelection.Front();
336 auto canRemoveCornerCondition =
406 for(
const EDA_ITEM* it : aSelection )
417 const std::vector<FOOTPRINT::FP_UNIT_INFO>& units = fp->
GetUnitInfo();
419 if( units.size() < 2 )
422 const wxString& padNum =
pad->GetNumber();
423 bool inAnyUnit =
false;
427 for(
const wxString& pnum : u.m_pins )
445 else if( single != fp )
456 std::unordered_set<wxString> padNums;
458 for(
const EDA_ITEM* it : aSelection )
465 if(
pad->GetParentFootprint() != aFootprint )
468 padNums.insert(
pad->GetNumber() );
477 const std::unordered_set<wxString>& aSelPadNums )
479 std::vector<int> indices;
481 const std::vector<FOOTPRINT::FP_UNIT_INFO>& units = aFootprint->
GetUnitInfo();
483 for(
size_t i = 0; i < units.size(); ++i )
487 for(
const wxString& pn : units[i].m_pins )
489 if( aSelPadNums.count( pn ) )
497 indices.push_back(
static_cast<int>( i ) );
507 if( aUnitIndices.empty() )
510 const std::vector<FOOTPRINT::FP_UNIT_INFO>& units = aFootprint->
GetUnitInfo();
511 const size_t cnt = units[
static_cast<size_t>( aUnitIndices.front() )].m_pins.size();
513 for(
int idx : aUnitIndices )
515 if( units[
static_cast<size_t>( idx )].m_pins.size() != cnt )
526 std::vector<int> targets;
528 const std::vector<FOOTPRINT::FP_UNIT_INFO>& units = aFootprint->
GetUnitInfo();
529 const size_t pinCount = units[
static_cast<size_t>( aSourceIdx )].m_pins.size();
531 for(
size_t i = 0; i < units.size(); ++i )
533 if(
static_cast<int>( i ) == aSourceIdx )
536 if( units[i].m_pins.size() != pinCount )
539 targets.push_back(
static_cast<int>( i ) );
569 if( unitsHit.size() != 1 )
572 const int sourceIdx = unitsHit.front();
575 for(
int idx : targets )
578 label.Printf(
_(
"Swap with %s" ), fp->
GetUnitInfo()[
static_cast<size_t>( idx )].m_unitName );
586 int id = aEvent.GetId();
598 const std::vector<FOOTPRINT::FP_UNIT_INFO>& units = fp->
GetUnitInfo();
601 if( targetIdx < 0 || targetIdx >=
static_cast<int>( units.size() ) )
617 std::shared_ptr<GATE_SWAP_MENU> menu = std::make_shared<GATE_SWAP_MENU>();
618 menu->SetTool( aTool );
632 m_selectionTool->GetToolMenu().RegisterSubMenu( positioningToolsSubMenu );
638 m_selectionTool->GetToolMenu().RegisterSubMenu( shapeModificationSubMenu );
643 std::shared_ptr<CONDITIONAL_MENU> fpAttributesMenu = std::make_shared<CONDITIONAL_MENU>(
this );
644 fpAttributesMenu->SetUntranslatedTitle(
_HKI(
"Attributes" ) );
650 auto positioningToolsCondition =
654 subMenu->Evaluate( aSel );
655 return subMenu->GetMenuItemCount() > 0;
658 auto shapeModificationCondition =
662 subMenu->Evaluate( aSel );
663 return subMenu->GetMenuItemCount() > 0;
667 auto gateSwapSingleUnitOnOneFootprint =
679 if( unitsHit.size() != 1 )
682 const int sourceIdx = unitsHit.front();
684 return !targets.empty();
688 auto gateSwapMultipleUnitsOnOneFootprint =
700 if( unitsHit.size() < 2 )
706 auto propertiesCondition =
709 if( aSel.GetSize() == 0 )
723 if( aSel.GetSize() == 1 )
735 auto inFootprintEditor =
760 auto multipleFootprintsCondition =
763 bool foundFirst =
false;
779 auto excludeFromBOMCond =
782 wxString variantName;
783 int checked = 0, unchecked = 0;
786 variantName =
board->GetCurrentVariant();
792 if(
static_cast<const FOOTPRINT*
>( item )->GetExcludedFromBOMForVariant( variantName ) )
799 return checked > 0 && unchecked == 0;
802 auto excludeFromPosFilesCond =
805 wxString variantName;
806 int checked = 0, unchecked = 0;
809 variantName =
board->GetCurrentVariant();
815 if(
static_cast<const FOOTPRINT*
>( item )->GetExcludedFromPosFilesForVariant( variantName ) )
822 return checked > 0 && unchecked == 0;
825 auto excludeFromSimCond =
828 wxString variantName;
829 int checked = 0, unchecked = 0;
832 variantName =
board->GetCurrentVariant();
838 if(
static_cast<const FOOTPRINT*
>( item )->GetExcludedFromSimForVariant( variantName ) )
845 return checked > 0 && unchecked == 0;
848 auto noActiveToolCondition =
851 return frame()->ToolStackIsEmpty();
854 auto notMovingCondition =
857 return aSelection.Empty() || !aSelection.Front()->IsMoving();
860 auto noItemsCondition =
861 [
this](
const SELECTION& aSelections ) ->
bool
863 return frame()->GetBoard() && !
frame()->GetBoard()->IsEmpty();
874 && notMovingCondition && !inFootprintEditor;
914 menu.AddMenu( gateSwapSubMenu.get(), gateSwapSingleUnitOnOneFootprint );
929 && !inFootprintEditor );
939 menu.AddMenu( fpAttributesMenu.get(), singleFootprintCondition || multipleFootprintsCondition );
942 menu.AddSeparator( 100 );
943 menu.AddMenu( routingSubMenu.get(), isRoutable, 100 );
944 menu.AddMenu( mirrorRotateSubMenu.get(), canMirror, 100 );
945 menu.AddMenu( shapeModificationSubMenu.get(), shapeModificationCondition, 100 );
946 menu.AddMenu( positioningToolsSubMenu.get(), positioningToolsCondition, 100 );
948 menu.AddSeparator( 150 );
961 menu.AddSeparator( 2000 );
981 wxString footprintName;
982 wxArrayString fplist;
987 fplist.Add( fp->GetReference() + wxT(
" ( " ) + fp->GetValue() + wxT(
" )" ) );
997 footprintName.Trim(
true );
998 footprintName.Trim(
false );
1000 if( !footprintName.IsEmpty() )
1004 if( fp->GetReference().CmpNoCase( footprintName ) == 0 )
1061 frame()->ShowInfoBarMsg(
_(
"This selection cannot be dragged in this mode." ) );
1105 std::vector<PCB_TRACK*> tracks;
1106 std::vector<PCB_TRACK*> vias;
1107 std::vector<FOOTPRINT*> footprints;
1110 const auto gatherItemsByType =
1118 vias.push_back( track );
1120 tracks.push_back( track );
1130 gatherItemsByType();
1137 const auto draggable = [](
KICAD_T aType )
1143 bool anyDraggable =
false;
1145 for(
int ii = 0; ii < aCollector.
GetCount(); ++ii )
1146 anyDraggable |= draggable( aCollector[ii]->Type() );
1152 for(
int ii = aCollector.
GetCount() - 1; ii >= 0; --ii )
1154 if( !draggable( aCollector[ii]->Type() ) )
1159 else if( tracks.size() || vias.size() )
1173 gatherItemsByType();
1187 if( tracks.size() == 2 && vias.size() == 0 )
1189 if( connected( tracks[0], tracks[1]->GetStart() )
1190 || connected( tracks[0], tracks[1]->GetEnd() ) )
1192 aCollector.
Remove( tracks[1] );
1195 else if( tracks.size() == 2 && vias.size() == 1 )
1197 if( connected( tracks[0], vias[0]->GetPosition() )
1198 && connected( tracks[1], vias[0]->GetPosition() ) )
1200 aCollector.
Remove( tracks[0] );
1201 aCollector.
Remove( tracks[1] );
1227 wxString variantName;
1230 variantName =
board->GetCurrentVariant();
1232 bool new_state =
false;
1257 if( !variantName.IsEmpty() )
1285 if( !commit.
Empty() )
1286 commit.
Push(
_(
"Toggle Attribute" ) );
1301 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1306 aCollector.
Remove( item );
1332 via->SetDrill(
board()->GetDesignSettings().GetCurrentViaDrill() );
1341 wxCHECK( track, 0 );
1345 int new_width =
board()->GetDesignSettings().GetCurrentTrackWidth();
1350 commit.
Push(
_(
"Edit Track Width/Via Size" ) );
1375 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1380 aCollector.
Remove( item );
1397 if( newLayer == origLayer )
1408 wxCHECK( track, 0 );
1416 commit.
Push(
_(
"Edit Track Layer" ) );
1433 static int filletRadius = 0;
1439 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1444 aCollector.
Remove( item );
1455 frame()->ShowInfoBarMsg(
_(
"At least two straight track segments must be selected." ) );
1471 bool t1Start =
true;
1472 bool t2Start =
true;
1475 std::vector<FILLET_OP> filletOperations;
1476 bool operationPerformedOnAtLeastOne =
false;
1477 bool didOneAttemptFail =
false;
1478 std::set<PCB_TRACK*> processedTracks;
1480 auto processFilletOp =
1481 [&](
PCB_TRACK* aTrack,
bool aStartPoint )
1483 std::shared_ptr<CONNECTIVITY_DATA> c =
board()->GetConnectivity();
1485 std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
1489 if( itemsOnAnchor.size() > 0 &&
selection.Contains( itemsOnAnchor.at( 0 ) )
1495 if( processedTracks.find( trackOther ) == processedTracks.end() )
1497 if( itemsOnAnchor.size() == 1 )
1500 filletOp.t1 = aTrack;
1501 filletOp.t2 = trackOther;
1502 filletOp.t1Start = aStartPoint;
1503 filletOp.t2Start = aTrack->
IsPointOnEnds( filletOp.t2->GetStart() );
1504 filletOperations.push_back( filletOp );
1510 didOneAttemptFail =
true;
1524 processFilletOp( track,
true );
1525 processFilletOp( track,
false );
1527 processedTracks.insert( track );
1533 std::vector<BOARD_ITEM*> itemsToAddToSelection;
1535 for( FILLET_OP filletOp : filletOperations )
1543 if( trackOnStart && trackOnEnd )
1546 if( ( trackOnStart || trackOnEnd ) && track1->
GetLayer() == track2->
GetLayer() )
1554 SHAPE_ARC sArc( t1Seg, t2Seg, filletRadius );
1557 auto setIfPointOnSeg =
1560 VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
1565 aPointToSet.
x = aVecToTest.x;
1566 aPointToSet.
y = aVecToTest.y;
1574 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP0() )
1575 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP0() ) )
1577 didOneAttemptFail =
true;
1581 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP1() )
1582 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP1() ) )
1584 didOneAttemptFail =
true;
1596 itemsToAddToSelection.push_back( tArc );
1601 if( filletOp.t1Start )
1604 track1->
SetEnd( t1newPoint );
1606 if( filletOp.t2Start )
1609 track2->
SetEnd( t2newPoint );
1611 operationPerformedOnAtLeastOne =
true;
1615 commit.
Push(
_(
"Fillet Tracks" ) );
1618 for(
BOARD_ITEM* item : itemsToAddToSelection )
1621 if( !operationPerformedOnAtLeastOne )
1622 frame()->ShowInfoBarMsg(
_(
"Unable to fillet the selected track segments." ) );
1623 else if( didOneAttemptFail )
1624 frame()->ShowInfoBarMsg(
_(
"Some of the track segments could not be filleted." ) );
1644 return std::nullopt;
1648 return aPersitentRadius;
1660 std::vector<WX_MULTI_ENTRY_DIALOG::ENTRY> entries{
1667 _(
"Add slots in acute corners" ),
1669 _(
"Add slots in acute corners to allow access to a cutter of the given radius" ),
1676 return std::nullopt;
1678 std::vector<WX_MULTI_ENTRY_DIALOG::RESULT> results = dlg.
GetValues();
1679 wxCHECK( results.size() == 2, std::nullopt );
1683 s_dogBoneParams.DogboneRadiusIU = std::get<long long int>( results[0] );
1684 s_dogBoneParams.AddSlots = std::get<bool>( results[1] );
1686 catch(
const std::bad_variant_access& )
1689 return std::nullopt;
1692 return s_dogBoneParams;
1704 const int default_setback =
pcbIUScale.mmToIU( 1 );
1706 static CHAMFER_PARAMS params{ default_setback, default_setback };
1708 WX_UNIT_ENTRY_DIALOG dlg( &aFrame,
_(
"Chamfer Lines" ),
_(
"Chamfer setback:" ), params.m_chamfer_setback_a );
1711 return std::nullopt;
1713 params.m_chamfer_setback_a = dlg.
GetValue();
1716 params.m_chamfer_setback_b = params.m_chamfer_setback_a;
1727 std::vector<VECTOR2I> pts;
1730 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1737 { PCB_SHAPE_LOCATE_SEGMENT_T, PCB_SHAPE_LOCATE_POLY_T, PCB_SHAPE_LOCATE_RECT_T } ) )
1739 aCollector.
Remove( item );
1748 std::set<PCB_SHAPE*> lines_to_add;
1749 std::vector<PCB_SHAPE*> items_to_remove;
1753 std::vector<VECTOR2I> pts;
1760 items_to_remove.push_back( graphic );
1763 pts.emplace_back( start );
1765 pts.emplace_back(
end );
1771 items_to_remove.push_back( graphic );
1773 for(
int jj = 0; jj < graphic->
GetPolyShape().VertexCount(); ++jj )
1777 for(
size_t jj = 1; jj < pts.size(); ++jj )
1785 lines_to_add.insert( line );
1788 if( pts.size() > 1 )
1793 line->
SetEnd( pts.front() );
1796 lines_to_add.insert( line );
1804 frame()->ShowInfoBarMsg(
_(
"Exactly two lines must be selected to extend them." ) );
1811 else if( segmentCount < 2 )
1813 frame()->ShowInfoBarMsg(
_(
"A shape with at least two lines must be selected." ) );
1831 for(
PCB_SHAPE* item : items_to_remove )
1842 std::vector<BOARD_ITEM*> items_to_select_on_success;
1845 std::vector<BOARD_ITEM*> items_to_deselect_on_success;
1850 auto item_modification_handler =
1857 items_to_select_on_success.push_back( &aItem );
1861 bool any_items_created = !lines_to_add.empty();
1862 auto item_creation_handler =
1863 [&]( std::unique_ptr<BOARD_ITEM> aItem )
1865 any_items_created =
true;
1866 items_to_select_on_success.push_back( aItem.get() );
1867 commit.
Add( aItem.release() );
1870 bool any_items_removed = !items_to_remove.empty();
1871 auto item_removal_handler =
1875 any_items_removed =
true;
1876 items_to_deselect_on_success.push_back( &aItem );
1882 item_removal_handler );
1885 std::unique_ptr<PAIRWISE_LINE_ROUTINE> pairwise_line_routine;
1889 static int s_filletRadius =
pcbIUScale.mmToIU( 1 );
1890 std::optional<int> filletRadiusIU =
GetRadiusParams( *
frame(),
_(
"Fillet Lines" ), s_filletRadius );
1892 if( filletRadiusIU.has_value() )
1894 pairwise_line_routine = std::make_unique<LINE_FILLET_ROUTINE>(
frame()->GetModel(), change_handler,
1902 if( dogboneParams.has_value() )
1904 pairwise_line_routine = std::make_unique<DOGBONE_CORNER_ROUTINE>(
frame()->GetModel(), change_handler,
1912 if( chamfer_params.has_value() )
1914 pairwise_line_routine = std::make_unique<LINE_CHAMFER_ROUTINE>(
frame()->GetModel(), change_handler,
1920 pairwise_line_routine = std::make_unique<LINE_EXTENSION_ROUTINE>(
frame()->GetModel(), change_handler );
1923 if( !pairwise_line_routine )
1934 if( ( a->GetFlags() & STRUCT_DELETED ) == 0 && ( b->GetFlags() & STRUCT_DELETED ) == 0 )
1936 PCB_SHAPE* line_a = static_cast<PCB_SHAPE*>( a );
1937 PCB_SHAPE* line_b = static_cast<PCB_SHAPE*>( b );
1939 pairwise_line_routine->ProcessLinePair( *line_a, *line_b );
1944 for(
BOARD_ITEM* item : items_to_select_on_success )
1945 m_selectionTool->AddItemToSel( item,
true );
1948 for(
BOARD_ITEM* item : items_to_deselect_on_success )
1949 m_selectionTool->RemoveItemFromSel( item,
true );
1951 if( any_items_removed )
1954 if( any_items_created )
1960 commit.Push( pairwise_line_routine->GetCommitDescription() );
1962 if(
const std::optional<wxString> msg = pairwise_line_routine->GetStatusMessage( segmentCount ) )
1963 frame()->ShowInfoBarMsg( *msg );
1974 std::vector<VECTOR2I> pts;
1977 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1981 if( !item->
IsType( { PCB_SHAPE_LOCATE_POLY_T, PCB_ZONE_T } ) )
1982 aCollector.
Remove( item );
1986 if( zone->IsTeardropArea() )
1987 aCollector.
Remove( item );
1997 static int s_toleranceValue =
pcbIUScale.mmToIU( 3 );
2006 if( s_toleranceValue <= 0 )
2011 std::vector<PCB_SHAPE*> shapeList;
2015 commit.Modify( item );
2029 zone->HatchBorder();
2033 commit.
Push(
_(
"Simplify Polygons" ) );
2047 std::vector<VECTOR2I> pts;
2050 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
2056 if( !item->
IsType( { PCB_SHAPE_LOCATE_SEGMENT_T,
2057 PCB_SHAPE_LOCATE_ARC_T,
2058 PCB_SHAPE_LOCATE_BEZIER_T } ) )
2060 aCollector.
Remove( item );
2070 static int s_toleranceValue =
pcbIUScale.mmToIU( 3 );
2079 if( s_toleranceValue <= 0 )
2084 std::vector<PCB_SHAPE*> shapeList;
2090 shapeList.push_back( shape );
2091 commit.Modify( shape );
2097 commit.Push(
_(
"Heal Shapes" ) );
2112 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
2116 static const std::vector<KICAD_T> polygonBooleanTypes = {
2122 if( !item->
IsType( polygonBooleanTypes ) )
2123 aCollector.
Remove( item );
2134 std::vector<PCB_SHAPE*> items_to_process;
2138 items_to_process.push_back(
static_cast<PCB_SHAPE*
>( item ) );
2143 if( item == last_item )
2144 std::swap( items_to_process.back(), items_to_process.front() );
2150 auto item_modification_handler =
2153 commit.Modify( &aItem );
2156 std::vector<BOARD_ITEM*> items_to_select_on_success;
2158 auto item_creation_handler =
2159 [&]( std::unique_ptr<BOARD_ITEM> aItem )
2161 items_to_select_on_success.push_back( aItem.get() );
2162 commit.Add( aItem.release() );
2165 auto item_removal_handler =
2168 commit.Remove( &aItem );
2173 item_removal_handler );
2176 std::unique_ptr<POLYGON_BOOLEAN_ROUTINE> boolean_routine;
2178 const auto create_routine =
2179 [&]() -> std::unique_ptr<POLYGON_BOOLEAN_ROUTINE>
2186 wxCHECK(
model,
nullptr );
2190 return std::make_unique<POLYGON_MERGE_ROUTINE>(
model, change_handler );
2194 return std::make_unique<POLYGON_SUBTRACT_ROUTINE>(
model, change_handler );
2198 return std::make_unique<POLYGON_INTERSECT_ROUTINE>(
model, change_handler );
2203 const auto run_routine =
2207 for(
PCB_SHAPE* shape : items_to_process )
2208 boolean_routine->ProcessShape( *shape );
2210 boolean_routine->Finalize();
2213 boolean_routine = create_routine();
2215 wxCHECK_MSG( boolean_routine, 0,
"Could not find a polygon routine for this action" );
2222 if( !boolean_routine->IsCommutative() && items_to_select_on_success.empty() )
2226 items_to_select_on_success.clear();
2228 std::map<const PCB_SHAPE*, VECTOR2I::extended_type> items_area;
2230 for(
PCB_SHAPE* shape : items_to_process )
2233 items_area[shape] = area;
2242 std::sort( items_to_process.begin(), items_to_process.end(),
2245 return items_area[a] > items_area[b];
2249 boolean_routine = create_routine();
2254 for(
BOARD_ITEM* item : items_to_select_on_success )
2260 commit.Push( boolean_routine->GetCommitDescription() );
2262 if(
const std::optional<wxString> msg = boolean_routine->GetStatusMessage() )
2263 frame()->ShowInfoBarMsg( *msg );
2292 auto containsReadOnlyGenChild =
2297 if( !item->IsBOARD_ITEM() )
2314 if( containsReadOnlyGenChild(
selection ) )
2326 std::vector<PCB_TABLECELL*> cells;
2375 if( !
frame()->GetPropertiesPanel()->IsShownOnScreen() )
2377 infobar->
AddLink(
_(
"Show Properties panel" ),
2378 [
this]( wxHyperlinkEvent& aHyperlinkEvent )
2380 frame()->ToggleProperties();
2385 infobar->
ShowMessageFor(
_(
"Use Properties panel to edit properties common to selected items." ),
2386 8000, wxICON_INFORMATION );
2395 std::vector<PCB_SHAPE*> shapes;
2397 constraintTool->SolveAfterEdit( shapes );
2412 for(
EDA_ITEM* eda_item : selCopy )
2414 if( !eda_item->IsBOARD_ITEM() )
2456 if( editFrame && item )
2469 std::unordered_set<BOARD_ITEM*> visited;
2474 if( !aItem || !visited.insert( aItem ).second )
2478 aShapes.push_back(
static_cast<PCB_SHAPE*
>( aItem ) );
2485 if( item->IsBOARD_ITEM() )
2495 if( !constraintTool )
2498 std::vector<PCB_SHAPE*> shapes;
2518 commit = &localCommit;
2542 std::optional<VECTOR2I> oldRefPt;
2547 oldRefPt =
selection.GetReferencePoint();
2576 bool usePcbShapeCenter =
false;
2583 usePcbShapeCenter =
true;
2587 usePcbShapeCenter =
true;
2593 else if( usePcbShapeCenter )
2605 if(
frame()->GetCanvas()->GetView()->GetGAL()->IsFlippedX() )
2606 rotateAngle = -rotateAngle;
2612 viewBBox.
Merge( item->ViewBBox() );
2621 typedef std::numeric_limits<int> coord_limits;
2626 bool outOfBounds = rotPos.
x < min || rotPos.
x > max || rotPos.
y < min || rotPos.
y > max || rotEnd.
x < min
2627 || rotEnd.
x > max || rotEnd.
y < min || rotEnd.
y > max;
2635 if( item->IsBOARD_ITEM() )
2639 board_item->
Rotate( refPt, rotateAngle );
2643 static_cast<FOOTPRINT*
>( board_item )->InvalidateComponentClassCache();
2651 localCommit.
Push(
_(
"Rotate" ) );
2670 selection.SetReferencePoint( *oldRefPt );
2678const std::vector<KICAD_T> EDIT_TOOL::MirrorableItems = {
2708 if(
dynamic_cast<PCB_TABLE*
>( aChild ) )
2722 std::vector<BOARD_ITEM*> targets;
2726 if( !item->IsBOARD_ITEM() )
2740 targets.push_back( target );
2768 const bool axisAligned = ( aAxis.
A.
x == aAxis.
B.
x ) || ( aAxis.
A.
y == aAxis.
B.
y );
2772 if( !item->IsType( EDIT_TOOL::MirrorableItems ) )
2794 if(
table && !axisAligned )
2807 table->Mirror( aAxis.
A, flipDirection );
2811 item->Mirror( aAxis );
2831 commit = &localCommit;
2853 const SEG mirrorAxis =
MIRROR_AXIS( mirrorPoint, flipDirection );
2860 localCommit.
Push(
_(
"Mirror" ) );
2866 frame()->ShowInfoBarMsg(
_(
"Footprints cannot be mirrored. Use Flip to move them to "
2867 "the other side of the board." ) );
2871 frame()->ShowInfoBarMsg(
_(
"Groups containing footprints or other items that cannot be "
2872 "mirrored were skipped." ) );
2922 bool applied =
false;
2925 view->Add( &axisPreview );
2926 view->SetVisible( &axisPreview,
false );
2928 const auto setCursor = [&]()
2933 const auto setMsg = [&](
const wxString& aMsg )
2939 const auto cancelAxis = [&]()
2942 view->SetVisible( &axisPreview,
false );
2946 setMsg(
_(
"Select the first point of the mirror axis..." ) );
2949 const auto applyMirror = [&](
const SEG& aAxis )
2955 if( !commit.
Empty() )
2957 commit.
Push(
_(
"Mirror" ) );
2963 frame()->ShowInfoBarMsg(
_(
"Footprints cannot be mirrored. Use Flip to move them to "
2964 "the other side of the board." ) );
2966 else if( skips.
groups > 0 )
2968 frame()->ShowInfoBarMsg(
_(
"Groups containing footprints or other items that cannot be "
2969 "mirrored were skipped." ) );
2971 else if( skips.
items > 0 )
2973 frame()->ShowInfoBarMsg(
_(
"Items that cannot be mirrored about an arbitrary axis were "
2988 controls->ForceCursorPosition(
false );
2993 setMsg(
_(
"Select the first point of the mirror axis..." ) );
3001 grid.SetUseGrid(
view->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
3002 VECTOR2I cursorPos = evt->HasPosition() ? evt->Position() :
controls->GetMousePosition();
3004 if( !evt->IsActivate() && !evt->IsCancelInteractive() )
3007 cursorPos =
grid.ResolveSnap( cursorPos,
nullptr ).position;
3013 axisGeom.
SetEnd( cursorPos );
3014 cursorPos = axisGeom.
GetEnd();
3017 controls->ForceCursorPosition(
true, cursorPos );
3024 if( evt->IsCancelInteractive() )
3031 else if( evt->IsActivate() )
3045 axisGeom.
SetEnd( cursorPos );
3050 setMsg(
_(
"Select the second point of the mirror axis..." ) );
3059 frame()->ShowInfoBarMsg(
_(
"The mirror axis must have a non-zero length." ) );
3069 else if( !axisGeom.
IsReset() && ( evt->IsMotion()
3073 view->SetVisible( &axisPreview,
true );
3078 evt->SetPassEvent();
3082 view->SetVisible( &axisPreview,
false );
3083 view->Remove( &axisPreview );
3088 controls->ForceCursorPosition(
false );
3090 canvas()->SetStatusPopup(
nullptr );
3112 commit = &localCommit;
3142 setJustify(
static_cast<PCB_TEXT*
>( item ) );
3151 if( !localCommit.
Empty() )
3154 localCommit.
Push(
_(
"Left Justify" ) );
3156 localCommit.
Push(
_(
"Center Justify" ) );
3158 localCommit.
Push(
_(
"Right Justify" ) );
3188 commit = &localCommit;
3205 std::optional<VECTOR2I> oldRefPt;
3208 oldRefPt =
selection.GetReferencePoint();
3238 if( !item->IsBOARD_ITEM() )
3245 boardItem->
Flip( refPt, flipDirection );
3249 static_cast<FOOTPRINT*
>( boardItem )->InvalidateComponentClassCache();
3256 localCommit.
Push(
_(
"Change Side / Flip" ) );
3274 selection.SetReferencePoint( *oldRefPt );
3286 int commitFlags = 0;
3291 int itemsDeleted = 0;
3292 int fieldsHidden = 0;
3293 int fieldsAlreadyHidden = 0;
3297 if( !item->IsBOARD_ITEM() )
3303 switch( item->Type() )
3309 wxASSERT( parentFP );
3310 commit.
Modify( parentFP );
3319 fieldsAlreadyHidden++;
3322 getView()->Update( parentFP );
3341 commit.
Remove( board_item );
3351 commit.
Modify( board_item );
3352 static_cast<PCB_TABLECELL*
>( board_item )->SetText( wxEmptyString );
3364 commit.
Remove( board_item );
3371 commit.
Remove( board_item );
3381 if( !aIsCut && aItems.
GetSize() == 1 )
3384 ZONE* zone =
static_cast<ZONE*
>( board_item );
3386 int outlineIdx, holeIdx;
3407 commit.
Remove( board_item );
3419 if( stitch && !aItems.
Contains( stitch ) )
3427 commit.
Remove( board_item );
3439 commit.Push(
_(
"Delete" ), commitFlags );
3447 commit.
Remove( board_item );
3455 commit.
Remove( board_item );
3464 if( enteredGroup && enteredGroup->
GetItems().empty() )
3469 commit.
Push(
_(
"Cut" ), commitFlags );
3471 else if( itemsDeleted == 0 )
3473 if( fieldsHidden == 1 )
3474 commit.
Push(
_(
"Hide Field" ), commitFlags );
3475 else if( fieldsHidden > 1 )
3476 commit.
Push(
_(
"Hide Fields" ), commitFlags );
3477 else if( fieldsAlreadyHidden > 0 )
3478 editFrame->
ShowInfoBarError(
_(
"Use the Footprint Properties dialog to remove fields." ) );
3482 commit.
Push(
_(
"Delete" ), commitFlags );
3507 std::vector<BOARD_ITEM*> lockedItems;
3524 const bool hadInitialSelection = !
m_selectionTool->GetSelection().Empty();
3539 if( hadInitialSelection && selectionCopy.
Empty() )
3565 if( selectionCopy.
Empty() )
3608 if( ret == wxID_OK )
3616 selCenter += translation;
3618 if( !
frame()->GetPcbNewSettings()->m_Display.m_DisplayInvertYAxis )
3619 rotation = -rotation;
3623 if( !item->IsBOARD_ITEM() )
3631 boardItem->
Move( translation );
3633 switch( rotationAnchor )
3639 boardItem->
Rotate( selCenter, angle );
3642 boardItem->
Rotate(
frame()->GetScreen()->m_LocalOrigin, angle );
3645 boardItem->
Rotate(
board()->GetDesignSettings().GetAuxOrigin(), angle );
3650 getView()->Update( boardItem );
3653 commit.
Push(
_(
"Move Exactly" ) );
3675 return std::any_of( aSelection.
begin(), aSelection.
end(),
3678 PCB_GENERATOR* generator = dynamic_cast<PCB_GENERATOR*>( aItem );
3679 return !generator || generator->CanDuplicate();
3697 if(
PAD*
pad =
dynamic_cast<PAD*
>( item ) )
3740 std::vector<BOARD_ITEM*> new_items;
3745 std::map<KIID, KIID> idMap;
3751 if( !item->IsBOARD_ITEM() )
3763 switch( orig_item->
Type() )
3785 dupe_item = parentFootprint->
DuplicateItem(
true, &commit, orig_item );
3787 dupe_item = orig_item->
Duplicate(
true, &commit );
3797 new_items.push_back( dupe_item );
3798 commit.
Add( dupe_item );
3808 dupe_item = parentFootprint->
DuplicateItem(
true, &commit, orig_item );
3810 if( increment &&
static_cast<PAD*
>( dupe_item )->CanHaveNumber() )
3816 static_cast<PAD*
>( dupe_item )->SetNumber( padNumber );
3824 new_items.push_back( dupe_item );
3825 commit.
Add( dupe_item );
3839 dupe_item =
static_cast<PCB_GROUP*
>( orig_item )->DeepDuplicate(
true, &commit, &idMap );
3845 new_items.push_back( aItem );
3846 commit.
Add( aItem );
3851 new_items.push_back( dupe_item );
3852 commit.
Add( dupe_item );
3866 :
board()->Constraints();
3869 commit.
Add( clone );
3875 EDA_ITEMS nItems( new_items.begin(), new_items.end() );
3881 editFrame->
DisplayToolMsg( wxString::Format(
_(
"Duplicated %d item(s)" ), (
int) new_items.size() ) );
3886 commit.
Push(
_(
"Duplicate" ) );
3909 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
3911 switch( aCollector[i]->Type() )
3915 default: aCollector.
Remove( i );
break;
3940 commit = &localCommit;
3944 switch( item->Type() )
3954 if( !
pad.CanHaveNumber() )
3963 pad.SetNumber( *newNumber );
3977 text.SetText( *newText );
3989 commit->
Push(
_(
"Increment" ) );
3997 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
3999 if( aCollector[i]->Type() !=
PCB_PAD_T )
4007 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
4018 if( aSelection.
Empty() )
4042 BOX2I nonFieldsBBox;
4046 if( !item->IsType( { PCB_TEXT_T, PCB_FIELD_T } ) )
4047 nonFieldsBBox.
Merge( item->GetBoundingBox() );
4062 const wxString& aCanceledMessage,
VECTOR2I& aReferencePoint )
4066 std::optional<VECTOR2I> pickedPoint;
4076 const auto setPickerLayerSet =
4083 layerFilter =
LSET( { editFrame->GetActiveLayer() } );
4091 setPickerLayerSet();
4094 [&](
const VECTOR2D& aPoint ) ->
bool
4096 pickedPoint = aPoint;
4098 if( !aSuccessMessage.empty() )
4120 if( !aCanceledMessage.empty() )
4132 [&](
const int& aFinalState )
4151 setPickerLayerSet();
4154 evt->SetPassEvent();
4165 canvas()->SetStatusPopup(
nullptr );
4169 aReferencePoint = *pickedPoint;
4171 return pickedPoint.has_value();
4179 TOOL_EVENT selectReferencePoint( aEvent.
Category(), aEvent.
Action(),
"pcbnew.InteractiveEdit.selectReferencePoint",
4205 if( !
pickReferencePoint(
_(
"Select reference point for the copy..." ),
_(
"Selection copied" ),
4206 _(
"Copy canceled" ), refPoint ) )
4216 selection.SetReferencePoint( refPoint );
4220 frame()->SetStatusText(
_(
"Selection copied" ) );
4242 const auto getItemText =
4245 switch( aItem.Type() )
4273 for(
int row = 0; row <
table.GetRowCount(); ++row )
4275 for(
int col = 0; col <
table.GetColCount(); ++col )
4280 if( col <
table.GetColCount() - 1 )
4284 if( row <
table.GetRowCount() - 1 )
4294 return wxEmptyString;
4297 wxArrayString itemTexts;
4301 if( item->IsBOARD_ITEM() )
4304 wxString itemText = getItemText( *boardItem );
4306 itemText.Trim(
false ).Trim(
true );
4308 if( !itemText.IsEmpty() )
4309 itemTexts.Add( std::move( itemText ) );
4314 if( !itemTexts.empty() )
4339 board()->BuildConnectivity();
4341 canvas()->RedrawRatsnest();
constexpr EDA_IU_SCALE pcbIUScale
SEG MIRROR_AXIS(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
static TOOL_ACTION decrementPrimary
static TOOL_ACTION pickerSubTool
static TOOL_ACTION unselectAll
static TOOL_ACTION decrementSecondary
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
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
REMOVE_FLAGS
Remove event modifier flags.
static TOOL_ACTION increment
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION leftJustify
static TOOL_ACTION copyAsText
static TOOL_ACTION refreshPreview
static TOOL_ACTION selectAll
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static TOOL_ACTION centerJustify
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
void Revert() override
Revert the commit by restoring the modified items state.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
NETINFO_ITEM * GetNet() const
Return NETINFO_ITEM object for a given item.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
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.
void SetLocked(bool aLocked) override
bool IsLocked() const override
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Rotate this object.
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const
Invoke a function on all children.
BOARD_ITEM_CONTAINER * GetParent() const
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.
Information pertinent to a Pcbnew printed circuit board.
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
const FOOTPRINTS & Footprints() const
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
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
static std::vector< BOARD_ITEM * > CopiedItems(const PCB_SELECTION &aSelection)
The items a copy of aSelection carries, which is what its reference point has to be picked from.
void SetBoard(BOARD *aBoard)
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, 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.
@ 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, INFOBAR_MESSAGE_TYPE aType=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...
virtual int GetUndoCommandCount() const
void DisplayToolMsg(const wxString &msg) override
A set of EDA_ITEMs (i.e., without duplicates).
std::unordered_set< EDA_ITEM * > & GetItems()
virtual EDA_ITEM * AsEdaItem()=0
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)
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
SHAPE_POLY_SET & GetPolyShape()
bool IsHatchedFill() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
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 item had a property changed (except movement)
static const TOOL_EVENT ConnectivityChangedEvent
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.
void SetStrokeColor(const COLOR4D &aNewColor)
Set the stroke color to set before drawing preview.
Represent a very simple geometry manager for items that have a start and end point.
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
void SetAngleSnap(LEADER_MODE aSnap)
VECTOR2I GetOrigin() const
void Reset()
Reset the manager to the initial state.
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.
An interface for classes handling user events controlling the view behavior such as zooming,...
bool IsBOARD_ITEM() const
virtual wxString GetClass() const =0
Return the class name.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllLayersMask()
Preview of the axis the selection is about to be mirrored about.
A collection of nets and the parameters used to route or test these nets.
int GetuViaDiameter() const
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
static TOOL_ACTION drag45Degree
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
static TOOL_ACTION layerPrev
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 repeatLayout
static TOOL_ACTION routerRouteSelectedFromEnd
static TOOL_ACTION toggleExcludeFromSim
static TOOL_ACTION swapPadNets
Swap nets between selected pads/gates (and connected copper)
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION editFpInFpEditor
static TOOL_ACTION moveWithReference
move with a reference point
static TOOL_ACTION changeTrackLayerPrev
static TOOL_ACTION swap
Swapping of selected items.
static TOOL_ACTION routerOptimizeSelected
static TOOL_ACTION routerAutorouteSelected
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 toggleExcludeFromBOM
static TOOL_ACTION extendGraphic
Extend one graphical line or arc to the nearest boundary.
static TOOL_ACTION dragFreeAngle
static TOOL_ACTION inspectClearance
static TOOL_ACTION updateLocalRatsnest
static TOOL_ACTION updateFootprints
static TOOL_ACTION deleteFull
static TOOL_ACTION unrouteSegment
Removes track segment from the selected item to the next segment.
static TOOL_ACTION moveIndividually
move items one-by-one
static TOOL_ACTION changeFootprints
static TOOL_ACTION mirrorInteractive
static TOOL_ACTION toggleExcludeFromPosFiles
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 interactiveOffsetTool
static TOOL_ACTION footprintProperties
static TOOL_ACTION pointEditorChamferCorner
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 pointEditorRemoveCorner
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 changeTrackLayerNext
static TOOL_ACTION flip
Flipping of selected objects.
static TOOL_ACTION pointEditorAddCorner
static TOOL_ACTION editVertices
Edit polygon vertices in a table.
static TOOL_ACTION swapGateNets
static TOOL_ACTION layerNext
static TOOL_ACTION extendLines
Extend selected lines to meet at a point.
static TOOL_ACTION routerRouteSelected
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
static TOOL_ACTION trimGraphic
Trim a section from one graphical line or arc.
Common, abstract interface for edit frames.
virtual void OnEditItemRequest(BOARD_ITEM *aItem)
Install the corresponding dialog editor for the given item.
void OpenVertexEditor(BOARD_ITEM *aItem)
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.
A geometric constraint between board items (issue #2329).
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
static const TOOL_EVENT & SnappingModeChangedByKeyEvent()
Hotkey feedback.
virtual bool ChildrenAreIndividuallySelectable() const
virtual bool ChildrenAreReadOnly() const
A set of BOARD_ITEMs (i.e., without duplicates).
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction, RECURSE_MODE aMode) const override
Invoke a function on all children.
Tool that displays edit points allowing to modify items by dragging the points.
bool CanRemoveCorner(const SELECTION &aSelection)
Condition to display "Remove Corner" context menu entry.
static bool CanChamferCorner(const EDA_ITEM &aItem)
Check if a corner of the given item can be chamfered (zones, polys only).
static bool CanAddCorner(const EDA_ITEM &aItem)
Check if a corner can be added to the given item (zones, polys, segments, arcs).
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void SetWidth(int aWidth) override
int GetWidth() const override
void SetEnd(const VECTOR2I &aEnd) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStart(const VECTOR2I &aStart) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
wxString GetShownText(RESOLUTION_CONTEXT aContext, 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
void ExcludePosition(const VECTOR2I &aPos)
Add a board position to the exclusion set so the next Update() skips it.
bool ApproxCollinear(const SEG &aSeg, int aDistanceThreshold=1) const
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 bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
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 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.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
VECTOR2_TRAITS< int32_t >::extended_type extended_type
A modified version of the wxInfoBar class that allows us to:
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
void AddLink(const wxString &aLinkText, const std::function< void(wxHyperlinkEvent &)> &aFn)
Add a hypertext link to the infobar.
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
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 IsTeardropArea() const
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::vector< PCB_CONSTRAINT * > CloneFullySelectedConstraints(const CONSTRAINTS &aSource, const std::map< KIID, KIID > &aIdMap)
Clone the constraints in aSource that a duplicate should carry.
@ ROTATE_AROUND_USER_ORIGIN
@ ROTATE_AROUND_SEL_CENTER
@ ROTATE_AROUND_AUX_ORIGIN
@ ROTATE_AROUND_ITEM_ANCHOR
static std::string ToStdString(const wxString &aStr)
#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, int aChainingEpsilon)
Connects shapes to each other, making continious contours (adjacent shapes will have a common vertex)...
a few functions useful in geometry calculations.
@ DIRECT
Unconstrained point-to-point.
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_ANCHOR
Anchor of items having an anchor point (texts, footprints).
@ 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)
@ LEFT_RIGHT
Flip left to right (around the Y axis)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
@ GEOMETRY
Position or shape has changed.
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::deque< FOOTPRINT * > FOOTPRINTS
std::deque< PCB_CONSTRAINT * > CONSTRAINTS
bool IsGeneratedTableCell(const EDA_ITEM *aItem)
True for a cell whose text is generated from the board, so only its formatting is the user's.
@ ID_POPUP_PCB_SWAP_UNIT_LAST
@ ID_POPUP_PCB_SWAP_UNIT_BASE
std::vector< EDA_ITEM * > EDA_ITEMS
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
Increment event parameters.
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
Parameters that define a simple chamfer operation.
What a mirror operation could not move, so the caller can say why.
STRING_INCREMENTER incrementer
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.
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
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_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_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_SHAPE_LOCATE_CIRCLE_T
@ 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_GRID_ITEM_T
a subgrid placed on a board
@ 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_STACKUP_TABLE_T
class PCB_STACKUP_TABLE, a live stackup table derived from PCB_TABLE
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_DRILL_CHART_T
class PCB_DRILL_CHART, a live drill chart derived from PCB_TABLE
Casted dyn_cast(From aObject)
A lightweight dynamic downcast.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)