30using namespace std::placeholders;
117 m_isFootprintEditor( false ),
119 m_enteredGroup( nullptr ),
120 m_priv(
std::make_unique<
PRIV>() )
156 std::shared_ptr<SELECT_MENU> selectMenu = std::make_shared<SELECT_MENU>();
157 selectMenu->SetTool(
this );
162 auto activeToolCondition =
176 auto groupEnterCondition =
179 auto inGroupCondition =
188 menu.AddSeparator( 1000 );
197 menu.AddSeparator( 1 );
211 m_frame = getEditFrame<PCB_BASE_FRAME>();
240 wxMouseState keyboardState = wxGetMouseState();
243 keyboardState.AltDown() );
267 evt->Modifier(
MD_ALT ) );
278 else if( evt->IsMouseDown(
BUT_LEFT ) )
316 bool selectionCancelled =
false;
320 selectPoint( evt->Position(),
false, &selectionCancelled );
324 if( !selectionCancelled )
327 else if( evt->IsDblClick(
BUT_LEFT ) )
366 if(
hasModifier() || dragAction == MOUSE_DRAG_ACTION::SELECT )
377 auto zoneFilledAreaFilter =
381 int accuracy =
KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
382 std::set<EDA_ITEM*> remove;
388 ZONE* zone =
static_cast<ZONE*
>( item );
393 remove.insert( zone );
399 aCollector.Remove( item );
405 if( evt->HasPosition() )
408 &&
selectPoint( evt->DragOrigin(),
false,
nullptr, zoneFilledAreaFilter ) )
425 if( haveTrack && trackDragAction == TRACK_DRAG_ACTION::DRAG )
427 else if( haveTrack && trackDragAction == TRACK_DRAG_ACTION::DRAG_FREE_ANGLE )
439 else if( evt->IsCancel() )
448 else if( evt->FirstResponder() ==
this && evt->GetCommandId() == (
int) WXK_ESCAPE )
473 && dragAction == MOUSE_DRAG_ACTION::DRAG_SELECTED
475 && evt->HasPosition()
498 wxT(
"EnterGroup called when selection is not a single group" ) );
549 bool aConfirmLockedItems )
562 enum DISPOSITION { BEFORE = 1, AFTER, BOTH };
564 std::map<EDA_ITEM*, DISPOSITION> itemDispositions;
573 itemDispositions[ item ] = BEFORE;
576 aClientFilter(
VECTOR2I(), collector,
this );
580 if( itemDispositions.count( item ) )
581 itemDispositions[ item ] = BOTH;
583 itemDispositions[ item ] = AFTER;
591 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
593 EDA_ITEM* item = itemDisposition.first;
594 DISPOSITION disposition = itemDisposition.second;
596 if( disposition == BEFORE )
600 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
602 EDA_ITEM* item = itemDisposition.first;
603 DISPOSITION disposition = itemDisposition.second;
607 if( disposition == AFTER || disposition == BOTH )
614 if( aConfirmLockedItems )
616 std::vector<BOARD_ITEM*> lockedItems;
625 bool lockedDescendant =
false;
627 group->RunOnDescendants(
631 lockedDescendant =
true;
634 if( lockedDescendant )
635 lockedItems.push_back(
group );
639 lockedItems.push_back( boardItem );
643 if( !lockedItems.empty() )
706 bool* aSelectionCancelledFlag,
723 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
725 if( !
Selectable( collector[ i ] ) || ( aOnDrag && collector[i]->IsLocked() ) )
734 aClientFilter( aWhere, collector,
this );
744 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
746 if( !collector[i]->IsSelected() )
758 catch(
const ClipperLib::clipperException& exc )
760 wxLogWarning( wxS(
"Exception \"%s\" occurred attemption to guess selection "
761 "candidates." ), exc.what() );
774 if( aSelectionCancelledFlag )
775 *aSelectionCancelledFlag =
true;
782 bool anySubtracted =
false;
789 anySubtracted =
true;
795 for(
int i = 0; i < collector.
GetCount(); ++i )
800 anySubtracted =
true;
810 if( addedCount == 1 )
815 else if( addedCount > 1 )
820 else if( anySubtracted )
857 bool cancelled =
false;
864 bool anyAdded =
false;
865 bool anySubtracted =
false;
875 bool greedySelection = width >= 0 ? false :
true;
878 greedySelection = !greedySelection;
881 : KICURSOR::SELECT_LASSO );
883 if( evt->IsCancelInteractive() || evt->IsActivate() )
895 anySubtracted =
true;
902 area.
SetEnd( evt->Position() );
919 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
932 std::set<BOARD_ITEM*> group_items;
940 std::unordered_set<BOARD_ITEM*>& newset =
group->GetItems();
944 if( !greedySelection && selectionRect.
Contains(
group->GetBoundingBox() )
950 collector.
Append( *newset.begin() );
955 group_items.emplace( group_item );
962 if( item &&
Selectable( item ) && item->
HitTest( selectionRect, !greedySelection )
963 && ( greedySelection || !group_items.count( item ) ) )
966 padsCollector.
Append( item );
980 collector = padsCollector;
992 anySubtracted =
true;
1006 else if( anySubtracted )
1017 evt->SetPassEvent();
1040 wxMouseState keyboardState = wxGetMouseState();
1043 keyboardState.AltDown() );
1077 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
1086 view->
Query( selectionBox, selectedItems );
1095 collection.
Append( item );
1116 std::set<int> representedNets;
1118 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
1124 else if ( representedNets.count( item->
GetNetCode() ) )
1127 representedNets.insert( item->
GetNetCode() );
1137 std::vector<BOARD_CONNECTED_ITEM*> toUnroute;
1139 for(
EDA_ITEM* item : selectedItems )
1144 toUnroute.push_back(
pad );
1160 for(
EDA_ITEM* item : selectedItems )
1172 unsigned initialCount = 0;
1180 if( initialCount == 0 )
1183 m_frame->SetStatusText(
_(
"Select/Expand Connection..." ) );
1189 for(
EDA_ITEM* item : selectedItems )
1190 item->ClearTempFlags();
1192 std::vector<BOARD_CONNECTED_ITEM*> startItems;
1194 for(
EDA_ITEM* item : selectedItems )
1201 startItems.push_back(
pad );
1215 m_frame->SetStatusText( wxEmptyString );
1225 const std::vector<BOARD_CONNECTED_ITEM*>& aStartItems,
STOP_CONDITION aStopCondition )
1230 double refreshIntervalMs = 500;
1235 std::map<VECTOR2I, std::vector<PCB_TRACK*>> trackMap;
1236 std::map<VECTOR2I, PCB_VIA*> viaMap;
1237 std::map<VECTOR2I, PAD*> padMap;
1238 std::set<PAD*> startPadSet;
1239 std::vector<BOARD_CONNECTED_ITEM*> cleanupItems;
1240 std::vector<std::pair<VECTOR2I, LSET>> activePts;
1246 startPadSet.insert(
static_cast<PAD*
>( startItem ) );
1254 auto connectedItems = connectivity->GetConnectedItems( startItem,
1260 switch( item->Type() )
1266 trackMap[track->
GetStart()].push_back( track );
1267 trackMap[track->
GetEnd()].push_back( track );
1274 viaMap[
via->GetStart()] =
via;
1281 padMap[
pad->GetPosition()] =
pad;
1291 switch( startItem->Type() )
1304 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1308 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1319 while( expand && failSafe++ < 100000 )
1323 for(
int i = (
int) activePts.size() - 1; i >= 0; --i )
1326 LSET layerSetCu = activePts[i].second & allCuMask;
1328 auto viaIt = viaMap.find( pt );
1329 auto padIt = padMap.find( pt );
1331 bool gotVia = ( viaIt != viaMap.end() )
1332 && ( layerSetCu & ( viaIt->second->GetLayerSet() ) ).any();
1334 bool gotPad = ( padIt != padMap.end() )
1335 && ( layerSetCu & ( padIt->second->GetLayerSet() ) ).any();
1337 bool gotNonStartPad =
1338 gotPad && ( startPadSet.find( padIt->second ) == startPadSet.end() );
1342 size_t pt_count = 0;
1346 if( track->GetStart() != track->GetEnd()
1347 && layerSetCu.
Contains( track->GetLayer() ) )
1353 if( pt_count > 2 || gotVia || gotNonStartPad )
1355 activePts.erase( activePts.begin() + i );
1361 if( gotNonStartPad )
1363 activePts.erase( activePts.begin() + i );
1370 PAD*
pad = padIt->second;
1375 cleanupItems.push_back(
pad );
1377 activePts.push_back( {
pad->GetPosition(),
pad->GetLayerSet() } );
1384 if( !layerSetCu.
Contains( track->GetLayer() ) )
1387 if( !track->IsSelected() )
1393 cleanupItems.push_back( track );
1395 if( track->GetStart() == pt )
1396 activePts.push_back( { track->GetEnd(), track->GetLayerSet() } );
1398 activePts.push_back( { track->GetStart(), track->GetLayerSet() } );
1404 if( viaMap.count( pt ) )
1408 if( !
via->IsSelected() )
1414 cleanupItems.push_back(
via );
1416 activePts.push_back( {
via->GetPosition(),
via->GetLayerSet() } );
1421 activePts.erase( activePts.begin() + i );
1425 if( refreshTimer.
msecs() >= refreshIntervalMs )
1433 refreshTimer.
Start();
1446 std::vector<PAD*> pads;
1453 pads.push_back(
pad );
1457 pads.push_back(
static_cast<PAD*
>( item ) );
1466 for(
const CN_EDGE& edge : conn->GetRatsnestForPad(
pad ) )
1471 if( sourceParent ==
pad )
1474 select(
static_cast<PAD*
>( targetParent )->GetParent() );
1476 else if( targetParent ==
pad )
1479 select(
static_cast<PAD*
>( sourceParent )->GetParent() );
1493 std::vector<PAD*> pads;
1500 pads.push_back(
pad );
1504 pads.push_back(
static_cast<PAD*
>( item ) );
1515 const std::vector<CN_EDGE> edges = conn->GetRatsnestForPad(
pad );
1518 if( edges.size() == 0 )
1521 double currentDistance = DBL_MAX;
1525 for(
const CN_EDGE& edge : edges )
1528 const CN_ANCHOR* other = edge.GetSourceNode()->
Parent() ==
pad ? edge.GetTargetNode().get()
1529 : edge.GetSourceNode().get();
1535 if( edge.GetLength() < currentDistance )
1537 currentDistance = edge.GetLength();
1538 nearest =
static_cast<PAD*
>( other->
Parent() )->GetParent();
1542 if( nearest !=
nullptr )
1556 for(
BOARD_ITEM* item : conn->GetNetItems( aNetCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
1569 int netcode = (int) aEvent.
Parameter<intptr_t>();
1610 std::vector<BOARD_ITEM*> footprints;
1615 if( footprint ==
nullptr )
1618 wxString footprint_path = footprint->GetPath().AsString().BeforeLast(
'/' );
1620 if( footprint_path.IsEmpty() )
1621 footprint_path +=
'/';
1623 if( footprint_path == aSheetPath )
1624 footprints.push_back( footprint );
1640 std::list<int> netcodeList;
1641 std::vector<BOARD_CONNECTED_ITEM*> padList;
1645 switch( item->Type() )
1651 if(
pad->IsConnected() )
1653 netcodeList.push_back(
pad->GetNetCode() );
1654 padList.push_back(
pad );
1665 if(
pad->IsConnected() )
1667 netcodeList.push_back(
pad->GetNetCode() );
1668 padList.push_back(
pad );
1680 std::sort( padList.begin(), padList.end() );
1684 netcodeList.unique();
1690 std::vector<int> removeCodeList;
1693 for(
int netCode : netcodeList )
1697 if( !std::binary_search( padList.begin(), padList.end(),
pad ) )
1701 removeCodeList.push_back( netCode );
1707 for(
int removeCode : removeCodeList )
1708 netcodeList.remove( removeCode );
1710 std::unordered_set<BOARD_ITEM*> localConnectionList;
1712 for(
int netCode : netcodeList )
1714 for(
BOARD_ITEM* item : conn->GetNetItems( netCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
1715 localConnectionList.insert( item );
1718 for(
BOARD_ITEM* item : localConnectionList )
1725 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
1736 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
1781 wxString sheetPath = *aEvent.
Parameter<wxString*>();
1807 if( !footprint || footprint->
GetPath().empty() )
1813 wxString sheetPath = footprint->
GetPath().
AsString().BeforeLast(
'/' );
1815 if( sheetPath.IsEmpty() )
1835 screenSize.
x = std::max( 10.0, screenSize.
x );
1836 screenSize.
y = std::max( 10.0, screenSize.
y );
1842 / std::max( fabs( vsize.
x / screenSize.
x ), fabs( vsize.
y / screenSize.
y ) );
1864#ifdef DEFAULT_PCBNEW_CODE
1866 auto screenSize =
view->
ToWorld( GetCanvas()->GetClientSize(),
false );
1869 screenSize.
x = std::max( 10.0, fabs( screenSize.x ) );
1870 screenSize.y = std::max( 10.0, screenSize.y );
1871 double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
1874 if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) )
1878#ifndef DEFAULT_PCBNEW_CODE
1895 double compRatio = bbSize.y / currTextHeight;
1898 double compRatioBent = 1.0;
1909 screenSize.
x = std::max( 10.0, fabs( screenSize.
x ) );
1910 screenSize.
y = std::max( 10.0, screenSize.
y );
1911 double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.
y ) );
1915 std::max( fabs( bbSize.x / screenSize.
x ), fabs( bbSize.y / screenSize.
y ) );
1923 std::vector<std::pair<double, double>> lut{
1924 { 1, 8 }, { 1.5, 5 }, { 3, 3 }, { 4.5, 2.5 }, { 8, 2.0 },
1925 { 12, 1.7 }, { 16, 1.5 }, { 24, 1.3 }, { 32, 1.0 },
1929 std::vector<std::pair<double, double>>::iterator it;
1931 compRatioBent = lut.back().second;
1933 if( compRatio >= lut.front().first )
1939 for( it = lut.begin(); it < lut.end() - 1; it++ )
1941 if( it->first <= compRatio &&
next( it )->first >= compRatio )
1943 double diffx = compRatio - it->first;
1944 double diffn =
next( it )->first - it->first;
1946 compRatioBent = it->second + (
next( it )->second - it->second ) * diffx / diffn;
1953 compRatioBent = lut.front().second;
1961 if( bbSize.x > screenSize.
x * ratio * compRatioBent )
1965 compRatioBent = 1.0;
1966 wxLogTrace(
"CROSS_PROBE_SCALE",
1967 "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
1972 ratio *= compRatioBent;
1974 bool alwaysZoom =
false;
1977 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
1985 bool cleared =
false;
1997 switch( aItem->
Type() )
2001 int netCode =
static_cast<NETINFO_ITEM*
>( aItem )->GetNetCode();
2020 double marginFactor = 2;
2025 BOX2I screenRect( screenBox.
GetOrigin(), screenSize / marginFactor );
2032 scaleX /= marginFactor;
2033 scaleY /= marginFactor;
2035 double scale = scaleX > scaleY ? scaleY : scaleX;
2066 switch( aItem.
Type() )
2116 const int cmd = dlg.ShowModal();
2118 if( cmd != wxID_OK )
2147 std::set<BOARD_ITEM*> rejected;
2154 rejected.insert( item );
2158 aCollector.
Remove( item );
2180 switch( aItem->
Type() )
2209 ZONE* zone =
static_cast<ZONE*
>( aItem );
2289 bool enteredGroupFound =
false;
2292 [&](
EDA_ITEM* item,
void* testData )
2300 return INSPECT_RESULT::CONTINUE;
2308 enteredGroupFound =
true;
2315 return INSPECT_RESULT::CONTINUE;
2321 if( !enteredGroupFound )
2333 auto visibleLayers =
2354 bool onActiveLayer =
false;
2356 for(
int layer : activeLayers )
2359 if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer(
ToLAYER_ID( layer ),
true ) )
2361 onActiveLayer =
true;
2366 if( !onActiveLayer )
2386 && footprint->
Pads().empty()
2387 && footprint->
Zones().empty() )
2404 for(
const ZONE* zone : footprint->
Zones() )
2427 const ZONE* zone =
nullptr;
2429 const PAD*
pad =
nullptr;
2432 switch( aItem->
Type() )
2438 zone =
static_cast<const ZONE*
>( aItem );
2449 && !checkVisibilityOnly )
2455 if( !( zone->
GetLayerSet() & visibleLayers() ).any() )
2485 if( !( visibleLayers() &
via->GetLayerSet() ).any() )
2511 switch(
text->GetType() )
2537 if( !checkVisibilityOnly )
2547 pad =
static_cast<const PAD*
>( aItem );
2549 if(
pad->GetAttribute() == PAD_ATTRIB::PTH ||
pad->GetAttribute() == PAD_ATTRIB::NPTH )
2568 if( !(
pad->GetLayerSet() & visibleLayers() ).any() )
2621 aGroup->
Add( aItem );
2645 static_cast<FOOTPRINT*
>( aItem )->RunOnChildren(
2653 static_cast<PCB_GROUP*
>( aItem )->RunOnChildren(
2688 static_cast<FOOTPRINT*
>( aItem )->RunOnChildren(
2696 static_cast<PCB_GROUP*
>( aItem )->RunOnChildren(
2707 const unsigned GRIP_MARGIN = 20;
2713 BOX2I itemBox = item->ViewBBox();
2718 if( item->HitTest( aPoint, margin ) )
2723 std::function<void(
PCB_GROUP* )> checkGroup;
2726 aGroup->RunOnChildren(
2730 checkGroup(
group );
2731 else if( aItem->
HitTest( aPoint, margin ) )
2738 checkGroup(
group );
2751 int aMaxDistance )
const
2756 SEG loc( aWhere, aWhere );
2758 switch( aItem->
Type() )
2763 text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &
distance );
2776 ZONE* zone =
static_cast<ZONE*
>( aItem );
2798 catch(
const ClipperLib::clipperException& exc )
2802 wxLogError( wxT(
"Clipper library exception '%s' occurred." ), exc.what() );
2861 std::set<BOARD_ITEM*> preferred;
2862 std::set<BOARD_ITEM*> rejected;
2867 if( silkLayers[activeLayer] )
2869 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2877 preferred.insert( item );
2881 else if( courtyardLayers[activeLayer] && settings->
GetHighContrast() )
2883 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2889 preferred.insert( item );
2893 if( preferred.size() > 0 )
2898 aCollector.
Append( item );
2904 constexpr int MAX_SLOP = 5;
2908 int minSlop = INT_MAX;
2910 std::map<BOARD_ITEM*, int> itemsBySloppiness;
2912 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2917 itemsBySloppiness[ item ] = itemSlop;
2919 if( itemSlop < minSlop )
2924 if( minSlop < INT_MAX )
2926 for( std::pair<BOARD_ITEM*, int> pair : itemsBySloppiness )
2928 if( pair.second > minSlop + singlePixel )
2935 constexpr double sizeRatio = 1.5;
2937 std::vector<std::pair<BOARD_ITEM*, double>> itemsByArea;
2939 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2948 area = (double)
SEG::Square( singlePixel ) * MAX_SLOP;
2959 area = size.
x * size.
y;
2967 catch(
const ClipperLib::clipperException& e )
2969 wxLogError( wxT(
"A clipper exception %s was detected." ), e.what() );
2973 itemsByArea.emplace_back( item, area );
2976 std::sort( itemsByArea.begin(), itemsByArea.end(),
2977 [](
const std::pair<BOARD_ITEM*, double>& lhs,
2978 const std::pair<BOARD_ITEM*, double>& rhs ) ->
bool
2980 return lhs.second < rhs.second;
2983 bool rejecting =
false;
2985 for(
int i = 1; i < (int) itemsByArea.size(); ++i )
2987 if( itemsByArea[i].second > itemsByArea[i-1].second * sizeRatio )
2991 rejected.insert( itemsByArea[i].first );
2996 constexpr double maxCoverRatio = 0.70;
2998 for(
int i = 0; i < aCollector.
GetCount(); ++i )
3002 if( footprint->CoverageRatio( aCollector ) > maxCoverRatio )
3003 rejected.erase( footprint );
3008 if( (
unsigned) aCollector.
GetCount() > rejected.size() )
3020 bool haveItemOnActive =
false;
3023 for(
int i = 0; i < aCollector.
GetCount(); ++i )
3025 if( !aCollector[i]->IsOnLayer( activeLayer ) )
3026 rejected.insert( aCollector[i] );
3028 haveItemOnActive =
true;
3031 if( haveItemOnActive )
3039 bool aMultiselect )
const
3041 std::unordered_set<BOARD_ITEM*> toAdd;
3045 for(
int j = 0; j < aCollector.
GetCount(); j++ )
3047 if( aCollector[j]->GetParent() )
3048 aCollector[j]->GetParent()->ClearFlags(
CANDIDATE );
3053 for(
int j = 0; j < aCollector.
GetCount(); j++ )
3057 for(
int j = 0; j < aCollector.
GetCount(); )
3069 aCollector.
Remove( item );
3079 toAdd.insert( top );
3082 aCollector.
Remove( item );
3091 aCollector.
Remove( item );
3100 if( !aCollector.
HasItem( item ) )
3101 aCollector.
Append( item );
3108 std::set<BOARD_ITEM*> to_add;
3111 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
3116 && !
frame()->GetPcbNewSettings()->m_AllowFreePads )
3121 aCollector.
Remove( item );
3126 aCollector.
Append( item );
3133 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
3138 aCollector.
Remove( item );
constexpr EDA_IU_SCALE pcbIUScale
static TOOL_ACTION cancelInteractive
static TOOL_ACTION cursorLeft
static TOOL_ACTION zoomOutCenter
static TOOL_ACTION zoomIn
static TOOL_ACTION cursorLeftFast
static TOOL_ACTION cursorDown
static TOOL_ACTION zoomOut
static TOOL_ACTION cursorRightFast
static TOOL_ACTION zoomCenter
static TOOL_ACTION panDown
static TOOL_ACTION cursorDownFast
static TOOL_ACTION cursorUpFast
static TOOL_ACTION panLeft
static TOOL_ACTION updateMenu
static TOOL_ACTION doDelete
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION zoomFitObjects
static TOOL_ACTION zoomInCenter
static TOOL_ACTION panRight
static TOOL_ACTION cursorUp
Cursor control with keyboard.
static TOOL_ACTION cursorRight
static TOOL_ACTION selectAll
CROSS_PROBING_SETTINGS m_CrossProbing
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 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 bool IsLocked() const
BOARD_ITEM_CONTAINER * GetParent() 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...
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
bool LegacyTeardrops() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
const Vec & GetPosition() const
const Vec & GetOrigin() const
coord_type GetHeight() const
coord_type GetWidth() const
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
const Vec & 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.
bool IsType(FRAME_T aType) const
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
void ForceRefresh()
Force a redraw.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
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)
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
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
EDA_ITEM_FLAGS GetFlags() const
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, bool aUseTextRotation=true) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
static const TOOL_EVENT DisambiguatePoint
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 SetIgnoreMTextsMarkedNoShow(bool ignore)
void SetIgnoreModulesOnFront(bool ignore)
void SetIgnoreModulesRefs(bool ignore)
void SetIgnoreMicroVias(bool ignore)
void SetIgnoreZoneFills(bool ignore)
void SetIgnorePadsOnBack(bool ignore)
void SetIgnoreModulesOnBack(bool ignore)
void SetIgnoreModulesVals(bool ignore)
void SetIgnoreThroughVias(bool ignore)
void SetIgnoreThroughHolePads(bool ignore)
void SetIgnoreMTextsOnFront(bool ignore)
void SetIgnoreMTextsOnBack(bool ignore)
void SetIgnorePadsOnFront(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.
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 SetSubtractive(bool aSubtractive)
void SetAdditive(bool aAdditive)
void SetOrigin(const VECTOR2I &aOrigin)
const BOX2I ViewBBox() const override
Set the origin of the rectangle (the fixed corner)
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.
bool GetHighContrast() const
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void Clear()
Remove all the stored items from the group.
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
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 Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
virtual 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...
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
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 SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
bool IsVisible(const VIEW_ITEM *aItem) const
Return information if the item is visible (or not).
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
wxString AsString() const
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
static LSET FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
static LSET BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
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.
bool m_CtrlClickHighlight
TRACK_DRAG_ACTION m_TrackDragAction
bool m_ESCClearsNetHighlight
static TOOL_ACTION drag45Degree
static TOOL_ACTION unrouteSelected
Removes all tracks from the selected items to the first pad.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
static TOOL_ACTION groupLeave
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 unselectItem
static TOOL_ACTION hideLocalRatsnest
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION selectionClear
Clear the current selection.
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 dragFreeAngle
static TOOL_ACTION clearHighlight
static TOOL_ACTION unselectItems
static TOOL_ACTION selectUnconnected
Select unconnected footprints from ratsnest of selection.
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 groupEnter
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
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 selectionActivate
Activation of the selection tool.
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 selectItems
Select a list of items (specified as the event parameter)
static TOOL_ACTION deselectNet
Remove all connections belonging to a single net from the active selection.
static TOOL_ACTION selectionMenu
Run a selection menu to select from a list of items.
static TOOL_ACTION selectOnSchematic
Select symbols/pins on schematic corresponding to selected footprints/pads.
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...
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Object to handle a bitmap image that can be inserted in a PCB.
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).
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
static bool WithinScope(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
static PCB_GROUP * TopLevelGroup(BOARD_ITEM *aItem, PCB_GROUP *aScope, bool isFootprintEditor)
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all members of the group.
bool AddItem(BOARD_ITEM *aItem)
Add item to group.
Tool that displays edit points allowing to modify items by dragging the points.
bool HasPoint()
Indicate the cursor is over an edit point.
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
int GetDrill() const
Return the local drill setting for this PCB_VIA.
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 Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
virtual void Add(EDA_ITEM *aItem)
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
const std::deque< EDA_ITEM * > GetItems() const
void SetIsHover(bool aIsHover)
virtual void Remove(EDA_ITEM *aItem)
virtual unsigned int GetSize() const override
Return the number of stored items.
virtual void Clear() override
Remove all the stored items from the group.
int Size() const
Returns the number of selected parts.
void ClearReferencePoint()
bool Empty() const
Checks if there is anything selected.
bool Contains(EDA_ITEM *aItem) const
virtual BOX2I GetBoundingBox() const
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
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.
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,...
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.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
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.
@ FRAME_FOOTPRINT_VIEWER_MODAL
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
@ LAYER_PAD_FR
smd pads, front layer
@ LAYER_ZONES
Control for copper zone opacity/visibility (color ignored)
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored)
@ LAYER_MOD_FR
show footprints on front
@ LAYER_PAD_BK
smd pads, back layer
@ LAYER_MOD_VALUES
show footprints values (when texts are visible)
@ LAYER_PADS_TH
multilayer pads, usually with holes
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
@ LAYER_MOD_BK
show footprints on back
@ LAYER_MOD_REFERENCES
show footprints references (when texts are visible)
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
@ REPAINT
Item needs to be redrawn.
@ TARGET_OVERLAY
Items that may change while the view stays the same (noncached)
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)
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
bool center_on_items
Automatically pan to cross-probed items.
Struct that will be set with the result of the user choices in the dialog.
bool includeItemsOnTechLayers
bool includeLockedModules
bool includeBoardOutlineLayer
constexpr int mmToIU(double mm) const
bool graphics
Graphic lines, shapes, polygons.
bool text
Text (free or attached to a footprint)
bool vias
Vias (all types>
bool lockedItems
Allow selecting locked items.
bool tracks
Copper tracks.
bool footprints
Allow selecting entire footprints.
bool keepouts
Keepout zones.
bool dimensions
Dimension items.
bool otherItems
Anything not fitting one of the above categories.
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_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
@ NOT_USED
the 3d code uses this value
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ 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_NETINFO_T
class NETINFO_ITEM, a description of a net
@ 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
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)