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>();
246 wxMouseState keyboardState = wxGetMouseState();
249 keyboardState.AltDown() );
273 evt->Modifier(
MD_ALT ) );
284 else if( evt->IsMouseDown(
BUT_LEFT ) )
322 bool selectionCancelled =
false;
326 selectPoint( evt->Position(),
false, &selectionCancelled );
330 if( !selectionCancelled )
333 else if( evt->IsDblClick(
BUT_LEFT ) )
383 auto zoneFilledAreaFilter =
387 int accuracy =
KiROUND( 5 * aCollector.GetGuide()->OnePixelInIU() );
388 std::set<EDA_ITEM*> remove;
394 ZONE* zone =
static_cast<ZONE*
>( item );
399 remove.insert( zone );
405 aCollector.Remove( item );
411 if( evt->HasPosition() )
414 &&
selectPoint( evt->DragOrigin(),
false,
nullptr, zoneFilledAreaFilter ) )
445 else if( evt->IsCancel() )
454 else if( evt->FirstResponder() ==
this && evt->GetCommandId() == (
int) WXK_ESCAPE )
481 && evt->HasPosition()
504 wxT(
"EnterGroup called when selection is not a single group" ) );
555 bool aConfirmLockedItems )
568 enum DISPOSITION { BEFORE = 1, AFTER, BOTH };
570 std::map<EDA_ITEM*, DISPOSITION> itemDispositions;
579 itemDispositions[ item ] = BEFORE;
582 aClientFilter(
VECTOR2I(), collector,
this );
586 if( itemDispositions.count( item ) )
587 itemDispositions[ item ] = BOTH;
589 itemDispositions[ item ] = AFTER;
597 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
599 EDA_ITEM* item = itemDisposition.first;
600 DISPOSITION disposition = itemDisposition.second;
602 if( disposition == BEFORE )
606 for( std::pair<EDA_ITEM* const, DISPOSITION> itemDisposition : itemDispositions )
608 EDA_ITEM* item = itemDisposition.first;
609 DISPOSITION disposition = itemDisposition.second;
613 if( disposition == AFTER || disposition == BOTH )
620 if( aConfirmLockedItems )
622 std::vector<BOARD_ITEM*> lockedItems;
631 bool lockedDescendant =
false;
633 group->RunOnDescendants(
637 lockedDescendant =
true;
640 if( lockedDescendant )
641 lockedItems.push_back(
group );
645 lockedItems.push_back( boardItem );
649 if( !lockedItems.empty() )
712 bool* aSelectionCancelledFlag,
729 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
731 if( !
Selectable( collector[ i ] ) || ( aOnDrag && collector[i]->IsLocked() ) )
740 aClientFilter( aWhere, collector,
this );
750 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
752 if( !collector[i]->IsSelected() )
769 if( aSelectionCancelledFlag )
770 *aSelectionCancelledFlag =
true;
777 bool anySubtracted =
false;
784 anySubtracted =
true;
790 for(
int i = 0; i < collector.
GetCount(); ++i )
795 anySubtracted =
true;
805 if( addedCount == 1 )
810 else if( addedCount > 1 )
815 else if( anySubtracted )
852 bool cancelled =
false;
859 bool anyAdded =
false;
860 bool anySubtracted =
false;
870 bool greedySelection = width >= 0 ? false :
true;
873 greedySelection = !greedySelection;
878 if( evt->IsCancelInteractive() || evt->IsActivate() )
890 anySubtracted =
true;
897 area.
SetEnd( evt->Position() );
914 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
927 std::set<BOARD_ITEM*> group_items;
935 std::unordered_set<BOARD_ITEM*>& newset =
group->GetItems();
939 if( !greedySelection && selectionRect.
Contains(
group->GetBoundingBox() )
945 collector.
Append( *newset.begin() );
950 group_items.emplace( group_item );
957 if( item &&
Selectable( item ) && item->
HitTest( selectionRect, !greedySelection )
958 && ( greedySelection || !group_items.count( item ) ) )
961 padsCollector.
Append( item );
975 collector = padsCollector;
987 anySubtracted =
true;
1001 else if( anySubtracted )
1012 evt->SetPassEvent();
1035 wxMouseState keyboardState = wxGetMouseState();
1038 keyboardState.AltDown() );
1072 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
1081 view->
Query( selectionBox, selectedItems );
1090 collection.
Append( item );
1111 std::set<int> representedNets;
1113 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
1119 else if ( representedNets.count( item->
GetNetCode() ) )
1122 representedNets.insert( item->
GetNetCode() );
1132 std::vector<BOARD_CONNECTED_ITEM*> toUnroute;
1134 for(
EDA_ITEM* item : selectedItems )
1139 toUnroute.push_back(
pad );
1155 for(
EDA_ITEM* item : selectedItems )
1167 unsigned initialCount = 0;
1175 if( initialCount == 0 )
1178 m_frame->SetStatusText(
_(
"Select/Expand Connection..." ) );
1184 for(
EDA_ITEM* item : selectedItems )
1185 item->ClearTempFlags();
1187 std::vector<BOARD_CONNECTED_ITEM*> startItems;
1189 for(
EDA_ITEM* item : selectedItems )
1196 startItems.push_back(
pad );
1210 m_frame->SetStatusText( wxEmptyString );
1220 const std::vector<BOARD_CONNECTED_ITEM*>& aStartItems,
STOP_CONDITION aStopCondition )
1225 double refreshIntervalMs = 500;
1230 std::map<VECTOR2I, std::vector<PCB_TRACK*>> trackMap;
1231 std::map<VECTOR2I, PCB_VIA*> viaMap;
1232 std::map<VECTOR2I, PAD*> padMap;
1233 std::set<PAD*> startPadSet;
1234 std::vector<BOARD_CONNECTED_ITEM*> cleanupItems;
1235 std::vector<std::pair<VECTOR2I, LSET>> activePts;
1241 startPadSet.insert(
static_cast<PAD*
>( startItem ) );
1249 auto connectedItems = connectivity->GetConnectedItems( startItem,
1255 switch( item->Type() )
1261 trackMap[track->
GetStart()].push_back( track );
1262 trackMap[track->
GetEnd()].push_back( track );
1269 viaMap[
via->GetStart()] =
via;
1276 padMap[
pad->GetPosition()] =
pad;
1286 switch( startItem->Type() )
1299 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1303 activePts.push_back( { startItem->GetPosition(), startItem->GetLayerSet() } );
1314 while( expand && failSafe++ < 100000 )
1318 for(
int i = (
int) activePts.size() - 1; i >= 0; --i )
1321 LSET layerSetCu = activePts[i].second & allCuMask;
1323 auto viaIt = viaMap.find( pt );
1324 auto padIt = padMap.find( pt );
1326 bool gotVia = ( viaIt != viaMap.end() )
1327 && ( layerSetCu & ( viaIt->second->GetLayerSet() ) ).any();
1329 bool gotPad = ( padIt != padMap.end() )
1330 && ( layerSetCu & ( padIt->second->GetLayerSet() ) ).any();
1332 bool gotNonStartPad =
1333 gotPad && ( startPadSet.find( padIt->second ) == startPadSet.end() );
1337 size_t pt_count = 0;
1341 if( track->GetStart() != track->GetEnd()
1342 && layerSetCu.
Contains( track->GetLayer() ) )
1348 if( pt_count > 2 || gotVia || gotNonStartPad )
1350 activePts.erase( activePts.begin() + i );
1356 if( gotNonStartPad )
1358 activePts.erase( activePts.begin() + i );
1365 PAD*
pad = padIt->second;
1370 cleanupItems.push_back(
pad );
1372 activePts.push_back( {
pad->GetPosition(),
pad->GetLayerSet() } );
1379 if( !layerSetCu.
Contains( track->GetLayer() ) )
1382 if( !track->IsSelected() )
1388 cleanupItems.push_back( track );
1390 if( track->GetStart() == pt )
1391 activePts.push_back( { track->GetEnd(), track->GetLayerSet() } );
1393 activePts.push_back( { track->GetStart(), track->GetLayerSet() } );
1399 if( viaMap.count( pt ) )
1403 if( !
via->IsSelected() )
1409 cleanupItems.push_back(
via );
1411 activePts.push_back( {
via->GetPosition(),
via->GetLayerSet() } );
1416 activePts.erase( activePts.begin() + i );
1420 if( refreshTimer.
msecs() >= refreshIntervalMs )
1428 refreshTimer.
Start();
1441 std::vector<PAD*> pads;
1448 pads.push_back(
pad );
1452 pads.push_back(
static_cast<PAD*
>( item ) );
1461 for(
const CN_EDGE& edge : conn->GetRatsnestForPad(
pad ) )
1466 if( sourceParent ==
pad )
1469 select(
static_cast<PAD*
>( targetParent )->GetParent() );
1471 else if( targetParent ==
pad )
1474 select(
static_cast<PAD*
>( sourceParent )->GetParent() );
1488 std::vector<PAD*> pads;
1495 pads.push_back(
pad );
1499 pads.push_back(
static_cast<PAD*
>( item ) );
1510 const std::vector<CN_EDGE> edges = conn->GetRatsnestForPad(
pad );
1513 if( edges.size() == 0 )
1516 double currentDistance = DBL_MAX;
1520 for(
const CN_EDGE& edge : edges )
1523 const CN_ANCHOR* other = edge.GetSourceNode()->
Parent() ==
pad ? edge.GetTargetNode().get()
1524 : edge.GetSourceNode().get();
1530 if( edge.GetLength() < currentDistance )
1532 currentDistance = edge.GetLength();
1533 nearest =
static_cast<PAD*
>( other->
Parent() )->GetParent();
1537 if( nearest !=
nullptr )
1551 for(
BOARD_ITEM* item : conn->GetNetItems( aNetCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
1564 int netcode = (int) aEvent.
Parameter<intptr_t>();
1605 std::vector<BOARD_ITEM*> footprints;
1610 if( footprint ==
nullptr )
1613 wxString footprint_path = footprint->GetPath().AsString().BeforeLast(
'/' );
1615 if( footprint_path.IsEmpty() )
1616 footprint_path +=
'/';
1618 if( footprint_path == aSheetPath )
1619 footprints.push_back( footprint );
1635 std::list<int> netcodeList;
1636 std::vector<BOARD_CONNECTED_ITEM*> padList;
1640 switch( item->Type() )
1646 if(
pad->IsConnected() )
1648 netcodeList.push_back(
pad->GetNetCode() );
1649 padList.push_back(
pad );
1660 if(
pad->IsConnected() )
1662 netcodeList.push_back(
pad->GetNetCode() );
1663 padList.push_back(
pad );
1675 std::sort( padList.begin(), padList.end() );
1679 netcodeList.unique();
1685 std::vector<int> removeCodeList;
1688 for(
int netCode : netcodeList )
1692 if( !std::binary_search( padList.begin(), padList.end(),
pad ) )
1696 removeCodeList.push_back( netCode );
1702 for(
int removeCode : removeCodeList )
1703 netcodeList.remove( removeCode );
1705 std::unordered_set<BOARD_ITEM*> localConnectionList;
1707 for(
int netCode : netcodeList )
1709 for(
BOARD_ITEM* item : conn->GetNetItems( netCode, { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } ) )
1710 localConnectionList.insert( item );
1713 for(
BOARD_ITEM* item : localConnectionList )
1720 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
1731 std::vector<BOARD_ITEM*>* items = aEvent.
Parameter<std::vector<BOARD_ITEM*>*>();
1776 wxString sheetPath = *aEvent.
Parameter<wxString*>();
1802 if( !footprint || footprint->
GetPath().empty() )
1808 wxString sheetPath = footprint->
GetPath().
AsString().BeforeLast(
'/' );
1810 if( sheetPath.IsEmpty() )
1830 screenSize.
x = std::max( 10.0, screenSize.
x );
1831 screenSize.
y = std::max( 10.0, screenSize.
y );
1837 / std::max( fabs( vsize.
x / screenSize.
x ), fabs( vsize.
y / screenSize.
y ) );
1859#ifdef DEFAULT_PCBNEW_CODE
1861 auto screenSize =
view->
ToWorld( GetCanvas()->GetClientSize(),
false );
1864 screenSize.
x = std::max( 10.0, fabs( screenSize.x ) );
1865 screenSize.y = std::max( 10.0, screenSize.y );
1866 double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
1869 if( crossProbingSettings.zoom_to_fit && ( ratio < 0.5 || ratio > 1.0 ) )
1873#ifndef DEFAULT_PCBNEW_CODE
1890 double compRatio = bbSize.y / currTextHeight;
1893 double compRatioBent = 1.0;
1904 screenSize.x = std::max( 10.0, fabs( screenSize.x ) );
1905 screenSize.y = std::max( 10.0, screenSize.y );
1906 double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
1910 std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
1918 std::vector<std::pair<double, double>> lut{
1919 { 1, 8 }, { 1.5, 5 }, { 3, 3 }, { 4.5, 2.5 }, { 8, 2.0 },
1920 { 12, 1.7 }, { 16, 1.5 }, { 24, 1.3 }, { 32, 1.0 },
1924 std::vector<std::pair<double, double>>::iterator it;
1926 compRatioBent = lut.back().second;
1928 if( compRatio >= lut.front().first )
1934 for( it = lut.begin(); it < lut.end() - 1; it++ )
1936 if( it->first <= compRatio &&
next( it )->first >= compRatio )
1938 double diffx = compRatio - it->first;
1939 double diffn =
next( it )->first - it->first;
1941 compRatioBent = it->second + (
next( it )->second - it->second ) * diffx / diffn;
1948 compRatioBent = lut.front().second;
1956 if( bbSize.x > screenSize.x * ratio * compRatioBent )
1960 compRatioBent = 1.0;
1961 wxLogTrace(
"CROSS_PROBE_SCALE",
1962 "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
1967 ratio *= compRatioBent;
1969 bool alwaysZoom =
false;
1972 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
1980 bool cleared =
false;
1992 switch( aItem->
Type() )
1996 int netCode =
static_cast<NETINFO_ITEM*
>( aItem )->GetNetCode();
2015 double marginFactor = 2;
2020 BOX2I screenRect( screenBox.
GetOrigin(), screenSize / marginFactor );
2027 scaleX /= marginFactor;
2028 scaleY /= marginFactor;
2030 double scale = scaleX > scaleY ? scaleY : scaleX;
2061 bool include =
true;
2067 switch( aItem.
Type() )
2135 const int cmd = dlg.ShowModal();
2137 if( cmd != wxID_OK )
2166 std::set<BOARD_ITEM*> rejected;
2173 rejected.insert( item );
2177 aCollector.
Remove( item );
2199 switch( aItem->
Type() )
2229 ZONE* zone =
static_cast<ZONE*
>( aItem );
2321 bool enteredGroupFound =
false;
2324 [&](
EDA_ITEM* item,
void* testData )
2340 enteredGroupFound =
true;
2353 if( !enteredGroupFound )
2365 auto visibleLayers =
2386 bool onActiveLayer =
false;
2388 for(
int layer : activeLayers )
2391 if( layer < PCB_LAYER_ID_COUNT && aItem->IsOnLayer(
ToLAYER_ID( layer ) ) )
2393 onActiveLayer =
true;
2398 if( !onActiveLayer )
2418 && footprint->
Pads().empty()
2419 && footprint->
Zones().empty() )
2436 for(
const ZONE* zone : footprint->
Zones() )
2459 const ZONE* zone =
nullptr;
2461 const PAD*
pad =
nullptr;
2464 switch( aItem->
Type() )
2471 zone =
static_cast<const ZONE*
>( aItem );
2477 && !checkVisibilityOnly )
2483 if( !( zone->
GetLayerSet() & visibleLayers() ).any() )
2513 if( !( visibleLayers() &
via->GetLayerSet() ).any() )
2565 if( !checkVisibilityOnly )
2575 pad =
static_cast<const PAD*
>( aItem );
2596 if( !(
pad->GetLayerSet() & visibleLayers() ).any() )
2649 aGroup->
Add( aItem );
2673 static_cast<FOOTPRINT*
>( aItem )->RunOnChildren(
2681 static_cast<PCB_GROUP*
>( aItem )->RunOnChildren(
2716 static_cast<FOOTPRINT*
>( aItem )->RunOnChildren(
2724 static_cast<PCB_GROUP*
>( aItem )->RunOnChildren(
2735 const unsigned GRIP_MARGIN = 20;
2741 BOX2I itemBox = item->ViewBBox();
2746 if( item->HitTest( aPoint, margin ) )
2751 std::function<void(
PCB_GROUP* )> checkGroup;
2754 aGroup->RunOnChildren(
2758 checkGroup(
group );
2759 else if( aItem->
HitTest( aPoint, margin ) )
2766 checkGroup(
group );
2779 int aMaxDistance )
const
2784 SEG loc( aWhere, aWhere );
2786 switch( aItem->
Type() )
2791 text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &
distance );
2805 text->GetEffectiveTextShape()->Collide( loc, aMaxDistance, &
distance );
2818 ZONE* zone =
static_cast<ZONE*
>( aItem );
2840 catch(
const ClipperLib::clipperException& exc )
2844 wxLogError( wxT(
"Clipper library exception '%s' occurred." ), exc.what() );
2900 std::set<BOARD_ITEM*> preferred;
2901 std::set<BOARD_ITEM*> rejected;
2902 wxPoint where( aWhere.
x, aWhere.
y );
2907 if( silkLayers[activeLayer] )
2909 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2917 preferred.insert( item );
2921 if( preferred.size() > 0 )
2926 aCollector.
Append( item );
2933 constexpr int MAX_SLOP = 5;
2937 int minSlop = INT_MAX;
2939 std::map<BOARD_ITEM*, int> itemsBySloppiness;
2941 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2946 itemsBySloppiness[ item ] = itemSlop;
2948 if( itemSlop < minSlop )
2953 if( minSlop < INT_MAX )
2955 for( std::pair<BOARD_ITEM*, int> pair : itemsBySloppiness )
2957 if( pair.second > minSlop + singlePixel )
2964 constexpr double sizeRatio = 1.5;
2966 std::vector<std::pair<BOARD_ITEM*, double>> itemsByArea;
2968 for(
int i = 0; i < aCollector.
GetCount(); ++i )
2977 area = (double)
SEG::Square( singlePixel ) * MAX_SLOP;
2988 area = size.
x * size.
y;
2996 catch(
const ClipperLib::clipperException& e )
2998 wxLogError( wxT(
"A clipper exception %s was detected." ), e.what() );
3002 itemsByArea.emplace_back( item, area );
3005 std::sort( itemsByArea.begin(), itemsByArea.end(),
3006 [](
const std::pair<BOARD_ITEM*, double>& lhs,
3007 const std::pair<BOARD_ITEM*, double>& rhs ) ->
bool
3009 return lhs.second < rhs.second;
3012 bool rejecting =
false;
3014 for(
int i = 1; i < (int) itemsByArea.size(); ++i )
3016 if( itemsByArea[i].second > itemsByArea[i-1].second * sizeRatio )
3020 rejected.insert( itemsByArea[i].first );
3025 constexpr double maxCoverRatio = 0.70;
3027 for(
int i = 0; i < aCollector.
GetCount(); ++i )
3031 if( footprint->CoverageRatio( aCollector ) > maxCoverRatio )
3032 rejected.erase( footprint );
3037 if( (
unsigned) aCollector.
GetCount() > rejected.size() )
3049 bool haveItemOnActive =
false;
3052 for(
int i = 0; i < aCollector.
GetCount(); ++i )
3054 if( !aCollector[i]->IsOnLayer( activeLayer ) )
3055 rejected.insert( aCollector[i] );
3057 haveItemOnActive =
true;
3060 if( haveItemOnActive )
3068 bool aMultiselect )
const
3070 std::unordered_set<BOARD_ITEM*> toAdd;
3074 for(
int j = 0; j < aCollector.
GetCount(); j++ )
3076 if( aCollector[j]->GetParent() )
3077 aCollector[j]->GetParent()->ClearFlags(
CANDIDATE );
3082 for(
int j = 0; j < aCollector.
GetCount(); j++ )
3086 for(
int j = 0; j < aCollector.
GetCount(); )
3098 aCollector.
Remove( item );
3108 toAdd.insert( top );
3111 aCollector.
Remove( item );
3120 aCollector.
Remove( item );
3129 if( !aCollector.
HasItem( item ) )
3130 aCollector.
Append( item );
3137 std::set<BOARD_ITEM*> to_add;
3140 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
3145 && !
frame()->GetPcbNewSettings()->m_AllowFreePads )
3150 aCollector.
Remove( item );
3155 aCollector.
Append( item );
3162 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
3167 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.
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...
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
TEXT_TYPE GetType() const
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
Function GetDrill returns 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.
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)
@ NPTH
like PAD_PTH, but not plated
@ PTH
Plated through hole pad.
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_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ 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_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ 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_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ 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_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ 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_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_FP_TEXT_T
class FP_TEXT, text 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".