39#include <unordered_set>
74 if( aSel.GetSize() == 1 )
88 return aSel.GetSize() == 1 && aSel.Front()->Type() ==
SCH_SYMBOL_T;
94 if( aSel.GetSize() == 1 )
108 if( aSel.GetSize() == 1 )
122 if( aSel.GetSize() == 1 )
126 if(
pin &&
pin->GetLibPin() )
127 return !
pin->GetLibPin()->GetAlternates().empty();
145 return aSel.GetSize() > 1 && aSel.OnlyContains( {
SCH_SYMBOL_T } );
151 return aSel.GetSize() >= 1 && aSel.OnlyContains( {
SCH_PIN_T } );
163 for(
int i = 0; aAllowedActions[i]; ++i )
165 if( aEvent->
IsAction( aAllowedActions[i] ) )
174#define HITTEST_THRESHOLD_PIXELS 5
261 if( symbolEditorFrame )
276 auto expandableSelection =
284 auto schEditSheetPageNumberCondition =
294 auto schEditCondition =
300 auto belowRootSheetCondition =
324 auto groupEnterCondition =
327 auto inGroupCondition =
333 auto multipleUnitsSelection = [](
const SELECTION& aSel )
342 m_frame->eeconfig()->m_Input.allow_unconstrained_pin_swaps;
346 auto& menu =
m_menu->GetMenu();
361 menu.AddSeparator( 100 );
365 menu.AddSeparator( 100 );
372 menu.AddSeparator( 200 );
390 menu.AddSeparator( 400 );
394 menu.AddSeparator( 1000 );
430 if( symbolEditFrame )
457 auto pinOrientation =
467 return pin->GetOrientation();
472 return dummy.GetOrientation();
496 bool selCancelled =
false;
497 bool displayWireCursor =
false;
498 bool displayBusCursor =
false;
499 bool displayLineCursor =
false;
500 KIID rolloverItemId = lastRolloverItemId;
504 evt->Modifier(
MD_ALT ) );
510 if( !
m_frame->ToolStackIsEmpty() )
544 schframe->ClearFocus();
551 size_t preFilterCount = collector.
GetCount();
553 narrowSelection( collector, evt->Position(),
false,
false, &rejected );
560 bool allCellsFromSameTable =
true;
572 allCellsFromSameTable =
false;
592 VECTOR2D bottomRight( std::max( start.
x,
end.x ), std::max( start.
y,
end.y ) );
615 else if( collector[0]->HasHoveredHypertext() )
617 collector[ 0 ]->DoHypertextAction(
m_frame, evt->Position() );
620 else if( collector[0]->IsBrightened() )
626 schframe->SelectNetNavigatorItem( &itemData );
633 if( collector.
GetCount() == 0 && preFilterCount > 0 )
636 frame->HighlightSelectionFilter( rejected );
651 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T },
nullptr, &selCancelled );
660 .Contains( evt->Position() ) )
664 if(
CollectHits( collector, evt->Position(), { SCH_LOCATE_ANY_T } ) )
668 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T },
nullptr, &selCancelled );
676 else if( evt->IsDblClick(
BUT_LEFT ) )
682 schframe->ClearFocus();
720 schframe->ClearFocus();
729 else if(
CollectHits( collector, evt->DragOrigin(), { SCH_TABLECELL_T } )
730 && ( collector[0]->GetParent()->GetParentGroup() ==
nullptr
731 || collector[0]->GetParent()->GetParentGroup() ==
m_enteredGroup ) )
794 else if( evt->IsMouseDown(
BUT_AUX1 ) )
798 else if( evt->IsMouseDown(
BUT_AUX2 ) )
814 const int delta = evt->Parameter<
int>();
857 wxString alt = *evt->Parameter<wxString*>();
881 newItems.push_back( nc );
884 if( !commit.
Empty() )
886 commit.
Push( wxS(
"No Connect Pins" ) );
905 switch( pinOrientation( item ) )
926 newItems.push_back( wire );
929 if( !commit.
Empty() )
947 commit.
Push( wxS(
"Wire Pins" ) );
967 labelText =
pin->GetShownName();
969 if( labelText.IsEmpty() )
971 labelText.Printf(
"%s_%s",
972 pin->GetParentSymbol()->GetRef( &sheetPath ),
978 labelText = sheetPin->
GetShownText( &sheetPath,
false );
985 switch( *evt->GetCommandId() )
988 label =
new SCH_LABEL( item->GetPosition(), labelText );
1000 switch( pinOrientation( item ) )
1021 pinType =
pin->GetType();
1057 newItems.push_back( label );
1060 if( !commit.
Empty() )
1062 commit.
Push( wxS(
"Label Pins" ) );
1074 wxString* net =
new wxString( *evt->Parameter<wxString*>() );
1078 else if( evt->IsCancelInteractive() )
1088 schframe->ClearFocus();
1094 else if( evt->FirstResponder() ==
this && evt->GetCommandId() == (
int) WXK_ESCAPE )
1104 if(
editor &&
m_frame->eeconfig()->m_Input.esc_clears_net_highlight )
1105 editor->ClearHighlight( *evt );
1112 schframe->ClearFocus();
1114 else if( evt->IsMotion() && !
m_isSymbolEditor && evt->FirstResponder() ==
this )
1133 displayBusCursor =
true;
1135 displayWireCursor =
true;
1137 displayLineCursor =
true;
1139 else if( collector[0]->HasHypertext() && !collector[0]->IsSelected() )
1141 rolloverItemId = collector[0]->m_Uuid;
1148 evt->SetPassEvent();
1151 if( lastRolloverItemId !=
niluuid && lastRolloverItemId != rolloverItemId )
1160 m_frame->GetCanvas()->GetView()->Update( item );
1165 if( rolloverItemId !=
niluuid )
1167 rolloverItem =
static_cast<SCH_ITEM*
>(
m_frame->ResolveItem( rolloverItemId ) );
1174 m_frame->GetCanvas()->GetView()->Update( rolloverItem );
1177 lastRolloverItemId = rolloverItemId;
1179 if(
m_frame->ToolStackIsEmpty() )
1181 if( displayWireCursor )
1185 else if( displayBusCursor )
1189 else if( displayLineCursor )
1199 && evt->HasPosition()
1224 wxT(
"EnterGroup called when selection is not a single group" ) );
1278 if(
m_frame->eeconfig()->m_Drawing.auto_start_wires
1311 if( possibleConnection.
IsBus() )
1319 if( !
pin || !
pin->IsPointClickableAnchor( pos ) )
1322 if( !
pin->IsVisible()
1323 && !(
m_frame->eeconfig()->m_Appearance.show_hidden_pins
1324 ||
m_frame->GetRenderSettings()->m_ShowHiddenPins ) )
1330 newEvt->SetMousePosition( pos );
1331 newEvt->SetHasPosition(
true );
1332 newEvt->SetForceImmediate(
true );
1345 wxMouseState keyboardState = wxGetMouseState();
1348 keyboardState.AltDown() );
1363 wxMouseState keyboardState = wxGetMouseState();
1366 keyboardState.AltDown() );
1387 const std::vector<KICAD_T>& aScanTypes )
1390 int gridThreshold =
KiROUND(
getView()->GetGAL()->GetGridSize().EuclideanNorm() / 2.0 );
1391 aCollector.
m_Threshold = std::max( pixelThreshold, gridThreshold );
1411 int originalCount = aCollector.
GetCount();
1413 for(
int ii = 0; ii < originalCount; ++ii )
1415 if( aCollector[ii]->Type() ==
SCH_PIN_T )
1419 if( !aCollector.
HasItem(
pin->GetParentSymbol() ) )
1420 aCollector.
Append(
pin->GetParentSymbol() );
1431 bool aCheckLocked,
bool aSelectedOnly,
1436 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
1438 if( symbolEditorFrame )
1445 if( !
static_cast<SCH_FIELD*
>( item )->IsVisible()
1454 if( !
static_cast<SCH_PIN*
>( item )->IsVisible()
1469 if( aCheckLocked && collector[i]->IsLocked() )
1483 if( aSelectedOnly && !collector[i]->IsSelected() )
1499 EDA_ITEM** aItem,
bool* aSelectionCancelledFlag,
bool aAdd,
1500 bool aSubtract,
bool aExclusiveOr )
1518 if( aSelectionCancelledFlag )
1519 *aSelectionCancelledFlag =
true;
1525 if( !aAdd && !aSubtract && !aExclusiveOr )
1533 bool foundEnteredGroup =
false;
1538 foundEnteredGroup =
true;
1543 if( !foundEnteredGroup )
1550 bool anySubtracted =
false;
1554 for(
int i = 0; i < aCollector.
GetCount(); ++i )
1557 bool isLine = aCollector[i]->Type() ==
SCH_LINE_T;
1573 || ( aExclusiveOr && aCollector[i]->IsSelected()
1574 && ( !isLine || ( isLine && aCollector[i]->HasFlag( flags ) ) ) ) )
1576 aCollector[i]->ClearFlags( flags );
1586 anySubtracted =
true;
1591 aCollector[i]->SetFlags( flags );
1598 if( addedCount == 1 )
1602 if( aItem && aCollector.
GetCount() == 1 )
1603 *aItem = aCollector[0];
1607 else if( addedCount > 1 )
1612 else if( anySubtracted )
1618 m_frame->GetCanvas()->ForceRefresh();
1624 const std::vector<KICAD_T>& aScanTypes,
1625 EDA_ITEM** aItem,
bool* aSelectionCancelledFlag,
1626 bool aCheckLocked,
bool aAdd,
bool aSubtract,
1631 if( !
CollectHits( collector, aWhere, aScanTypes ) )
1634 size_t preFilterCount = collector.
GetCount();
1636 rejected.
SetAll(
false );
1637 narrowSelection( collector, aWhere, aCheckLocked, aSubtract, &rejected );
1639 if( collector.
GetCount() == 0 && preFilterCount > 0 )
1642 frame->HighlightSelectionFilter( rejected );
1647 return selectPoint( collector, aWhere, aItem, aSelectionCancelledFlag, aAdd, aSubtract,
1658 std::vector<EDA_ITEM*> sheetPins;
1664 view->
Query( selectionBox,
1672 collection.
Append( item );
1686 sheetPins.emplace_back(
pin );
1707 m_frame->GetCanvas()->ForceRefresh();
1717 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
1723 view->
Query( selectionBox, selectedItems );
1750 m_frame->GetCanvas()->ForceRefresh();
1758 std::set<EDA_ITEM*> exactHits;
1760 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
1773 if( item->
HitTest( aPos, pixelThreshold ) )
1774 exactHits.insert( item );
1783 if(
m_frame->GetRenderSettings()->m_ShowPinsElectricalType )
1786 if( item->
HitTest( aPos, 0 ) )
1787 exactHits.insert( item );
1793 if( exactHits.size() > 0 && exactHits.size() < (
unsigned) collector.
GetCount() )
1795 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
1799 if( !exactHits.contains( item ) )
1805 SEG poss( aPos, aPos );
1807 int closestDist = INT_MAX / 4;
1811 BOX2I bbox = item->GetBoundingBox();
1812 int dist = INT_MAX / 4;
1817 bool dominating =
false;
1819 if( exactHits.contains( item ) )
1857 text->GetEffectiveTextShape(
false )->Collide( poss, INT_MAX / 4, &dist );
1863 shapes->Collide( poss, INT_MAX / 4, &dist );
1877 rect.
Collide( poss, closestDist, &dist );
1895 if( dist == closestDist )
1897 if( item->GetParent() == closest )
1900 else if( dist < closestDist )
1916 for(
int i = collector.
GetCount() - 1; i >= 0; --i )
1920 if( item == closest )
1923 if( !item->
HitTest( tightBox,
true ) )
1931 bool aPromoteCellSelections,
1932 bool aPromoteGroups )
1934 bool anyUnselected =
false;
1935 bool anySelected =
false;
1948 bool isMoving =
false;
1950 for(
int i = (
int)
m_selection.GetSize() - 1; i >= 0; --i )
1953 isMoving |=
static_cast<SCH_ITEM*
>( item )->IsMoving();
1955 if( !item->
IsType( aScanTypes ) )
1958 anyUnselected =
true;
1966 if( aPromoteGroups )
1968 for(
int i = (
int)
m_selection.GetSize() - 1; i >= 0; --i )
1972 std::set<EDA_ITEM*> selectedChildren;
1978 if( aChild->
IsType( aScanTypes ) )
1979 selectedChildren.insert( aChild );
1983 anyUnselected =
true;
1986 for(
EDA_ITEM* child : selectedChildren )
1988 if( !child->IsSelected() )
2000 if( aPromoteCellSelections )
2002 std::set<EDA_ITEM*> parents;
2004 for(
int i = (
int)
m_selection.GetSize() - 1; i >= 0; --i )
2012 anyUnselected =
true;
2018 if( !parent->IsSelected() )
2041 std::set<EDA_ITEM*> rejected;
2046 rejected.insert( item );
2050 aCollector.
Remove( item );
2063 if( schItem->IsLocked() && !
m_filter.lockedItems )
2068 switch( aItem->
Type() )
2086 aRejected->
pins =
true;
2096 aRejected->
wires =
true;
2104 switch(
static_cast<SCH_LINE*
>( aItem )->GetLayer() )
2111 aRejected->
wires =
true;
2147 aRejected->
text =
true;
2159 aRejected->
labels =
true;
2169 aRejected->
images =
true;
2249 bool cancelled =
false;
2265 isGreedy = !isGreedy;
2270 if( evt->IsCancelInteractive() || evt->IsActivate() )
2283 area.
SetEnd( evt->Position() );
2300 evt->SetPassEvent(
false );
2322 bool cancelled =
false;
2338 bool isClockwise = shapeArea > 0 ? true :
false;
2340 if(
getView()->IsMirroredX() && shapeArea != 0 )
2341 isClockwise = !isClockwise;
2354 if( evt->IsCancelInteractive() || evt->IsActivate() )
2363 points.
Append( evt->Position() );
2365 else if( evt->IsDblClick(
BUT_LEFT )
2404 area.
SetMode( selectionMode );
2431 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> candidates;
2433 view->
Query( selectionRect, candidates );
2435 std::set<SCH_ITEM*> uniqueCandidates;
2437 for(
const auto& [viewItem, layer] : candidates )
2439 if( viewItem->IsSCH_ITEM() )
2440 uniqueCandidates.insert(
static_cast<SCH_ITEM*
>( viewItem ) );
2449 if( boxMode ? selectionRect.
Intersects(
pin->GetBoundingBox() )
2451 uniqueCandidates.insert(
pin );
2458 if( boxMode ? selectionRect.
Intersects(
pin->GetBoundingBox() )
2460 uniqueCandidates.insert(
pin );
2465 if( field.IsVisible()
2466 && ( boxMode ? selectionRect.
Intersects( field.GetBoundingBox() )
2469 uniqueCandidates.insert( &field );
2477 std::set<EDA_ITEM*> group_items;
2486 std::unordered_set<EDA_ITEM*>& newset =
group->GetItems();
2489 [&](
const BOX2I& aBox )
2491 return boxMode ? selectionRect.
Contains( aBox )
2495 if( containedMode && boxContained(
group->GetBoundingBox() ) && newset.size() )
2497 for(
EDA_ITEM* group_item : newset )
2499 if( !group_item->IsSCH_ITEM() )
2503 collector.
Append( group_item );
2507 for(
EDA_ITEM* group_item : newset )
2508 group_items.emplace( group_item );
2514 return boxMode ? aItem->HitTest( selectionRect, containedMode )
2515 : aItem->HitTest( aArea.
GetPoly(), containedMode );
2518 for(
SCH_ITEM* item : uniqueCandidates )
2521 && ( !containedMode || !group_items.count( item ) ) )
2524 pinsCollector.
Append( item );
2526 collector.
Append( item );
2535 collector = pinsCollector;
2540 std::sort( collector.
begin(), collector.
end(),
2543 VECTOR2I aPos = a->GetPosition();
2544 VECTOR2I bPos = b->GetPosition();
2546 if( aPos.y == bPos.y )
2547 return aPos.x < bPos.x;
2549 return aPos.y < bPos.y;
2552 bool anyAdded =
false;
2553 bool anySubtracted =
false;
2558 if( aSubtractive || ( aExclusiveOr && aItem->
IsSelected() ) )
2568 anySubtracted =
true;
2571 if( flags && !anySubtracted )
2582 std::vector<EDA_ITEM*> flaggedItems;
2584 auto shapeContains =
2587 return boxMode ? selectionRect.
Contains( aPoint )
2596 flaggedItems.push_back( item );
2598 if(
m_frame->GetRenderSettings()->m_ShowPinsElectricalType )
2607 hits = line->
HitTest( selectionRect,
false );
2611 if( ( !containedMode && hits )
2616 else if( containedMode )
2626 selectItem( item, flags );
2629 selectItem( item, flags );
2634 for(
EDA_ITEM* item : pinsCollector )
2636 if(
m_frame->GetRenderSettings()->m_ShowPinsElectricalType )
2653 selectItem( item, 0 );
2659 for(
EDA_ITEM* item : flaggedItems )
2666 else if( anySubtracted )
2672 bool aMultiselect )
const
2674 std::unordered_set<EDA_ITEM*> toAdd;
2678 for(
int j = 0; j < aCollector.
GetCount(); j++ )
2680 if( aCollector[j]->GetParent() )
2683 if( aCollector[j]->GetParentSymbol() )
2689 for(
int j = 0; j < aCollector.
GetCount(); j++ )
2693 for(
int j = 0; j < aCollector.
GetCount(); )
2705 aCollector.
Remove( item );
2713 if(
top->AsEdaItem() != item )
2715 toAdd.insert(
top->AsEdaItem() );
2718 aCollector.
Remove( item );
2727 aCollector.
Remove( item );
2736 if( !aCollector.
HasItem( item ) )
2737 aCollector.
Append( item );
2755 if( cell->IsSelected() )
2767 auto wasSelected = [](
EDA_ITEM* aItem )
2774 bool doSelect =
false;
2776 if( cell->HitTest( selectionRect,
false ) )
2781 doSelect = !wasSelected( cell );
2785 else if( wasSelected( cell ) )
2790 if( doSelect && !cell->IsSelected() )
2792 else if( !doSelect && cell->IsSelected() )
2799 bool cancelled =
false;
2806 if( evt->IsCancelInteractive() || evt->IsActivate() )
2814 SelectCellsBetween( evt->DragOrigin(), evt->Position() - evt->DragOrigin(), aTable );
2816 else if( evt->IsMouseUp(
BUT_LEFT ) )
2820 bool anyAdded =
false;
2821 bool anySubtracted =
false;
2828 anySubtracted =
true;
2844 evt->SetPassEvent();
2868 int gridThreshold =
KiROUND(
getView()->GetGAL()->GetGridSize().EuclideanNorm() );
2869 int thresholdMax = std::max( pixelThreshold, gridThreshold );
2871 for(
int threshold : { 0, thresholdMax/4, thresholdMax/2, thresholdMax } )
2880 return collector.
GetCount() ? collector[ 0 ] :
nullptr;
2906 std::vector<SCH_ITEM*> startItems;
2907 std::set<SCH_ITEM*> added;
2910 for(
auto item : aItems )
2912 if( !item->IsSCH_ITEM() )
2923 startItems.push_back(
pin );
2928 startItems.push_back( schItem );
2932 if( startItems.empty() )
2935 std::deque<SCH_ITEM*> queue;
2936 std::unordered_set<SCH_ITEM*> visited;
2938 auto enqueue = [&](
SCH_ITEM* aItem )
2943 if( visited.insert( aItem ).second )
2944 queue.push_back( aItem );
2950 while( !queue.empty() )
2960 added.insert( symbol );
2965 for(
SCH_ITEM* neighbor : neighbors )
2975 added.insert( symbol );
2980 enqueue( neighbor );
2986 added.insert( item );
2995 std::set<SCH_ITEM*> added;
2997 for(
auto item : aItems )
2999 if( !item->IsSCH_ITEM() )
3004 std::set<SCH_ITEM*> conns =
m_frame->GetScreen()->MarkConnections( schItem, schItem->
IsConnectable() );
3012 added.insert( connItem );
3035 if( !selItem->IsSCH_ITEM() )
3041 graphicalSelection.
Add( item );
3043 graphicalSelection.
Add( item );
3045 connectableSelection.
Add( item );
3050 std::set<SCH_ITEM*> graphAdded;
3051 std::set<SCH_ITEM*> graphicalAdded;
3053 if( !connectableSelection.
Empty() )
3056 if( !graphicalSelection.
Empty() )
3061 if( graphAdded.empty() && !connectableSelection.
Empty() )
3066 combinedSelection.
Add( selItem );
3068 graphicalSelection = combinedSelection;
3073 auto smartAddToSel = [&](
EDA_ITEM* aItem )
3082 for(
auto item : graphAdded )
3083 smartAddToSel( item );
3085 for(
auto item : graphicalAdded )
3086 smartAddToSel( item );
3088 for(
auto item : originalSelection )
3089 smartAddToSel( item );
3108 std::set<std::pair<SCH_TABLE*, int>> columns;
3116 columns.insert( std::make_pair(
table, cell->GetColumn() ) );
3120 for(
auto& [
table, col ] : columns )
3122 for(
int row = 0; row <
table->GetRowCount(); ++row )
3143 std::set<std::pair<SCH_TABLE*, int>> rows;
3151 rows.insert( std::make_pair(
table, cell->GetRow() ) );
3155 for(
auto& [
table, row ] : rows )
3157 for(
int col = 0; col <
table->GetColCount(); ++col )
3178 std::set<SCH_TABLE*> tables;
3184 tables.insert(
static_cast<SCH_TABLE*
>( cell->GetParent() ) );
3191 if( !
table->IsSelected() )
3234 double compRatio = bbSize.
y / currTextHeight;
3235 double compRatioBent = 1.0;
3241 std::vector<std::pair<double, double>> lut{ { 1.25, 16 },
3250 std::vector<std::pair<double, double>>::iterator it;
3253 compRatioBent = lut.back().second;
3257 if( compRatio >= lut.front().first )
3259 for( it = lut.begin(); it < lut.end() - 1; ++it )
3261 if( it->first <= compRatio &&
next( it )->first >= compRatio )
3263 double diffx = compRatio - it->first;
3264 double diffn =
next( it )->first - it->first;
3266 compRatioBent = it->second + (
next( it )->second - it->second ) * diffx / diffn;
3273 compRatioBent = lut.front().second;
3282 screenSize.
x = std::max( 10.0, screenSize.
x );
3283 screenSize.
y = std::max( 10.0, screenSize.
y );
3284 double ratio = std::max( -1.0, fabs( bbSize.
y / screenSize.
y ) );
3287 double kicadRatio = std::max( fabs( bbSize.
x / screenSize.
x ),
3288 fabs( bbSize.
y / screenSize.
y ) );
3293 if( bbSize.
x > screenSize.
x * ratio * compRatioBent )
3297 compRatioBent = 1.0;
3298 wxLogTrace(
"CROSS_PROBE_SCALE",
3299 "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
3304 ratio *= compRatioBent;
3306 bool alwaysZoom =
false;
3309 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
3315 SCH_ITEM* focusItem,
const std::vector<SCH_ITEM*>& items )
3322 double targetZoom = 0.0;
3324 bool targetZoomValid =
false;
3325 bool changedSheet =
false;
3327 if( targetSheetPath )
3333 targetZoom = screen->m_LastZoomLevel;
3334 targetCenter = screen->m_ScrollCenter;
3335 targetZoomValid = screen->IsZoomInitialized();
3341 changedSheet =
true;
3345 if( changedSheet && targetZoomValid && !
m_frame->eeconfig()->m_CrossProbing.zoom_to_fit )
3359 if(
m_frame->GetScreen()->CheckIfOnDrawList( item )
3360 || ( parent &&
m_frame->GetScreen()->CheckIfOnDrawList( parent ) ) )
3370 if(
m_frame->eeconfig()->m_CrossProbing.center_on_items )
3372 if(
m_frame->eeconfig()->m_CrossProbing.zoom_to_fit )
3391 bool enteredGroupFound =
false;
3399 if( item.IsSelected() )
3407 enteredGroupFound =
true;
3421 if( item->IsSelected() )
3427 item->RunOnChildren(
3441 enteredGroupFound =
true;
3453 if( !enteredGroupFound )
3465 bool checkVisibilityOnly )
const
3476 switch( aItem->
Type() )
3484 if(
pin->GetUnit() &&
pin->GetUnit() != symEditFrame->
GetUnit() )
3491 if( !
pin->IsVisible() && !
m_frame->GetShowAllPins() )
3502 if(
pin->IsPointClickableAnchor(
grid.BestSnapAnchor( *aPos, pinGrid ) ) )
3513 if( !
m_frame->eeconfig()->m_Appearance.show_directive_labels )
3618 aGroup->
Add( aItem );
3628 sch_item->RunOnChildren(
3679 sch_item->RunOnChildren(
3693 aGroup->
Remove( aChild );
3707 const unsigned GRIP_MARGIN = 20;
3713 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...
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.
Calculate the connectivity of a schematic and generates netlists.
bool IsHorizontal() 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,...
const EDA_ANGLE & GetTextAngle() const
virtual bool IsVisible() const
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, const BOX2I &aBBox=BOX2I(), const EDA_ANGLE &aAngle=ANGLE_0) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
GRID_HELPER_GRIDS GetItemGrid(const EDA_ITEM *aItem) const override
Get the coarsest grid that applies to an item.
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, GRID_HELPER_GRIDS aGrid, SCH_ITEM *aSkip)
static const TOOL_EVENT DisambiguatePoint
Used for hotkey feedback.
static const TOOL_EVENT ClearedEvent
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 PointSelectedEvent
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
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)
const BOX2I ViewBBox() const override
Set the origin of the rectangle (the fixed corner)
SHAPE_LINE_CHAIN & GetPoly()
void SetExclusiveOr(bool aExclusiveOr)
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
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_ITEMS.
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.
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.
CONNECTION_GRAPH * ConnectionGraph() const
SCH_SHEET_PATH & CurrentSheet() const
static TOOL_ACTION placeClassLabel
static TOOL_ACTION placeSheetPin
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 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 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 editPageNumber
static TOOL_ACTION selectOnPCB
static TOOL_ACTION syncSheetPins
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
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Execute the changes.
virtual void Revert() override
Revert the commit by restoring the modified items state.
static SELECTION_CONDITION SingleMultiFunctionPin
static SELECTION_CONDITION SingleSymbol
static SELECTION_CONDITION MultipleSymbolsOrPower
static SELECTION_CONDITION AllPinsOrSheetPins
static SELECTION_CONDITION SingleSymbolOrPower
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.
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.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
wxTreeCtrl * GetNetNavigator()
const SCH_ITEM * SelectNextPrevNetNavigatorItem(bool aNext)
const wxString & GetHighlightedConnection() const
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 SCH_ITEM_VEC & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
const SYMBOL * GetParentSymbol() const
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
virtual bool IsPointClickableAnchor(const VECTOR2I &aPos) const
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
void SetShape(LABEL_FLAG_SHAPE aShape)
LABEL_SHAPE GetLabelShape() const
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)
Tool that displays edit points allowing to modify items by dragging the points.
bool HasPoint()
Indicate the cursor is over an edit point.
VECTOR2I GetCenter() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
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()
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
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)
const std::deque< EDA_ITEM * > GetItems() const
VECTOR2I GetReferencePoint() const
virtual void Remove(EDA_ITEM *aItem)
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
bool PointInside(const VECTOR2I &aPt, int aAccuracy=0, bool aUseBBoxCache=false) const override
Check if point aP lies inside a closed shape.
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 Collide(const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) 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
Return true if aLibId is an alias for the editor screen symbol.
bool GetShowInvisiblePins()
Symbol library viewer main window.
A base class for LIB_SYMBOL and SCH_SYMBOL.
const TRANSFORM & GetTransform() const
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
static constexpr EDA_ANGLE ANGLE_VERTICAL
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
#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_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 BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
@ REPAINT
Item needs to be redrawn.
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< SCH_ITEM * > SCH_ITEM_VEC
std::function< bool(const SELECTION &)> SELECTION_CONDITION
Functor type that checks a specific condition for selected items.
std::vector< FAB_LAYER_COLOR > dummy
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)
@ 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