27using namespace std::placeholders;
159 if( oldA && oldA->
m_Uuid == newId )
160 itemA->Enable(
false );
162 if( oldB && oldB->
m_Uuid == newId )
163 itemB->Enable(
false );
268 std::shared_ptr<SELECT_MENU> selectMenu = std::make_shared<SELECT_MENU>();
269 selectMenu->SetTool(
this );
270 m_menu->RegisterSubMenu( selectMenu );
272 std::shared_ptr<NET_CHAINS_MENU> netChainsMenu = std::make_shared<NET_CHAINS_MENU>();
273 netChainsMenu->SetTool(
this );
274 m_menu->RegisterSubMenu( netChainsMenu );
278 auto& menu =
m_menu->GetMenu();
280 auto activeToolCondition =
295 auto groupEnterCondition =
298 auto applyDesignBlockLayoutCondition = [](
const SELECTION& aSel )
311 auto inGroupCondition =
322 if( aSel.GetSize() != 1 )
332 menu.AddMenu( netChainsMenu.get(), netItemSelection );
333 menu.AddSeparator( 1000 );
344 menu.AddSeparator( haveHighlight, 1 );
350 menu.AddSeparator( 1 );
394 wxMouseState keyboardState = wxGetMouseState();
396 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), keyboardState.AltDown() );
419 trackDragAction = cfg->m_TrackDragAction;
433 else if( evt->IsMouseDown(
BUT_LEFT ) )
458 if( constraintTool->SelectConstraintAt( evt->Position() ) )
464 constraintTool->ClearConstraintSelection();
497 bool selectionCancelled =
false;
501 selectPoint( evt->Position(),
false, &selectionCancelled );
506 m_frame->GetCanvas()->ForceRefresh();
508 if( !selectionCancelled )
514 else if( evt->IsDblClick(
BUT_LEFT ) )
563 const int delta = evt->Parameter<
int>();
614 wxASSERT_MSG(
false, wxT(
"Unknown selection mode" ) );
621 auto zoneFilledAreaFilter =
624 int accuracy = aCollector.GetGuide()->Accuracy();
625 std::set<EDA_ITEM*> remove;
631 ZONE* zone =
static_cast<ZONE*
>( item );
636 remove.insert( zone );
642 aCollector.Remove( item );
648 if( evt->HasPosition() )
651 &&
selectPoint( evt->DragOrigin(),
false,
nullptr, zoneFilledAreaFilter ) )
669 bool routable = ( segs >= 1 || arcs >= 1 || vias == 1 )
670 && ( segs + arcs + vias ==
m_selection.GetSize() );
694 else if( evt->IsCancel() )
709 else if( evt->FirstResponder() ==
this && evt->GetCommandId() == (
int) WXK_ESCAPE )
721 if( controller &&
m_frame->GetPcbNewSettings()->m_ESCClearsNetHighlight )
724 catch(
const std::runtime_error& e )
726 wxCHECK_MSG(
false, 0, e.what() );
737 if(
m_frame->ToolStackIsEmpty() )
743 && evt->HasPosition()
767 wxT(
"EnterGroup called when selection is not a single group" ) );
836 enum DISPOSITION { BEFORE = 1, AFTER,
BOTH };
838 std::map<EDA_ITEM*, DISPOSITION> itemDispositions;
847 itemDispositions[ item ] = BEFORE;
850 aClientFilter(
VECTOR2I(), collector,
this );
856 m_frame->GetCanvas()->ForceRefresh();
863 if( itemDispositions.count( item ) )
864 itemDispositions[ item ] =
BOTH;
866 itemDispositions[ item ] = AFTER;
874 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
876 EDA_ITEM* item = itemDisposition.first;
877 DISPOSITION disposition = itemDisposition.second;
879 if( disposition == BEFORE )
883 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
885 EDA_ITEM* item = itemDisposition.first;
886 DISPOSITION disposition = itemDisposition.second;
890 if( disposition == AFTER || disposition ==
BOTH )
894 m_frame->GetCanvas()->ForceRefresh();
950 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
952 if( !
Selectable( collector[ i ] ) || ( aOnDrag && collector[i]->IsLocked() ) )
958 size_t preFilterCount = collector.
GetCount();
965 if( collector.
GetCount() == 0 && preFilterCount > 0 )
968 editFrame->HighlightSelectionFilter( rejected );
983 aClientFilter( aWhere, collector,
this );
992 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
994 if( !collector[i]->IsSelected() )
1006 catch(
const std::exception& exc )
1008 wxLogWarning( wxS(
"Exception '%s' occurred attempting to guess selection candidates." ),
1022 if( aSelectionCancelledFlag )
1023 *aSelectionCancelledFlag =
true;
1030 bool anySubtracted =
false;
1037 anySubtracted =
true;
1043 for(
int i = 0; i < collector.
GetCount(); ++i )
1048 anySubtracted =
true;
1058 if( addedCount == 1 )
1063 else if( addedCount > 1 )
1068 else if( anySubtracted )
1105 for(
int i = 0; aAllowedActions[i]; ++i )
1107 if( aEvent->
IsAction( aAllowedActions[i] ) )
1120 if( cell->IsSelected() )
1131 BOX2I selectionRect( aStart, aEnd );
1137 return ( aItem->GetFlags() &
CANDIDATE ) > 0;
1142 bool doSelect =
false;
1144 if( cell->HitTest( selectionRect,
false ) )
1149 doSelect = !wasSelected( cell );
1153 else if( wasSelected( cell ) )
1158 if( doSelect && !cell->IsSelected() )
1160 else if( !doSelect && cell->IsSelected() )
1208 std::set<EDA_ITEM*> previousSelection;
1211 previousSelection.insert( item );
1223 VECTOR2D topLeft( std::min( start.
x,
end.x ), std::min( start.
y,
end.y ) );
1224 VECTOR2D bottomRight( std::max( start.
x,
end.x ), std::max( start.
y,
end.y ) );
1228 bool anyAdded =
false;
1229 bool anySubtracted =
false;
1233 bool wasInPrevious = previousSelection.count( cell ) > 0;
1235 if( cell->IsSelected() && !wasInPrevious )
1237 else if( wasInPrevious && !cell->IsSelected() )
1238 anySubtracted =
true;
1289 if( !cell || cell->
GetParent() != selectedTable )
1301 if( clickedCell->
GetParent() != selectedTable )
1324 bool cancelled =
false;
1330 bool haveAnchorStart =
false;
1337 haveAnchorStart =
true;
1349 return ( aItem->GetFlags() &
CANDIDATE ) > 0;
1354 if( evt->IsCancelInteractive() || evt->IsActivate() )
1363 VECTOR2D start = haveAnchorStart ? anchorStart :
VECTOR2D( evt->DragOrigin() );
1368 else if( evt->IsMouseUp(
BUT_LEFT ) )
1372 bool anyAdded =
false;
1373 bool anySubtracted =
false;
1377 if( cell->IsSelected() && !wasSelected( cell ) )
1379 else if( wasSelected( cell ) && !cell->IsSelected() )
1380 anySubtracted =
true;
1412 bool cancelled =
false;
1427 if(
view->IsMirroredX() )
1428 greedySelection = !greedySelection;
1433 if( evt->IsCancelInteractive() || evt->IsActivate() )
1452 area.
SetEnd( evt->Position() );
1458 view->SetVisible( &area,
true );
1459 view->Update( &area );
1468 view->SetVisible( &area,
false );
1482 view->Remove( &area );
1514 bool cancelled =
false;
1532 bool isClockwise = shapeArea > 0 ? true :
false;
1534 if(
getView()->IsMirroredX() && shapeArea != 0 )
1535 isClockwise = !isClockwise;
1539 if( evt->IsCancelInteractive() || evt->IsActivate() )
1542 evt->SetPassEvent(
false );
1549 points.
Append( evt->Position() );
1551 else if( evt->IsDblClick(
BUT_LEFT )
1557 evt->SetPassEvent(
false );
1593 area.
SetMode( selectionMode );
1616 bool anyAdded =
false;
1617 bool anySubtracted =
false;
1625 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
1627 view->Query( selectionBox, candidates );
1631 std::set<EDA_ITEM*> group_items;
1639 std::unordered_set<EDA_ITEM*>& newset =
group->GetItems();
1642 [&](
const BOX2I& aBox )
1644 return boxMode ? selectionBox.
Contains( aBox )
1650 if( containedMode && boxContained(
group->GetBoundingBox() ) && newset.size() )
1652 for(
EDA_ITEM* group_item : newset )
1654 if( !group_item->IsBOARD_ITEM() )
1658 collector.
Append( *newset.begin() );
1662 for(
EDA_ITEM* group_item : newset )
1663 group_items.emplace( group_item );
1669 return boxMode ? aItem->HitTest( selectionBox, containedMode )
1670 : aItem->HitTest( aArea.
GetPoly(), containedMode );
1673 for(
const auto& [item, layer] : candidates )
1675 if( !item->IsBOARD_ITEM() )
1680 if(
Selectable( boardItem ) && hitTest( boardItem )
1681 && ( !containedMode || !group_items.count( boardItem ) ) )
1684 padsCollector.
Append( boardItem );
1686 collector.
Append( boardItem );
1698 collector = padsCollector;
1705 std::sort( collector.
begin(), collector.
end(),
1708 VECTOR2I aPos = a->GetPosition();
1709 VECTOR2I bPos = b->GetPosition();
1711 if( aPos.y == bPos.y )
1712 return aPos.x < bPos.x;
1714 return aPos.y < bPos.y;
1719 if( !i->IsBOARD_ITEM() )
1724 if( aSubtractive || ( aExclusiveOr && item->
IsSelected() ) )
1727 anySubtracted =
true;
1741 else if( anySubtracted )
1748 wxMouseState keyboardState = wxGetMouseState();
1750 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), keyboardState.AltDown() );
1794 collection.
Append( item );
1807 m_frame->GetCanvas()->ForceRefresh();
1835 m_frame->GetCanvas()->ForceRefresh();
1845 std::set<int> representedNets;
1847 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
1853 else if ( representedNets.count( item->
GetNetCode() ) )
1856 representedNets.insert( item->
GetNetCode() );
1863 std::deque<EDA_ITEM*> selectedItems =
m_selection.GetItems();
1866 std::vector<BOARD_CONNECTED_ITEM*> toUnroute;
1867 std::set<EDA_ITEM*> toDelete;
1869 for(
EDA_ITEM* item : selectedItems )
1874 toUnroute.push_back(
pad );
1878 toDelete.insert( item );
1894 std::set<int> selectedNets;
1897 if( item->GetNetCode() > 0 )
1898 selectedNets.insert( item->GetNetCode() );
1900 std::set<VECTOR2I> endpointSet;
1906 endpointSet.insert( track->GetStart() );
1907 endpointSet.insert( track->GetEnd() );
1911 endpointSet.insert( item->GetPosition() );
1915 endpointSet.insert( item->GetPosition() );
1919 bool expanded =
true;
1927 if( toDelete.count( gen ) )
1931 std::map<VECTOR2I, int> epCount;
1933 for(
BOARD_ITEM* child : gen->GetBoardItems() )
1937 if( track && selectedNets.count( track->
GetNetCode() ) )
1940 epCount[track->
GetEnd()]++;
1945 bool connected =
false;
1947 for(
auto& [pt, count] : epCount )
1949 if( count == 1 && endpointSet.count( pt ) )
1958 toDelete.insert( gen );
1972 endpointSet.insert( track->GetStart() );
1973 endpointSet.insert( track->GetEnd() );
1996 std::set<BOARD_ITEM*> removed;
2000 if( !item->IsBOARD_ITEM() )
2006 toDelete.insert( bi );
2009 removed.insert( bi );
2015 for(
BOARD_ITEM* child : gen->GetBoardItems() )
2017 if( removed.count( child ) )
2019 toDelete.insert( gen );
2027 if( !item->IsBOARD_ITEM() )
2035 if( removed.find( aItem ) == removed.end() )
2038 removed.insert( aItem );
2043 if( removed.find( boardItem ) == removed.end() )
2044 commit.
Remove( boardItem );
2048 commit.
Push(
_(
"Unroute Selected" ) );
2053 for(
EDA_ITEM* item : selectedItems )
2065 std::deque<EDA_ITEM*> selectedItems =
m_selection.GetItems();
2068 std::vector<BOARD_CONNECTED_ITEM*> toUnroute;
2070 std::set<EDA_ITEM*> toDelete;
2072 for(
EDA_ITEM* item : selectedItems )
2083 if( !toDelete.count( gen ) )
2085 toDelete.insert( gen );
2089 toDelete.insert( generatedItem );
2099 toDelete.insert( item );
2104 toDelete.insert( item );
2108 toDelete.insert( generatedItem );
2119 std::deque<EDA_ITEM*> toSelectAfter;
2123 if( !item->IsBOARD_ITEM() )
2126 if( toDelete.find( item ) == toDelete.end() )
2127 toSelectAfter.push_back( item );
2131 std::set<BOARD_ITEM*> removed;
2135 if( !item->IsBOARD_ITEM() )
2145 if( removed.insert( aItem ).second )
2150 if( removed.insert( boardItem ).second )
2151 commit.
Remove( boardItem );
2155 if( removed.insert( boardItem ).second )
2156 commit.
Remove( boardItem );
2160 commit.
Push(
_(
"Unroute Segment" ) );
2165 for(
EDA_ITEM* item : toSelectAfter )
2167 if( !toDelete.count( item ) )
2180 unsigned initialCount = 0;
2192 if( initialCount == 0 )
2195 std::vector<PCB_SHAPE*> startShapes;
2200 startShapes.push_back(
static_cast<PCB_SHAPE*
>( item ) );
2204 if( !startShapes.empty() )
2210 m_frame->SetStatusText(
_(
"Select/Expand Connection..." ) );
2214 std::deque<EDA_ITEM*> selectedItems =
m_selection.GetItems();
2216 for(
EDA_ITEM* item : selectedItems )
2217 item->ClearTempFlags();
2219 std::vector<BOARD_CONNECTED_ITEM*> startItems;
2221 for(
EDA_ITEM* item : selectedItems )
2228 startItems.push_back(
pad );
2246 if(
m_selection.GetItems().size() > initialCount )
2250 m_frame->SetStatusText( wxEmptyString );
2263 double refreshIntervalMs = 500;
2264 int lastSelectionSize = (int)
m_selection.GetSize();
2274 std::set<PAD*> startPadSet;
2275 std::vector<BOARD_CONNECTED_ITEM*> cleanupItems;
2281 startPadSet.insert(
static_cast<PAD*
>( startItem ) );
2284 if( startItem->IsType( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
2293 std::map<VECTOR2I, std::vector<PCB_TRACK*>> trackMap;
2294 std::map<VECTOR2I, PCB_VIA*> viaMap;
2295 std::map<VECTOR2I, PAD*> padMap;
2296 std::map<VECTOR2I, std::vector<PCB_SHAPE*>> shapeMap;
2297 std::vector<std::pair<VECTOR2I, LSET>> activePts;
2307 switch( item->Type() )
2313 trackMap[track->
GetStart()].push_back( track );
2314 trackMap[track->
GetEnd()].push_back( track );
2321 viaMap[
via->GetStart()] =
via;
2328 padMap[
pad->GetPosition()] =
pad;
2337 shapeMap[point].push_back( shape );
2348 switch( startItem->Type() )
2361 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
2365 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
2373 activePts.push_back( { point, startItem->GetLayerSet() } );
2386 while( expand && failSafe++ < 100000 )
2390 for(
int i = (
int) activePts.size() - 1; i >= 0; --i )
2398 auto exactIt = viaMap.find( pt );
2400 if( exactIt != viaMap.end() && ( exactIt->second->GetLayerSet() & layerSetCu ).any() )
2402 hitVia = exactIt->second;
2407 for(
auto& [pos,
via] : viaMap )
2409 if( !(
via->GetLayerSet() & layerSetCu ).any() )
2416 int radius =
via->GetWidth( layer ) / 2;
2417 int64_t radiusSq =
static_cast<int64_t
>(
radius ) *
radius;
2419 if( ( pt - pos ).SquaredEuclideanNorm() <= radiusSq )
2434 auto padIt = padMap.find( pt );
2436 bool gotVia = hitVia !=
nullptr;
2437 bool gotPad = padIt != padMap.end() && ( padIt->second->GetLayerSet() & layerSetCu ).any();
2438 bool gotNonStartPad = gotPad && ( startPadSet.find( padIt->second ) == startPadSet.end() );
2442 activePts.erase( activePts.begin() + i );
2448 activePts.erase( activePts.begin() + i );
2454 size_t pt_count = 0;
2458 if( track->GetStart() != track->GetEnd() && layerSetCu.
Contains( track->GetLayer() ) )
2462 if( pt_count > 2 || gotVia || gotNonStartPad )
2464 activePts.erase( activePts.begin() + i );
2470 if( gotNonStartPad )
2472 activePts.erase( activePts.begin() + i );
2479 PAD*
pad = padIt->second;
2484 cleanupItems.push_back(
pad );
2486 activePts.push_back( {
pad->GetPosition(),
pad->GetLayerSet() } );
2493 if( !layerSetCu.
Contains( track->GetLayer() ) )
2499 if( !track->IsSelected() && inScope( track ) )
2505 cleanupItems.push_back( track );
2507 if( track->GetStart() == pt )
2508 activePts.push_back( { track->GetEnd(), track->GetLayerSet() } );
2510 activePts.push_back( { track->GetStart(), track->GetLayerSet() } );
2519 if( !layerSetCu.
Contains( shape->GetLayer() ) )
2525 if( !shape->IsSelected() && inScope( shape ) )
2531 cleanupItems.push_back( shape );
2533 for(
const VECTOR2I& newPoint : shape->GetConnectionPoints() )
2535 if( newPoint == pt )
2538 activePts.push_back( { newPoint, shape->GetLayerSet() } );
2548 if( !hitVia->
IsSelected() && inScope( hitVia ) )
2554 cleanupItems.push_back( hitVia );
2561 maxRadius = std::max( maxRadius, hitVia->
GetWidth( layer ) / 2 );
2563 int64_t maxRadiusSq =
static_cast<int64_t
>( maxRadius ) * maxRadius;
2565 for(
auto& [trkPt, tracks] : trackMap )
2567 if( ( trkPt - viaPos ).SquaredEuclideanNorm() > maxRadiusSq )
2571 bool inside =
false;
2580 int r = hitVia->
GetWidth( trkLayer ) / 2;
2581 int64_t rSq =
static_cast<int64_t
>( r ) * r;
2583 if( ( trkPt - viaPos ).SquaredEuclideanNorm() <= rSq )
2591 activePts.push_back( { trkPt, hitVia->
GetLayerSet() } );
2599 activePts.erase( activePts.begin() + i );
2603 if( refreshTimer.
msecs() >= refreshIntervalMs )
2607 m_frame->GetCanvas()->ForceRefresh();
2611 refreshTimer.
Start();
2616 std::set<EDA_ITEM*> toDeselect;
2617 std::set<EDA_ITEM*> toSelect;
2622 if( !item->IsBOARD_ITEM() )
2630 toDeselect.insert( item );
2675 std::stack<PCB_SHAPE*> toSearch;
2676 std::set<PCB_SHAPE*> toCleanup;
2678 for(
PCB_SHAPE* startItem : aStartItems )
2679 toSearch.push( startItem );
2692 toSearch.push(
static_cast<PCB_SHAPE*
>( item ) );
2696 while( !toSearch.empty() )
2705 toCleanup.insert( shape );
2714 searchPoint( shape->
GetEnd() );
2725 std::vector<PAD*> pads;
2732 pads.push_back(
pad );
2736 pads.push_back(
static_cast<PAD*
>( item ) );
2745 for(
const CN_EDGE& edge : conn->GetRatsnestForPad(
pad ) )
2747 wxCHECK2( edge.GetSourceNode() && !edge.GetSourceNode()->Dirty(),
continue );
2748 wxCHECK2( edge.GetTargetNode() && !edge.GetTargetNode()->Dirty(),
continue );
2753 if( sourceParent ==
pad )
2756 select(
static_cast<PAD*
>( targetParent )->GetParent() );
2758 else if( targetParent ==
pad )
2761 select(
static_cast<PAD*
>( sourceParent )->GetParent() );
2775 std::vector<BOARD_CONNECTED_ITEM*> sourceItems;
2782 sourceItems.push_back(
pad );
2786 sourceItems.push_back( connItem );
2793 std::shared_ptr<CN_CONNECTIVITY_ALGO> connAlgo = conn->GetConnectivityAlgo();
2797 RN_NET* net = conn->GetRatsnestForNet( sourceItem->GetNetCode() );
2800 if( !net || net->
GetEdges().empty() || !connAlgo->ItemExists( sourceItem ) )
2803 std::vector<std::shared_ptr<CN_CLUSTER>> sourceClusters;
2805 for(
CN_ITEM* cnItem : connAlgo->ItemEntry( sourceItem ).GetItems() )
2807 for(
const std::shared_ptr<CN_ANCHOR>&
anchor : cnItem->Anchors() )
2809 if(
anchor->GetCluster() )
2810 sourceClusters.push_back(
anchor->GetCluster() );
2814 if( sourceClusters.empty() )
2817 auto isSourceAnchor =
2818 [&](
const std::shared_ptr<const CN_ANCHOR>& aAnchor )
2820 if( aAnchor->Parent() == sourceItem )
2823 return std::find( sourceClusters.begin(), sourceClusters.end(),
2824 aAnchor->GetCluster() ) != sourceClusters.end();
2827 double currentDistance = DBL_MAX;
2833 const std::shared_ptr<const CN_ANCHOR>& source = edge.GetSourceNode();
2834 const std::shared_ptr<const CN_ANCHOR>& target = edge.GetTargetNode();
2836 wxCHECK2( source && !source->Dirty() && target && !target->Dirty(),
continue );
2838 if( source->Parent()->GetParentFootprint() == target->Parent()->GetParentFootprint() )
2843 bool sourceMatches = isSourceAnchor( source );
2844 bool targetMatches = isSourceAnchor( target );
2846 if( sourceMatches == targetMatches )
2849 const CN_ANCHOR* other = sourceMatches ? target.get() : source.get();
2855 if( edge.GetLength() < currentDistance )
2857 currentDistance = edge.GetLength();
2862 if( nearest !=
nullptr )
2876 for(
BOARD_ITEM* item : conn->GetNetItems( aNetCode, { PCB_TRACE_T,
2950 const wxString& chainName = netInfo->
GetNetChain();
2952 if( chainName.IsEmpty() )
2961 if( candidate && candidate->GetNetChain() == chainName )
2977 std::vector<BOARD_ITEM*> footprints;
2982 if( footprint ==
nullptr )
2985 wxString footprint_path = footprint->GetPath().AsString().BeforeLast(
'/' );
2987 if( footprint_path.IsEmpty() )
2988 footprint_path +=
'/';
2990 if( footprint_path == aSheetPath )
2991 footprints.push_back( footprint );
3007 std::list<int> netcodeList;
3008 std::vector<BOARD_CONNECTED_ITEM*> padList;
3012 switch( item->Type() )
3018 if(
pad->IsConnected() )
3020 netcodeList.push_back(
pad->GetNetCode() );
3021 padList.push_back(
pad );
3032 if(
pad->IsConnected() )
3034 netcodeList.push_back(
pad->GetNetCode() );
3035 padList.push_back(
pad );
3047 std::sort( padList.begin(), padList.end() );
3051 netcodeList.unique();
3057 std::vector<int> removeCodeList;
3060 for(
int netCode : netcodeList )
3064 if( !std::binary_search( padList.begin(), padList.end(),
pad ) )
3068 removeCodeList.push_back( netCode );
3074 for(
int removeCode : removeCodeList )
3075 netcodeList.remove( removeCode );
3077 std::unordered_set<BOARD_ITEM*> localConnectionList;
3079 for(
int netCode : netcodeList )
3081 for(
BOARD_ITEM* item : conn->GetNetItems( netCode, { PCB_TRACE_T,
3086 localConnectionList.insert( item );
3090 for(
BOARD_ITEM* item : localConnectionList )
3097 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
3108 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
3126 if( item->IsMoving() )
3143 if(
m_frame->GetPcbNewSettings()->m_CrossProbing.center_on_items )
3145 if(
m_frame->GetPcbNewSettings()->m_CrossProbing.zoom_to_fit )
3154 m_frame->GetCanvas()->ForceRefresh();
3164 wxString sheetPath = *aEvent.
Parameter<wxString*>();
3190 if( !footprint || footprint->
GetPath().empty() )
3196 wxString sheetPath = footprint->
GetPath().
AsString().BeforeLast(
'/' );
3198 if( sheetPath.IsEmpty() )
3219 screenSize.
x = std::max( 10.0, screenSize.
x );
3220 screenSize.
y = std::max( 10.0, screenSize.
y );
3225 double scale =
view->GetScale() / std::max( fabs( vsize.
x / screenSize.
x ),
3226 fabs( vsize.
y / screenSize.
y ) );
3232 m_frame->GetCanvas()->ForceRefresh();
3248#ifdef DEFAULT_PCBNEW_CODE
3250 auto screenSize =
view->ToWorld( GetCanvas()->GetClientSize(),
false );
3253 screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
3254 screenSize.y = std::max( 10.0, screenSize.y );
3255 double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
3258 if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) )
3259 view->SetScale(
view->GetScale() / ratio );
3262#ifndef DEFAULT_PCBNEW_CODE
3279 double compRatio = bbSize.y / currTextHeight;
3282 double compRatioBent = 1.0;
3293 screenSize.
x = std::max( 10.0, fabs( screenSize.
x ) );
3294 screenSize.
y = std::max( 10.0, screenSize.
y );
3295 double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.
y ) );
3298 double kicadRatio = std::max( fabs( bbSize.x / screenSize.
x ),
3299 fabs( bbSize.y / screenSize.
y ) );
3307 std::vector<std::pair<double, double>> lut {
3320 std::vector<std::pair<double, double>>::iterator it;
3322 compRatioBent = lut.back().second;
3324 if( compRatio >= lut.front().first )
3330 for( it = lut.begin(); it < lut.end() - 1; it++ )
3332 if( it->first <= compRatio &&
next( it )->first >= compRatio )
3334 double diffx = compRatio - it->first;
3335 double diffn =
next( it )->first - it->first;
3337 compRatioBent = it->second + (
next( it )->second - it->second ) * diffx / diffn;
3344 compRatioBent = lut.front().second;
3352 if( bbSize.x > screenSize.
x * ratio * compRatioBent )
3356 compRatioBent = 1.0;
3357 wxLogTrace(
"CROSS_PROBE_SCALE",
"Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
3362 ratio *= compRatioBent;
3364 bool alwaysZoom =
false;
3367 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
3368 view->SetScale(
view->GetScale() / ratio );
3375 bool cleared =
false;
3387 switch( aItem->
Type() )
3391 int netCode =
static_cast<NETINFO_ITEM*
>( aItem )->GetNetCode();
3410 double marginFactor = 2;
3419 double scaleX = screenSize.
x /
static_cast<double>( aItem->
GetBoundingBox().GetWidth() );
3420 double scaleY = screenSize.
y /
static_cast<double>( aItem->
GetBoundingBox().GetHeight() );
3422 scaleX /= marginFactor;
3423 scaleY /= marginFactor;
3425 double scale = scaleX > scaleY ? scaleY : scaleX;
3444 m_frame->GetCanvas()->ForceRefresh();
3456 switch( aItem.
Type() )
3511 if( cmd != wxID_OK )
3522 if( !i->IsBOARD_ITEM() )
3544 std::set<BOARD_ITEM*> rejected;
3548 if( !i->IsBOARD_ITEM() )
3554 rejected.insert( item );
3558 aCollector.
Remove( item );
3623 aRejected->
pads =
true;
3635 aRejected->
tracks =
true;
3646 aRejected->
vias =
true;
3655 ZONE* zone =
static_cast<ZONE*
>( aItem );
3665 aRejected->
zones =
true;
3674 if( zone ==
m_frame->GetBoard()->m_SolderMaskBridges )
3705 aRejected->
text =
true;
3741 aRejected->
points =
true;
3797 bool enteredGroupFound =
false;
3800 [&](
EDA_ITEM* item,
void* testData )
3818 enteredGroupFound =
true;
3832 if( !enteredGroupFound )
3845 auto visibleLayers =
3853 set.
set( layer,
view()->IsLayerVisible( layer ) );
3875 bool onActiveLayer =
false;
3877 for(
int layer : activeLayers )
3880 if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer(
ToLAYER_ID( layer ) ) )
3882 onActiveLayer =
true;
3905 && footprint->
Pads().empty()
3906 && footprint->
Zones().empty() )
3923 for(
const ZONE* zone : footprint->
Zones() )
3955 const ZONE* zone =
nullptr;
3957 const PAD*
pad =
nullptr;
3970 switch( aItem->
Type() )
3976 zone =
static_cast<const ZONE*
>( aItem );
3994 if( !layerVisible( aItem->
GetLayer() ) )
4006 if( !( visibleLayers() &
via->GetLayerSet() ).any() )
4012 field =
static_cast<const PCB_FIELD*
>( aItem );
4028 if( !layerVisible(
text->GetLayer() ) )
4039 if(
text->GetText() == wxT(
"${REFERENCE}" ) )
4041 else if(
text->GetText() == wxT(
"${VALUE}" ) )
4044 if( !
view()->IsLayerVisible( controlLayer ) )
4058 if( !layerVisible( aItem->
GetLayer() ) )
4067 if( !layerVisible( aItem->
GetLayer() ) )
4073 if( !layerVisible( aItem->
GetLayer() ) )
4080 if( !layerVisible( aItem->
GetLayer() ) )
4088 if( !layerVisible( aItem->
GetLayer() ) )
4101 if( !layerVisible( aItem->
GetLayer() ) )
4110 pad =
static_cast<const PAD*
>( aItem );
4121 if( !(
pad->GetLayerSet() & visibleLayers() ).
any() )
4128 marker =
static_cast<const PCB_MARKER*
>( aItem );
4136 if( !layerVisible( aItem->
GetLayer() ) )
4191 aGroup->
Add( aItem );
4260 const unsigned GRIP_MARGIN = 20;
4266 if( !item->IsBOARD_ITEM() )
4269 BOX2I itemBox = item->ViewBBox();
4274 if( item->HitTest( aPoint, margin ) )
4281 group->RunOnChildren(
4284 if( aItem->
HitTest( aPoint, margin ) )
4304 SEG loc( aWhere, aWhere );
4306 switch( aItem->
Type() )
4314 if(
text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &
distance ) )
4336 shape->Collide( loc, aMaxDistance, &
distance );
4356 ZONE* zone =
static_cast<ZONE*
>( aItem );
4378 catch(
const std::exception& e )
4380 wxFAIL_MSG( wxString::Format( wxT(
"Clipper exception occurred: %s" ), e.what() ) );
4414 static_cast<PAD*
>( aItem )->Padstack().ForEachUniqueLayer(
4417 int layerDistance = INT_MAX;
4443 wxCHECK( settings, );
4446 LSET visibleLayers =
m_frame->GetBoard()->GetVisibleLayers();
4447 LSET enabledLayers =
m_frame->GetBoard()->GetEnabledLayers();
4450 wxCHECK( !enabledLayerStack.empty(), );
4452 auto isZoneFillKeepout =
4457 const ZONE* zone =
static_cast<const ZONE*
>( aItem );
4466 std::vector<LAYER_OPACITY_ITEM> opacityStackup;
4468 for(
int i = 0; i < aCollector.
GetCount(); i++ )
4472 LSET itemLayers = item->
GetLayerSet() & enabledLayers & visibleLayers;
4473 LSEQ itemLayerSeq = itemLayers.
Seq( enabledLayerStack );
4486 opacityItem.
m_Item = item;
4488 if( isZoneFillKeepout( item ) )
4491 opacityStackup.emplace_back( opacityItem );
4495 std::sort( opacityStackup.begin(), opacityStackup.end(),
4498 int retv = enabledLayerStack.TestLayers( aLhs.m_Layer, aRhs.m_Layer );
4503 return aLhs.m_Opacity > aRhs.m_Opacity;
4506 std::set<const BOARD_ITEM*> visibleItems;
4507 std::set<const BOARD_ITEM*> itemsToRemove;
4509 double currentStackupOpacity = 0.0;
4516 currentStackupOpacity = opacityItem.m_Opacity;
4517 lastVisibleLayer = opacityItem.m_Layer;
4518 visibleItems.emplace( opacityItem.m_Item );
4528 wxCHECK( item,
false );
4531 if( visibleItems.count( item ) )
4537 && visibleItems.count( item->
GetParent() ) )
4544 if( isZoneFillKeepout( item ) )
4551 if( opacityItem.m_Layer == enabledLayerStack[0] )
4553 visibleItems.emplace( opacityItem.m_Item );
4557 double itemVisibility = opacityItem.m_Opacity * ( 1.0 - currentStackupOpacity );
4559 if( ( itemVisibility <= minAlphaLimit ) && !ignoreItem() )
4560 itemsToRemove.emplace( opacityItem.m_Item );
4562 visibleItems.emplace( opacityItem.m_Item );
4565 if( opacityItem.m_Layer != lastVisibleLayer )
4567 currentStackupOpacity += opacityItem.m_Opacity * ( 1.0 - currentStackupOpacity );
4568 currentStackupOpacity = std::min( currentStackupOpacity, 1.0 );
4569 lastVisibleLayer = opacityItem.m_Layer;
4573 for(
const BOARD_ITEM* itemToRemove : itemsToRemove )
4575 wxCHECK( aCollector.
GetCount() > 1, );
4576 aCollector.
Remove( itemToRemove );
4599 static std::vector<KICAD_T> singleLayerSilkTypes = {
PCB_FIELD_T,
4611 std::set<BOARD_ITEM*> preferred;
4612 std::set<BOARD_ITEM*> rejected;
4619 if( silkLayers[activeLayer] )
4621 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4625 if( item->
IsType( singleLayerSilkTypes ) && silkLayers[ item->
GetLayer() ] )
4626 preferred.insert( item );
4631 else if( courtyardLayers[activeLayer] && settings->
GetHighContrast() )
4633 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4638 preferred.insert( item );
4642 if( preferred.size() > 0 )
4647 aCollector.
Append( item );
4649 if( preferred.size() == 1 )
4654 constexpr int MAX_SLOP = 5;
4658 int minSlop = INT_MAX;
4660 std::map<BOARD_ITEM*, int> itemsBySloppiness;
4662 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4667 itemsBySloppiness[ item ] = itemSlop;
4669 if( itemSlop < minSlop )
4674 if( minSlop < INT_MAX )
4676 for( std::pair<BOARD_ITEM*, int> pair : itemsBySloppiness )
4678 if( pair.second > minSlop + singlePixel )
4685 constexpr double sizeRatio = 1.5;
4687 std::vector<std::pair<BOARD_ITEM*, double>> itemsByArea;
4689 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4698 area = (double)
SEG::Square( singlePixel ) * MAX_SLOP;
4717 catch(
const std::exception& e )
4719 wxFAIL_MSG( wxString::Format( wxT(
"Clipper exception occurred: %s" ), e.what() ) );
4723 itemsByArea.emplace_back( item, area );
4726 std::sort( itemsByArea.begin(), itemsByArea.end(),
4727 [](
const std::pair<BOARD_ITEM*, double>& lhs,
4728 const std::pair<BOARD_ITEM*, double>& rhs ) ->
bool
4730 return lhs.second < rhs.second;
4733 bool rejecting =
false;
4735 for(
int i = 1; i < (int) itemsByArea.size(); ++i )
4737 if( itemsByArea[i].second > itemsByArea[i-1].second * sizeRatio )
4741 rejected.insert( itemsByArea[i].first );
4746 constexpr double maxCoverRatio = 0.70;
4748 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4752 if( footprint->CoverageRatio( aCollector ) > maxCoverRatio )
4753 rejected.erase( footprint );
4758 if( (
unsigned) aCollector.
GetCount() > rejected.size() )
4770 bool haveItemOnActive =
false;
4773 for(
int i = 0; i < aCollector.
GetCount(); ++i )
4775 if( !aCollector[i]->IsOnLayer( activeLayer ) )
4776 rejected.insert( aCollector[i] );
4778 haveItemOnActive =
true;
4781 if( haveItemOnActive )
4794 m_frame->ShowInfoBarWarning(
_(
"Selection contains locked items. "
4795 "Enable 'Override locks' to operate on them." ),
4805 bool lockedDescendant =
false;
4811 lockedDescendant =
true;
4815 return lockedDescendant;
4837 for(
int i = (
int) aCollector.
GetCount() - 1; i >= 0; --i )
4843 aCollector.
Remove( item );
4853 std::unordered_set<EDA_ITEM*> toAdd;
4857 for(
int j = 0; j < aCollector.
GetCount(); j++ )
4859 if( aCollector[j]->GetParent() )
4860 aCollector[j]->GetParent()->ClearFlags(
CANDIDATE );
4862 if( aCollector[j]->GetParentFootprint() )
4863 aCollector[j]->GetParentFootprint()->ClearFlags(
CANDIDATE );
4868 for(
int j = 0; j < aCollector.
GetCount(); j++ )
4872 for(
int j = 0; j < aCollector.
GetCount(); )
4884 aCollector.
Remove( item );
4892 if(
top->AsEdaItem() != item )
4894 toAdd.insert(
top->AsEdaItem() );
4897 aCollector.
Remove( item );
4906 aCollector.
Remove( item );
4915 if( !aCollector.
HasItem( item ) )
4916 aCollector.
Append( item );
4923 std::set<BOARD_ITEM*> to_add;
4926 for(
int i = (
int) aCollector.
GetCount() - 1; i >= 0; --i )
4935 aCollector.
Remove( item );
4940 aCollector.
Append( item );
4945 bool aForcePromotion )
const
4947 std::set<BOARD_ITEM*> to_add;
4950 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
4955 && ( !
frame()->GetPcbNewSettings()->m_AllowFreePads || aForcePromotion ) )
4960 aCollector.
Remove( item );
4965 aCollector.
Append( item );
4972 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
4977 aCollector.
Remove( item );
4989 bool need_direct_hit =
false;
4997 need_direct_hit =
true;
5005 else if( item->IsBOARD_ITEM() )
5006 fp =
static_cast<BOARD_ITEM*
>( item )->GetParentFootprint();
5012 single_fp =
nullptr;
5015 else if( !single_fp )
5021 else if( single_fp != fp )
5023 single_fp =
nullptr;
5029 auto visibleLayers =
5037 set.
set( layer,
view()->IsLayerVisible( layer ) );
5047 LSET layers = visibleLayers();
5055 for(
int layer : activeLayers )
5058 layers.
set( layer );
5063 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
5079 aCollector.
Remove( item );
5081 bool has_hit =
false;
5095 aCollector.
Remove( item );
5100 else if( single_fp )
5102 if( fp == single_fp )
5105 else if( need_direct_hit )
5119 aCollector.
Remove( item );
5136 std::set<std::pair<PCB_TABLE*, int>> columns;
5144 columns.insert( std::make_pair(
table, cell->GetColumn() ) );
5148 for(
auto& [
table, col ] : columns )
5150 for(
int row = 0; row <
table->GetRowCount(); ++row )
5171 std::set<std::pair<PCB_TABLE*, int>> rows;
5179 rows.insert( std::make_pair(
table, cell->GetRow() ) );
5183 for(
auto& [
table, row ] : rows )
5185 for(
int col = 0; col <
table->GetColCount(); ++col )
5206 std::set<PCB_TABLE*> tables;
5212 tables.insert(
static_cast<PCB_TABLE*
>( cell->GetParent() ) );
5219 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 deleteLastPoint
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.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given 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.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
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.
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
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()
bool HasDesignBlockLink() const
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 CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
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.
const wxString & GetNetChain() const
PAD * GetTerminalPad(int aIndex) const
static TOOL_ACTION drag45Degree
static TOOL_ACTION selectNetChain
Select all connections belonging to every net in the current item's net chain.
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 setTerminalPad
static TOOL_ACTION highlightNet
static TOOL_ACTION hideLocalRatsnest
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION highlightNetChain
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.
The main frame for Pcbnew.
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...
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
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
VECTOR2I GetPosition() const override
int GetWidth() const override
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
A small class to help profiling.
void Start()
Start or restart the counter.
double msecs(bool aSinceLast=false)
Describe ratsnest for a single net.
const std::vector< CN_EDGE > & GetEdges() const
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)
A null aItem is ignored; the selection never holds null members.
virtual void Remove(EDA_ITEM *aItem)
void ClearReferencePoint()
bool Empty() const
Checks if there is anything selected.
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 to handle a set of BOARD_ITEMs.
Class that computes missing connections on a PCB.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
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_CONSTRAINT_T
class PCB_CONSTRAINT, a geometric constraint between board items
@ 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)