30using namespace std::placeholders;
161 std::shared_ptr<SELECT_MENU> selectMenu = std::make_shared<SELECT_MENU>();
162 selectMenu->SetTool(
this );
163 m_menu->RegisterSubMenu( selectMenu );
167 auto& menu =
m_menu->GetMenu();
169 auto activeToolCondition =
184 auto groupEnterCondition =
187 auto inGroupCondition =
199 menu.AddSeparator( 1000 );
210 menu.AddSeparator( haveHighlight, 1 );
216 menu.AddSeparator( 1 );
260 wxMouseState keyboardState = wxGetMouseState();
262 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), keyboardState.AltDown() );
285 trackDragAction = cfg->m_TrackDragAction;
299 else if( evt->IsMouseDown(
BUT_LEFT ) )
337 bool selectionCancelled =
false;
341 selectPoint( evt->Position(),
false, &selectionCancelled );
346 m_frame->GetCanvas()->ForceRefresh();
348 if( !selectionCancelled )
354 else if( evt->IsDblClick(
BUT_LEFT ) )
396 const int delta = evt->Parameter<
int>();
456 wxASSERT_MSG(
false, wxT(
"Unknown selection mode" ) );
463 auto zoneFilledAreaFilter =
466 int accuracy = aCollector.GetGuide()->Accuracy();
467 std::set<EDA_ITEM*> remove;
473 ZONE* zone =
static_cast<ZONE*
>( item );
478 remove.insert( zone );
484 aCollector.Remove( item );
490 if( evt->HasPosition() )
493 &&
selectPoint( evt->DragOrigin(),
false,
nullptr, zoneFilledAreaFilter ) )
511 bool routable = ( segs >= 1 || arcs >= 1 || vias == 1 )
512 && ( segs + arcs + vias ==
m_selection.GetSize() );
536 else if( evt->IsCancel() )
545 else if( evt->FirstResponder() ==
this && evt->GetCommandId() == (
int) WXK_ESCAPE )
557 if( controller &&
m_frame->GetPcbNewSettings()->m_ESCClearsNetHighlight )
560 catch(
const std::runtime_error& e )
562 wxCHECK_MSG(
false, 0, e.what() );
573 if(
m_frame->ToolStackIsEmpty() )
579 && evt->HasPosition()
602 wxT(
"EnterGroup called when selection is not a single group" ) );
664 enum DISPOSITION { BEFORE = 1, AFTER,
BOTH };
666 std::map<EDA_ITEM*, DISPOSITION> itemDispositions;
675 itemDispositions[ item ] = BEFORE;
678 aClientFilter(
VECTOR2I(), collector,
this );
682 if( itemDispositions.count( item ) )
683 itemDispositions[ item ] =
BOTH;
685 itemDispositions[ item ] = AFTER;
693 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
695 EDA_ITEM* item = itemDisposition.first;
696 DISPOSITION disposition = itemDisposition.second;
698 if( disposition == BEFORE )
702 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
704 EDA_ITEM* item = itemDisposition.first;
705 DISPOSITION disposition = itemDisposition.second;
709 if( disposition == AFTER || disposition ==
BOTH )
713 m_frame->GetCanvas()->ForceRefresh();
769 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
771 if( !
Selectable( collector[ i ] ) || ( aOnDrag && collector[i]->IsLocked() ) )
777 size_t preFilterCount = collector.
GetCount();
784 if( collector.
GetCount() == 0 && preFilterCount > 0 )
787 editFrame->HighlightSelectionFilter( rejected );
795 aClientFilter( aWhere, collector,
this );
804 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
806 if( !collector[i]->IsSelected() )
818 catch(
const std::exception& exc )
820 wxLogWarning( wxS(
"Exception '%s' occurred attempting to guess selection candidates." ),
834 if( aSelectionCancelledFlag )
835 *aSelectionCancelledFlag =
true;
842 bool anySubtracted =
false;
849 anySubtracted =
true;
855 for(
int i = 0; i < collector.
GetCount(); ++i )
860 anySubtracted =
true;
870 if( addedCount == 1 )
875 else if( addedCount > 1 )
880 else if( anySubtracted )
917 for(
int i = 0; aAllowedActions[i]; ++i )
919 if( aEvent->
IsAction( aAllowedActions[i] ) )
930 bool cancelled =
false;
935 if( cell->IsSelected() )
944 return ( aItem->GetFlags() &
CANDIDATE ) > 0;
949 if( evt->IsCancelInteractive() || evt->IsActivate() )
958 BOX2I selectionRect( evt->DragOrigin(), evt->Position() - evt->DragOrigin() );
963 bool doSelect =
false;
965 if( cell->HitTest( selectionRect,
false ) )
970 doSelect = !wasSelected( cell );
974 else if( wasSelected( cell ) )
979 if( doSelect && !cell->IsSelected() )
981 else if( !doSelect && cell->IsSelected() )
985 else if( evt->IsMouseUp(
BUT_LEFT ) )
989 bool anyAdded =
false;
990 bool anySubtracted =
false;
994 if( cell->IsSelected() && !wasSelected( cell ) )
996 else if( wasSelected( cell ) && !cell->IsSelected() )
997 anySubtracted =
true;
1029 bool cancelled =
false;
1044 if(
view->IsMirroredX() )
1045 greedySelection = !greedySelection;
1050 if( evt->IsCancelInteractive() || evt->IsActivate() )
1069 area.
SetEnd( evt->Position() );
1075 view->SetVisible( &area,
true );
1076 view->Update( &area );
1085 view->SetVisible( &area,
false );
1099 view->Remove( &area );
1131 bool cancelled =
false;
1149 bool isClockwise = shapeArea > 0 ? true :
false;
1151 if(
getView()->IsMirroredX() && shapeArea != 0 )
1152 isClockwise = !isClockwise;
1156 if( evt->IsCancelInteractive() || evt->IsActivate() )
1159 evt->SetPassEvent(
false );
1166 points.
Append( evt->Position() );
1168 else if( evt->IsDblClick(
BUT_LEFT )
1174 evt->SetPassEvent(
false );
1210 area.
SetMode( selectionMode );
1233 bool anyAdded =
false;
1234 bool anySubtracted =
false;
1242 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
1244 view->Query( selectionBox, candidates );
1248 std::set<EDA_ITEM*> group_items;
1256 std::unordered_set<EDA_ITEM*>& newset =
group->GetItems();
1259 [&](
const BOX2I& aBox )
1261 return boxMode ? selectionBox.
Contains( aBox )
1267 if( containedMode && boxContained(
group->GetBoundingBox() ) && newset.size() )
1269 for(
EDA_ITEM* group_item : newset )
1271 if( !group_item->IsBOARD_ITEM() )
1275 collector.
Append( *newset.begin() );
1279 for(
EDA_ITEM* group_item : newset )
1280 group_items.emplace( group_item );
1286 return boxMode ? aItem->HitTest( selectionBox, containedMode )
1287 : aItem->HitTest( aArea.
GetPoly(), containedMode );
1290 for(
const auto& [item, layer] : candidates )
1292 if( !item->IsBOARD_ITEM() )
1297 if(
Selectable( boardItem ) && hitTest( boardItem )
1298 && ( !containedMode || !group_items.count( boardItem ) ) )
1301 padsCollector.
Append( boardItem );
1303 collector.
Append( boardItem );
1315 collector = padsCollector;
1322 std::sort( collector.
begin(), collector.
end(),
1325 VECTOR2I aPos = a->GetPosition();
1326 VECTOR2I bPos = b->GetPosition();
1328 if( aPos.y == bPos.y )
1329 return aPos.x < bPos.x;
1331 return aPos.y < bPos.y;
1336 if( !i->IsBOARD_ITEM() )
1341 if( aSubtractive || ( aExclusiveOr && item->
IsSelected() ) )
1344 anySubtracted =
true;
1358 else if( anySubtracted )
1365 wxMouseState keyboardState = wxGetMouseState();
1367 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), keyboardState.AltDown() );
1411 collection.
Append( item );
1424 m_frame->GetCanvas()->ForceRefresh();
1452 m_frame->GetCanvas()->ForceRefresh();
1462 std::set<int> representedNets;
1464 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
1470 else if ( representedNets.count( item->
GetNetCode() ) )
1473 representedNets.insert( item->
GetNetCode() );
1480 std::deque<EDA_ITEM*> selectedItems =
m_selection.GetItems();
1483 std::vector<BOARD_CONNECTED_ITEM*> toUnroute;
1484 std::set<EDA_ITEM*> toDelete;
1486 for(
EDA_ITEM* item : selectedItems )
1491 toUnroute.push_back(
pad );
1495 toDelete.insert( item );
1511 std::set<int> selectedNets;
1514 if( item->GetNetCode() > 0 )
1515 selectedNets.insert( item->GetNetCode() );
1517 std::set<VECTOR2I> endpointSet;
1523 endpointSet.insert( track->GetStart() );
1524 endpointSet.insert( track->GetEnd() );
1528 endpointSet.insert( item->GetPosition() );
1532 endpointSet.insert( item->GetPosition() );
1536 bool expanded =
true;
1544 if( toDelete.count( gen ) )
1548 std::map<VECTOR2I, int> epCount;
1550 for(
BOARD_ITEM* child : gen->GetBoardItems() )
1554 if( track && selectedNets.count( track->
GetNetCode() ) )
1557 epCount[track->
GetEnd()]++;
1562 bool connected =
false;
1564 for(
auto& [pt, count] : epCount )
1566 if( count == 1 && endpointSet.count( pt ) )
1575 toDelete.insert( gen );
1589 endpointSet.insert( track->GetStart() );
1590 endpointSet.insert( track->GetEnd() );
1613 std::set<BOARD_ITEM*> removed;
1617 if( !item->IsBOARD_ITEM() )
1623 toDelete.insert( bi );
1626 removed.insert( bi );
1632 for(
BOARD_ITEM* child : gen->GetBoardItems() )
1634 if( removed.count( child ) )
1636 toDelete.insert( gen );
1644 if( !item->IsBOARD_ITEM() )
1652 if( removed.find( aItem ) == removed.end() )
1655 removed.insert( aItem );
1660 if( removed.find( boardItem ) == removed.end() )
1661 commit.
Remove( boardItem );
1665 commit.
Push(
_(
"Unroute Selected" ) );
1670 for(
EDA_ITEM* item : selectedItems )
1682 std::deque<EDA_ITEM*> selectedItems =
m_selection.GetItems();
1685 std::vector<BOARD_CONNECTED_ITEM*> toUnroute;
1687 std::set<EDA_ITEM*> toDelete;
1689 for(
EDA_ITEM* item : selectedItems )
1700 if( !toDelete.count( gen ) )
1702 toDelete.insert( gen );
1706 toDelete.insert( generatedItem );
1716 toDelete.insert( item );
1721 toDelete.insert( item );
1725 toDelete.insert( generatedItem );
1736 std::deque<EDA_ITEM*> toSelectAfter;
1740 if( !item->IsBOARD_ITEM() )
1743 if( toDelete.find( item ) == toDelete.end() )
1744 toSelectAfter.push_back( item );
1748 std::set<BOARD_ITEM*> removed;
1752 if( !item->IsBOARD_ITEM() )
1762 if( removed.insert( aItem ).second )
1767 if( removed.insert( boardItem ).second )
1768 commit.
Remove( boardItem );
1772 if( removed.insert( boardItem ).second )
1773 commit.
Remove( boardItem );
1777 commit.
Push(
_(
"Unroute Segment" ) );
1782 for(
EDA_ITEM* item : toSelectAfter )
1784 if( !toDelete.count( item ) )
1797 unsigned initialCount = 0;
1809 if( initialCount == 0 )
1812 std::vector<PCB_SHAPE*> startShapes;
1817 startShapes.push_back(
static_cast<PCB_SHAPE*
>( item ) );
1821 if( !startShapes.empty() )
1827 m_frame->SetStatusText(
_(
"Select/Expand Connection..." ) );
1831 std::deque<EDA_ITEM*> selectedItems =
m_selection.GetItems();
1833 for(
EDA_ITEM* item : selectedItems )
1834 item->ClearTempFlags();
1836 std::vector<BOARD_CONNECTED_ITEM*> startItems;
1838 for(
EDA_ITEM* item : selectedItems )
1845 startItems.push_back(
pad );
1863 if(
m_selection.GetItems().size() > initialCount )
1867 m_frame->SetStatusText( wxEmptyString );
1880 double refreshIntervalMs = 500;
1881 int lastSelectionSize = (int)
m_selection.GetSize();
1885 std::set<PAD*> startPadSet;
1886 std::vector<BOARD_CONNECTED_ITEM*> cleanupItems;
1892 startPadSet.insert(
static_cast<PAD*
>( startItem ) );
1895 if( startItem->IsType( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
1904 std::map<VECTOR2I, std::vector<PCB_TRACK*>> trackMap;
1905 std::map<VECTOR2I, PCB_VIA*> viaMap;
1906 std::map<VECTOR2I, PAD*> padMap;
1907 std::map<VECTOR2I, std::vector<PCB_SHAPE*>> shapeMap;
1908 std::vector<std::pair<VECTOR2I, LSET>> activePts;
1918 switch( item->Type() )
1924 trackMap[track->
GetStart()].push_back( track );
1925 trackMap[track->
GetEnd()].push_back( track );
1932 viaMap[
via->GetStart()] =
via;
1939 padMap[
pad->GetPosition()] =
pad;
1948 shapeMap[point].push_back( shape );
1959 switch( startItem->Type() )
1972 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1976 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1984 activePts.push_back( { point, startItem->GetLayerSet() } );
1997 while( expand && failSafe++ < 100000 )
2001 for(
int i = (
int) activePts.size() - 1; i >= 0; --i )
2006 auto viaIt = viaMap.find( pt );
2007 auto padIt = padMap.find( pt );
2009 bool gotVia = viaIt != viaMap.end() && ( viaIt->second->GetLayerSet() & layerSetCu ).any();
2010 bool gotPad = padIt != padMap.end() && ( padIt->second->GetLayerSet() & layerSetCu ).any();
2011 bool gotNonStartPad = gotPad && ( startPadSet.find( padIt->second ) == startPadSet.end() );
2015 activePts.erase( activePts.begin() + i );
2021 activePts.erase( activePts.begin() + i );
2027 size_t pt_count = 0;
2031 if( track->GetStart() != track->GetEnd() && layerSetCu.
Contains( track->GetLayer() ) )
2035 if( pt_count > 2 || gotVia || gotNonStartPad )
2037 activePts.erase( activePts.begin() + i );
2043 if( gotNonStartPad )
2045 activePts.erase( activePts.begin() + i );
2052 PAD*
pad = padIt->second;
2057 cleanupItems.push_back(
pad );
2059 activePts.push_back( {
pad->GetPosition(),
pad->GetLayerSet() } );
2066 if( !layerSetCu.
Contains( track->GetLayer() ) )
2072 if( !track->IsSelected() )
2078 cleanupItems.push_back( track );
2080 if( track->GetStart() == pt )
2081 activePts.push_back( { track->GetEnd(), track->GetLayerSet() } );
2083 activePts.push_back( { track->GetStart(), track->GetLayerSet() } );
2092 if( !layerSetCu.
Contains( shape->GetLayer() ) )
2098 if( !shape->IsSelected() )
2104 cleanupItems.push_back( shape );
2106 for(
const VECTOR2I& newPoint : shape->GetConnectionPoints() )
2108 if( newPoint == pt )
2111 activePts.push_back( { newPoint, shape->GetLayerSet() } );
2119 if( viaMap.count( pt ) )
2125 activePts.erase( activePts.begin() + i );
2129 if( !
via->IsSelected() )
2135 cleanupItems.push_back(
via );
2137 activePts.push_back( {
via->GetPosition(),
via->GetLayerSet() } );
2144 activePts.erase( activePts.begin() + i );
2148 if( refreshTimer.
msecs() >= refreshIntervalMs )
2152 m_frame->GetCanvas()->ForceRefresh();
2156 refreshTimer.
Start();
2161 std::set<EDA_ITEM*> toDeselect;
2162 std::set<EDA_ITEM*> toSelect;
2167 if( !item->IsBOARD_ITEM() )
2175 toDeselect.insert( item );
2220 std::stack<PCB_SHAPE*> toSearch;
2221 std::set<PCB_SHAPE*> toCleanup;
2223 for(
PCB_SHAPE* startItem : aStartItems )
2224 toSearch.push( startItem );
2237 toSearch.push(
static_cast<PCB_SHAPE*
>( item ) );
2241 while( !toSearch.empty() )
2250 toCleanup.insert( shape );
2259 searchPoint( shape->
GetEnd() );
2270 std::vector<PAD*> pads;
2277 pads.push_back(
pad );
2281 pads.push_back(
static_cast<PAD*
>( item ) );
2290 for(
const CN_EDGE& edge : conn->GetRatsnestForPad(
pad ) )
2292 wxCHECK2( edge.GetSourceNode() && !edge.GetSourceNode()->Dirty(),
continue );
2293 wxCHECK2( edge.GetTargetNode() && !edge.GetTargetNode()->Dirty(),
continue );
2298 if( sourceParent ==
pad )
2301 select(
static_cast<PAD*
>( targetParent )->GetParent() );
2303 else if( targetParent ==
pad )
2306 select(
static_cast<PAD*
>( sourceParent )->GetParent() );
2320 std::vector<PAD*> pads;
2327 pads.push_back(
pad );
2331 pads.push_back(
static_cast<PAD*
>( item ) );
2342 const std::vector<CN_EDGE> edges = conn->GetRatsnestForPad(
pad );
2345 if( edges.size() == 0 )
2348 double currentDistance = DBL_MAX;
2352 for(
const CN_EDGE& edge : edges )
2354 if( edge.GetSourceNode()->Parent()->GetParentFootprint()
2355 == edge.GetTargetNode()->Parent()->GetParentFootprint() )
2361 const CN_ANCHOR* other = edge.GetSourceNode()->
Parent() ==
pad ? edge.GetTargetNode().get()
2362 : edge.GetSourceNode().get();
2364 wxCHECK2( other && !other->
Dirty(),
continue );
2370 if( edge.GetLength() < currentDistance )
2372 currentDistance = edge.GetLength();
2377 if( nearest !=
nullptr )
2391 for(
BOARD_ITEM* item : conn->GetNetItems( aNetCode, { PCB_TRACE_T,
2448 std::vector<BOARD_ITEM*> footprints;
2453 if( footprint ==
nullptr )
2456 wxString footprint_path = footprint->GetPath().AsString().BeforeLast(
'/' );
2458 if( footprint_path.IsEmpty() )
2459 footprint_path +=
'/';
2461 if( footprint_path == aSheetPath )
2462 footprints.push_back( footprint );
2478 std::list<int> netcodeList;
2479 std::vector<BOARD_CONNECTED_ITEM*> padList;
2483 switch( item->Type() )
2489 if(
pad->IsConnected() )
2491 netcodeList.push_back(
pad->GetNetCode() );
2492 padList.push_back(
pad );
2503 if(
pad->IsConnected() )
2505 netcodeList.push_back(
pad->GetNetCode() );
2506 padList.push_back(
pad );
2518 std::sort( padList.begin(), padList.end() );
2522 netcodeList.unique();
2528 std::vector<int> removeCodeList;
2531 for(
int netCode : netcodeList )
2535 if( !std::binary_search( padList.begin(), padList.end(),
pad ) )
2539 removeCodeList.push_back( netCode );
2545 for(
int removeCode : removeCodeList )
2546 netcodeList.remove( removeCode );
2548 std::unordered_set<BOARD_ITEM*> localConnectionList;
2550 for(
int netCode : netcodeList )
2552 for(
BOARD_ITEM* item : conn->GetNetItems( netCode, { PCB_TRACE_T,
2557 localConnectionList.insert( item );
2561 for(
BOARD_ITEM* item : localConnectionList )
2568 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
2579 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
2597 if( item->IsMoving() )
2614 if(
m_frame->GetPcbNewSettings()->m_CrossProbing.center_on_items )
2616 if(
m_frame->GetPcbNewSettings()->m_CrossProbing.zoom_to_fit )
2625 m_frame->GetCanvas()->ForceRefresh();
2635 wxString sheetPath = *aEvent.
Parameter<wxString*>();
2661 if( !footprint || footprint->
GetPath().empty() )
2667 wxString sheetPath = footprint->
GetPath().
AsString().BeforeLast(
'/' );
2669 if( sheetPath.IsEmpty() )
2690 screenSize.
x = std::max( 10.0, screenSize.
x );
2691 screenSize.
y = std::max( 10.0, screenSize.
y );
2696 double scale =
view->GetScale() / std::max( fabs( vsize.
x / screenSize.
x ),
2697 fabs( vsize.
y / screenSize.
y ) );
2703 m_frame->GetCanvas()->ForceRefresh();
2719#ifdef DEFAULT_PCBNEW_CODE
2721 auto screenSize =
view->ToWorld( GetCanvas()->GetClientSize(),
false );
2724 screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
2725 screenSize.y = std::max( 10.0, screenSize.y );
2726 double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
2729 if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) )
2730 view->SetScale(
view->GetScale() / ratio );
2733#ifndef DEFAULT_PCBNEW_CODE
2750 double compRatio = bbSize.y / currTextHeight;
2753 double compRatioBent = 1.0;
2764 screenSize.
x = std::max( 10.0, fabs( screenSize.
x ) );
2765 screenSize.
y = std::max( 10.0, screenSize.
y );
2766 double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.
y ) );
2769 double kicadRatio = std::max( fabs( bbSize.x / screenSize.
x ),
2770 fabs( bbSize.y / screenSize.
y ) );
2778 std::vector<std::pair<double, double>> lut {
2791 std::vector<std::pair<double, double>>::iterator it;
2793 compRatioBent = lut.back().second;
2795 if( compRatio >= lut.front().first )
2801 for( it = lut.begin(); it < lut.end() - 1; it++ )
2803 if( it->first <= compRatio &&
next( it )->first >= compRatio )
2805 double diffx = compRatio - it->first;
2806 double diffn =
next( it )->first - it->first;
2808 compRatioBent = it->second + (
next( it )->second - it->second ) * diffx / diffn;
2815 compRatioBent = lut.front().second;
2823 if( bbSize.x > screenSize.
x * ratio * compRatioBent )
2827 compRatioBent = 1.0;
2828 wxLogTrace(
"CROSS_PROBE_SCALE",
"Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
2833 ratio *= compRatioBent;
2835 bool alwaysZoom =
false;
2838 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
2839 view->SetScale(
view->GetScale() / ratio );
2846 bool cleared =
false;
2858 switch( aItem->
Type() )
2862 int netCode =
static_cast<NETINFO_ITEM*
>( aItem )->GetNetCode();
2881 double marginFactor = 2;
2890 double scaleX = screenSize.
x /
static_cast<double>( aItem->
GetBoundingBox().GetWidth() );
2891 double scaleY = screenSize.
y /
static_cast<double>( aItem->
GetBoundingBox().GetHeight() );
2893 scaleX /= marginFactor;
2894 scaleY /= marginFactor;
2896 double scale = scaleX > scaleY ? scaleY : scaleX;
2915 m_frame->GetCanvas()->ForceRefresh();
2927 switch( aItem.
Type() )
2982 if( cmd != wxID_OK )
2993 if( !i->IsBOARD_ITEM() )
3015 std::set<BOARD_ITEM*> rejected;
3019 if( !i->IsBOARD_ITEM() )
3025 rejected.insert( item );
3029 aCollector.
Remove( item );
3094 aRejected->
pads =
true;
3106 aRejected->
tracks =
true;
3117 aRejected->
vias =
true;
3126 ZONE* zone =
static_cast<ZONE*
>( aItem );
3136 aRejected->
zones =
true;
3145 if( zone ==
m_frame->GetBoard()->m_SolderMaskBridges )
3176 aRejected->
text =
true;
3212 aRejected->
points =
true;
3260 bool enteredGroupFound =
false;
3263 [&](
EDA_ITEM* item,
void* testData )
3281 enteredGroupFound =
true;
3295 if( !enteredGroupFound )
3308 auto visibleLayers =
3316 set.
set( layer,
view()->IsLayerVisible( layer ) );
3338 bool onActiveLayer =
false;
3340 for(
int layer : activeLayers )
3343 if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer(
ToLAYER_ID( layer ) ) )
3345 onActiveLayer =
true;
3368 && footprint->
Pads().empty()
3369 && footprint->
Zones().empty() )
3386 for(
const ZONE* zone : footprint->
Zones() )
3418 const ZONE* zone =
nullptr;
3420 const PAD*
pad =
nullptr;
3433 switch( aItem->
Type() )
3439 zone =
static_cast<const ZONE*
>( aItem );
3457 if( !layerVisible( aItem->
GetLayer() ) )
3469 if( !( visibleLayers() &
via->GetLayerSet() ).any() )
3475 field =
static_cast<const PCB_FIELD*
>( aItem );
3491 if( !layerVisible(
text->GetLayer() ) )
3502 if(
text->GetText() == wxT(
"${REFERENCE}" ) )
3504 else if(
text->GetText() == wxT(
"${VALUE}" ) )
3507 if( !
view()->IsLayerVisible( controlLayer ) )
3521 if( !layerVisible( aItem->
GetLayer() ) )
3530 if( !layerVisible( aItem->
GetLayer() ) )
3536 if( !layerVisible( aItem->
GetLayer() ) )
3543 if( !layerVisible( aItem->
GetLayer() ) )
3551 if( !layerVisible( aItem->
GetLayer() ) )
3564 if( !layerVisible( aItem->
GetLayer() ) )
3573 pad =
static_cast<const PAD*
>( aItem );
3584 if( !(
pad->GetLayerSet() & visibleLayers() ).
any() )
3591 marker =
static_cast<const PCB_MARKER*
>( aItem );
3599 if( !layerVisible( aItem->
GetLayer() ) )
3653 aGroup->
Add( aItem );
3722 const unsigned GRIP_MARGIN = 20;
3728 if( !item->IsBOARD_ITEM() )
3731 BOX2I itemBox = item->ViewBBox();
3736 if( item->HitTest( aPoint, margin ) )
3743 group->RunOnChildren(
3746 if( aItem->
HitTest( aPoint, margin ) )
3766 SEG loc( aWhere, aWhere );
3768 switch( aItem->
Type() )
3776 if(
text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &
distance ) )
3798 shape->Collide( loc, aMaxDistance, &
distance );
3818 ZONE* zone =
static_cast<ZONE*
>( aItem );
3840 catch(
const std::exception& e )
3842 wxFAIL_MSG( wxString::Format( wxT(
"Clipper exception occurred: %s" ), e.what() ) );
3876 static_cast<PAD*
>( aItem )->Padstack().ForEachUniqueLayer(
3879 int layerDistance = INT_MAX;
3905 wxCHECK( settings, );
3908 LSET visibleLayers =
m_frame->GetBoard()->GetVisibleLayers();
3909 LSET enabledLayers =
m_frame->GetBoard()->GetEnabledLayers();
3912 wxCHECK( !enabledLayerStack.empty(), );
3914 auto isZoneFillKeepout =
3919 const ZONE* zone =
static_cast<const ZONE*
>( aItem );
3928 std::vector<LAYER_OPACITY_ITEM> opacityStackup;
3930 for(
int i = 0; i < aCollector.
GetCount(); i++ )
3934 LSET itemLayers = item->
GetLayerSet() & enabledLayers & visibleLayers;
3935 LSEQ itemLayerSeq = itemLayers.
Seq( enabledLayerStack );
3948 opacityItem.
m_Item = item;
3950 if( isZoneFillKeepout( item ) )
3953 opacityStackup.emplace_back( opacityItem );
3957 std::sort( opacityStackup.begin(), opacityStackup.end(),
3960 int retv = enabledLayerStack.TestLayers( aLhs.m_Layer, aRhs.m_Layer );
3965 return aLhs.m_Opacity > aRhs.m_Opacity;
3968 std::set<const BOARD_ITEM*> visibleItems;
3969 std::set<const BOARD_ITEM*> itemsToRemove;
3971 double currentStackupOpacity = 0.0;
3978 currentStackupOpacity = opacityItem.m_Opacity;
3979 lastVisibleLayer = opacityItem.m_Layer;
3980 visibleItems.emplace( opacityItem.m_Item );
3990 wxCHECK( item,
false );
3993 if( visibleItems.count( item ) )
3999 && visibleItems.count( item->
GetParent() ) )
4006 if( isZoneFillKeepout( item ) )
4013 if( opacityItem.m_Layer == enabledLayerStack[0] )
4015 visibleItems.emplace( opacityItem.m_Item );
4019 double itemVisibility = opacityItem.m_Opacity * ( 1.0 - currentStackupOpacity );
4021 if( ( itemVisibility <= minAlphaLimit ) && !ignoreItem() )
4022 itemsToRemove.emplace( opacityItem.m_Item );
4024 visibleItems.emplace( opacityItem.m_Item );
4027 if( opacityItem.m_Layer != lastVisibleLayer )
4029 currentStackupOpacity += opacityItem.m_Opacity * ( 1.0 - currentStackupOpacity );
4030 currentStackupOpacity = std::min( currentStackupOpacity, 1.0 );
4031 lastVisibleLayer = opacityItem.m_Layer;
4035 for(
const BOARD_ITEM* itemToRemove : itemsToRemove )
4037 wxCHECK( aCollector.
GetCount() > 1, );
4038 aCollector.
Remove( itemToRemove );
4061 static std::vector<KICAD_T> singleLayerSilkTypes = {
PCB_FIELD_T,
4073 std::set<BOARD_ITEM*> preferred;
4074 std::set<BOARD_ITEM*> rejected;
4081 if( silkLayers[activeLayer] )
4083 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4087 if( item->
IsType( singleLayerSilkTypes ) && silkLayers[ item->
GetLayer() ] )
4088 preferred.insert( item );
4093 else if( courtyardLayers[activeLayer] && settings->
GetHighContrast() )
4095 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4100 preferred.insert( item );
4104 if( preferred.size() > 0 )
4109 aCollector.
Append( item );
4111 if( preferred.size() == 1 )
4116 constexpr int MAX_SLOP = 5;
4120 int minSlop = INT_MAX;
4122 std::map<BOARD_ITEM*, int> itemsBySloppiness;
4124 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4129 itemsBySloppiness[ item ] = itemSlop;
4131 if( itemSlop < minSlop )
4136 if( minSlop < INT_MAX )
4138 for( std::pair<BOARD_ITEM*, int> pair : itemsBySloppiness )
4140 if( pair.second > minSlop + singlePixel )
4147 constexpr double sizeRatio = 1.5;
4149 std::vector<std::pair<BOARD_ITEM*, double>> itemsByArea;
4151 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4160 area = (double)
SEG::Square( singlePixel ) * MAX_SLOP;
4179 catch(
const std::exception& e )
4181 wxFAIL_MSG( wxString::Format( wxT(
"Clipper exception occurred: %s" ), e.what() ) );
4185 itemsByArea.emplace_back( item, area );
4188 std::sort( itemsByArea.begin(), itemsByArea.end(),
4189 [](
const std::pair<BOARD_ITEM*, double>& lhs,
4190 const std::pair<BOARD_ITEM*, double>& rhs ) ->
bool
4192 return lhs.second < rhs.second;
4195 bool rejecting =
false;
4197 for(
int i = 1; i < (int) itemsByArea.size(); ++i )
4199 if( itemsByArea[i].second > itemsByArea[i-1].second * sizeRatio )
4203 rejected.insert( itemsByArea[i].first );
4208 constexpr double maxCoverRatio = 0.70;
4210 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4214 if( footprint->CoverageRatio( aCollector ) > maxCoverRatio )
4215 rejected.erase( footprint );
4220 if( (
unsigned) aCollector.
GetCount() > rejected.size() )
4232 bool haveItemOnActive =
false;
4235 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4237 if( !aCollector[i]->IsOnLayer( activeLayer ) )
4238 rejected.insert( aCollector[i] );
4240 haveItemOnActive =
true;
4243 if( haveItemOnActive )
4257 for(
int i = (
int) aCollector.
GetCount() - 1; i >= 0; --i )
4260 bool lockedDescendant =
false;
4266 lockedDescendant =
true;
4270 if( item->
IsLocked() || lockedDescendant )
4271 aCollector.
Remove( item );
4279 std::unordered_set<EDA_ITEM*> toAdd;
4283 for(
int j = 0; j < aCollector.
GetCount(); j++ )
4285 if( aCollector[j]->GetParent() )
4286 aCollector[j]->GetParent()->ClearFlags(
CANDIDATE );
4288 if( aCollector[j]->GetParentFootprint() )
4289 aCollector[j]->GetParentFootprint()->ClearFlags(
CANDIDATE );
4294 for(
int j = 0; j < aCollector.
GetCount(); j++ )
4298 for(
int j = 0; j < aCollector.
GetCount(); )
4310 aCollector.
Remove( item );
4318 if(
top->AsEdaItem() != item )
4320 toAdd.insert(
top->AsEdaItem() );
4323 aCollector.
Remove( item );
4332 aCollector.
Remove( item );
4341 if( !aCollector.
HasItem( item ) )
4342 aCollector.
Append( item );
4349 std::set<BOARD_ITEM*> to_add;
4352 for(
int i = (
int) aCollector.
GetCount() - 1; i >= 0; --i )
4361 aCollector.
Remove( item );
4366 aCollector.
Append( item );
4371 bool aForcePromotion )
const
4373 std::set<BOARD_ITEM*> to_add;
4376 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
4381 && ( !
frame()->GetPcbNewSettings()->m_AllowFreePads || aForcePromotion ) )
4386 aCollector.
Remove( item );
4391 aCollector.
Append( item );
4398 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
4403 aCollector.
Remove( item );
4415 bool need_direct_hit =
false;
4423 need_direct_hit =
true;
4431 else if( item->IsBOARD_ITEM() )
4432 fp =
static_cast<BOARD_ITEM*
>( item )->GetParentFootprint();
4438 single_fp =
nullptr;
4441 else if( !single_fp )
4447 else if( single_fp != fp )
4449 single_fp =
nullptr;
4455 auto visibleLayers =
4463 set.
set( layer,
view()->IsLayerVisible( layer ) );
4473 LSET layers = visibleLayers();
4481 for(
int layer : activeLayers )
4484 layers.
set( layer );
4489 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
4505 aCollector.
Remove( item );
4507 bool has_hit =
false;
4521 aCollector.
Remove( item );
4526 else if( single_fp )
4528 if( fp == single_fp )
4531 else if( need_direct_hit )
4545 aCollector.
Remove( item );
4562 std::set<std::pair<PCB_TABLE*, int>> columns;
4570 columns.insert( std::make_pair(
table, cell->GetColumn() ) );
4574 for(
auto& [
table, col ] : columns )
4576 for(
int row = 0; row <
table->GetRowCount(); ++row )
4597 std::set<std::pair<PCB_TABLE*, int>> rows;
4605 rows.insert( std::make_pair(
table, cell->GetRow() ) );
4609 for(
auto& [
table, row ] : rows )
4611 for(
int col = 0; col <
table->GetColCount(); ++col )
4632 std::set<PCB_TABLE*> tables;
4638 tables.insert(
static_cast<PCB_TABLE*
>( cell->GetParent() ) );
4645 if( !
table->IsSelected() )
std::function< void(const VECTOR2I &, GENERAL_COLLECTOR &, PCB_SELECTION_TOOL *)> CLIENT_SELECTION_FILTER
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION cancelInteractive
static TOOL_ACTION unselectAll
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
static TOOL_ACTION cursorLeft
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION unselectItem
static TOOL_ACTION zoomIn
static TOOL_ACTION cursorLeftFast
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
static TOOL_ACTION selectSetLasso
static TOOL_ACTION selectSetRect
Set lasso selection mode.
static TOOL_ACTION groupEnter
static TOOL_ACTION selectColumns
static TOOL_ACTION cursorDown
static TOOL_ACTION zoomOut
static TOOL_ACTION cursorRightFast
static TOOL_ACTION zoomCenter
static TOOL_ACTION panDown
static TOOL_ACTION cursorDblClick
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION cursorDownFast
static TOOL_ACTION selectionMenu
Run a selection menu to select from a list of items.
static TOOL_ACTION reselectItem
static TOOL_ACTION selectRows
static TOOL_ACTION cursorUpFast
static TOOL_ACTION panLeft
static TOOL_ACTION updateMenu
static TOOL_ACTION doDelete
static TOOL_ACTION selectionTool
static TOOL_ACTION cursorClick
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION increment
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION zoomFitObjects
static TOOL_ACTION zoomInCenter
static TOOL_ACTION panRight
static TOOL_ACTION selectTable
static TOOL_ACTION cursorUp
Cursor control with keyboard.
static TOOL_ACTION groupLeave
static TOOL_ACTION finishInteractive
static TOOL_ACTION cursorRight
static TOOL_ACTION selectAll
static TOOL_ACTION unselectItems
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
BASE_SET & reset(size_t pos)
BASE_SET & set(size_t pos)
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
static bool ClassOf(const EDA_ITEM *aItem)
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
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 bool IsConnected() const
Returns information if the object is derived from BOARD_CONNECTED_ITEM.
bool IsLocked() const override
virtual VECTOR2I GetCenter() const
This defaults to the center of the bounding box if not overridden.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
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 bool IsOnCopperLayer() const
Information pertinent to a Pcbnew printed circuit board.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
const LSET & GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
constexpr void SetMaximum()
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr const SizeVec & GetSize() const
CN_ANCHOR represents a physical location that can be connected: a pad or a track/arc/via endpoint.
BOARD_CONNECTED_ITEM * Parent() const
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
virtual double OnePixelInIU() const =0
void Transfer(int aIndex)
Move the item at aIndex (first position is 0) to the backup list.
void Empty()
Clear the list.
int GetCount() const
Return the number of objects in the list.
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
void Append(EDA_ITEM *item)
Add an item to the end of the list.
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
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
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
EDA_ITEM * GetParent() const
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
EDA_ITEM_FLAGS GetFlags() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
virtual std::vector< SHAPE * > MakeEffectiveShapesForHitTesting() const
virtual bool IsVisible() const
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, const BOX2I &aBBox=BOX2I(), const EDA_ANGLE &aAngle=ANGLE_0) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
static const TOOL_EVENT DisambiguatePoint
Used for hotkey feedback.
static const TOOL_EVENT ClearedEvent
static const TOOL_EVENT InhibitSelectionEditing
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 UninhibitSelectionEditing
Used to inform tool that it should display the disambiguation menu.
static const TOOL_EVENT PointSelectedEvent
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
static const TOOL_EVENT UnselectedEvent
A general implementation of a COLLECTORS_GUIDE.
void SetIgnoreBlindBuriedVias(bool ignore)
void SetIgnoreTracks(bool ignore)
void SetIgnoreFootprintsOnFront(bool ignore)
void SetIgnoreFPTextOnFront(bool ignore)
void SetIgnoreMicroVias(bool ignore)
void SetIgnoreZoneFills(bool ignore)
void SetIgnorePadsOnBack(bool ignore)
void SetIgnoreFPTextOnBack(bool ignore)
void SetLayerVisibleBits(const LSET &aLayerBits)
void SetIgnoreThroughVias(bool ignore)
void SetIgnoreThroughHolePads(bool ignore)
void SetIgnoreFPReferences(bool ignore)
void SetIgnoreFPValues(bool ignore)
void SetIgnorePadsOnFront(bool ignore)
void SetIgnoreFootprintsOnBack(bool ignore)
Used when the right click button is pressed, or when the select tool is in effect.
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
const COLLECTORS_GUIDE * GetGuide() const
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
void Collect(BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
static const std::vector< KICAD_T > FootprintItems
A scan list for primary footprint items.
A color representation with 4 components: red, green, blue, alpha.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between two poin...
VECTOR2I GetOrigin() const
void SetMode(SELECTION_MODE aMode)
void SetSubtractive(bool aSubtractive)
SELECTION_MODE GetMode() const
void SetAdditive(bool aAdditive)
void SetPoly(SHAPE_LINE_CHAIN &aPoly)
void SetOrigin(const VECTOR2I &aOrigin)
const BOX2I ViewBBox() const override
Set the origin of the rectangle (the fixed corner)
SHAPE_LINE_CHAIN & GetPoly()
void SetExclusiveOr(bool aExclusiveOr)
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
const std::set< int > GetHighContrastLayers() const
Returns the set of currently high-contrast layers.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const =0
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
bool GetHighContrast() const
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
An abstract base class for deriving all objects that can be added to a VIEW.
bool IsBOARD_ITEM() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
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.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
wxString AsString() const
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
LSEQ SeqStackupTop2Bottom(PCB_LAYER_ID aSelectedLayer=UNDEFINED_LAYER) const
Generate a sequence of layers that represent a top to bottom stack of this set of layers.
static const LSET & AllLayersMask()
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
const VECTOR2I & GetPos() const
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
Handle the data for a net.
static TOOL_ACTION deleteLastPoint
static TOOL_ACTION drag45Degree
static TOOL_ACTION unrouteSelected
Removes all tracks from the selected items to the first pad.
static TOOL_ACTION saveToLinkedDesignBlock
static TOOL_ACTION grabUnconnected
Select and move nearest unconnected footprint from ratsnest of selection.
static TOOL_ACTION filterSelection
Filter the items in the current selection (invokes dialog)
static TOOL_ACTION highlightNet
static TOOL_ACTION hideLocalRatsnest
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION selectOnSheetFromEeschema
Select all components on sheet from Eeschema crossprobing.
static TOOL_ACTION selectConnection
Select tracks between junctions or expands an existing selection to pads or the entire connection.
static TOOL_ACTION applyDesignBlockLayout
static TOOL_ACTION dragFreeAngle
static TOOL_ACTION clearHighlight
static TOOL_ACTION selectUnconnected
Select unconnected footprints from ratsnest of selection.
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 syncSelection
Sets selection to specified items, zooms to fit, if enabled.
static TOOL_ACTION selectSameSheet
Select all components on the same sheet as the selected footprint.
static TOOL_ACTION selectNet
Select all connections belonging to a single net.
static TOOL_ACTION move
move or drag an item
static TOOL_ACTION syncSelectionWithNets
Sets selection to specified items with connected nets, zooms to fit, if enabled.
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
static TOOL_ACTION placeLinkedDesignBlock
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
Common, abstract interface for edit frames.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
double m_TrackOpacity
Opacity override for all tracks.
double m_FilledShapeOpacity
Opacity override for graphic shapes.
double m_ZoneOpacity
Opacity override for filled zone areas.
double m_ImageOpacity
Opacity override for user images.
double m_PadOpacity
Opacity override for SMD pads and PTHs.
double m_ViaOpacity
Opacity override for all types of via.
ZONE_DISPLAY_MODE m_ZoneDisplayMode
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
A set of BOARD_ITEMs (i.e., without duplicates).
static bool WithinScope(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
static EDA_GROUP * TopLevelGroup(BOARD_ITEM *aItem, EDA_GROUP *aScope, bool isFootprintEditor)
std::unordered_set< BOARD_ITEM * > GetBoardItems() const
Tool that displays edit points allowing to modify items by dragging the points.
bool HasPoint()
Indicate the cursor is over an edit point.
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
std::vector< VECTOR2I > GetConnectionPoints() const
std::vector< PCB_TABLECELL * > GetCells() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
A small class to help profiling.
void Start()
Start or restart the counter.
double msecs(bool aSinceLast=false)
static SEG::ecoord Square(int a)
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 void Add(EDA_ITEM *aItem)
virtual void Remove(EDA_ITEM *aItem)
void ClearReferencePoint()
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Move(const VECTOR2I &aVector) override
void GenerateBBoxCache() const
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if point aP lies closer to us than aClearance.
double Area(bool aAbsolute=true) const
Return the area of this chain.
virtual size_t GetPointCount() const override
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
void Remove(int aStartIndex, int aEndIndex)
Remove the range of points [start_index, end_index] from the line chain.
bool Collide(const SHAPE *aShape, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
virtual bool Collide(const VECTOR2I &aP, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const
Check if the boundary of shape (this) lies closer to the point aP than aClearance,...
Handle a list of polygons defining a copper zone.
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
bool HitTestForCorner(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a corner.
bool HitTestForEdge(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a segment defined by 2 corners.
bool IsTeardropArea() const
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
bool GetDoNotAllowZoneFills() const
A type-safe container of any type.
#define IGNORE_NETS
Function GetConnectedItems() Returns a list of items connected to a source item aItem.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static bool empty(const wxTextEntryBase *aCtrl)
std::function< INSPECT_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Used to inspect and possibly collect the (search) results of iterating over a list or tree of KICAD_T...
#define BRIGHTENED
item is drawn with a bright contour
#define IS_NEW
New item, just created.
#define SELECTED
Item was manually selected by the user.
#define ENTERED
indicates a group has been entered
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define CANDIDATE
flag indicating that the structure is connected
#define IS_MOVING
Item being moved.
a few functions useful in geometry calculations.
double m_PcbSelectionVisibilityRatio
Board object selection visibility limit.
@ LAYER_POINTS
PCB reference/manual snap points visibility.
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
@ LAYER_DRAW_BITMAPS
Draw images.
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
@ LAYER_DRC_EXCLUSION
Layer for DRC markers which have been individually excluded.
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored).
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
@ REPAINT
Item needs to be redrawn.
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
@ PTH
Plated through hole pad.
Class that computes missing connections on a PCB.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
Struct that will be set with the result of the user choices in the dialog.
bool includeLockedFootprints
bool includeItemsOnTechLayers
bool includeBoardOutlineLayer
const BOARD_ITEM * m_Item
This file contains data structures that are saved in the project file or project local settings file ...
bool otherItems
Anything not fitting one of the above categories.
bool vias
Vias (all types>
bool keepouts
Keepout zones.
bool graphics
Graphic lines, shapes, polygons.
bool footprints
Allow selecting entire footprints.
bool text
Text (free or attached to a footprint)
bool lockedItems
Allow selecting locked items.
bool tracks
Copper tracks.
bool dimensions
Dimension items.
KIBIS top(path, &reporter)
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
@ NOT_USED
the 3d code uses this value
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_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_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
@ 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
Casted dyn_cast(From aObject)
A lightweight dynamic downcast.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)