65#define QUIET_MODE true
70 switch( aItem->
Type() )
78 return static_cast<const SCH_LINE*
>( aItem )->IsGraphicLine();
93 long long bot =
top + h;
114 long long bot =
top + h;
115 long long perimeter = 2 * ( w + h );
124 aArc = ( ( aArc % perimeter ) + perimeter ) % perimeter;
131 else if( aArc <= w + h )
136 else if( aArc <= 2 * w + h )
139 aPos =
VECTOR2I( (
int) (
right - ( aArc - w - h ) ), (
int) bot );
144 aPos =
VECTOR2I( (
int)
left, (
int) ( bot - ( aArc - 2 * w - h ) ) );
151 if( !aNewLine || !aSource || !aFrame )
162 if( !sourceConnection )
170 newConnection->
Clone( *sourceConnection );
261 bool foundAttachment =
false;
262 bool foundJunction =
false;
263 bool foundPin =
false;
268 foundAttachment =
true;
272 switch( cItem->Type() )
288 if( !foundLine && cLine->
GetLength() == 0 )
294 foundJunction =
true;
304 if( pair.first->IsConnected( selectedEnd ) )
324 bool preferOriginalLine =
false;
328 && line->GetLength() == 0
329 &&
EDA_ANGLE( splitDelta ).IsParallelTo( line->GetStoredAngle() ) )
331 preferOriginalLine =
true;
337 else if( !foundLine && foundJunction && !foundPin )
340 foundLine =
new SCH_LINE( unselectedEnd, line->GetLayer() );
357 if( foundLine && !preferOriginalLine )
378 else if( foundLine->
GetEndPoint() == unselectedEnd )
379 foundLine->
MoveEnd( splitDelta );
411 if(
info.attachedLine == bendLine ||
info.attachedLine == foundLine )
413 info.attachedLine = line;
414 info.originalLineStart = line->GetStartPoint();
415 info.originalLineEnd = line->GetEndPoint();
436 line->MoveEnd( splitDelta );
438 line->MoveStart( splitDelta );
443 else if( line->GetLength() == 0 )
453 else if( foundAttachment && line->IsOrthogonal() )
460 unsigned int xMoveBit = splitDelta.
x != 0;
461 unsigned int yMoveBit = splitDelta.
y != 0;
462 int xLength = abs( unselectedEnd.
x - selectedEnd.
x );
463 int yLength = abs( unselectedEnd.
y - selectedEnd.
y );
464 int xMove = ( xLength - ( xBendCount * lineGrid.
x ) )
465 *
sign( selectedEnd.
x - unselectedEnd.
x );
466 int yMove = ( yLength - ( yBendCount * lineGrid.
y ) )
467 *
sign( selectedEnd.
y - unselectedEnd.
y );
489 xBendCount += yMoveBit;
490 yBendCount += xMoveBit;
495 line->MoveEnd(
VECTOR2I( splitDelta.
x ? splitDelta.
x : xMove,
496 splitDelta.
y ? splitDelta.
y : yMove ) );
500 line->MoveStart(
VECTOR2I( splitDelta.
x ? splitDelta.
x : xMove,
501 splitDelta.
y ? splitDelta.
y : yMove ) );
533 else if( !foundAttachment )
536 line->MoveEnd( splitDelta );
538 line->MoveStart( splitDelta );
555 bool requestedModeIsDragLike = mode !=
MOVE;
560 if( requestedModeIsDragLike != currentModeIsDragLike )
564 if( item && !item->
IsNew() )
599 case MOVE: localCommit.
Push(
_(
"Move" ) );
break;
600 case DRAG: localCommit.
Push(
_(
"Drag" ) );
break;
601 case BREAK: localCommit.
Push(
_(
"Break Wire" ) );
break;
602 case SLICE: localCommit.
Push(
_(
"Slice Wire" ) );
break;
630 if( selection.
Empty() )
633 std::vector<SCH_LINE*> lines;
646 lines.push_back(
static_cast<SCH_LINE*
>( item ) );
657 bool useCursorForSingleLine =
false;
659 if( lines.size() == 1 )
660 useCursorForSingleLine =
true;
667 VECTOR2I breakPos = useCursorForSingleLine ? cursorPos : line->GetMidPoint();
674 lwbTool->
BreakSegment( aCommit, line, breakPos, &newLine, screen );
701 bool didAtLeastOneBreak =
false;
710 bool unselect =
false;
714 std::vector<DANGLING_END_ITEM> internalPoints;
717 bool selectionHasSheetPins =
false;
718 bool selectionHasGraphicItems =
false;
719 bool selectionHasNonGraphicItems =
false;
720 bool selectionIsGraphicsOnly =
false;
722 std::unique_ptr<SCH_DRAG_NET_COLLISION_MONITOR> netCollisionMonitor;
728 selectionHasNonGraphicItems, selectionIsGraphicsOnly );
734 && std::all_of( selection.
begin(), selection.
end(),
737 return isGraphicItemForDrop( static_cast<SCH_ITEM*>( item ) );
740 if( !selection.
Empty() && !graphicsOnly )
742 netCollisionMonitor = std::make_unique<SCH_DRAG_NET_COLLISION_MONITOR>(
m_frame,
m_view );
743 netCollisionMonitor->Initialize( selection );
746 bool lastCtrlDown =
false;
752 bool pasteHoldingCtrl =
false;
758 pasteHoldingCtrl = wxGetKeyState( WXK_CONTROL );
772 if( selection.
Empty() )
775 bool restore_state =
false;
786 AXIS_LOCK axisLock = AXIS_LOCK::NONE;
787 long lastArrowKeyAction = 0;
792 wxLogTrace(
traceSchMove,
"doMoveSelection: event loop iteration, evt=%s, action=%s",
798 m_frame->GetCanvas()->SetCurrentCursor( currentCursor );
806 if( pasteHoldingCtrl && hasModifierState && !ctrlDown )
807 pasteHoldingCtrl =
false;
811 bool gridSnapDisabled = ctrlDown && !pasteHoldingCtrl;
813 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !gridSnapDisabled );
815 lastCtrlDown = ctrlDown;
851 grid.SetSnap(
false );
857 if( axisLock == AXIS_LOCK::HORIZONTAL )
863 axisLock = AXIS_LOCK::NONE;
869 axisLock = AXIS_LOCK::HORIZONTAL;
874 if( axisLock == AXIS_LOCK::VERTICAL )
880 axisLock = AXIS_LOCK::NONE;
886 axisLock = AXIS_LOCK::VERTICAL;
890 lastArrowKeyAction = action;
898 if( axisLock == AXIS_LOCK::HORIZONTAL )
900 else if( axisLock == AXIS_LOCK::VERTICAL )
912 if( sheet != hoverSheet )
917 m_frame->UpdateItem( hoverSheet,
false );
925 m_frame->UpdateItem( hoverSheet,
false );
931 if( netCollisionMonitor )
932 currentCursor = netCollisionMonitor->AdjustCursor( currentCursor );
944 std::vector<SCH_ITEM*> previewItems;
947 previewItems.push_back(
static_cast<SCH_ITEM*
>( it ) );
950 previewItems.push_back( line );
953 previewItems.push_back( line );
955 std::vector<SCH_JUNCTION*> previewJunctions =
958 if( netCollisionMonitor )
959 netCollisionMonitor->Update( previewJunctions, selection );
962 m_view->AddToPreview( jct,
true );
976 m_frame->GetInfoBar()->Dismiss();
993 case MOVE:
m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel move." ) );
break;
994 case DRAG:
m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel drag." ) );
break;
995 case BREAK:
m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel break." ) );
break;
996 case SLICE:
m_frame->ShowInfoBarMsg(
_(
"Press <ESC> to cancel slice." ) );
break;
1004 restore_state =
true;
1014 restore_state =
true;
1028 wxLogTrace(
traceSchMove,
"doMoveSelection: handleMoveToolActions returned false, exiting" );
1051 didAtLeastOneBreak =
true;
1091 wxLogTrace(
traceSchMove,
"doMoveSelection: event handled, not passing" );
1100 }
while( ( evt =
Wait() ) );
1104 restore_state =
true;
1108 if( selectionHasSheetPins || ( selectionIsGraphicsOnly && !lastCtrlDown ) )
1109 targetSheet =
nullptr;
1114 m_frame->UpdateItem( hoverSheet,
false );
1120 m_view->Hide( hidden.m_junction,
false );
1153 return !restore_state;
1162 if( userSelection.
GetSize() == 1 )
1181 aUnselect = selection.
IsHover();
1190 bool& aHasGraphicItems,
bool& aHasNonGraphicItems,
1191 bool& aIsGraphicsOnly )
1193 aHasSheetPins =
false;
1194 aHasGraphicItems =
false;
1195 aHasNonGraphicItems =
false;
1197 for(
EDA_ITEM* edaItem : aSelection )
1202 aHasSheetPins =
true;
1205 aHasGraphicItems =
true;
1207 aHasNonGraphicItems =
true;
1210 aIsGraphicsOnly = aHasGraphicItems && !aHasNonGraphicItems;
1226 std::vector<SCH_ITEM*> stageTwo;
1228 for(
EDA_ITEM* edaItem : aSelection )
1231 std::vector<VECTOR2I> connections;
1233 switch( item->
Type() )
1239 stageTwo.emplace_back( item );
1243 static_cast<SCH_LINE*
>( item )->GetSelectedPoints( connections );
1250 for(
const VECTOR2I& point : connections )
1258 for(
const VECTOR2I& point : item->GetConnectionPoints() )
1262 for(
EDA_ITEM* item : connectedDragItems )
1270 for(
EDA_ITEM* edaItem : aSelection )
1293 static_cast<SCH_ITEM*
>( item )->GetEndPoints( aInternalPoints );
1295 std::vector<DANGLING_END_ITEM> endPointsByType = aInternalPoints;
1296 std::vector<DANGLING_END_ITEM> endPointsByPos = endPointsByType;
1300 static_cast<SCH_ITEM*
>( item )->UpdateDanglingState( endPointsByType, endPointsByPos );
1305 std::vector<DANGLING_END_ITEM>& aInternalPoints,
1310 m_view->Hide( hidden.m_junction,
false );
1348 std::vector<DANGLING_END_ITEM>& aInternalPoints,
1360 aInternalPoints.clear();
1367 if( !it->IsSelected() )
1377 aSnapLayer =
grid.GetSelectionGrid( aSelection );
1383 if( schItem->
IsNew() )
1394 enteredGroup->AddItem( schItem );
1411 shape->SetHatchingDirty();
1412 shape->UpdateHatching();
1434 std::vector<DANGLING_END_ITEM>& aInternalPoints,
GRID_HELPER_GRIDS& aSnapLayer )
1439 bool placingNewItems = sch_item && sch_item->
IsNew();
1455 if( placingNewItems )
1463 bool isPasted =
false;
1469 if( item->GetParent() && item->GetParent()->IsSelected() )
1475 isPasted |= ( item->GetFlags() &
IS_PASTED ) != 0;
1482 aSelection.SetReferencePoint(
m_cursor );
1495 if(
m_frame->GetMoveWarpsCursor() )
1516 bool aHasSheetPins,
bool aIsGraphicsOnly,
bool aCtrlDown )
1539 selBBox.
Merge( schIt->GetBoundingBox() );
1580 if( sheet->
GetPin( pt ) )
1595 bool dropAllowedBySelection = !aHasSheetPins;
1596 bool dropAllowedByModifiers = !aIsGraphicsOnly || aCtrlDown;
1598 if( sheet && !( dropAllowedBySelection && dropAllowedByModifiers ) )
1609 if( !destScreen || destScreen->
GetFileName().IsEmpty() )
1612 std::vector<SCH_SHEET*> movedSheets;
1617 movedSheets.push_back(
static_cast<SCH_SHEET*
>( item ) );
1620 if( movedSheets.empty() )
1625 for(
SCH_SHEET* movedSheet : movedSheets )
1638 SCH_COMMIT* aCommit,
int& aXBendCount,
int& aYBendCount,
1641 wxLogTrace(
traceSchMove,
"performItemMove: delta=(%d,%d), moveOffset=(%d,%d), selection size=%u",
1648 std::vector<VECTOR2I> splitMoves;
1657 splitMoves.emplace_back(
VECTOR2I( aDelta.
x, 0 ) );
1667 splitMoves.emplace_back(
VECTOR2I( 0, aDelta.
y ) );
1673 for(
const VECTOR2I& splitDelta : splitMoves )
1676 if( splitDelta ==
VECTOR2I( 0, 0 ) )
1680 ( aDelta.
y >= 0 ) ) )
1683 if( item->GetParent() && item->GetParent()->IsSelected() )
1687 bool isLineModeConstrained =
false;
1696 if( (
m_mode ==
DRAG ) && isLineModeConstrained && line
1700 orthoLineDrag( aCommit, line, splitDelta, aXBendCount, aYBendCount, aGrid );
1713 if( lineEnd.second && lineEnd.first->HasFlag(
STARTPOINT ) )
1714 lineEnd.first->SetStartPoint(
pin->GetPosition() );
1715 else if( !lineEnd.second && lineEnd.first->HasFlag(
ENDPOINT ) )
1716 lineEnd.first->SetEndPoint(
pin->GetPosition() );
1726 if( !label || !
info.attachedLine )
1729 if(
info.trackMovingEnd )
1731 label->Move( splitDelta );
1736 if(
info.attachedLine->GetLength() > 0
1737 &&
info.attachedLine->HitTest(
info.originalLabelPos, 1 )
1738 &&
info.originalLabelPos != start
1739 &&
info.originalLabelPos !=
end )
1741 info.trackMovingEnd =
false;
1742 label->SetPosition(
info.originalLabelPos );
1743 info.originalLineStart = start;
1761 if( deltaStart == deltaEnd )
1763 label->SetPosition(
info.originalLabelPos + deltaStart );
1768 VECTOR2I fixedEndDelta = startDrags ? deltaEnd : deltaStart;
1770 label->SetPosition(
info.originalLabelPos + fixedEndDelta );
1774 if( !
info.attachedLine->HitTest( label->GetPosition(), 1 ) )
1777 label->SetPosition( seg.
NearestPoint( label->GetPosition() ) );
1781 if( label->GetPosition() == movingEnd )
1782 info.trackMovingEnd =
true;
1801 std::map<SCH_SHEET*, std::vector<SCH_SHEET_PIN*>> groups;
1812 groups[sheet].push_back(
pin );
1816 for(
auto& [sheet, pins] : groups )
1818 if( pins.size() < 2 )
1834 bool sameEdge =
true;
1837 sameEdge &= ( startSide(
pin ) == refStartSide );
1852 pin->SetSide( side );
1855 pin->SetTextY( pos.
y );
1857 pin->SetTextX( pos.
x );
1866 if( lineEnd.second && lineEnd.first->HasFlag(
STARTPOINT ) )
1867 lineEnd.first->SetStartPoint(
pin->GetPosition() );
1868 else if( !lineEnd.second && lineEnd.first->HasFlag(
ENDPOINT ) )
1869 lineEnd.first->SetEndPoint(
pin->GetPosition() );
1877 wxLogTrace(
traceSchMove,
"handleMoveToolActions: received event, action=%s",
1878 aEvent->
Format().c_str() );
1882 wxLogTrace(
traceSchMove,
"handleMoveToolActions: doDelete, exiting move" );
1883 const_cast<TOOL_EVENT*
>( aEvent )->SetPassEvent();
1894 wxLogTrace(
traceSchMove,
"handleMoveToolActions: rotateCW event received, selection size=%u",
1897 wxLogTrace(
traceSchMove,
"handleMoveToolActions: rotateCW RunSynchronousAction completed" );
1899 wxLogTrace(
traceSchMove,
"handleMoveToolActions: rotateCW updateStoredPositions completed" );
1904 wxLogTrace(
traceSchMove,
"handleMoveToolActions: rotateCCW event received, selection size=%u",
1907 wxLogTrace(
traceSchMove,
"handleMoveToolActions: rotateCCW RunSynchronousAction completed" );
1909 wxLogTrace(
traceSchMove,
"handleMoveToolActions: rotateCCW updateStoredPositions completed" );
1968 m_frame->SelectUnit( symbol, unit, aCommit );
1980 m_frame->SelectBodyStyle( symbol, bodyStyle, aCommit );
2001 wxLogTrace(
traceSchMove,
"updateStoredPositions: start, selection size=%u",
2029 wxLogTrace(
traceSchMove,
" item[%d] type=%d: stored pos updated (%d,%d) -> (%d,%d)",
2030 itemCount++, (
int) schItem->
Type(), oldPos.
x, oldPos.
y, newPos.
x, newPos.
y );
2040 pin->SetStoredPos( pinNewPos );
2041 wxLogTrace(
traceSchMove,
" sheet pin: stored pos updated (%d,%d) -> (%d,%d)",
2042 pinOldPos.
x, pinOldPos.
y, pinNewPos.
x, pinNewPos.
y );
2047 wxLogTrace(
traceSchMove,
"updateStoredPositions: complete, updated %d items", itemCount );
2058 for(
EDA_ITEM* edaItem : aSelection )
2073 return aHidden.m_junction == jct;
2079 if( !
info.isJunction )
2082 m_view->Hide( jct,
true );
2099 m_view->Hide( hidden.m_junction,
false );
2101 SCH_LINE* line =
dynamic_cast<SCH_LINE*
>(
m_frame->Schematic().ResolveItem( hidden.m_lineId,
nullptr,
true ) );
2108 if( newPos != hidden.m_junction->GetPosition()
2112 aCommit->
Modify( hidden.m_junction, screen );
2113 hidden.m_junction->SetPosition( newPos );
2114 m_frame->UpdateItem( hidden.m_junction,
false,
true );
2121 const std::vector<DANGLING_END_ITEM>& aInternalPoints )
2130 newLine->ClearEditFlags();
2137 oldLine->ClearEditFlags();
2152 sch_item->SetConnectivityDirty(
true );
2166 if(
m_frame->GetScreen()->IsExplicitJunctionNeeded( it.GetPosition() ) )
2176 selectionCopy.
Add( line );
2179 selectionCopy.
Add( line );
2189 if( isDragLike && !isSlice )
2199 item->ClearTempFlags();
2201 for(
EDA_ITEM* item : selectionCopy )
2202 item->ClearTempFlags();
2204 m_frame->Schematic().CleanUp( aCommit );
2208 auto clearChildEditFlags =
2211 aItem->RunOnChildren(
2221 item->ClearEditFlags();
2224 clearChildEditFlags( schItem );
2229 for(
EDA_ITEM* item : selectionCopy )
2231 item->ClearEditFlags();
2234 clearChildEditFlags( schItem );
2256 bbox.
Merge(
static_cast<SCH_ITEM*
>( item )->GetBoundingBox() );
2260 bool overlap =
false;
2265 moved.Move( offset );
2270 if(
moved.Intersects( existing->GetBoundingBox() ) )
2286 m_frame->RemoveFromScreen( schItem, srcScreen );
2289 schItem->
Move( offset );
2292 destScreen->
Append( schItem );
2306 std::set<SCH_ITEM*> danglers;
2308 std::function<void(
SCH_ITEM* )> changeHandler =
2309 [&](
SCH_ITEM* aChangedItem ) ->
void
2313 if( aChangedItem->IsSelected() )
2325 danglers.insert( aChangedItem );
2333 danglers.insert( aChangedItem );
2337 m_frame->GetScreen()->TestDanglingEnds(
nullptr, &changeHandler );
2361 for(
SCH_ITEM* item : itemsOverlapping )
2363 if( item != aOriginalItem && item->
IsConnected( aPoint ) )
2366 foundJunction = item;
2372 if( foundSymbol && foundJunction )
2374 aList.push_back( foundSymbol );
2380 aList.push_back( foundJunction );
2387 if(
test == aOriginalItem || !
test->CanConnect( aOriginalItem ) )
2390 switch(
test->Type() )
2406 if(
test->IsConnected( aPoint ) )
2407 aList.push_back(
test );
2412 if(
static_cast<SCH_LINE*
>(
test )->HitTest( label->GetPosition(), 1 ) )
2413 aList.push_back(
test );
2426 if(
pin->IsConnected( aPoint ) )
2428 if(
pin->IsSelected() )
2431 aList.push_back(
pin );
2441 if(
test->IsConnected( aPoint ) )
2442 aList.push_back(
test );
2457 aList.push_back( label );
2468 for(
const VECTOR2I& point :
test->GetConnectionPoints() )
2470 if( line->
HitTest( point, 1 ) )
2472 aList.push_back(
test );
2491 std::set<SCH_ITEM*> connectableCandidates;
2492 std::vector<SCH_ITEM*> itemsConnectable;
2493 bool ptHasUnselectedJunction =
false;
2496 connectableCandidates.insert( item );
2503 connectableCandidates.insert( item );
2511 bool isBusLabel =
false;
2522 || selected->GetLayer() ==
LAYER_BUS || isBusLabel )
2542 else if( fixedLine )
2555 auto makeNewJunction =
2572 for(
SCH_ITEM* item : connectableCandidates )
2585 if( !
pin->IsSelected()
2586 &&
pin->GetPosition() == aPoint
2587 &&
pin->CanConnect( aSelectedItem ) )
2589 itemsConnectable.push_back(
pin );
2600 if( item == aSelectedItem
2601 || ( item->Type() !=
SCH_LINE_T && ( item->IsSelected() || item->HasSelectedAncestorGroup() ) )
2607 itemsConnectable.push_back( item );
2610 for(
SCH_ITEM* item : itemsConnectable )
2612 if( item->Type() ==
SCH_JUNCTION_T && item->IsConnected( aPoint ) && !item->IsSelected() )
2614 ptHasUnselectedJunction =
true;
2631 if( ptHasUnselectedJunction )
2646 if( !lineInSelectedGroup )
2650 || lineInSelectedGroup )
2657 aList.push_back( line );
2662 if( !lineInSelectedGroup )
2666 || lineInSelectedGroup )
2673 aList.push_back( line );
2678 switch( aSelectedItem->
Type() )
2692 newWire = makeNewWire( aCommit, line, aSelectedItem, aPoint, aPoint );
2695 aList.push_back( newWire );
2705 makeNewWire( aCommit, line, line, aPoint, oldEnd );
2706 makeNewJunction( aCommit, line, aPoint );
2738 aList.push_back( label );
2741 info.attachedLine = line;
2755 if(
pin->IsConnected( aPoint ) )
2766 newWire = makeNewWire( aCommit,
pin, aSelectedItem, aPoint, aPoint );
2768 aList.push_back( newWire );
2777 if(
test->IsConnected( aPoint ) && !newWire )
2781 newWire = makeNewWire( aCommit,
test, aSelectedItem, aPoint, aPoint );
2783 aList.push_back( newWire );
2792 aList.push_back(
test );
2827 aList.push_back( label );
2832 info.attachedLine = line;
2841 else if(
test->IsConnected( aPoint ) && !newWire )
2845 newWire = makeNewWire( aCommit,
test, aSelectedItem, aPoint, aPoint );
2847 aList.push_back( newWire );
2873 if( line->
HitTest( point, 1 ) )
2876 aList.push_back(
test );
2879 std::vector<VECTOR2I> ends =
test->GetConnectionPoints();
2882 if( ends[0] == point )
2906 static int moveCallCount = 0;
2907 wxLogTrace(
traceSchMove,
"moveItem[%d]: type=%d, delta=(%d,%d)",
2908 ++moveCallCount, aItem->
Type(), aDelta.
x, aDelta.
y );
2910 switch( aItem->
Type() )
2916 static_cast<SCH_LINE*
>( aItem )->Move( aDelta );
2964 label->
Move( aDelta );
2970 static_cast<SCH_ITEM*
>( aItem )->Move( aDelta );
3006 if( !it->IsSelected() )
3009 if( !selection.
IsHover() && it->IsSelected() )
3012 it->SetStoredPos( it->GetPosition() );
3017 pin->SetStoredPos(
pin->GetPosition() );
3039 std::vector<EDA_ITEM*> items( selection.
begin(), selection.
end() );
3049 m_frame->Schematic().CleanUp( &commit );
3050 commit.
Push(
_(
"Align Items to Grid" ) );
constexpr EDA_IU_SCALE schIUScale
static TOOL_ACTION cursorDblClick
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION increment
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION refreshPreview
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr const Vec & GetPosition() const
constexpr coord_type GetY() const
constexpr size_type GetWidth() const
constexpr coord_type GetX() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr size_type GetHeight() const
constexpr bool Contains(const Vec &aPoint) const
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been removed.
static void sort_dangling_end_items(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos)
Helper class used to store the state of schematic items that can be connected to other schematic item...
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
virtual void ClearEditFlags()
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetFlags(EDA_ITEM_FLAGS aMask)
virtual EDA_GROUP * GetParentGroup() const
KICAD_T Type() const
Returns the type of object.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
EDA_ITEM * GetParent() const
bool HasSelectedAncestorGroup() const
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
virtual VECTOR2I GetTextPos() const
Implement an R-tree for fast spatial and type indexing of schematic items.
EE_TYPE Overlapping(const BOX2I &aRect) const
static const TOOL_EVENT SelectedItemsMoved
Selected items were moved, this can be very high frequency on the canvas, use with care.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
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.
const VC_SETTINGS & GetSettings() const
Return the current VIEW_CONTROLS settings.
static TOOL_ACTION rotateCCW
static TOOL_ACTION breakWire
static TOOL_ACTION toText
static TOOL_ACTION restartMove
static TOOL_ACTION toHLabel
static TOOL_ACTION rotateCW
static TOOL_ACTION toLabel
static TOOL_ACTION alignToGrid
static TOOL_ACTION toDLabel
static TOOL_ACTION toTextBox
static TOOL_ACTION highlightNet
static TOOL_ACTION repeatDrawItem
static TOOL_ACTION toGLabel
static TOOL_ACTION selectOnPCB
static const std::vector< KICAD_T > MovableItems
Commit for the schematic and symbol editors.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE) override
Add a change of the item aItem of type aChangeType to the change list.
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.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void Clone(const SCH_CONNECTION &aOther)
Copies connectivity information (but not parent) from another connection.
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
void SetStoredPos(const VECTOR2I &aPos)
virtual bool CanConnect(const SCH_ITEM *aItem) const
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
virtual void Move(const VECTOR2I &aMoveVector)
Move the item by aMoveVector to a new position.
void SetLayer(SCH_LAYER_ID aLayer)
void SetConnectivityDirty(bool aDirty=true)
Set the dirty flag.
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
virtual bool IsMovableFromAnchorPoint() const
Check if object is movable from the anchor point.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
VECTOR2I & GetStoredPos()
bool IsGroupableType() const
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
void SetLastResolvedState(const SCH_ITEM *aItem) override
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
bool CanConnect(const SCH_ITEM *aItem) const override
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.
void StoreAngle()
Save the current line angle.
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
bool IsStartDangling() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
EDA_ANGLE Angle() const
Get the angle between the start and end lines.
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
bool IsEndDangling() const
void MoveEnd(const VECTOR2I &aMoveVector)
void SetLastResolvedState(const SCH_ITEM *aItem) override
void MoveStart(const VECTOR2I &aMoveVector)
void SetEndPoint(const VECTOR2I &aPosition)
bool IsDangling() const override
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
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.
const wxString & GetFileName() const
bool IsExplicitJunctionNeeded(const VECTOR2I &aPosition) const
Indicate that a junction dot is necessary at the given location, and does not yet exist.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
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.
bool IsTopLevelSheet() const
Check if this sheet is a top-level sheet.
SCH_SHEET_PIN * GetPin(const VECTOR2I &aPosition)
Return the sheet pin item found at aPosition in the sheet.
SCH_SCREEN * GetScreen() const
VECTOR2I GetPosition() const override
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
std::vector< SCH_SHEET_PIN * > & GetPins()
VECTOR2I GetPosition() const override
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
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.
VECTOR2I GetReferencePoint() const
virtual unsigned int GetSize() const override
Return the number of stored items.
int Size() const
Returns the number of selected parts.
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
std::vector< EDA_ITEM * > GetItemsSortedByTypeAndXY(bool leftBeforeRight=true, bool topBeforeBottom=true) const
Returns a copy of this selection of items sorted by their X then Y position.
bool HasReferencePoint() const
const TRANSFORM & GetTransform() const
@ CHT_DONE
Flag to indicate the change is already applied.
static constexpr EDA_ANGLE ANGLE_90
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_CHANGED
Item was edited, and modified.
#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 SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define STRUCT_DELETED
flag indication structures to be erased
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_MOVING
Item being moved.
#define STARTPOINT
When a line is selected, these flags indicate which.
@ ID_POPUP_SCH_SELECT_UNIT
@ ID_POPUP_SCH_SELECT_BODY_STYLE
@ ID_POPUP_SCH_SELECT_BODY_STYLE_END
@ ID_POPUP_SCH_SELECT_UNIT_END
bool m_ConnectivityEngine
Use the schematic connectivity engine instead of CONNECTION_GRAPH.
const wxChar *const traceSchMove
Flag to watch how schematic move tool actions are handled.
std::vector< SCH_JUNCTION * > PreviewJunctions(const SCH_SCREEN *aScreen, const std::vector< class SCH_ITEM * > &aItems)
Determine the points where explicit junctions would be required if the given temporary items were com...
POINT_INFO AnalyzePoint(const EE_RTREE &aItem, const VECTOR2I &aPosition, bool aBreakCrossings)
Check a tree of items for a confluence at a given point and work out what kind of junction it is,...
@ REPAINT
Item needs to be redrawn.
bool signbit(T v)
Integral version of std::signbit that works all compilers.
@ VERTICAL
A segment (or two points) is vertical.
@ HORIZONTAL
A segment (or two points) is horizontal.
Class to handle a set of SCH_ITEMs.
void MoveSchematicItem(EDA_ITEM *aItem, const VECTOR2I &aDelta)
Move a schematic item by a delta.
void AlignSchematicItemsToGrid(SCH_SCREEN *aScreen, const std::vector< EDA_ITEM * > &aItems, EE_GRID_HELPER &aGrid, GRID_HELPER_GRIDS aSelectionGrid, const SCH_ALIGNMENT_CALLBACKS &aCallbacks)
Align a set of schematic items to the grid.
std::vector< EDA_ITEM * > EDA_ITEMS
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
T * GetAppSettings(const char *aFilename)
Increment event parameters.
The EE_TYPE struct provides a type-specific auto-range iterator to the RTree.
A selection of information about a point in the schematic that might be eligible for turning into a j...
VECTOR2D m_lastKeyboardCursorPosition
Position of the above event.
bool m_lastKeyboardCursorPositionValid
Is last cursor motion event coming from keyboard arrow cursor motion action.
long m_lastKeyboardCursorCommand
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
Callbacks for alignment operations.
std::function< void(SCH_ITEM *aItem, const VECTOR2I &aPoint, EDA_ITEMS &aList)> m_getConnectedDragItems
Callback to get items connected to a given item at a specific point.
std::function< void(EDA_ITEM *aItem, const VECTOR2I &aDelta)> m_doMoveItem
Callback to move an item by a delta.
std::function< void(EDA_ITEM *aItem)> m_updateItem
Optional callback to update an item's display after modification.
KIBIS top(path, &reporter)
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D