40#include <unordered_set>
76 if( aSel.GetSize() == 1 )
90 return aSel.GetSize() == 1 && aSel.Front()->Type() ==
SCH_SYMBOL_T;
96 if( aSel.GetSize() == 1 )
110 if( aSel.GetSize() == 1 )
124 if( aSel.GetSize() == 1 )
128 if(
pin &&
pin->GetLibPin() )
129 return !
pin->GetLibPin()->GetAlternates().empty();
147 return aSel.GetSize() > 1 && aSel.OnlyContains( {
SCH_SYMBOL_T } );
153 return aSel.GetSize() >= 1 && aSel.OnlyContains( {
SCH_PIN_T } );
209 itemA->Enable( !isEndpoint );
210 itemB->Enable( !isEndpoint );
258 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] update() invoked" );
266 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] defer: toolMgr not yet available" );
275 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] abort: selTool=%p baseFrame=%p", (
void*) selTool,
286 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] abort: empty selection" );
290 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] selection size=%u", sel.
GetSize() );
299 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] added createNetChain" );
303 auto pinFrom = [&](
int idx ) ->
SCH_PIN*
305 if( idx >= (
int) sel.
GetSize() )
312 bool singlePin = sel.
GetSize() == 1 && pinFrom( 0 ) && pinFrom( 0 )->GetConnectionName( &
path );
313 bool inSignal =
false;
314 bool canName =
false;
315 bool canRemove =
false;
318 for(
size_t i = 0; i < sel.
GetSize(); ++i )
326 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] sel[%zu]: not a pin or no connection", i );
330 bool hasSignal = chains.GetNetChainForNet( *netName );
331 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] sel[%zu]: pin uuid=%s net=%s committedSignal=%d", i,
344 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] flags: singlePin=%d inSignal=%d canName=%d canRemove=%d",
345 singlePin, inSignal, canName, canRemove );
351 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] added highlightNetChain" );
358 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] added removeFromNetChain" );
362 if( singlePin && inSignal )
365 replaceMenu->SetTool(
m_tool );
367 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] added replaceTerminalPin submenu" );
374 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] added nameNetChain" );
381 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] createNetChainBetweenPins attempted added=%d", added );
395 if( isConnectedPin || isConnectedWireOrBus )
398 wxLogTrace(
"KICAD_NET_CHAIN_MENU",
"[NetChainMenu] added createNetChain for single connected item" );
407 wxMenuItem* placeholder = Append( wxID_ANY,
_(
"(No net chain actions)" ) );
408 placeholder->Enable(
false );
431 wxString label = wxString::Format(
_(
"Create Net Chain between %s:%s and %s:%s" ),
443 for(
EDA_ITEM* item : aSel.Items() )
447 if( schItem->IsLocked() )
458 for(
EDA_ITEM* item : aSel.Items() )
462 if( !schItem->IsLocked() )
473 for(
int i = 0; aAllowedActions[i]; ++i )
475 if( aEvent->
IsAction( aAllowedActions[i] ) )
484#define HITTEST_THRESHOLD_PIXELS 5
571 if( symbolEditorFrame )
586 auto expandableSelection =
594 auto schEditSheetPageNumberCondition =
603 auto schEditCondition =
609 auto belowRootSheetCondition =
631 auto groupEnterCondition =
634 auto inGroupCondition =
640 auto multipleUnitsSelection =
649 return m_frame->eeconfig() &&
m_frame->eeconfig()->m_Input.allow_unconstrained_pin_swaps;
652 auto& menu =
m_menu->GetMenu();
660 return aSel.GetSize() >= 1 && aSel.OnlyContains( {
SCH_PIN_T } );
668 if( aSel.GetSize() != 1 )
678 if( !schItem->
IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ) )
690 return aSel.GetSize() >= 1 && aSel.OnlyContains( {
SCH_SYMBOL_T } );
693 std::shared_ptr<NET_CHAIN_MENU> netChainMenu = std::make_shared<NET_CHAIN_MENU>();
694 netChainMenu->SetTool(
this );
695 m_menu->RegisterSubMenu( netChainMenu );
710 menu.AddSeparator( 100 );
714 menu.AddSeparator( 100 );
721 menu.AddSeparator( 200 );
739 menu.AddSeparator( 400 );
742 menu.AddMenu( netChainMenu.get(), ( pinSelection || wireOrBusInSignal || symbolSelection ) &&
SCH_CONDITIONS::Idle, 400 );
744 menu.AddSeparator( 1000 );
780 if( symbolEditFrame )
807 auto pinOrientation =
817 return pin->GetOrientation();
822 return dummy.GetOrientation();
846 bool selCancelled =
false;
847 bool displayWireCursor =
false;
848 bool displayBusCursor =
false;
849 bool displayLineCursor =
false;
850 KIID rolloverItemId = lastRolloverItemId;
859 if( !
m_frame->ToolStackIsEmpty() )
893 schframe->ClearFocus();
900 size_t preFilterCount = collector.
GetCount();
902 narrowSelection( collector, evt->Position(),
false,
false, &rejected );
912 bool allCellsFromSameTable =
true;
922 allCellsFromSameTable =
false;
942 VECTOR2D bottomRight( std::max( start.
x,
end.x ), std::max( start.
y,
end.y ) );
965 else if( collector[0]->HasHoveredHypertext() )
967 collector[ 0 ]->DoHypertextAction(
m_frame, evt->Position() );
970 else if( collector[0]->IsNetHighlighted() )
976 schframe->SelectNetNavigatorItem( &itemData );
983 if( collector.
GetCount() == 0 && preFilterCount > 0 )
984 m_frame->HighlightSelectionFilter( rejected );
998 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T },
nullptr, &selCancelled );
1007 .Contains( evt->Position() ) )
1011 if(
CollectHits( collector, evt->Position(), { SCH_LOCATE_ANY_T } ) )
1015 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T },
nullptr, &selCancelled );
1029 schframe->ClearFocus();
1048 if( evt->Modifier(
MD_CTRL ) )
1060 evt->SetPassEvent();
1067 schframe->ClearFocus();
1073 && evt->HasPosition()
1080 else if(
CollectHits( collector, evt->DragOrigin(), { SCH_TABLECELL_T } )
1081 && !collector[0]->GetParent()->IsSelected()
1082 && ( collector[0]->GetParent()->GetParentGroup() ==
nullptr
1083 || collector[0]->GetParent()->GetParentGroup() ==
m_enteredGroup ) )
1140 std::vector<SCH_PIN*> pins;
1143 pins.push_back(
static_cast<SCH_PIN*
>( item ) );
1180 else if( evt->IsMouseDown(
BUT_AUX1 ) )
1184 else if( evt->IsMouseDown(
BUT_AUX2 ) )
1200 const int delta = evt->Parameter<
int>();
1245 wxString alt = *evt->Parameter<wxString*>();
1270 newItems.push_back( nc );
1273 if( !commit.
Empty() )
1275 commit.
Push( wxS(
"No Connect Pins" ) );
1294 switch( pinOrientation( item ) )
1307 newItems.push_back( wire );
1310 if( !commit.
Empty() )
1328 commit.
Push( wxS(
"Wire Pins" ) );
1348 labelText =
pin->GetShownName();
1350 if( labelText.IsEmpty() )
1352 labelText.Printf(
"%s_%s",
1353 pin->GetParentSymbol()->GetRef( &sheetPath ),
1366 switch( *evt->GetCommandId() )
1369 label =
new SCH_LABEL( item->GetPosition(), labelText );
1372 label =
new SCH_HIERLABEL( item->GetPosition(), labelText );
1381 switch( pinOrientation( item ) )
1394 pinType =
pin->GetType();
1430 newItems.push_back( label );
1433 if( !commit.
Empty() )
1435 commit.
Push( wxS(
"Label Pins" ) );
1447 wxString* net =
new wxString( *evt->Parameter<wxString*>() );
1451 else if( evt->IsCancelInteractive() )
1461 schframe->ClearFocus();
1467 else if( evt->FirstResponder() ==
this && evt->GetCommandId() == (
int) WXK_ESCAPE )
1477 if(
editor &&
m_frame->eeconfig()->m_Input.esc_clears_net_highlight )
1478 editor->ClearHighlight( *evt );
1485 evt->SetPassEvent(
false );
1491 schframe->ClearFocus();
1493 else if( evt->IsMotion() && !
m_isSymbolEditor && evt->FirstResponder() ==
this )
1512 displayBusCursor =
true;
1514 displayWireCursor =
true;
1516 displayLineCursor =
true;
1518 else if( collector[0]->HasHypertext() && !collector[0]->IsSelected() )
1520 rolloverItemId = collector[0]->m_Uuid;
1527 evt->SetPassEvent();
1530 if( lastRolloverItemId !=
niluuid && lastRolloverItemId != rolloverItemId )
1539 m_frame->GetCanvas()->GetView()->Update( item );
1544 if( rolloverItemId !=
niluuid )
1546 rolloverItem =
static_cast<SCH_ITEM*
>(
m_frame->ResolveItem( rolloverItemId ) );
1553 m_frame->GetCanvas()->GetView()->Update( rolloverItem );
1556 lastRolloverItemId = rolloverItemId;
1558 if(
m_frame->ToolStackIsEmpty() )
1560 if( displayWireCursor )
1564 else if( displayBusCursor )
1568 else if( displayLineCursor )
1578 && evt->HasPosition()
1603 wxT(
"EnterGroup called when selection is not a single group" ) );
1662 if(
m_frame->eeconfig()->m_Drawing.auto_start_wires
1697 if( possibleConnection.
IsBus() )
1705 if( !
pin || !
pin->IsPointClickableAnchor( pos ) )
1708 if( !
pin->IsVisible() && !(
m_frame->eeconfig()->m_Appearance.show_hidden_pins
1709 ||
m_frame->GetRenderSettings()->m_ShowHiddenPins ) )
1715 newEvt->SetMousePosition( pos );
1716 newEvt->SetHasPosition(
true );
1717 newEvt->SetForceImmediate(
true );
1730 wxMouseState keyboardState = wxGetMouseState();
1732 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), keyboardState.AltDown() );
1747 wxMouseState keyboardState = wxGetMouseState();
1749 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(), keyboardState.AltDown() );
1770 const std::vector<KICAD_T>& aScanTypes )
1773 int gridThreshold =
KiROUND(
getView()->GetGAL()->GetGridSize().EuclideanNorm() / 2.0 );
1774 aCollector.
m_Threshold = std::max( pixelThreshold, gridThreshold );
1792 if( (
m_frame->eeconfig() &&
m_frame->eeconfig()->m_Selection.select_pin_selects_symbol ) || !
m_filter.pins )
1794 int originalCount = aCollector.
GetCount();
1796 for(
int ii = 0; ii < originalCount; ++ii )
1798 if( aCollector[ii]->Type() ==
SCH_PIN_T )
1802 if( !aCollector.
HasItem(
pin->GetParentSymbol() ) )
1803 aCollector.
Append(
pin->GetParentSymbol() );
1818 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
1820 if( symbolEditorFrame )
1849 if( aCheckLocked && collector[i]->IsLocked() )
1864 if( aSelectedOnly && !collector[i]->IsSelected() )
1880 bool* aSelectionCancelledFlag,
bool aAdd,
bool aSubtract,
bool aExclusiveOr )
1898 if( aSelectionCancelledFlag )
1899 *aSelectionCancelledFlag =
true;
1905 if( !aAdd && !aSubtract && !aExclusiveOr )
1913 bool foundEnteredGroup =
false;
1919 foundEnteredGroup =
true;
1924 if( !foundEnteredGroup )
1931 bool anySubtracted =
false;
1935 for(
int i = 0; i < aCollector.
GetCount(); ++i )
1938 bool isLine = aCollector[i]->Type() ==
SCH_LINE_T;
1954 || ( aExclusiveOr && aCollector[i]->IsSelected()
1955 && ( !isLine || ( isLine && aCollector[i]->HasFlag( flags ) ) ) ) )
1957 aCollector[i]->ClearFlags( flags );
1967 anySubtracted =
true;
1972 aCollector[i]->SetFlags( flags );
1979 if( addedCount == 1 )
1983 if( aItem && aCollector.
GetCount() == 1 )
1984 *aItem = aCollector[0];
1988 else if( addedCount > 1 )
1993 else if( anySubtracted )
1999 m_frame->GetCanvas()->ForceRefresh();
2005 EDA_ITEM** aItem,
bool* aSelectionCancelledFlag,
bool aCheckLocked,
2006 bool aAdd,
bool aSubtract,
bool aExclusiveOr )
2010 if( !
CollectHits( collector, aWhere, aScanTypes ) )
2013 size_t preFilterCount = collector.
GetCount();
2015 rejected.
SetAll(
false );
2016 narrowSelection( collector, aWhere, aCheckLocked, aSubtract, &rejected );
2018 if( collector.
GetCount() == 0 && preFilterCount > 0 )
2021 frame->HighlightSelectionFilter( rejected );
2023 if( !aAdd && !aSubtract && !aExclusiveOr &&
m_selection.GetSize() > 0 )
2032 return selectPoint( collector, aWhere, aItem, aSelectionCancelledFlag, aAdd, aSubtract, aExclusiveOr );
2042 std::vector<EDA_ITEM*> sheetPins;
2048 view->
Query( selectionBox,
2056 collection.
Append( item );
2070 sheetPins.emplace_back(
pin );
2091 m_frame->GetCanvas()->ForceRefresh();
2101 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
2107 view->
Query( selectionBox, selectedItems );
2132 m_frame->GetCanvas()->ForceRefresh();
2140 std::set<EDA_ITEM*> exactHits;
2142 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
2156 if( item->
HitTest( aPos, pixelThreshold ) )
2157 exactHits.insert( item );
2159 else if( symbol &&
m_frame->eeconfig()->m_Selection.select_pin_selects_symbol )
2162 exactHits.insert( item );
2171 if(
m_frame->GetRenderSettings()->m_ShowPinsElectricalType )
2174 if( item->
HitTest( aPos, 0 ) )
2175 exactHits.insert( item );
2181 if( exactHits.size() > 0 && exactHits.size() < (
unsigned) collector.
GetCount() )
2183 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
2187 if( !exactHits.contains( item ) )
2193 SEG poss( aPos, aPos );
2195 int closestDist = INT_MAX / 4;
2199 BOX2I bbox = item->GetBoundingBox();
2200 int dist = INT_MAX / 4;
2205 bool dominating =
false;
2207 if( exactHits.contains( item ) )
2245 text->GetEffectiveTextShape(
false )->Collide( poss, INT_MAX / 4, &dist );
2251 shapes->Collide( poss, INT_MAX / 4, &dist );
2265 rect.
Collide( poss, closestDist, &dist );
2283 if( dist == closestDist )
2285 if( item->GetParent() == closest )
2288 else if( dist < closestDist )
2304 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
2308 if( item == closest )
2311 if( !item->
HitTest( tightBox,
true ) )
2319 bool aPromoteCellSelections,
bool aPromoteGroups )
2321 bool anyUnselected =
false;
2322 bool anySelected =
false;
2335 bool isMoving =
false;
2337 for(
int i = (
int)
m_selection.GetSize() - 1; i >= 0; --i )
2342 if( !item->
IsType( aScanTypes ) )
2345 anyUnselected =
true;
2353 if( aPromoteGroups )
2355 for(
int i = (
int)
m_selection.GetSize() - 1; i >= 0; --i )
2359 std::set<EDA_ITEM*> selectedChildren;
2363 static_cast<SCH_ITEM*
>(item)->RunOnChildren(
2366 if( aChild->
IsType( aScanTypes ) )
2367 selectedChildren.insert( aChild );
2371 anyUnselected =
true;
2374 for(
EDA_ITEM* child : selectedChildren )
2376 if( !child->IsSelected() )
2388 if( aPromoteCellSelections )
2390 std::set<EDA_ITEM*> parents;
2392 for(
int i = (
int)
m_selection.GetSize() - 1; i >= 0; --i )
2400 anyUnselected =
true;
2406 if( !parent->IsSelected() )
2429 std::set<EDA_ITEM*> rejected;
2434 rejected.insert( item );
2438 aCollector.
Remove( item );
2449 if( schItem->IsLocked() && !
m_filter.lockedItems )
2458 switch( aItem->
Type() )
2477 aRejected->
pins =
true;
2488 aRejected->
wires =
true;
2497 switch(
static_cast<SCH_LINE*
>( aItem )->GetLayer() )
2504 aRejected->
wires =
true;
2543 aRejected->
text =
true;
2556 aRejected->
labels =
true;
2567 aRejected->
images =
true;
2650 bool cancelled =
false;
2666 isGreedy = !isGreedy;
2671 if( evt->IsCancelInteractive() || evt->IsActivate() )
2684 area.
SetEnd( evt->Position() );
2701 evt->SetPassEvent(
false );
2723 bool cancelled =
false;
2739 bool isClockwise = shapeArea > 0 ? true :
false;
2741 if(
getView()->IsMirroredX() && shapeArea != 0 )
2742 isClockwise = !isClockwise;
2755 if( evt->IsCancelInteractive() || evt->IsActivate() )
2764 points.
Append( evt->Position() );
2766 else if( evt->IsDblClick(
BUT_LEFT )
2805 area.
SetMode( selectionMode );
2832 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>
candidates;
2836 std::set<SCH_ITEM*> uniqueCandidates;
2838 for(
const auto& [viewItem, layer] :
candidates )
2840 if( viewItem->IsSCH_ITEM() )
2841 uniqueCandidates.insert(
static_cast<SCH_ITEM*
>( viewItem ) );
2850 if( boxMode ? selectionRect.
Intersects(
pin->GetBoundingBox() )
2853 uniqueCandidates.insert(
pin );
2861 if( boxMode ? selectionRect.
Intersects(
pin->GetBoundingBox() )
2864 uniqueCandidates.insert(
pin );
2870 if( field.IsVisible()
2871 && ( boxMode ? selectionRect.
Intersects( field.GetBoundingBox() )
2874 uniqueCandidates.insert( &field );
2882 std::set<EDA_ITEM*> group_items;
2891 std::unordered_set<EDA_ITEM*>& newset =
group->GetItems();
2894 [&](
const BOX2I& aBox )
2896 return boxMode ? selectionRect.
Contains( aBox )
2900 if( containedMode && boxContained(
group->GetBoundingBox() ) && newset.size() )
2902 for(
EDA_ITEM* group_item : newset )
2904 if( !group_item->IsSCH_ITEM() )
2908 collector.
Append( group_item );
2912 for(
EDA_ITEM* group_item : newset )
2913 group_items.emplace( group_item );
2919 return boxMode ? aItem->HitTest( selectionRect, containedMode )
2920 : aItem->HitTest( aArea.
GetPoly(), containedMode );
2923 for(
SCH_ITEM* item : uniqueCandidates )
2926 && ( hitTest( item ) || item->Type() ==
SCH_LINE_T )
2927 && ( !containedMode || !group_items.count( item ) ) )
2930 pinsCollector.
Append( item );
2932 collector.
Append( item );
2941 collector = pinsCollector;
2946 std::sort( collector.
begin(), collector.
end(),
2949 VECTOR2I aPos = a->GetPosition();
2950 VECTOR2I bPos = b->GetPosition();
2952 if( aPos.y == bPos.y )
2953 return aPos.x < bPos.x;
2955 return aPos.y < bPos.y;
2958 bool anyAdded =
false;
2959 bool anySubtracted =
false;
2964 if( aSubtractive || ( aExclusiveOr && aItem->
IsSelected() ) )
2974 anySubtracted =
true;
2977 if( flags && !anySubtracted )
2988 std::vector<EDA_ITEM*> flaggedItems;
2990 auto shapeContains =
2993 return boxMode ? selectionRect.
Contains( aPoint )
3002 flaggedItems.push_back( item );
3004 if(
m_frame->GetRenderSettings()->m_ShowPinsElectricalType )
3013 hits = line->
HitTest( selectionRect,
false );
3017 if( ( !containedMode && hits )
3022 else if( containedMode )
3032 selectItem( item, flags );
3035 selectItem( item, flags );
3040 for(
EDA_ITEM* item : pinsCollector )
3042 if(
m_frame->GetRenderSettings()->m_ShowPinsElectricalType )
3059 && hitTest(
static_cast<SCH_ITEM*
>( item ) ) )
3061 selectItem( item, 0 );
3067 for(
EDA_ITEM* item : flaggedItems )
3074 else if( anySubtracted )
3081 std::unordered_set<EDA_ITEM*> toAdd;
3085 for(
int j = 0; j < aCollector.
GetCount(); j++ )
3087 if( aCollector[j]->GetParent() )
3090 if( aCollector[j]->GetParentSymbol() )
3096 for(
int j = 0; j < aCollector.
GetCount(); j++ )
3101 const std::vector<KICAD_T>& scanTypes = aCollector.
GetScanTypes();
3102 bool promoteToGroups = scanTypes.empty()
3106 for(
int j = 0; j < aCollector.
GetCount(); )
3118 aCollector.
Remove( item );
3127 if(
top->AsEdaItem() != item )
3129 toAdd.insert(
top->AsEdaItem() );
3132 aCollector.
Remove( item );
3141 aCollector.
Remove( item );
3150 if( !aCollector.
HasItem( item ) )
3151 aCollector.
Append( item );
3161 std::vector<EDA_ITEM*> toRemove;
3167 bool lockedDescendant =
false;
3169 schItem->RunOnChildren(
3173 lockedDescendant =
true;
3177 if( schItem->IsLocked() || lockedDescendant )
3178 toRemove.push_back( item );
3200 if( cell->IsSelected() )
3212 auto wasSelected = [](
EDA_ITEM* aItem )
3219 bool doSelect =
false;
3221 if( cell->HitTest( selectionRect,
false ) )
3226 doSelect = !wasSelected( cell );
3230 else if( wasSelected( cell ) )
3235 if( doSelect && !cell->IsSelected() )
3237 else if( !doSelect && cell->IsSelected() )
3244 bool cancelled =
false;
3251 if( evt->IsCancelInteractive() || evt->IsActivate() )
3259 SelectCellsBetween( evt->DragOrigin(), evt->Position() - evt->DragOrigin(), aTable );
3261 else if( evt->IsMouseUp(
BUT_LEFT ) )
3265 bool anyAdded =
false;
3266 bool anySubtracted =
false;
3273 anySubtracted =
true;
3289 evt->SetPassEvent();
3313 int gridThreshold =
KiROUND(
getView()->GetGAL()->GetGridSize().EuclideanNorm() );
3314 int thresholdMax = std::max( pixelThreshold, gridThreshold );
3316 for(
int threshold : { 0, thresholdMax/4, thresholdMax/2, thresholdMax } )
3325 return collector.
GetCount() ? collector[ 0 ] :
nullptr;
3349 std::vector<SCH_ITEM*> startItems;
3350 std::set<SCH_ITEM*> added;
3352 for(
auto item : aItems )
3354 if( !item->IsSCH_ITEM() )
3364 startItems.push_back(
pin );
3369 startItems.push_back( schItem );
3373 if( startItems.empty() )
3378 std::unordered_set<SCH_SYMBOL*> startSymbols;
3385 startSymbols.insert( parent );
3391 std::set<VECTOR2I> pinPositions;
3398 pinPositions.insert(
pin->GetPosition() );
3402 auto isStopPoint = [&](
const VECTOR2I& aPoint ) ->
bool
3407 if( pinPositions.count( aPoint ) )
3418 switch( it->Type() )
3426 if( it->IsConnected( aPoint ) )
3441 auto shouldPullInSymbol = [&]()
3446 std::deque<SCH_ITEM*> queue;
3447 std::unordered_set<SCH_ITEM*> visited;
3449 auto enqueue = [&](
SCH_ITEM* aItem )
3454 if( visited.insert( aItem ).second )
3455 queue.push_back( aItem );
3470 std::vector<SCH_ITEM*> publishedNeighbors;
3471 const auto neighborsOf = [&](
SCH_ITEM* aItem ) ->
const std::vector<SCH_ITEM*>&
3474 return aItem->ConnectedItems( currentSheet );
3477 aItem->m_Uuid, currentSheet.
PathRef() );
3478 publishedNeighbors = connection ? connection->ConnectedItems() : std::vector<SCH_ITEM*>();
3479 return publishedNeighbors;
3482 while( !queue.empty() )
3491 if( shouldPullInSymbol() && symbol &&
Selectable( symbol )
3494 added.insert( symbol );
3499 std::vector<VECTOR2I> openPoints;
3505 if( !isStopPoint( pt ) )
3506 openPoints.push_back( pt );
3510 for(
SCH_ITEM* neighbor : neighborsOf( item ) )
3522 added.insert( symbol );
3531 bool sharesOpenPoint =
false;
3533 for(
const VECTOR2I& pt : openPoints )
3535 if( neighbor->IsConnected( pt ) )
3537 sharesOpenPoint =
true;
3542 if( !sharesOpenPoint )
3546 enqueue( neighbor );
3552 added.insert( item );
3561 std::set<SCH_ITEM*> added;
3563 for(
auto item : aItems )
3565 if( !item->IsSCH_ITEM() )
3570 std::set<SCH_ITEM*> conns =
m_frame->GetScreen()->MarkConnections( schItem, schItem->
IsConnectable() );
3578 added.insert( connItem );
3601 if( !selItem->IsSCH_ITEM() )
3607 graphicalSelection.
Add( item );
3609 graphicalSelection.
Add( item );
3611 connectableSelection.
Add( item );
3624 std::unordered_set<const SCH_ITEM*> originalConnectableSet;
3627 originalConnectableSet.insert(
static_cast<const SCH_ITEM*
>( selItem ) );
3631 std::set<SCH_ITEM*> graphAdded;
3632 std::set<SCH_ITEM*> graphicalAdded;
3634 if( !connectableSelection.
Empty() )
3642 bool grew = std::any_of( graphAdded.begin(), graphAdded.end(),
3645 return !originalConnectableSet.count( c );
3655 if( graphAdded.empty() && !connectableSelection.
Empty() )
3660 combinedSelection.
Add( selItem );
3662 graphicalSelection = combinedSelection;
3667 auto smartAddToSel = [&](
EDA_ITEM* aItem )
3676 for(
auto item : graphAdded )
3677 smartAddToSel( item );
3679 for(
auto item : graphicalAdded )
3680 smartAddToSel( item );
3682 for(
auto item : originalSelection )
3683 smartAddToSel( item );
3702 std::set<std::pair<SCH_TABLE*, int>> columns;
3710 columns.insert( std::make_pair(
table, cell->GetColumn() ) );
3714 for(
auto& [
table, col ] : columns )
3716 for(
int row = 0; row <
table->GetRowCount(); ++row )
3737 std::set<std::pair<SCH_TABLE*, int>> rows;
3745 rows.insert( std::make_pair(
table, cell->GetRow() ) );
3749 for(
auto& [
table, row ] : rows )
3751 for(
int col = 0; col <
table->GetColCount(); ++col )
3772 std::set<SCH_TABLE*> tables;
3778 tables.insert(
static_cast<SCH_TABLE*
>( cell->GetParent() ) );
3785 if( !
table->IsSelected() )
3828 double compRatio = bbSize.
y / currTextHeight;
3829 double compRatioBent = 1.0;
3835 std::vector<std::pair<double, double>> lut{ { 1.25, 16 },
3844 std::vector<std::pair<double, double>>::iterator it;
3847 compRatioBent = lut.back().second;
3851 if( compRatio >= lut.front().first )
3853 for( it = lut.begin(); it < lut.end() - 1; ++it )
3855 if( it->first <= compRatio &&
next( it )->first >= compRatio )
3857 double diffx = compRatio - it->first;
3858 double diffn =
next( it )->first - it->first;
3860 compRatioBent = it->second + (
next( it )->second - it->second ) * diffx / diffn;
3867 compRatioBent = lut.front().second;
3876 screenSize.
x = std::max( 10.0, screenSize.
x );
3877 screenSize.
y = std::max( 10.0, screenSize.
y );
3878 double ratio = std::max( -1.0, fabs( bbSize.
y / screenSize.
y ) );
3881 double kicadRatio = std::max( fabs( bbSize.
x / screenSize.
x ),
3882 fabs( bbSize.
y / screenSize.
y ) );
3887 if( bbSize.
x > screenSize.
x * ratio * compRatioBent )
3891 compRatioBent = 1.0;
3892 wxLogTrace(
"CROSS_PROBE_SCALE",
3893 "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
3898 ratio *= compRatioBent;
3900 bool alwaysZoom =
false;
3903 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
3909 SCH_ITEM* focusItem,
const std::vector<SCH_ITEM*>& items )
3916 double targetZoom = 0.0;
3918 bool targetZoomValid =
false;
3919 bool changedSheet =
false;
3921 if( targetSheetPath )
3927 targetZoom = screen->m_LastZoomLevel;
3928 targetCenter = screen->m_ScrollCenter;
3929 targetZoomValid = screen->IsZoomInitialized();
3935 changedSheet =
true;
3939 if( changedSheet && targetZoomValid && !
m_frame->eeconfig()->m_CrossProbing.zoom_to_fit )
3953 if(
m_frame->GetScreen()->CheckIfOnDrawList( item )
3954 || ( parent &&
m_frame->GetScreen()->CheckIfOnDrawList( parent ) ) )
3964 if(
m_frame->eeconfig()->m_CrossProbing.center_on_items )
3966 if(
m_frame->eeconfig()->m_CrossProbing.zoom_to_fit )
3985 bool enteredGroupFound =
false;
3993 if( item.IsSelected() )
4001 enteredGroupFound =
true;
4015 if( item->IsSelected() )
4021 item->RunOnChildren(
4035 enteredGroupFound =
true;
4047 if( !enteredGroupFound )
4069 switch( aItem->
Type() )
4084 if( !
pin->IsVisible() && !
m_frame->GetShowAllPins() )
4087 if( (
m_frame->eeconfig() &&
m_frame->eeconfig()->m_Selection.select_pin_selects_symbol ) || !
m_filter.pins )
4095 if(
pin->IsPointClickableAnchor(
grid.ResolveSnap( *aPos, pinGrid ).position ) )
4106 if( !
m_frame->eeconfig()->m_Appearance.show_directive_labels )
4114 if( !
m_frame->eeconfig()->m_Appearance.show_directive_labels
4222 aGroup->
Add( aItem );
4232 sch_item->RunOnChildren(
4283 sch_item->RunOnChildren(
4297 aGroup->
Remove( aChild );
4311 const unsigned GRIP_MARGIN = 20;
4317 BOX2I itemBox = item->ViewBBox();
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
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 selectSetLasso
static TOOL_ACTION selectSetRect
Set lasso selection mode.
static TOOL_ACTION groupEnter
static TOOL_ACTION selectColumns
static TOOL_ACTION cursorDown
static TOOL_ACTION zoomOut
static TOOL_ACTION cursorRightFast
static TOOL_ACTION zoomCenter
static TOOL_ACTION panDown
static TOOL_ACTION cursorDblClick
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION cursorDownFast
static TOOL_ACTION selectionMenu
Run a selection menu to select from a list of items.
static TOOL_ACTION 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.
constexpr const Vec & GetPosition() const
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 const Vec GetCenter() const
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const SizeVec & GetSize() const
constexpr bool Intersects(const BOX2< Vec > &aRect) const
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
const std::vector< KICAD_T > & GetScanTypes() const
void Transfer(int aIndex)
Move the item at aIndex (first position is 0) to the backup 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 & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
bool IsHorizontal() const
The base frame for deriving all KiCad main window classes.
bool IsType(FRAME_T aType) const
void FocusOnLocation(const VECTOR2I &aPos, bool aAllowScroll=true)
Useful to focus on a particular location, in find functions.
A set of EDA_ITEMs (i.e., without duplicates).
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
void SetIsRollover(bool aIsRollover, const VECTOR2I &aMousePos)
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 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
void XorFlags(EDA_ITEM_FLAGS aMask)
EDA_ITEM_FLAGS GetFlags() const
virtual bool IsFilledForHitTesting() const
virtual std::vector< SHAPE * > MakeEffectiveShapesForHitTesting() const
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
virtual bool IsVisible() const
virtual EDA_ANGLE GetTextAngle() 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.
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Get the coarsest grid that applies to an item.
SNAP_RESULT ResolveSnap(const VECTOR2I &aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM *aSkip)
EE_TYPE Overlapping(const BOX2I &aRect) const
EE_TYPE OfType(KICAD_T aType) const
static const TOOL_EVENT DisambiguatePoint
Used to inform tool that it should display the disambiguation menu.
static const TOOL_EVENT ClearedEvent
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected item had a property changed (except movement)
static const TOOL_EVENT PointSelectedEvent
static const TOOL_EVENT SelectedItemsMoved
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT UnselectedEvent
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
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)
Set the origin of the rectangle (the fixed corner)
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
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.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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.
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.
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...
bool IsMirroredX() const
Return true if view is flipped across the X axis.
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
void Hide(VIEW_ITEM *aItem, bool aHide=true, bool aHideOverlay=false)
Temporarily hide the item in the view (e.g.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
wxString AsString() const
Define a library symbol object.
bool IsPower() const override
bool IsMultiBodyStyle() const override
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
int GetUnitCount() const override
Tree view item data for the net navigator.
SCH_CONNECTIVITY::NETCHAIN_MANAGER & NetChains() const
SCH_CONNECTIVITY::FACADE & Connectivity() const
CONNECTION_GRAPH * ConnectionGraph() const
SCH_SHEET_PATH & CurrentSheet() const
static TOOL_ACTION placeClassLabel
static TOOL_ACTION placeSheetPin
static TOOL_ACTION createNetChain
static TOOL_ACTION placeNextSymbolUnit
static TOOL_ACTION swapPins
static TOOL_ACTION saveToLinkedDesignBlock
static TOOL_ACTION clearHighlight
static TOOL_ACTION placeGlobalLabel
static TOOL_ACTION pinTable
static TOOL_ACTION navigateBack
static TOOL_ACTION properties
static TOOL_ACTION leaveSheet
static TOOL_ACTION breakWire
static TOOL_ACTION removeFromNetChain
static TOOL_ACTION findNetInInspector
static TOOL_ACTION autoplaceAllSheetPins
static TOOL_ACTION drawLines
static TOOL_ACTION placeHierLabel
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
static TOOL_ACTION placeLabel
static TOOL_ACTION nextNetItem
static TOOL_ACTION drawWire
static TOOL_ACTION highlightNetChain
static TOOL_ACTION placeJunction
static TOOL_ACTION previousNetItem
static TOOL_ACTION swapUnitLabels
static TOOL_ACTION navigateForward
static TOOL_ACTION placeLinkedDesignBlock
static TOOL_ACTION selectNode
Select the junction, wire or bus segment under the cursor.
static TOOL_ACTION unfoldBus
static TOOL_ACTION drawBus
static TOOL_ACTION symbolProperties
static TOOL_ACTION changeSheet
static TOOL_ACTION assignNetclass
static TOOL_ACTION swapPinLabels
static TOOL_ACTION enterSheet
static TOOL_ACTION replaceTerminalPin
static TOOL_ACTION createNetChainBetweenPins
static TOOL_ACTION editPageNumber
static TOOL_ACTION selectOnPCB
static TOOL_ACTION syncSheetPins
static TOOL_ACTION nameNetChain
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Class for a wire to bus entry.
SCH_ITEM * m_connected_bus_item
Pointer to the bus item (usually a bus wire) connected to this bus-wire entry, if it is connected to ...
void Collect(SCH_SCREEN *aScreen, const std::vector< KICAD_T > &aScanTypes, const VECTOR2I &aPos, int aUnit=0, int aBodyStyle=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
bool m_ShowPinElectricalTypes
static const std::vector< KICAD_T > MovableItems
Commit for the schematic and symbol editors.
void Revert() override
Revert the commit by restoring the modified items state.
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
static SELECTION_CONDITION SingleMultiFunctionPin
static SELECTION_CONDITION SingleSymbol
static SELECTION_CONDITION MultipleSymbolsOrPower
static SELECTION_CONDITION HasLockedItems
static SELECTION_CONDITION AllPinsOrSheetPins
static SELECTION_CONDITION SingleSymbolOrPower
static SELECTION_CONDITION HasUnlockedItems
static SELECTION_CONDITION SingleNonExcludedMarker
static SELECTION_CONDITION SingleMultiUnitSymbol
static SELECTION_CONDITION SingleMultiBodyStyleSymbol
static SELECTION_CONDITION AllPins
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void ConfigureFromLabel(const wxString &aLabel)
Configures the connection given a label.
std::optional< ITEM_VIEW > Connection(const KIID &aItem, const KIID_PATH &aPath) const
One UI operation's hierarchy index.
std::vector< SCH_ITEM * > WholeNetItems(const std::vector< SCH_ITEM * > &aSeeds, const SCH_SHEET_PATH &aSheet) const
SCH_NETCHAIN * GetNetChainForNet(const wxString &aNet)
SCH_NETCHAIN * FindPotentialNetChainBetweenPins(SCH_PIN *aPinA, const SCH_SHEET_PATH &aPathA, SCH_PIN *aPinB, const SCH_SHEET_PATH &aPathB)
Handle actions specific to the schematic editor.
Schematic editor (Eeschema) main window.
void FocusOnItem(EDA_ITEM *aItem, bool aAllowScroll=true) override
Focus on a particular canvas item.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr, bool aCleanupDone=false)
Generate the connection data for the entire schematic hierarchy.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
const SCH_ITEM * SelectNextPrevNetNavigatorItem(bool aNext)
const wxString & GetHighlightedConnection() const
wxGenericTreeCtrl * GetNetNavigator()
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
A set of SCH_ITEMs (i.e., without duplicates).
static bool WithinScope(SCH_ITEM *aItem, SCH_GROUP *aScope, bool isSymbolEditor)
static EDA_GROUP * TopLevelGroup(SCH_ITEM *aItem, EDA_GROUP *aScope, bool isSymbolEditor)
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
virtual bool HasHoveredHypertext() const
Indicates that a hypertext link is currently active.
const SYMBOL * GetParentSymbol() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
virtual bool IsPointClickableAnchor(const VECTOR2I &aPos) const
bool IsLocked() const override
std::optional< wxString > GetConnectionName(const SCH_SHEET_PATH *aSheet=nullptr, bool aLocal=false, bool aIgnoreSheet=false) const
Return the active connection name; absent for missing or stale published rows.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
void SetShape(LABEL_FLAG_SHAPE aShape)
LABEL_SHAPE GetLabelShape() const
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, int aDepth=0) const override
virtual void SetSpinStyle(SPIN_STYLE aSpinStyle)
Segment description base class to describe items which have 2 end points (track, wire,...
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool IsStartDangling() const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
SEG GetSeg() const
Get the geometric aspect of the wire as a SEG.
bool IsEndDangling() const
bool IsBus() const
Return true if the line is a bus.
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
void SetEndPoint(const VECTOR2I &aPosition)
A net chain is a collection of nets that are connected together through passive components.
const wxString & GetNumber() const
Tool that displays edit points allowing to modify items by dragging the points.
bool HasPoint()
Indicate the cursor is over an edit point.
bool IsDirectiveLabelOnlyArea() const
Return true when the rule area exists only as a container for attached directive labels.
bool IsExplicitJunction(const VECTOR2I &aPosition) const
Indicate that a junction dot is necessary at the given location.
EE_RTREE & Items()
Get the full RTree, usually for iterating.
bool IsJunction(const VECTOR2I &aPosition) const
Test if a junction is required for the items at aPosition on the screen.
VECTOR2I GetCenter() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
const KIID_PATH & PathRef() const
Borrow the cached path until this sheet path is modified or destroyed.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
SHEET_SIDE GetSide() const
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
std::vector< SCH_SHEET_PIN * > & GetPins()
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
int GetOrientation() const override
Get the display symbol orientation.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
std::vector< SCH_TABLECELL * > GetCells() const
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
static SELECTION_CONDITION HasTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if among the selected items there is at least one of a given types.
static SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
static bool Empty(const SELECTION &aSelection)
Test if there are no 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 bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static SELECTION_CONDITION LessThan(int aNumber)
Create a functor that tests if the number of selected items is smaller 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.
const std::deque< EDA_ITEM * > GetItems() const
VECTOR2I GetReferencePoint() const
virtual void Remove(EDA_ITEM *aItem)
virtual unsigned int GetSize() const override
Return the number of stored items.
bool OnlyContains(std::vector< KICAD_T > aList) const
Checks if all items in the selection have a type in aList.
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
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.
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 PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const override
Check if point aP lies inside a closed shape.
bool Collide(const SHAPE *aShape, int aClearance, VECTOR2I *aActual) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
The symbol library editor main window.
bool GetShowInvisibleFields()
bool IsSymbolAlias() const
bool GetShowInvisiblePins()
Symbol library viewer main window.
A base class for LIB_SYMBOL and SCH_SYMBOL.
virtual const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const =0
const TRANSFORM & GetTransform() const
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
#define DEFAULT_TEXT_SIZE
The default text size in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
#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 SELECTION_CANDIDATE
indicates an item is a candidate for selection
#define ENTERED
indicates a group has been entered
#define ENDPOINT
ends. (Used to support dragging.)
std::uint32_t EDA_ITEM_FLAGS
#define IS_MOVING
Item being moved.
#define SHOW_ELEC_TYPE
Show pin electrical type.
#define STARTPOINT
When a line is selected, these flags indicate which.
@ ID_POPUP_SCH_PIN_TRICKS_START
@ ID_POPUP_SCH_PIN_TRICKS_HIER_LABEL
@ ID_POPUP_SCH_PIN_TRICKS_WIRE
@ ID_POPUP_SCH_PLACE_UNIT_END
@ ID_POPUP_SCH_ALT_PIN_FUNCTION
@ ID_POPUP_SCH_UNFOLD_BUS_END
@ ID_POPUP_SCH_SELECT_UNIT
@ ID_POPUP_SCH_SELECT_BODY_STYLE
@ ID_POPUP_SCH_PIN_TRICKS_NET_LABEL
@ ID_POPUP_SCH_SELECT_BODY_STYLE_END
@ ID_POPUP_SCH_PIN_TRICKS_NO_CONNECT
@ ID_POPUP_SCH_UNFOLD_BUS
@ ID_POPUP_SCH_SELECT_UNIT_END
@ ID_POPUP_SCH_ALT_PIN_FUNCTION_END
@ ID_REPLACE_TERMINAL_PIN_A
@ ID_REPLACE_TERMINAL_PIN_B
@ ID_POPUP_SCH_PLACE_UNIT
@ ID_POPUP_SCH_PIN_TRICKS_GLOBAL_LABEL
@ ID_POPUP_SCH_PIN_TRICKS_END
a few functions useful in geometry calculations.
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
@ REPAINT
Item needs to be redrawn.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
@ PT_INPUT
usual pin input: must be connected
@ PT_TRISTATE
tri state bus pin
@ PT_BIDI
input or output (like port for a microprocessor)
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
@ PIN_UP
The pin extends upwards from the connection point: Probably on the bottom side of the symbol.
@ PIN_RIGHT
The pin extends rightwards from the connection point.
@ PIN_LEFT
The pin extends leftwards from the connection point: Probably on the right side of the symbol.
@ PIN_DOWN
The pin extends downwards from the connection: Probably on the top side of the symbol.
#define HITTEST_THRESHOLD_PIXELS
Class to handle a set of SCH_ITEMs.
std::vector< EDA_ITEM * > EDA_ITEMS
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
std::vector< FAB_LAYER_COLOR > dummy
Increment event parameters.
bool text
Text and fields.
bool symbols
Allow selecting symbols and sheet symbols.
bool labels
Net and bus labels.
bool pins
Symbol and sheet pins.
bool graphics
Graphic lines, shapes, polygons.
bool lockedItems
Allow selecting locked items.
bool images
Bitmap/vector images.
bool otherItems
Anything not fitting one of the above categories.
bool ruleAreas
Rule areas.
bool wires
Net and bus wires and junctions.
KIBIS top(path, &reporter)
static std::vector< int > candidates(const SEGMENT_INDEX &aIndex, const SEG &aQuery, int aPadding)
@ NOT_USED
the 3d code uses this value
@ SCH_ITEM_LOCATE_GRAPHIC_LINE_T
@ SCH_SYMBOL_LOCATE_POWER_T
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D