KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_move_tool.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <cmath>
26#include <memory>
27#include <optional>
28#include <wx/log.h>
29#include <trigo.h>
31#include <tool/tool_manager.h>
36#include <tools/sch_move_tool.h>
37
38#include <sch_actions.h>
39#include <sch_commit.h>
40#include <eda_item.h>
41#include <sch_group.h>
42#include <sch_item.h>
43#include <sch_symbol.h>
44#include <sch_sheet.h>
45#include <sch_sheet_pin.h>
46#include <sch_line.h>
47#include <sch_connection.h>
48#include <sch_junction.h>
49#include <junction_helpers.h>
50#include <sch_edit_frame.h>
51#include <eeschema_id.h>
52#include <pgm_base.h>
53#include <view/view_controls.h>
55#include <math/box2.h>
56#include <base_units.h>
57#include <sch_screen.h>
58#include <trace_helpers.h>
59
60
61// For adding to or removing from selections
62#define QUIET_MODE true
63
64
65static bool isGraphicItemForDrop( const SCH_ITEM* aItem )
66{
67 switch( aItem->Type() )
68 {
69 case SCH_SHAPE_T:
70 case SCH_BITMAP_T:
71 case SCH_TEXT_T:
72 case SCH_TEXTBOX_T:
73 return true;
74 case SCH_LINE_T:
75 return static_cast<const SCH_LINE*>( aItem )->IsGraphicLine();
76 default:
77 return false;
78 }
79}
80
81
82static void cloneWireConnection( SCH_LINE* aNewLine, SCH_ITEM* aSource, SCH_EDIT_FRAME* aFrame )
83{
84 if( !aNewLine || !aSource || !aFrame )
85 return;
86
87 SCH_LINE* sourceLine = dynamic_cast<SCH_LINE*>( aSource );
88
89 if( !sourceLine )
90 return;
91
92 SCH_SHEET_PATH sheetPath = aFrame->GetCurrentSheet();
93 SCH_CONNECTION* sourceConnection = sourceLine->Connection( &sheetPath );
94
95 if( !sourceConnection )
96 return;
97
98 SCH_CONNECTION* newConnection = aNewLine->InitializeConnection( sheetPath, nullptr );
99
100 if( !newConnection )
101 return;
102
103 newConnection->Clone( *sourceConnection );
104}
105
106
108 SCH_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveMove" ),
109 m_inMoveTool( false ),
110 m_moveInProgress( false ),
111 m_mode( MOVE ),
112 m_moveOffset( 0, 0 )
113{
114}
115
116
118{
120
121 auto moveCondition =
122 []( const SELECTION& aSel )
123 {
124 if( aSel.Empty() || SELECTION_CONDITIONS::OnlyTypes( { SCH_MARKER_T } )( aSel ) )
125 return false;
126
128 return false;
129
130 return true;
131 };
132
133 // Add move actions to the selection tool menu
134 //
135 CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
136
137 selToolMenu.AddItem( SCH_ACTIONS::move, moveCondition, 150 );
138 selToolMenu.AddItem( SCH_ACTIONS::drag, moveCondition, 150 );
139 selToolMenu.AddItem( SCH_ACTIONS::alignToGrid, moveCondition, 150 );
140
141 return true;
142}
143
144
146{
147 SCH_TOOL_BASE::Reset( aReason );
148
149 if( aReason == MODEL_RELOAD || aReason == SUPERMODEL_RELOAD )
150 {
151 // If we were in the middle of a move/drag operation and the model changes (e.g., sheet
152 // switch), we need to clean up our state to avoid blocking future move/drag operations
153 if( m_moveInProgress )
154 {
155 // Clear the move state
156 m_moveInProgress = false;
157 m_mode = MOVE;
158 m_moveOffset = VECTOR2I( 0, 0 );
159 m_anchorPos.reset();
160 m_breakPos.reset();
161
162 // Clear cached data that references items from the previous sheet
163 m_dragAdditions.clear();
164 m_lineConnectionCache.clear();
165 m_newDragLines.clear();
166 m_changedDragLines.clear();
167 m_specialCaseLabels.clear();
169 m_hiddenJunctions.clear();
170
171 // Clear any preview
172 if( m_view )
173 m_view->ClearPreview();
174 }
175 }
176}
177
178
179void SCH_MOVE_TOOL::orthoLineDrag( SCH_COMMIT* aCommit, SCH_LINE* line, const VECTOR2I& splitDelta,
180 int& xBendCount, int& yBendCount, const EE_GRID_HELPER& grid )
181{
182 // If the move is not the same angle as this move, then we need to do something special with
183 // the unselected end to maintain orthogonality. Either drag some connected line that is the
184 // same angle as the move or add two lines to make a 90 degree connection
185 if( !EDA_ANGLE( splitDelta ).IsParallelTo( line->Angle() ) || line->GetLength() == 0 )
186 {
187 VECTOR2I unselectedEnd = line->HasFlag( STARTPOINT ) ? line->GetEndPoint()
188 : line->GetStartPoint();
189 VECTOR2I selectedEnd = line->HasFlag( STARTPOINT ) ? line->GetStartPoint()
190 : line->GetEndPoint();
191
192 // Look for pre-existing lines we can drag with us instead of creating new ones
193 bool foundAttachment = false;
194 bool foundJunction = false;
195 bool foundPin = false;
196 SCH_LINE* foundLine = nullptr;
197
198 for( EDA_ITEM* cItem : m_lineConnectionCache[line] )
199 {
200 foundAttachment = true;
201
202 // If the move is the same angle as a connected line, we can shrink/extend that line
203 // endpoint
204 switch( cItem->Type() )
205 {
206 case SCH_LINE_T:
207 {
208 SCH_LINE* cLine = static_cast<SCH_LINE*>( cItem );
209
210 // A matching angle on a non-zero-length line means lengthen/shorten will work
211 if( EDA_ANGLE( splitDelta ).IsParallelTo( cLine->Angle() )
212 && cLine->GetLength() != 0 )
213 {
214 foundLine = cLine;
215 }
216
217 // Zero length lines are lines that this algorithm has shortened to 0 so they also
218 // work but we should prefer using a segment with length and angle matching when
219 // we can (otherwise the zero length line will draw overlapping segments on them)
220 if( !foundLine && cLine->GetLength() == 0 )
221 foundLine = cLine;
222
223 break;
224 }
225 case SCH_JUNCTION_T:
226 foundJunction = true;
227 break;
228
229 case SCH_PIN_T:
230 foundPin = true;
231 break;
232
233 case SCH_SHEET_T:
234 for( const auto& pair : m_specialCaseSheetPins )
235 {
236 if( pair.first->IsConnected( selectedEnd ) )
237 {
238 foundPin = true;
239 break;
240 }
241 }
242
243 break;
244
245 default:
246 break;
247 }
248 }
249
250 // Ok... what if our original line is length zero from moving in its direction, and the
251 // last added segment of the 90 bend we are connected to is zero from moving it in its
252 // direction after it was added?
253 //
254 // If we are moving in original direction, we should lengthen the original drag wire.
255 // Otherwise we should lengthen the new wire.
256 bool preferOriginalLine = false;
257
258 if( foundLine
259 && foundLine->GetLength() == 0
260 && line->GetLength() == 0
261 && EDA_ANGLE( splitDelta ).IsParallelTo( line->GetStoredAngle() ) )
262 {
263 preferOriginalLine = true;
264 }
265 // If we have found an attachment, but not a line, we want to check if it's a junction.
266 // These are special-cased and get a single line added instead of a 90-degree bend. Except
267 // when we're on a pin, because pins always need bends, and junctions are just added to
268 // pins for visual clarity.
269 else if( !foundLine && foundJunction && !foundPin )
270 {
271 // Create a new wire ending at the unselected end
272 foundLine = new SCH_LINE( unselectedEnd, line->GetLayer() );
273 foundLine->SetFlags( IS_NEW );
274 foundLine->SetLastResolvedState( line );
275 cloneWireConnection( foundLine, line, m_frame );
276 m_frame->AddToScreen( foundLine, m_frame->GetScreen() );
277 m_newDragLines.insert( foundLine );
278
279 // We just broke off of the existing items, so replace all of them with our new
280 // end connection.
282 m_lineConnectionCache[line].clear();
283 m_lineConnectionCache[line].emplace_back( foundLine );
284 }
285
286 // We want to drag our found line if it's in the same angle as the move or zero length,
287 // but if the original drag line is also zero and the same original angle we should extend
288 // that one first
289 if( foundLine && !preferOriginalLine )
290 {
291 // Move the connected line found oriented in the direction of our move.
292 //
293 // Make sure we grab the right endpoint, it's not always STARTPOINT since the user can
294 // draw a box of lines. We need to only move one though, and preferably the start point,
295 // in case we have a zero length line that we are extending (we want the foundLine
296 // start point to be attached to the unselected end of our drag line).
297 //
298 // Also, new lines are added already so they'll be in the undo list, skip adding them.
299
300 if( !foundLine->HasFlag( IS_CHANGED ) && !foundLine->HasFlag( IS_NEW ) )
301 {
302 aCommit->Modify( (SCH_ITEM*) foundLine, m_frame->GetScreen() );
303
304 if( !foundLine->IsSelected() )
305 m_changedDragLines.insert( foundLine );
306 }
307
308 if( foundLine->GetStartPoint() == unselectedEnd )
309 foundLine->MoveStart( splitDelta );
310 else if( foundLine->GetEndPoint() == unselectedEnd )
311 foundLine->MoveEnd( splitDelta );
312
313 updateItem( foundLine, true );
314
315 SCH_LINE* bendLine = nullptr;
316
317 if( m_lineConnectionCache.count( foundLine ) == 1
318 && m_lineConnectionCache[foundLine][0]->Type() == SCH_LINE_T )
319 {
320 bendLine = static_cast<SCH_LINE*>( m_lineConnectionCache[foundLine][0] );
321 }
322
323 // Remerge segments we've created if this is a segment that we've added whose only
324 // other connection is also an added segment
325 //
326 // bendLine is first added segment at the original attachment point, foundLine is the
327 // orthogonal line between bendLine and this line
328 if( foundLine->HasFlag( IS_NEW )
329 && foundLine->GetLength() == 0
330 && bendLine && bendLine->HasFlag( IS_NEW ) )
331 {
332 if( line->HasFlag( STARTPOINT ) )
333 line->SetEndPoint( bendLine->GetEndPoint() );
334 else
335 line->SetStartPoint( bendLine->GetEndPoint() );
336
337 // Update our cache of the connected items.
338
339 // Re-attach drag labels from lines being deleted to the surviving line.
340 // This prevents dangling pointers when bendLine/foundLine are deleted below.
341 for( auto& [label, info] : m_specialCaseLabels )
342 {
343 if( info.attachedLine == bendLine || info.attachedLine == foundLine )
344 info.attachedLine = line;
345 }
346
348 m_lineConnectionCache[bendLine].clear();
349 m_lineConnectionCache[foundLine].clear();
350
351 m_frame->RemoveFromScreen( bendLine, m_frame->GetScreen() );
352 m_frame->RemoveFromScreen( foundLine, m_frame->GetScreen() );
353
354 m_newDragLines.erase( bendLine );
355 m_newDragLines.erase( foundLine );
356
357 delete bendLine;
358 delete foundLine;
359 }
360 //Ok, move the unselected end of our item
361 else
362 {
363 if( line->HasFlag( STARTPOINT ) )
364 line->MoveEnd( splitDelta );
365 else
366 line->MoveStart( splitDelta );
367 }
368
369 updateItem( line, true );
370 }
371 else if( line->GetLength() == 0 )
372 {
373 // We didn't find another line to shorten/lengthen, (or we did but it's also zero)
374 // so now is a good time to use our existing zero-length original line
375 }
376 // Either no line was at the "right" angle, or this was a junction, pin, sheet, etc. We
377 // need to add segments to keep the soon-to-move unselected end connected to these items.
378 //
379 // To keep our drag selections all the same, we'll move our unselected end point and then
380 // put wires between it and its original endpoint.
381 else if( foundAttachment && line->IsOrthogonal() )
382 {
383 VECTOR2D lineGrid = grid.GetGridSize( grid.GetItemGrid( line ) );
384
385 // The bend counter handles a group of wires all needing their offset one grid movement
386 // further out from each other to not overlap. The absolute value stuff finds the
387 // direction of the line and hence the the bend increment on that axis
388 unsigned int xMoveBit = splitDelta.x != 0;
389 unsigned int yMoveBit = splitDelta.y != 0;
390 int xLength = abs( unselectedEnd.x - selectedEnd.x );
391 int yLength = abs( unselectedEnd.y - selectedEnd.y );
392 int xMove = ( xLength - ( xBendCount * lineGrid.x ) )
393 * sign( selectedEnd.x - unselectedEnd.x );
394 int yMove = ( yLength - ( yBendCount * lineGrid.y ) )
395 * sign( selectedEnd.y - unselectedEnd.y );
396
397 // Create a new wire ending at the unselected end, we'll move the new wire's start
398 // point to the unselected end
399 SCH_LINE* a = new SCH_LINE( unselectedEnd, line->GetLayer() );
400 a->MoveStart( VECTOR2I( xMove, yMove ) );
401 a->SetFlags( IS_NEW );
402 a->SetConnectivityDirty( true );
403 a->SetLastResolvedState( line );
404 cloneWireConnection( a, line, m_frame );
405 m_frame->AddToScreen( a, m_frame->GetScreen() );
406 m_newDragLines.insert( a );
407
408 SCH_LINE* b = new SCH_LINE( a->GetStartPoint(), line->GetLayer() );
409 b->MoveStart( VECTOR2I( splitDelta.x, splitDelta.y ) );
410 b->SetFlags( IS_NEW | STARTPOINT );
411 b->SetConnectivityDirty( true );
412 b->SetLastResolvedState( line );
413 cloneWireConnection( b, line, m_frame );
414 m_frame->AddToScreen( b, m_frame->GetScreen() );
415 m_newDragLines.insert( b );
416
417 xBendCount += yMoveBit;
418 yBendCount += xMoveBit;
419
420 // Ok move the unselected end of our item
421 if( line->HasFlag( STARTPOINT ) )
422 {
423 line->MoveEnd( VECTOR2I( splitDelta.x ? splitDelta.x : xMove,
424 splitDelta.y ? splitDelta.y : yMove ) );
425 }
426 else
427 {
428 line->MoveStart( VECTOR2I( splitDelta.x ? splitDelta.x : xMove,
429 splitDelta.y ? splitDelta.y : yMove ) );
430 }
431
432 // Update our cache of the connected items. First, attach our drag labels to the line
433 // left behind.
434 for( EDA_ITEM* candidate : m_lineConnectionCache[line] )
435 {
436 SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( candidate );
437
438 if( label && m_specialCaseLabels.count( label ) )
439 m_specialCaseLabels[label].attachedLine = a;
440 }
441
442 // We just broke off of the existing items, so replace all of them with our new end
443 // connection.
445 m_lineConnectionCache[b].emplace_back( a );
446 m_lineConnectionCache[line].clear();
447 m_lineConnectionCache[line].emplace_back( b );
448 }
449 // Original line has no attachments, just move the unselected end
450 else if( !foundAttachment )
451 {
452 if( line->HasFlag( STARTPOINT ) )
453 line->MoveEnd( splitDelta );
454 else
455 line->MoveStart( splitDelta );
456 }
457 }
458}
459
460
461int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
462{
463 if( aEvent.IsAction( &SCH_ACTIONS::drag ) )
464 m_mode = DRAG;
465 else if( aEvent.IsAction( &SCH_ACTIONS::breakWire ) )
466 m_mode = BREAK;
467 else if( aEvent.IsAction( &SCH_ACTIONS::slice ) )
468 m_mode = SLICE;
469 else
470 m_mode = MOVE;
471
472 if( SCH_COMMIT* commit = dynamic_cast<SCH_COMMIT*>( aEvent.Commit() ) )
473 {
474 wxCHECK( aEvent.SynchronousState(), 0 );
475 aEvent.SynchronousState()->store( STS_RUNNING );
476
477 if( doMoveSelection( aEvent, commit ) )
478 aEvent.SynchronousState()->store( STS_FINISHED );
479 else
480 aEvent.SynchronousState()->store( STS_CANCELLED );
481 }
482 else
483 {
484 SCH_COMMIT localCommit( m_toolMgr );
485
486 if( doMoveSelection( aEvent, &localCommit ) )
487 {
488 switch( m_mode )
489 {
490 case MOVE: localCommit.Push( _( "Move" ) ); break;
491 case DRAG: localCommit.Push( _( "Drag" ) ); break;
492 case BREAK: localCommit.Push( _( "Break Wire" ) ); break;
493 case SLICE: localCommit.Push( _( "Slice Wire" ) ); break;
494 }
495 }
496 else
497 {
498 localCommit.Revert();
499 }
500 }
501
502 return 0;
503}
504
505
507{
508 if( m_mode != BREAK && m_mode != SLICE )
509 return;
510
511 if( !aCommit )
512 return;
513
515
516 if( !lwbTool )
517 return;
518
519 SCH_SELECTION& selection = m_selectionTool->GetSelection();
520
521 if( selection.Empty() )
522 return;
523
524 std::vector<SCH_LINE*> lines;
525
526 for( EDA_ITEM* item : selection )
527 {
528 if( item->Type() == SCH_LINE_T )
529 {
530 // This function gets called every time segments are broken, which can
531 // also be for subsequent breaks in a loop without leaving the current move tool.
532 // Skip already placed segments (segment keeps IS_BROKEN but will have IS_NEW cleared below)
533 // so that only the actively placed tail segment gets split again.
534 if( item->HasFlag( IS_BROKEN ) && !item->HasFlag( IS_NEW ) )
535 continue;
536
537 lines.push_back( static_cast<SCH_LINE*>( item ) );
538 }
539 }
540
541 if( lines.empty() )
542 return;
543
545 SCH_SCREEN* screen = m_frame->GetScreen();
546 VECTOR2I cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
547
548 bool useCursorForSingleLine = false;
549
550 if( lines.size() == 1 )
551 useCursorForSingleLine = true;
552
553 m_selectionTool->ClearSelection();
554 m_breakPos.reset();
555
556 for( SCH_LINE* line : lines )
557 {
558 VECTOR2I breakPos = useCursorForSingleLine ? cursorPos : line->GetMidPoint();
559
560 if( m_mode == BREAK && !m_breakPos )
561 m_breakPos = breakPos;
562
563 SCH_LINE* newLine = nullptr;
564
565 lwbTool->BreakSegment( aCommit, line, breakPos, &newLine, screen );
566
567 if( !newLine )
568 continue;
569
570 // If this is a second+ round break, we need to get rid of the IS_NEW flag since
571 // the new segment is now an existing segment we are breaking from, this will be checked for
572 // in the line selection gathering above
573 line->ClearFlags( STARTPOINT | IS_NEW );
574 line->SetFlags( ENDPOINT );
575 m_selectionTool->AddItemToSel( line );
576
577 newLine->ClearFlags( ENDPOINT | STARTPOINT );
578
579 if( m_mode == BREAK )
580 {
581 m_selectionTool->AddItemToSel( newLine );
582 newLine->SetFlags( STARTPOINT );
583 }
584 }
585}
586
587
589{
592 bool currentModeIsDragLike = ( m_mode != MOVE );
593 bool wasDragging = m_moveInProgress && currentModeIsDragLike;
594 bool didAtLeastOneBreak = false;
595
596 m_anchorPos.reset();
597
598 // Check if already in progress and handle state transitions
599 if( checkMoveInProgress( aEvent, aCommit, currentModeIsDragLike, wasDragging ) )
600 return false;
601
602 if( m_inMoveTool ) // Must come after m_moveInProgress checks above...
603 return false;
604
606
607 preprocessBreakOrSliceSelection( aCommit, aEvent );
608
609 // Prepare selection (promote pins to symbols, request selection)
610 bool unselect = false;
611 SCH_SELECTION& selection = prepareSelection( unselect );
612
613 // Keep an original copy of the starting points for cleanup after the move
614 std::vector<DANGLING_END_ITEM> internalPoints;
615
616 // Track selection characteristics
617 bool selectionHasSheetPins = false;
618 bool selectionHasGraphicItems = false;
619 bool selectionHasNonGraphicItems = false;
620 bool selectionIsGraphicsOnly = false;
621
622 std::unique_ptr<SCH_DRAG_NET_COLLISION_MONITOR> netCollisionMonitor;
623
624 auto refreshTraits =
625 [&]()
626 {
627 refreshSelectionTraits( selection, selectionHasSheetPins, selectionHasGraphicItems,
628 selectionHasNonGraphicItems, selectionIsGraphicsOnly );
629 };
630
631 refreshTraits();
632
633 if( !selection.Empty() )
634
635 {
636 netCollisionMonitor = std::make_unique<SCH_DRAG_NET_COLLISION_MONITOR>( m_frame, m_view );
637 netCollisionMonitor->Initialize( selection );
638 }
639
640 bool lastCtrlDown = false;
641
642 Activate();
643
644 // Must be done after Activate() so that it gets set into the correct context
645 controls->ShowCursor( true );
646
647 m_frame->PushTool( aEvent );
648
649 if( selection.Empty() )
650 {
651 // Note that it's important to go through push/pop even when the selection is empty.
652 // This keeps other tools from having to special-case an empty move.
653 m_frame->PopTool( aEvent );
654 return false;
655 }
656
657 bool restore_state = false;
658 TOOL_EVENT copy = aEvent;
659 TOOL_EVENT* evt = &copy;
660 VECTOR2I prevPos = controls->GetCursorPosition();
662 SCH_SHEET* hoverSheet = nullptr;
663 KICURSOR currentCursor = KICURSOR::MOVING;
664 m_cursor = controls->GetCursorPosition();
665
666 // Axis locking for arrow key movement
667 enum class AXIS_LOCK { NONE, HORIZONTAL, VERTICAL };
668 AXIS_LOCK axisLock = AXIS_LOCK::NONE;
669 long lastArrowKeyAction = 0;
670
671 // Main loop: keep receiving events
672 do
673 {
674 wxLogTrace( traceSchMove, "doMoveSelection: event loop iteration, evt=%s, action=%s",
675 evt->Category() == TC_MOUSE ? "MOUSE" :
676 evt->Category() == TC_KEYBOARD ? "KEYBOARD" :
677 evt->Category() == TC_COMMAND ? "COMMAND" : "OTHER",
678 evt->Format().c_str() );
679
680 m_frame->GetCanvas()->SetCurrentCursor( currentCursor );
681 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
682 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
683
684 bool ctrlDown = evt->Modifier( MD_CTRL );
685 lastCtrlDown = ctrlDown;
686
688 || evt->IsAction( &SCH_ACTIONS::move )
689 || evt->IsAction( &SCH_ACTIONS::drag )
690 || evt->IsMotion()
691 || evt->IsDrag( BUT_LEFT )
693 {
694 refreshTraits();
695
696 if( !m_moveInProgress ) // Prepare to start moving/dragging
697 {
698 initializeMoveOperation( aEvent, selection, aCommit, internalPoints, snapLayer );
699 prevPos = m_cursor;
700 refreshTraits();
701 }
702
703 //------------------------------------------------------------------------
704 // Follow the mouse
705 //
706 m_view->ClearPreview();
707
708 // We need to bypass refreshPreview action here because it is triggered by the move,
709 // so we were getting double-key events that toggled the axis locking if you
710 // pressed them in a certain order.
712 {
713 VECTOR2I keyboardPos( controls->GetSettings().m_lastKeyboardCursorPosition );
714 long action = controls->GetSettings().m_lastKeyboardCursorCommand;
715
716 grid.SetSnap( false );
717 m_cursor = grid.Align( keyboardPos, snapLayer );
718
719 // Update axis lock based on arrow key press
720 if( action == ACTIONS::CURSOR_LEFT || action == ACTIONS::CURSOR_RIGHT )
721 {
722 if( axisLock == AXIS_LOCK::HORIZONTAL )
723 {
724 // Check if opposite horizontal key pressed to unlock
725 if( ( lastArrowKeyAction == ACTIONS::CURSOR_LEFT && action == ACTIONS::CURSOR_RIGHT ) ||
726 ( lastArrowKeyAction == ACTIONS::CURSOR_RIGHT && action == ACTIONS::CURSOR_LEFT ) )
727 {
728 axisLock = AXIS_LOCK::NONE;
729 }
730 // Same direction axis, keep locked
731 }
732 else
733 {
734 axisLock = AXIS_LOCK::HORIZONTAL;
735 }
736 }
737 else if( action == ACTIONS::CURSOR_UP || action == ACTIONS::CURSOR_DOWN )
738 {
739 if( axisLock == AXIS_LOCK::VERTICAL )
740 {
741 // Check if opposite vertical key pressed to unlock
742 if( ( lastArrowKeyAction == ACTIONS::CURSOR_UP && action == ACTIONS::CURSOR_DOWN ) ||
743 ( lastArrowKeyAction == ACTIONS::CURSOR_DOWN && action == ACTIONS::CURSOR_UP ) )
744 {
745 axisLock = AXIS_LOCK::NONE;
746 }
747 // Same direction axis, keep locked
748 }
749 else
750 {
751 axisLock = AXIS_LOCK::VERTICAL;
752 }
753 }
754
755 lastArrowKeyAction = action;
756 }
757 else
758 {
759 m_cursor = grid.BestSnapAnchor( controls->GetCursorPosition( false ), snapLayer, selection );
760 }
761
762 if( axisLock == AXIS_LOCK::HORIZONTAL )
763 m_cursor.y = prevPos.y;
764 else if( axisLock == AXIS_LOCK::VERTICAL )
765 m_cursor.x = prevPos.x;
766
767 // Find potential target sheet for dropping
768 SCH_SHEET* sheet = findTargetSheet( selection, m_cursor, selectionHasSheetPins,
769 selectionIsGraphicsOnly, ctrlDown );
770
771 if( sheet != hoverSheet )
772 {
773 hoverSheet = sheet;
774
775 if( hoverSheet )
776 {
777 hoverSheet->SetFlags( BRIGHTENED );
778 m_frame->UpdateItem( hoverSheet, false );
779 }
780 }
781
782 currentCursor = hoverSheet ? KICURSOR::PLACE : KICURSOR::MOVING;
783
784 if( netCollisionMonitor )
785 currentCursor = netCollisionMonitor->AdjustCursor( currentCursor );
786
787 VECTOR2I delta( m_cursor - prevPos );
789
790 // Used for tracking how far off a drag end should have its 90 degree elbow added
791 int xBendCount = 1;
792 int yBendCount = 1;
793
794 performItemMove( selection, delta, aCommit, xBendCount, yBendCount, grid );
795 prevPos = m_cursor;
796
797 std::vector<SCH_ITEM*> previewItems;
798
799 for( EDA_ITEM* it : selection )
800 previewItems.push_back( static_cast<SCH_ITEM*>( it ) );
801
802 for( SCH_LINE* line : m_newDragLines )
803 previewItems.push_back( line );
804
805 for( SCH_LINE* line : m_changedDragLines )
806 previewItems.push_back( line );
807
808 std::vector<SCH_JUNCTION*> previewJunctions =
809 JUNCTION_HELPERS::PreviewJunctions( m_frame->GetScreen(), previewItems );
810
811 if( netCollisionMonitor )
812 netCollisionMonitor->Update( previewJunctions, selection );
813
814 for( SCH_JUNCTION* jct : previewJunctions )
815 {
816 m_view->AddToPreview( jct, true );
817 }
818
820 }
821
822 //------------------------------------------------------------------------
823 // Handle cancel
824 //
825 else if( evt->IsCancelInteractive()
826 || evt->IsActivate()
827 || evt->IsAction( &ACTIONS::undo ) )
828 {
829 if( evt->IsCancelInteractive() )
830 {
831 m_frame->GetInfoBar()->Dismiss();
832
833 // When breaking, the user can cancel after multiple breaks to keep all but the last
834 // break, so exit normally if we have done at least one break
835 if( didAtLeastOneBreak && m_mode == BREAK )
836 break;
837 }
838
839 if( m_moveInProgress )
840 {
841 if( evt->IsActivate() )
842 {
843 // Allowing other tools to activate during a move runs the risk of race
844 // conditions in which we try to spool up both event loops at once.
845
846 switch( m_mode )
847 {
848 case MOVE: m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel move." ) ); break;
849 case DRAG: m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel drag." ) ); break;
850 case BREAK: m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel break." ) ); break;
851 case SLICE: m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel slice." ) ); break;
852 }
853
854 evt->SetPassEvent( false );
855 continue;
856 }
857
858 evt->SetPassEvent( false );
859 restore_state = true;
860 }
861
863
864 m_view->ClearPreview();
865
866 break;
867 }
868 //------------------------------------------------------------------------
869 // Handle TOOL_ACTION special cases
870 //
871 else if( !handleMoveToolActions( evt, aCommit, selection ) )
872 {
873 wxLogTrace( traceSchMove, "doMoveSelection: handleMoveToolActions returned false, exiting" );
874 break; // Exit if told to by handler
875 }
876 //------------------------------------------------------------------------
877 // Handle context menu
878 //
879 else if( evt->IsClick( BUT_RIGHT ) )
880 {
881 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
882 }
883 //------------------------------------------------------------------------
884 // Handle drop
885 //
886 else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
887 {
888 if( m_mode != BREAK )
889 break; // Finish
890 else
891 {
892 didAtLeastOneBreak = true;
893 preprocessBreakOrSliceSelection( aCommit, *evt );
894 selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::MovableItems, true );
895
896 if( m_breakPos )
897 {
900 selection.SetReferencePoint( m_cursor );
901 m_moveOffset = VECTOR2I( 0, 0 );
902 m_breakPos.reset();
903
904 controls->SetCursorPosition( m_cursor, false );
905 prevPos = m_cursor;
906 }
907 }
908 }
909 else if( evt->IsDblClick( BUT_LEFT ) )
910 {
911 // Double click always finishes, even breaks
912 break;
913 }
914 // Don't call SetPassEvent() for events we've handled - let them be consumed
915 else if( evt->IsAction( &SCH_ACTIONS::rotateCW )
917 || evt->IsAction( &ACTIONS::increment )
922 || evt->IsAction( &SCH_ACTIONS::toText )
926 || evt->IsAction( &ACTIONS::duplicate )
928 || evt->IsAction( &ACTIONS::redo ) )
929 {
930 // Event was already handled by handleMoveToolActions, don't pass it on
931 wxLogTrace( traceSchMove, "doMoveSelection: event handled, not passing" );
932 }
933 else
934 {
935 evt->SetPassEvent();
936 }
937
938 controls->SetAutoPan( m_moveInProgress );
939
940 } while( ( evt = Wait() ) ); //Should be assignment not equality test
941
942 SCH_SHEET* targetSheet = hoverSheet;
943
944 if( selectionHasSheetPins || ( selectionIsGraphicsOnly && !lastCtrlDown ) )
945 targetSheet = nullptr;
946
947 if( hoverSheet )
948 {
949 hoverSheet->ClearFlags( BRIGHTENED );
950 m_frame->UpdateItem( hoverSheet, false );
951 }
952
953 if( targetSheet )
954 {
955 moveSelectionToSheet( selection, targetSheet, aCommit );
957 m_newDragLines.clear();
958 m_changedDragLines.clear();
959 }
960
961 if( restore_state )
962 {
963 m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE );
964 }
965 else
966 {
967 finalizeMoveOperation( selection, aCommit, unselect, internalPoints );
968 }
969
970 m_dragAdditions.clear();
971 m_lineConnectionCache.clear();
972 m_moveInProgress = false;
973 m_breakPos.reset();
974
975 m_hiddenJunctions.clear();
976 m_view->ClearPreview();
977 m_frame->PopTool( aEvent );
978
979 return !restore_state;
980}
981
982
983bool SCH_MOVE_TOOL::checkMoveInProgress( const TOOL_EVENT& aEvent, SCH_COMMIT* aCommit, bool aCurrentModeIsDragLike,
984 bool aWasDragging )
985{
987
988 if( !m_moveInProgress )
989 return false;
990
991 if( aCurrentModeIsDragLike != aWasDragging )
992 {
993 EDA_ITEM* sel = m_selectionTool->GetSelection().Front();
994
995 if( sel && !sel->IsNew() )
996 {
997 // Reset the selected items so we can start again with the current drag mode state
998 aCommit->Revert();
999
1000 m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE );
1002 m_moveInProgress = false;
1003 controls->SetAutoPan( false );
1004
1005 // Give it a kick so it doesn't have to wait for the first mouse movement to refresh
1006 m_toolMgr->PostAction( SCH_ACTIONS::restartMove );
1007 }
1008 }
1009 else
1010 {
1011 // The tool hotkey is interpreted as a click when already dragging/moving
1012 m_toolMgr->PostAction( ACTIONS::cursorClick );
1013 }
1014
1015 return true;
1016}
1017
1018
1020{
1021 SCH_SELECTION& userSelection = m_selectionTool->GetSelection();
1022
1023 // If a single pin is selected, promote the move selection to its parent symbol
1024 if( userSelection.GetSize() == 1 )
1025 {
1026 EDA_ITEM* selItem = userSelection.Front();
1027
1028 if( selItem->Type() == SCH_PIN_T )
1029 {
1030 EDA_ITEM* parent = selItem->GetParent();
1031
1032 if( parent->Type() == SCH_SYMBOL_T )
1033 {
1034 m_selectionTool->ClearSelection();
1035 m_selectionTool->AddItemToSel( parent );
1036 }
1037 }
1038 }
1039
1040 // Be sure that there is at least one item that we can move. If there's no selection try
1041 // looking for the stuff under mouse cursor (i.e. KiCad old-style hover selection).
1042 SCH_SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::MovableItems,
1043 true );
1044 aUnselect = selection.IsHover();
1045
1046 return selection;
1047}
1048
1049
1050void SCH_MOVE_TOOL::refreshSelectionTraits( const SCH_SELECTION& aSelection, bool& aHasSheetPins,
1051 bool& aHasGraphicItems, bool& aHasNonGraphicItems,
1052 bool& aIsGraphicsOnly )
1053{
1054 aHasSheetPins = false;
1055 aHasGraphicItems = false;
1056 aHasNonGraphicItems = false;
1057
1058 for( EDA_ITEM* edaItem : aSelection )
1059 {
1060 SCH_ITEM* schItem = static_cast<SCH_ITEM*>( edaItem );
1061
1062 if( schItem->Type() == SCH_SHEET_PIN_T )
1063 aHasSheetPins = true;
1064
1065 if( isGraphicItemForDrop( schItem ) )
1066 aHasGraphicItems = true;
1067 else if( schItem->Type() != SCH_SHEET_T )
1068 aHasNonGraphicItems = true;
1069 }
1070
1071 aIsGraphicsOnly = aHasGraphicItems && !aHasNonGraphicItems;
1072}
1073
1074
1076{
1077 // Drag of split items start over top of their other segment, so we want to skip grabbing
1078 // the segments we split from
1079 if( m_mode != DRAG && m_mode != BREAK )
1080 return;
1081
1082 EDA_ITEMS connectedDragItems;
1083
1084 // Add connections to the selection for a drag.
1085 // Do all non-labels/entries first so we don't add junctions to drag when the line will
1086 // eventually be drag selected.
1087 std::vector<SCH_ITEM*> stageTwo;
1088
1089 for( EDA_ITEM* edaItem : aSelection )
1090 {
1091 SCH_ITEM* item = static_cast<SCH_ITEM*>( edaItem );
1092 std::vector<VECTOR2I> connections;
1093
1094 switch( item->Type() )
1095 {
1096 case SCH_LABEL_T:
1097 case SCH_HIER_LABEL_T:
1098 case SCH_GLOBAL_LABEL_T:
1100 stageTwo.emplace_back( item );
1101 break;
1102
1103 case SCH_LINE_T:
1104 static_cast<SCH_LINE*>( item )->GetSelectedPoints( connections );
1105 break;
1106
1107 default:
1108 connections = item->GetConnectionPoints();
1109 }
1110
1111 for( const VECTOR2I& point : connections )
1112 getConnectedDragItems( aCommit, item, point, connectedDragItems );
1113 }
1114
1115 // Go back and get all label connections now that we can test for drag-selected lines
1116 // the labels might be on
1117 for( SCH_ITEM* item : stageTwo )
1118 {
1119 for( const VECTOR2I& point : item->GetConnectionPoints() )
1120 getConnectedDragItems( aCommit, item, point, connectedDragItems );
1121 }
1122
1123 for( EDA_ITEM* item : connectedDragItems )
1124 {
1125 m_dragAdditions.push_back( item->m_Uuid );
1126 m_selectionTool->AddItemToSel( item, QUIET_MODE );
1127 }
1128
1129 // Pre-cache all connections of our selected objects so we can keep track of what they
1130 // were originally connected to as we drag them around
1131 for( EDA_ITEM* edaItem : aSelection )
1132 {
1133 SCH_ITEM* schItem = static_cast<SCH_ITEM*>( edaItem );
1134
1135 if( schItem->Type() == SCH_LINE_T )
1136 {
1137 SCH_LINE* line = static_cast<SCH_LINE*>( schItem );
1138
1139 // Store the original angle of the line; needed later to decide which segment
1140 // to extend when they've become zero length
1141 line->StoreAngle();
1142
1143 for( const VECTOR2I& point : line->GetConnectionPoints() )
1144 getConnectedItems( line, point, m_lineConnectionCache[line] );
1145 }
1146 }
1147}
1148
1149
1151 std::vector<DANGLING_END_ITEM>& aInternalPoints )
1152{
1153 // Mark the edges of the block with dangling flags for a move
1154 for( EDA_ITEM* item : aSelection )
1155 static_cast<SCH_ITEM*>( item )->GetEndPoints( aInternalPoints );
1156
1157 std::vector<DANGLING_END_ITEM> endPointsByType = aInternalPoints;
1158 std::vector<DANGLING_END_ITEM> endPointsByPos = endPointsByType;
1159 DANGLING_END_ITEM_HELPER::sort_dangling_end_items( endPointsByType, endPointsByPos );
1160
1161 for( EDA_ITEM* item : aSelection )
1162 static_cast<SCH_ITEM*>( item )->UpdateDanglingState( endPointsByType, endPointsByPos );
1163}
1164
1165
1167 std::vector<DANGLING_END_ITEM>& aInternalPoints,
1168 GRID_HELPER_GRIDS& aSnapLayer )
1169{
1172 SCH_ITEM* sch_item = static_cast<SCH_ITEM*>( aSelection.Front() );
1173 bool placingNewItems = sch_item && sch_item->IsNew();
1174
1175 //------------------------------------------------------------------------
1176 // Setup a drag or a move
1177 //
1178 m_dragAdditions.clear();
1179 m_specialCaseLabels.clear();
1180 m_specialCaseSheetPins.clear();
1181 aInternalPoints.clear();
1183
1184 for( SCH_ITEM* it : m_frame->GetScreen()->Items() )
1185 {
1186 it->ClearFlags( SELECTED_BY_DRAG );
1187
1188 if( !it->IsSelected() )
1189 it->ClearFlags( STARTPOINT | ENDPOINT );
1190 }
1191
1192 setupItemsForDrag( aSelection, aCommit );
1193 setupItemsForMove( aSelection, aInternalPoints );
1194
1195 // Hide junctions connected to line endpoints that are not selected
1196 m_hiddenJunctions.clear();
1197
1198 for( EDA_ITEM* item : aSelection )
1199 item->SetFlags( STRUCT_DELETED );
1200
1201 for( EDA_ITEM* edaItem : aSelection )
1202 {
1203 if( edaItem->Type() != SCH_LINE_T )
1204 continue;
1205
1206 SCH_LINE* line = static_cast<SCH_LINE*>( edaItem );
1207
1208 for( const VECTOR2I& pt : line->GetConnectionPoints() )
1209 {
1210 SCH_JUNCTION* jct = static_cast<SCH_JUNCTION*>(
1211 m_frame->GetScreen()->GetItem( pt, 0, SCH_JUNCTION_T ) );
1212
1213 if( jct && !jct->IsSelected()
1214 && std::find( m_hiddenJunctions.begin(), m_hiddenJunctions.end(), jct )
1215 == m_hiddenJunctions.end() )
1216 {
1218 m_frame->GetScreen()->Items(), pt, false );
1219
1220 if( !info.isJunction )
1221 {
1222 jct->SetFlags( STRUCT_DELETED );
1223 m_frame->RemoveFromScreen( jct, m_frame->GetScreen() );
1224 aCommit->Removed( jct, m_frame->GetScreen() );
1225 }
1226 }
1227 }
1228 }
1229
1230 for( EDA_ITEM* item : aSelection )
1231 item->ClearFlags( STRUCT_DELETED );
1232
1233 // Generic setup
1234 aSnapLayer = grid.GetSelectionGrid( aSelection );
1235
1236 for( EDA_ITEM* item : aSelection )
1237 {
1238 SCH_ITEM* schItem = static_cast<SCH_ITEM*>( item );
1239
1240 if( schItem->IsNew() )
1241 {
1242 // Item was added to commit in a previous command
1243
1244 // While SCH_COMMIT::Push() will add any new items to the entered group, we need
1245 // to do it earlier so that the previews while moving are correct.
1246 if( SCH_GROUP* enteredGroup = m_selectionTool->GetEnteredGroup() )
1247 {
1248 if( schItem->IsGroupableType() && !schItem->GetParentGroup() )
1249 {
1250 aCommit->Modify( enteredGroup, m_frame->GetScreen(), RECURSE_MODE::NO_RECURSE );
1251 enteredGroup->AddItem( schItem );
1252 }
1253 }
1254 }
1255 else if( schItem->GetParent() && schItem->GetParent()->IsSelected() )
1256 {
1257 // Item will be (or has been) added to commit by parent
1258 }
1259 else
1260 {
1261 aCommit->Modify( schItem, m_frame->GetScreen(), RECURSE_MODE::RECURSE );
1262 }
1263
1264 schItem->SetFlags( IS_MOVING );
1265
1266 if( SCH_SHAPE* shape = dynamic_cast<SCH_SHAPE*>( schItem ) )
1267 {
1268 shape->SetHatchingDirty();
1269 shape->UpdateHatching();
1270 }
1271
1272 schItem->RunOnChildren(
1273 [&]( SCH_ITEM* unused )
1274 {
1275 item->SetFlags( IS_MOVING );
1276 },
1278
1279 schItem->SetStoredPos( schItem->GetPosition() );
1280 }
1281
1282 // Set up the starting position and move/drag offset
1283 m_cursor = controls->GetCursorPosition();
1284
1285 if( m_mode == BREAK && m_breakPos )
1286 {
1289 aSelection.SetReferencePoint( m_cursor );
1290 m_moveOffset = VECTOR2I( 0, 0 );
1291 m_breakPos.reset();
1292 }
1293
1294 if( aEvent.IsAction( &SCH_ACTIONS::restartMove ) )
1295 {
1296 wxASSERT_MSG( m_anchorPos, "Should be already set from previous cmd" );
1297 }
1298 else if( placingNewItems )
1299 {
1300 m_anchorPos = aSelection.GetReferencePoint();
1301 }
1302
1303 if( m_anchorPos )
1304 {
1305 VECTOR2I delta = m_cursor - ( *m_anchorPos );
1306 bool isPasted = false;
1307
1308 // Drag items to the current cursor position
1309 for( EDA_ITEM* item : aSelection )
1310 {
1311 // Don't double move pins, fields, etc.
1312 if( item->GetParent() && item->GetParent()->IsSelected() )
1313 continue;
1314
1315 moveItem( item, delta );
1316 updateItem( item, false );
1317
1318 isPasted |= ( item->GetFlags() & IS_PASTED ) != 0;
1319 }
1320
1321 // The first time pasted items are moved we need to store the position of the cursor
1322 // so that rotate while moving works as expected (instead of around the original
1323 // anchor point)
1324 if( isPasted )
1325 aSelection.SetReferencePoint( m_cursor );
1326
1328 }
1329 // For some items, moving the cursor to anchor is not good (for instance large
1330 // hierarchical sheets or symbols can have the anchor outside the view)
1331 else if( aSelection.Size() == 1 && !sch_item->IsMovableFromAnchorPoint() )
1332 {
1335 }
1336 else
1337 {
1338 if( m_frame->GetMoveWarpsCursor() )
1339 {
1340 // User wants to warp the mouse
1341 m_cursor = grid.BestDragOrigin( m_cursor, aSnapLayer, aSelection );
1342 aSelection.SetReferencePoint( m_cursor );
1343 }
1344 else
1345 {
1346 // User does not want to warp the mouse
1348 }
1349 }
1350
1351 controls->SetCursorPosition( m_cursor, false );
1352 controls->SetAutoPan( true );
1353 m_moveInProgress = true;
1354}
1355
1356
1358 const VECTOR2I& aCursorPos, bool aHasSheetPins,
1359 bool aIsGraphicsOnly, bool aCtrlDown )
1360{
1361 // Determine potential target sheet
1362 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>(
1363 m_frame->GetScreen()->GetItem( aCursorPos, 0, SCH_SHEET_T ) );
1364
1365 if( sheet && sheet->IsSelected() )
1366 sheet = nullptr; // Never target a selected sheet
1367
1368 if( !sheet )
1369 {
1370 // Build current selection bounding box in its (already moved) position
1371 BOX2I selBBox;
1372
1373 for( EDA_ITEM* it : aSelection )
1374 {
1375 if( SCH_ITEM* schIt = dynamic_cast<SCH_ITEM*>( it ) )
1376 selBBox.Merge( schIt->GetBoundingBox() );
1377 }
1378
1379 if( selBBox.GetWidth() > 0 && selBBox.GetHeight() > 0 )
1380 {
1381 VECTOR2I selCenter( selBBox.GetX() + selBBox.GetWidth() / 2,
1382 selBBox.GetY() + selBBox.GetHeight() / 2 );
1383
1384 // Find first non-selected sheet whose body fully contains the selection or at
1385 // least contains its center point
1386 for( SCH_ITEM* it : m_frame->GetScreen()->Items().OfType( SCH_SHEET_T ) )
1387 {
1388 SCH_SHEET* candidate = static_cast<SCH_SHEET*>( it );
1389
1390 if( candidate->IsSelected() || candidate->IsTopLevelSheet() )
1391 continue;
1392
1393 BOX2I body = candidate->GetBodyBoundingBox();
1394
1395 if( body.Contains( selBBox ) || body.Contains( selCenter ) )
1396 {
1397 sheet = candidate;
1398 break;
1399 }
1400 }
1401 }
1402 }
1403
1404 bool dropAllowedBySelection = !aHasSheetPins;
1405 bool dropAllowedByModifiers = !aIsGraphicsOnly || aCtrlDown;
1406
1407 if( sheet && !( dropAllowedBySelection && dropAllowedByModifiers ) )
1408 sheet = nullptr;
1409
1410 return sheet;
1411}
1412
1413
1415 SCH_COMMIT* aCommit, int& aXBendCount, int& aYBendCount,
1416 const EE_GRID_HELPER& aGrid )
1417{
1418 wxLogTrace( traceSchMove, "performItemMove: delta=(%d,%d), moveOffset=(%d,%d), selection size=%u",
1419 aDelta.x, aDelta.y, m_moveOffset.x, m_moveOffset.y, aSelection.GetSize() );
1420
1421 // We need to check if the movement will change the net offset direction on the X and Y
1422 // axes. This is because we remerge added bend lines in realtime, and we also account for
1423 // the direction of the move when adding bend lines. So, if the move direction changes,
1424 // we need to split it into a move that gets us back to zero, then the rest of the move.
1425 std::vector<VECTOR2I> splitMoves;
1426
1427 if( alg::signbit( m_moveOffset.x ) != alg::signbit( ( m_moveOffset + aDelta ).x ) )
1428 {
1429 splitMoves.emplace_back( VECTOR2I( -1 * m_moveOffset.x, 0 ) );
1430 splitMoves.emplace_back( VECTOR2I( aDelta.x + m_moveOffset.x, 0 ) );
1431 }
1432 else
1433 {
1434 splitMoves.emplace_back( VECTOR2I( aDelta.x, 0 ) );
1435 }
1436
1437 if( alg::signbit( m_moveOffset.y ) != alg::signbit( ( m_moveOffset + aDelta ).y ) )
1438 {
1439 splitMoves.emplace_back( VECTOR2I( 0, -1 * m_moveOffset.y ) );
1440 splitMoves.emplace_back( VECTOR2I( 0, aDelta.y + m_moveOffset.y ) );
1441 }
1442 else
1443 {
1444 splitMoves.emplace_back( VECTOR2I( 0, aDelta.y ) );
1445 }
1446
1447 m_moveOffset += aDelta;
1448
1449 // Split the move into X and Y moves so we can correctly drag orthogonal lines
1450 for( const VECTOR2I& splitDelta : splitMoves )
1451 {
1452 // Skip non-moves
1453 if( splitDelta == VECTOR2I( 0, 0 ) )
1454 continue;
1455
1456 for( EDA_ITEM* item : aSelection.GetItemsSortedByTypeAndXY( ( aDelta.x >= 0 ),
1457 ( aDelta.y >= 0 ) ) )
1458 {
1459 // Don't double move pins, fields, etc.
1460 if( item->GetParent() && item->GetParent()->IsSelected() )
1461 continue;
1462
1463 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
1464 bool isLineModeConstrained = false;
1465
1466 if( EESCHEMA_SETTINGS* cfg = GetAppSettings<EESCHEMA_SETTINGS>( "eeschema" ) )
1467 isLineModeConstrained = cfg->m_Drawing.line_mode != LINE_MODE::LINE_MODE_FREE;
1468
1469 // Only partially selected drag lines in orthogonal line mode need special handling
1470 if( ( m_mode == DRAG ) && isLineModeConstrained && line
1471 && line->HasFlag( STARTPOINT ) != line->HasFlag( ENDPOINT ) )
1472 {
1473 orthoLineDrag( aCommit, line, splitDelta, aXBendCount, aYBendCount, aGrid );
1474 }
1475
1476 // Move all other items normally, including the selected end of partially selected
1477 // lines
1478 moveItem( item, splitDelta );
1479 updateItem( item, false );
1480
1481 // Update any lines connected to sheet pins to the sheet pin's location (which may
1482 // not exactly follow the splitDelta as the pins are constrained along the sheet
1483 // edges)
1484 for( const auto& [pin, lineEnd] : m_specialCaseSheetPins )
1485 {
1486 if( lineEnd.second && lineEnd.first->HasFlag( STARTPOINT ) )
1487 lineEnd.first->SetStartPoint( pin->GetPosition() );
1488 else if( !lineEnd.second && lineEnd.first->HasFlag( ENDPOINT ) )
1489 lineEnd.first->SetEndPoint( pin->GetPosition() );
1490 }
1491 }
1492 }
1493
1494 if( aSelection.HasReferencePoint() )
1495 aSelection.SetReferencePoint( aSelection.GetReferencePoint() + aDelta );
1496}
1497
1498
1500 const SCH_SELECTION& aSelection )
1501{
1502 wxLogTrace( traceSchMove, "handleMoveToolActions: received event, action=%s",
1503 aEvent->Format().c_str() );
1504
1505 if( aEvent->IsAction( &ACTIONS::doDelete ) )
1506 {
1507 wxLogTrace( traceSchMove, "handleMoveToolActions: doDelete, exiting move" );
1508 const_cast<TOOL_EVENT*>( aEvent )->SetPassEvent();
1509 return false; // Exit on delete; there will no longer be anything to drag
1510 }
1511 else if( aEvent->IsAction( &ACTIONS::duplicate )
1513 || aEvent->IsAction( &ACTIONS::redo ) )
1514 {
1515 wxBell();
1516 }
1517 else if( aEvent->IsAction( &SCH_ACTIONS::rotateCW ) )
1518 {
1519 wxLogTrace( traceSchMove, "handleMoveToolActions: rotateCW event received, selection size=%u",
1520 aSelection.GetSize() );
1521 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::rotateCW, aCommit );
1522 wxLogTrace( traceSchMove, "handleMoveToolActions: rotateCW RunSynchronousAction completed" );
1523 updateStoredPositions( aSelection );
1524 wxLogTrace( traceSchMove, "handleMoveToolActions: rotateCW updateStoredPositions completed" );
1525 // Note: SCH_EDIT_TOOL::Rotate already posts refreshPreview when moving
1526 }
1527 else if( aEvent->IsAction( &SCH_ACTIONS::rotateCCW ) )
1528 {
1529 wxLogTrace( traceSchMove, "handleMoveToolActions: rotateCCW event received, selection size=%u",
1530 aSelection.GetSize() );
1531 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::rotateCCW, aCommit );
1532 wxLogTrace( traceSchMove, "handleMoveToolActions: rotateCCW RunSynchronousAction completed" );
1533 updateStoredPositions( aSelection );
1534 wxLogTrace( traceSchMove, "handleMoveToolActions: rotateCCW updateStoredPositions completed" );
1535 // Note: SCH_EDIT_TOOL::Rotate already posts refreshPreview when moving
1536 }
1537 else if( aEvent->IsAction( &ACTIONS::increment ) )
1538 {
1539 if( aEvent->HasParameter() )
1540 m_toolMgr->RunSynchronousAction( ACTIONS::increment, aCommit, aEvent->Parameter<ACTIONS::INCREMENT>() );
1541 else
1542 m_toolMgr->RunSynchronousAction( ACTIONS::increment, aCommit, ACTIONS::INCREMENT{ 1, 0 } );
1543
1544 updateStoredPositions( aSelection );
1545 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1546 }
1547 else if( aEvent->IsAction( &SCH_ACTIONS::toDLabel ) )
1548 {
1549 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::toDLabel, aCommit );
1550 updateStoredPositions( aSelection );
1551 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1552 }
1553 else if( aEvent->IsAction( &SCH_ACTIONS::toGLabel ) )
1554 {
1555 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::toGLabel, aCommit );
1556 updateStoredPositions( aSelection );
1557 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1558 }
1559 else if( aEvent->IsAction( &SCH_ACTIONS::toHLabel ) )
1560 {
1561 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::toHLabel, aCommit );
1562 updateStoredPositions( aSelection );
1563 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1564 }
1565 else if( aEvent->IsAction( &SCH_ACTIONS::toLabel ) )
1566 {
1567 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::toLabel, aCommit );
1568 updateStoredPositions( aSelection );
1569 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1570 }
1571 else if( aEvent->IsAction( &SCH_ACTIONS::toText ) )
1572 {
1573 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::toText, aCommit );
1574 updateStoredPositions( aSelection );
1575 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1576 }
1577 else if( aEvent->IsAction( &SCH_ACTIONS::toTextBox ) )
1578 {
1579 m_toolMgr->RunSynchronousAction( SCH_ACTIONS::toTextBox, aCommit );
1580 updateStoredPositions( aSelection );
1581 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1582 }
1583 else if( aEvent->Action() == TA_CHOICE_MENU_CHOICE )
1584 {
1585 if( *aEvent->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT
1587 {
1588 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>(
1589 m_selectionTool->GetSelection().Front() );
1590 int unit = *aEvent->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT;
1591
1592 if( symbol )
1593 {
1594 m_frame->SelectUnit( symbol, unit );
1595 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1596 }
1597 }
1598 else if( *aEvent->GetCommandId() >= ID_POPUP_SCH_SELECT_BODY_STYLE
1600 {
1601 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>(
1602 m_selectionTool->GetSelection().Front() );
1603 int bodyStyle = ( *aEvent->GetCommandId() - ID_POPUP_SCH_SELECT_BODY_STYLE ) + 1;
1604
1605 if( symbol && symbol->GetBodyStyle() != bodyStyle )
1606 {
1607 m_frame->SelectBodyStyle( symbol, bodyStyle );
1608 m_toolMgr->PostAction( ACTIONS::refreshPreview );
1609 }
1610 }
1611 }
1612 else if( aEvent->IsAction( &SCH_ACTIONS::highlightNet )
1613 || aEvent->IsAction( &SCH_ACTIONS::selectOnPCB ) )
1614 {
1615 // These don't make any sense during a move. Eat them.
1616 }
1617 else
1618 {
1619 return true; // Continue processing
1620 }
1621
1622 return true; // Continue processing
1623}
1624
1625
1627{
1628 wxLogTrace( traceSchMove, "updateStoredPositions: start, selection size=%u",
1629 aSelection.GetSize() );
1630
1631 // After transformations like rotation during a move, we need to update the stored
1632 // positions that moveItem() uses, particularly for sheet pins which rely on them
1633 // for constraint calculations.
1634 int itemCount = 0;
1635
1636 for( EDA_ITEM* item : aSelection )
1637 {
1638 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( item );
1639
1640 if( !schItem )
1641 continue;
1642
1643 VECTOR2I oldPos = schItem->GetStoredPos();
1644 VECTOR2I newPos = schItem->GetPosition();
1645 schItem->SetStoredPos( newPos );
1646
1647 wxLogTrace( traceSchMove, " item[%d] type=%d: stored pos updated (%d,%d) -> (%d,%d)",
1648 itemCount++, (int) schItem->Type(), oldPos.x, oldPos.y, newPos.x, newPos.y );
1649
1650 // Also update stored positions for sheet pins
1651 if( schItem->Type() == SCH_SHEET_T )
1652 {
1653 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( schItem );
1654 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1655 {
1656 VECTOR2I pinOldPos = pin->GetStoredPos();
1657 VECTOR2I pinNewPos = pin->GetPosition();
1658 pin->SetStoredPos( pinNewPos );
1659 wxLogTrace( traceSchMove, " sheet pin: stored pos updated (%d,%d) -> (%d,%d)",
1660 pinOldPos.x, pinOldPos.y, pinNewPos.x, pinNewPos.y );
1661 }
1662 }
1663 }
1664
1665 wxLogTrace( traceSchMove, "updateStoredPositions: complete, updated %d items", itemCount );
1666}
1667
1668
1669void SCH_MOVE_TOOL::finalizeMoveOperation( SCH_SELECTION& aSelection, SCH_COMMIT* aCommit, bool aUnselect,
1670 const std::vector<DANGLING_END_ITEM>& aInternalPoints )
1671{
1673 const bool isSlice = ( m_mode == SLICE );
1674 const bool isDragLike = ( m_mode == DRAG || m_mode == BREAK );
1675
1676 // Save whatever new bend lines and changed lines survived the drag
1677 for( SCH_LINE* newLine : m_newDragLines )
1678 {
1679 newLine->ClearEditFlags();
1680 aCommit->Added( newLine, m_frame->GetScreen() );
1681 }
1682
1683 // These lines have been changed, but aren't selected. We need to manually clear these
1684 // edit flags or they'll stick around.
1685 for( SCH_LINE* oldLine : m_changedDragLines )
1686 oldLine->ClearEditFlags();
1687
1688 controls->ForceCursorPosition( false );
1689 controls->ShowCursor( false );
1690 controls->SetAutoPan( false );
1691
1692 m_moveOffset = { 0, 0 };
1693 m_anchorPos.reset();
1694
1695 // One last update after exiting loop (for slower stuff, such as updating SCREEN's RTree)
1696 for( EDA_ITEM* item : aSelection )
1697 {
1698 updateItem( item, true );
1699
1700 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
1701 sch_item->SetConnectivityDirty( true );
1702 }
1703
1704 if( aSelection.GetSize() == 1 && aSelection.Front()->IsNew() )
1705 m_frame->SaveCopyForRepeatItem( static_cast<SCH_ITEM*>( aSelection.Front() ) );
1706
1707 m_selectionTool->RemoveItemsFromSel( &m_dragAdditions, QUIET_MODE );
1708
1710
1711 // If we move items away from a junction, we _may_ want to add a junction there
1712 // to denote the state
1713 for( const DANGLING_END_ITEM& it : aInternalPoints )
1714 {
1715 if( m_frame->GetScreen()->IsExplicitJunctionNeeded( it.GetPosition() ) )
1716 lwbTool->AddJunction( aCommit, m_frame->GetScreen(), it.GetPosition() );
1717 }
1718
1719 // Create a selection of original selection, drag selected/changed items, and new bend
1720 // lines for later before we clear them in the aCommit. We'll need these to check for new
1721 // junctions needed, etc.
1722 SCH_SELECTION selectionCopy( aSelection );
1723
1724 for( SCH_LINE* line : m_newDragLines )
1725 selectionCopy.Add( line );
1726
1727 for( SCH_LINE* line : m_changedDragLines )
1728 selectionCopy.Add( line );
1729
1730 lwbTool->TrimOverLappingWires( aCommit, &selectionCopy );
1731 lwbTool->AddJunctionsIfNeeded( aCommit, &selectionCopy );
1732
1733 // This needs to run prior to `RecalculateConnections` because we need to identify the
1734 // lines that are newly dangling
1735 if( isDragLike && !isSlice )
1736 trimDanglingLines( aCommit );
1737
1738 // Auto-rotate any moved labels
1739 for( EDA_ITEM* item : aSelection )
1740 m_frame->AutoRotateItem( m_frame->GetScreen(), static_cast<SCH_ITEM*>( item ) );
1741
1742 m_frame->Schematic().CleanUp( aCommit );
1743
1744 for( EDA_ITEM* item : m_frame->GetScreen()->Items() )
1745 item->ClearEditFlags();
1746
1747 // Ensure any selected item not in screen main list (for instance symbol fields) has its
1748 // edit flags cleared
1749 for( EDA_ITEM* item : selectionCopy )
1750 item->ClearEditFlags();
1751
1752 m_newDragLines.clear();
1753 m_changedDragLines.clear();
1754
1755 if( aUnselect )
1756 m_toolMgr->RunAction( ACTIONS::selectionClear );
1757 else
1758 m_selectionTool->RebuildSelection(); // Schematic cleanup might have merged lines, etc.
1759}
1760
1761
1763 SCH_COMMIT* aCommit )
1764{
1765 SCH_SCREEN* destScreen = aTargetSheet->GetScreen();
1766 SCH_SCREEN* srcScreen = m_frame->GetScreen();
1767
1768 BOX2I bbox;
1769
1770 for( EDA_ITEM* item : aSelection )
1771 bbox.Merge( static_cast<SCH_ITEM*>( item )->GetBoundingBox() );
1772
1773 VECTOR2I offset = VECTOR2I( 0, 0 ) - bbox.GetPosition();
1774 int step = schIUScale.MilsToIU( 50 );
1775 bool overlap = false;
1776
1777 do
1778 {
1779 BOX2I moved = bbox;
1780 moved.Move( offset );
1781 overlap = false;
1782
1783 for( SCH_ITEM* existing : destScreen->Items() )
1784 {
1785 if( moved.Intersects( existing->GetBoundingBox() ) )
1786 {
1787 overlap = true;
1788 break;
1789 }
1790 }
1791
1792 if( overlap )
1793 offset += VECTOR2I( step, step );
1794 } while( overlap );
1795
1796 for( EDA_ITEM* item : aSelection )
1797 {
1798 SCH_ITEM* schItem = static_cast<SCH_ITEM*>( item );
1799
1800 // Remove from current screen and view manually
1801 m_frame->RemoveFromScreen( schItem, srcScreen );
1802
1803 // Move the item
1804 schItem->Move( offset );
1805
1806 // Add to destination screen manually (won't add to view since it's not current)
1807 destScreen->Append( schItem );
1808
1809 // Record in commit with CHT_DONE flag to bypass automatic screen/view operations
1810 aCommit->Stage( schItem, CHT_REMOVE | CHT_DONE, srcScreen );
1811 aCommit->Stage( schItem, CHT_ADD | CHT_DONE, destScreen );
1812 }
1813}
1814
1815
1817{
1818 // Need a local cleanup first to ensure we remove unneeded junctions
1819 m_frame->Schematic().CleanUp( aCommit, m_frame->GetScreen() );
1820
1821 std::set<SCH_ITEM*> danglers;
1822
1823 std::function<void( SCH_ITEM* )> changeHandler =
1824 [&]( SCH_ITEM* aChangedItem ) -> void
1825 {
1826 m_toolMgr->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1827
1828 // Delete newly dangling lines:
1829 // Find split segments (one segment is new, the other is changed) that
1830 // we aren't dragging and don't have selected
1831 if( aChangedItem->HasFlag( IS_BROKEN) && aChangedItem->IsDangling()
1832 && !aChangedItem->IsSelected() )
1833 {
1834 danglers.insert( aChangedItem );
1835 }
1836 };
1837
1838 m_frame->GetScreen()->TestDanglingEnds( nullptr, &changeHandler );
1839
1840 for( SCH_ITEM* line : danglers )
1841 {
1842 line->SetFlags( STRUCT_DELETED );
1843 aCommit->Removed( line, m_frame->GetScreen() );
1844 updateItem( line, false ); // Update any cached visuals before commit processes
1845 m_frame->RemoveFromScreen( line, m_frame->GetScreen() );
1846 }
1847}
1848
1849
1850void SCH_MOVE_TOOL::getConnectedItems( SCH_ITEM* aOriginalItem, const VECTOR2I& aPoint, EDA_ITEMS& aList )
1851{
1852 EE_RTREE& items = m_frame->GetScreen()->Items();
1853 EE_RTREE::EE_TYPE itemsOverlapping = items.Overlapping( aOriginalItem->GetBoundingBox() );
1854 SCH_ITEM* foundJunction = nullptr;
1855 SCH_ITEM* foundSymbol = nullptr;
1856
1857 // If you're connected to a junction, you're only connected to the junction.
1858 //
1859 // But, if you're connected to a junction on a pin, you're only connected to the pin. This
1860 // is because junctions and pins have different logic for how bend lines are generated and
1861 // we need to prioritize the pin version in some cases.
1862 for( SCH_ITEM* item : itemsOverlapping )
1863 {
1864 if( item != aOriginalItem && item->IsConnected( aPoint ) )
1865 {
1866 if( item->Type() == SCH_JUNCTION_T )
1867 foundJunction = item;
1868 else if( item->Type() == SCH_SYMBOL_T )
1869 foundSymbol = item;
1870 }
1871 }
1872
1873 if( foundSymbol && foundJunction )
1874 {
1875 aList.push_back( foundSymbol );
1876 return;
1877 }
1878
1879 if( foundJunction )
1880 {
1881 aList.push_back( foundJunction );
1882 return;
1883 }
1884
1885
1886 for( SCH_ITEM* test : itemsOverlapping )
1887 {
1888 if( test == aOriginalItem || !test->CanConnect( aOriginalItem ) )
1889 continue;
1890
1891 switch( test->Type() )
1892 {
1893 case SCH_LINE_T:
1894 {
1895 SCH_LINE* line = static_cast<SCH_LINE*>( test );
1896
1897 // When getting lines for the connection cache, it's important that we only add
1898 // items at the unselected end, since that is the only end that is handled specially.
1899 // Fully selected lines, and the selected end of a partially selected line, are moved
1900 // around normally and don't care about their connections.
1901 if( ( line->HasFlag( STARTPOINT ) && aPoint == line->GetStartPoint() )
1902 || ( line->HasFlag( ENDPOINT ) && aPoint == line->GetEndPoint() ) )
1903 {
1904 continue;
1905 }
1906
1907 if( test->IsConnected( aPoint ) )
1908 aList.push_back( test );
1909
1910 // Labels can connect to a wire (or bus) anywhere along the length
1911 if( SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( aOriginalItem ) )
1912 {
1913 if( static_cast<SCH_LINE*>( test )->HitTest( label->GetPosition(), 1 ) )
1914 aList.push_back( test );
1915 }
1916
1917 break;
1918 }
1919
1920 case SCH_SHEET_T:
1921 if( aOriginalItem->Type() == SCH_LINE_T )
1922 {
1923 SCH_LINE* line = static_cast<SCH_LINE*>( aOriginalItem );
1924
1925 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( test )->GetPins() )
1926 {
1927 if( pin->IsConnected( aPoint ) )
1928 {
1929 if( pin->IsSelected() )
1930 m_specialCaseSheetPins[pin] = { line, line->GetStartPoint() == aPoint };
1931
1932 aList.push_back( pin );
1933 }
1934 }
1935 }
1936
1937 break;
1938
1939 case SCH_SYMBOL_T:
1940 case SCH_JUNCTION_T:
1941 case SCH_NO_CONNECT_T:
1942 if( test->IsConnected( aPoint ) )
1943 aList.push_back( test );
1944
1945 break;
1946
1947 case SCH_LABEL_T:
1948 case SCH_GLOBAL_LABEL_T:
1949 case SCH_HIER_LABEL_T:
1951 // Labels can connect to a wire (or bus) anywhere along the length
1952 if( aOriginalItem->Type() == SCH_LINE_T && test->CanConnect( aOriginalItem ) )
1953 {
1954 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( test );
1955 SCH_LINE* line = static_cast<SCH_LINE*>( aOriginalItem );
1956
1957 if( line->HitTest( label->GetPosition(), 1 ) )
1958 aList.push_back( label );
1959 }
1960
1961 break;
1962
1965 if( aOriginalItem->Type() == SCH_LINE_T && test->CanConnect( aOriginalItem ) )
1966 {
1967 SCH_TEXT* label = static_cast<SCH_TEXT*>( test );
1968 SCH_LINE* line = static_cast<SCH_LINE*>( aOriginalItem );
1969
1970 if( line->HitTest( aPoint, 1 ) )
1971 aList.push_back( label );
1972 }
1973
1974 break;
1975
1976 default:
1977 break;
1978 }
1979 }
1980}
1981
1982
1984 const VECTOR2I& aPoint, EDA_ITEMS& aList )
1985{
1986 EE_RTREE& items = m_frame->GetScreen()->Items();
1987 EE_RTREE::EE_TYPE itemsOverlappingRTree = items.Overlapping( aSelectedItem->GetBoundingBox() );
1988 std::vector<SCH_ITEM*> itemsConnectable;
1989 bool ptHasUnselectedJunction = false;
1990
1991 auto makeNewWire =
1992 [this]( SCH_COMMIT* commit, SCH_ITEM* fixed, SCH_ITEM* selected, const VECTOR2I& start,
1993 const VECTOR2I& end )
1994 {
1995 SCH_LINE* newWire;
1996
1997 // Add a new newWire between the fixed item and the selected item so the selected
1998 // item can be dragged.
1999 if( fixed->GetLayer() == LAYER_BUS_JUNCTION || fixed->GetLayer() == LAYER_BUS
2000 || selected->GetLayer() == LAYER_BUS )
2001 {
2002 newWire = new SCH_LINE( start, LAYER_BUS );
2003 }
2004 else
2005 {
2006 newWire = new SCH_LINE( start, LAYER_WIRE );
2007 }
2008
2009 newWire->SetFlags( IS_NEW );
2010 newWire->SetConnectivityDirty( true );
2011
2012 SCH_LINE* selectedLine = dynamic_cast<SCH_LINE*>( selected );
2013 SCH_LINE* fixedLine = dynamic_cast<SCH_LINE*>( fixed );
2014
2015 if( selectedLine )
2016 {
2017 newWire->SetLastResolvedState( selected );
2018 cloneWireConnection( newWire, selectedLine, m_frame );
2019 }
2020 else if( fixedLine )
2021 {
2022 newWire->SetLastResolvedState( fixed );
2023 cloneWireConnection( newWire, fixedLine, m_frame );
2024 }
2025
2026 newWire->SetEndPoint( end );
2027 m_frame->AddToScreen( newWire, m_frame->GetScreen() );
2028 commit->Added( newWire, m_frame->GetScreen() );
2029
2030 return newWire;
2031 };
2032
2033 auto makeNewJunction =
2034 [this]( SCH_COMMIT* commit, SCH_LINE* line, const VECTOR2I& pt )
2035 {
2036 SCH_JUNCTION* junction = new SCH_JUNCTION( pt );
2037 junction->SetFlags( IS_NEW );
2038 junction->SetConnectivityDirty( true );
2039 junction->SetLastResolvedState( line );
2040
2041 if( line->IsBus() )
2042 junction->SetLayer( LAYER_BUS_JUNCTION );
2043
2044 m_frame->AddToScreen( junction, m_frame->GetScreen() );
2045 commit->Added( junction, m_frame->GetScreen() );
2046
2047 return junction;
2048 };
2049
2050 for( SCH_ITEM* item : itemsOverlappingRTree )
2051 {
2052 if( item->Type() == SCH_SHEET_T )
2053 {
2054 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
2055
2056 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
2057 {
2058 if( !pin->IsSelected()
2059 && pin->GetPosition() == aSelectedItem->GetPosition()
2060 && pin->CanConnect( aSelectedItem ) )
2061 {
2062 itemsConnectable.push_back( pin );
2063 }
2064 }
2065
2066 continue;
2067 }
2068
2069 // Skip ourselves, skip already selected items (but not lines, they need both ends tested)
2070 // and skip unconnectable items
2071 if( item == aSelectedItem
2072 || ( item->Type() != SCH_LINE_T && item->IsSelected() )
2073 || !item->CanConnect( aSelectedItem ) )
2074 {
2075 continue;
2076 }
2077
2078 itemsConnectable.push_back( item );
2079 }
2080
2081 for( SCH_ITEM* item : itemsConnectable )
2082 {
2083 if( item->Type() == SCH_JUNCTION_T && item->IsConnected( aPoint ) && !item->IsSelected() )
2084 {
2085 ptHasUnselectedJunction = true;
2086 break;
2087 }
2088 }
2089
2090 SCH_LINE* newWire = nullptr;
2091
2092 for( SCH_ITEM* test : itemsConnectable )
2093 {
2094 KICAD_T testType = test->Type();
2095
2096 switch( testType )
2097 {
2098 case SCH_LINE_T:
2099 {
2100 // Select the connected end of wires/bus connections that don't have an unselected
2101 // junction isolating them from the drag
2102 if( ptHasUnselectedJunction )
2103 break;
2104
2105 SCH_LINE* line = static_cast<SCH_LINE*>( test );
2106
2107 if( line->GetStartPoint() == aPoint )
2108 {
2109 // It's possible to manually select one end of a line and get a drag
2110 // connected other end, so we set the flag and then early exit the loop
2111 // later if the other drag items like labels attached to the line have
2112 // already been grabbed during the partial selection process.
2113 line->SetFlags( STARTPOINT );
2114
2115 if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) )
2116 {
2117 continue;
2118 }
2119 else
2120 {
2121 line->SetFlags( SELECTED_BY_DRAG );
2122 aList.push_back( line );
2123 }
2124 }
2125 else if( line->GetEndPoint() == aPoint )
2126 {
2127 line->SetFlags( ENDPOINT );
2128
2129 if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) )
2130 {
2131 continue;
2132 }
2133 else
2134 {
2135 line->SetFlags( SELECTED_BY_DRAG );
2136 aList.push_back( line );
2137 }
2138 }
2139 else
2140 {
2141 switch( aSelectedItem->Type() )
2142 {
2143 // These items can connect anywhere along a line
2146 case SCH_LABEL_T:
2147 case SCH_HIER_LABEL_T:
2148 case SCH_GLOBAL_LABEL_T:
2150 // Only add a line if this line is unselected; if the label and line are both
2151 // selected they'll move together
2152 if( line->HitTest( aPoint, 1 ) && !line->HasFlag( SELECTED )
2153 && !line->HasFlag( SELECTED_BY_DRAG ) )
2154 {
2155 newWire = makeNewWire( aCommit, line, aSelectedItem, aPoint, aPoint );
2156 newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
2157 newWire->StoreAngle( ( line->Angle() + ANGLE_90 ).Normalize() );
2158 aList.push_back( newWire );
2159
2160 if( aPoint != line->GetStartPoint() && aPoint != line->GetEndPoint() )
2161 {
2162 // Split line in half
2163 aCommit->Modify( line, m_frame->GetScreen() );
2164
2165 VECTOR2I oldEnd = line->GetEndPoint();
2166 line->SetEndPoint( aPoint );
2167
2168 makeNewWire( aCommit, line, line, aPoint, oldEnd );
2169 makeNewJunction( aCommit, line, aPoint );
2170 }
2171 else
2172 {
2173 m_lineConnectionCache[ newWire ] = { line };
2174 m_lineConnectionCache[ line ] = { newWire };
2175 }
2176 }
2177 break;
2178
2179 default:
2180 break;
2181 }
2182
2183 break;
2184 }
2185
2186 // Since only one end is going to move, the movement vector of any labels attached to
2187 // it is scaled by the proportion of the line length the label is from the moving end.
2188 for( SCH_ITEM* item : items.Overlapping( line->GetBoundingBox() ) )
2189 {
2190 SCH_LABEL_BASE* label = dynamic_cast<SCH_LABEL_BASE*>( item );
2191
2192 if( !label || label->IsSelected() )
2193 continue; // These will be moved on their own because they're selected
2194
2195 if( label->HasFlag( SELECTED_BY_DRAG ) )
2196 continue;
2197
2198 if( label->CanConnect( line ) && line->HitTest( label->GetPosition(), 1 ) )
2199 {
2200 label->SetFlags( SELECTED_BY_DRAG );
2201 aList.push_back( label );
2202
2204 info.attachedLine = line;
2205 info.originalLabelPos = label->GetPosition();
2206 m_specialCaseLabels[label] = info;
2207 }
2208 }
2209
2210 break;
2211 }
2212
2213 case SCH_SHEET_T:
2214 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( test )->GetPins() )
2215 {
2216 if( pin->IsConnected( aPoint ) )
2217 {
2218 if( pin->IsSelected() && aSelectedItem->Type() == SCH_LINE_T )
2219 {
2220 SCH_LINE* line = static_cast<SCH_LINE*>( aSelectedItem );
2221 m_specialCaseSheetPins[ pin ] = { line, line->GetStartPoint() == aPoint };
2222 }
2223 else if( !newWire )
2224 {
2225 // Add a new wire between the sheetpin and the selected item so the
2226 // selected item can be dragged.
2227 newWire = makeNewWire( aCommit, pin, aSelectedItem, aPoint, aPoint );
2228 newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
2229 aList.push_back( newWire );
2230 }
2231 }
2232 }
2233
2234 break;
2235
2236 case SCH_SYMBOL_T:
2237 case SCH_JUNCTION_T:
2238 if( test->IsConnected( aPoint ) )
2239 {
2240 if( test->Type() == SCH_JUNCTION_T && test->GetPosition() == aPoint )
2241 {
2242 test->SetFlags( SELECTED_BY_DRAG );
2243 aList.push_back( test );
2244 }
2245 else if( !newWire )
2246 {
2247 // Add a new wire between the symbol or junction and the selected item so
2248 // the selected item can be dragged.
2249 newWire = makeNewWire( aCommit, test, aSelectedItem, aPoint, aPoint );
2250 newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
2251 aList.push_back( newWire );
2252 }
2253 }
2254
2255 break;
2256
2257 case SCH_NO_CONNECT_T:
2258 // Select no-connects that are connected to items being moved.
2259 if( !test->HasFlag( SELECTED_BY_DRAG ) && test->IsConnected( aPoint ) )
2260 {
2261 aList.push_back( test );
2262 test->SetFlags( SELECTED_BY_DRAG );
2263 }
2264
2265 break;
2266
2267 case SCH_LABEL_T:
2268 case SCH_GLOBAL_LABEL_T:
2269 case SCH_HIER_LABEL_T:
2271 case SCH_SHEET_PIN_T:
2272 // Performance optimization:
2273 if( test->HasFlag( SELECTED_BY_DRAG ) )
2274 break;
2275
2276 // Select labels that are connected to a wire (or bus) being moved.
2277 if( aSelectedItem->Type() == SCH_LINE_T && test->CanConnect( aSelectedItem ) )
2278 {
2279 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( test );
2280 SCH_LINE* line = static_cast<SCH_LINE*>( aSelectedItem );
2281
2282 bool oneEndFixed = !line->HasFlag( STARTPOINT ) || !line->HasFlag( ENDPOINT );
2283
2284 if( line->HitTest( label->GetTextPos(), 1 ) )
2285 {
2286 if( ( !line->HasFlag( STARTPOINT ) && label->GetPosition() == line->GetStartPoint() )
2287 || ( !line->HasFlag( ENDPOINT ) && label->GetPosition() == line->GetEndPoint() ) )
2288 {
2289 //If we have a line selected at only one end, don't grab labels
2290 //connected directly to the unselected endpoint
2291 break;
2292 }
2293 else
2294 {
2295 label->SetFlags( SELECTED_BY_DRAG );
2296 aList.push_back( label );
2297
2298 if( oneEndFixed )
2299 {
2301 info.attachedLine = line;
2302 info.originalLabelPos = label->GetPosition();
2303 m_specialCaseLabels[label] = info;
2304 }
2305 }
2306 }
2307 }
2308 else if( test->IsConnected( aPoint ) && !newWire )
2309 {
2310 // Add a new wire between the label and the selected item so the selected item
2311 // can be dragged.
2312 newWire = makeNewWire( aCommit, test, aSelectedItem, aPoint, aPoint );
2313 newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
2314 aList.push_back( newWire );
2315 }
2316
2317 break;
2318
2321 // Performance optimization:
2322 if( test->HasFlag( SELECTED_BY_DRAG ) )
2323 break;
2324
2325 // Select bus entries that are connected to a bus being moved.
2326 if( aSelectedItem->Type() == SCH_LINE_T && test->CanConnect( aSelectedItem ) )
2327 {
2328 SCH_LINE* line = static_cast<SCH_LINE*>( aSelectedItem );
2329
2330 if( ( !line->HasFlag( STARTPOINT ) && test->IsConnected( line->GetStartPoint() ) )
2331 || ( !line->HasFlag( ENDPOINT ) && test->IsConnected( line->GetEndPoint() ) ) )
2332 {
2333 // If we have a line selected at only one end, don't grab bus entries
2334 // connected directly to the unselected endpoint
2335 continue;
2336 }
2337
2338 for( VECTOR2I& point : test->GetConnectionPoints() )
2339 {
2340 if( line->HitTest( point, 1 ) )
2341 {
2342 test->SetFlags( SELECTED_BY_DRAG );
2343 aList.push_back( test );
2344
2345 // A bus entry needs its wire & label as well
2346 std::vector<VECTOR2I> ends = test->GetConnectionPoints();
2347 VECTOR2I otherEnd;
2348
2349 if( ends[0] == point )
2350 otherEnd = ends[1];
2351 else
2352 otherEnd = ends[0];
2353
2354 getConnectedDragItems( aCommit, test, otherEnd, aList );
2355
2356 // No need to test the other end of the bus entry
2357 break;
2358 }
2359 }
2360 }
2361
2362 break;
2363
2364 default:
2365 break;
2366 }
2367 }
2368}
2369
2370
2371void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta )
2372{
2373 static int moveCallCount = 0;
2374 wxLogTrace( traceSchMove, "moveItem[%d]: type=%d, delta=(%d,%d)",
2375 ++moveCallCount, aItem->Type(), aDelta.x, aDelta.y );
2376
2377 switch( aItem->Type() )
2378 {
2379 case SCH_LINE_T:
2380 {
2381 SCH_LINE* line = static_cast<SCH_LINE*>( aItem );
2382
2383 if( aItem->HasFlag( STARTPOINT ) || ( m_mode == MOVE ) )
2384 line->MoveStart( aDelta );
2385
2386 if( aItem->HasFlag( ENDPOINT ) || ( m_mode == MOVE ) )
2387 line->MoveEnd( aDelta );
2388
2389 break;
2390 }
2391
2392 case SCH_PIN_T:
2393 case SCH_FIELD_T:
2394 {
2395 SCH_ITEM* parent = (SCH_ITEM*) aItem->GetParent();
2396 VECTOR2I delta( aDelta );
2397
2398 if( parent && parent->Type() == SCH_SYMBOL_T )
2399 {
2400 SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem->GetParent();
2401 TRANSFORM transform = symbol->GetTransform().InverseTransform();
2402
2403 delta = transform.TransformCoordinate( delta );
2404 }
2405
2406 static_cast<SCH_ITEM*>( aItem )->Move( delta );
2407
2408 // If we're moving a field with respect to its parent then it's no longer auto-placed
2409 if( aItem->Type() == SCH_FIELD_T && parent && !parent->IsSelected() )
2411
2412 break;
2413 }
2414
2415 case SCH_SHEET_PIN_T:
2416 {
2417 SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem;
2418
2419 pin->SetStoredPos( pin->GetStoredPos() + aDelta );
2420 pin->ConstrainOnEdge( pin->GetStoredPos(), true );
2421 break;
2422 }
2423
2424 case SCH_LABEL_T:
2426 case SCH_GLOBAL_LABEL_T:
2427 case SCH_HIER_LABEL_T:
2428 {
2429 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
2430
2431 if( m_specialCaseLabels.count( label ) )
2432 {
2434 SEG currentLine( info.attachedLine->GetStartPoint(), info.attachedLine->GetEndPoint() );
2435 label->SetPosition( currentLine.NearestPoint( info.originalLabelPos ) );
2436 }
2437 else
2438 {
2439 label->Move( aDelta );
2440 }
2441
2442 break;
2443 }
2444
2445 default:
2446 static_cast<SCH_ITEM*>( aItem )->Move( aDelta );
2447 break;
2448 }
2449
2450 aItem->SetFlags( IS_MOVING );
2451}
2452
2453
2455{
2457 SCH_SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::MovableItems );
2458 GRID_HELPER_GRIDS selectionGrid = grid.GetSelectionGrid( selection );
2459 SCH_COMMIT commit( m_toolMgr );
2460
2461 auto doMoveItem =
2462 [&]( EDA_ITEM* item, const VECTOR2I& delta )
2463 {
2464 commit.Modify( item, m_frame->GetScreen(), RECURSE_MODE::RECURSE );
2465
2466 // Ensure only one end is moved when calling moveItem
2467 // i.e. we are in drag mode
2468 MOVE_MODE tmpMode = m_mode;
2469 m_mode = DRAG;
2470 moveItem( item, delta );
2471 m_mode = tmpMode;
2472
2473 item->ClearFlags( IS_MOVING );
2474 updateItem( item, true );
2475 };
2476
2477 for( SCH_ITEM* it : m_frame->GetScreen()->Items() )
2478 {
2479 if( !it->IsSelected() )
2480 it->ClearFlags( STARTPOINT | ENDPOINT );
2481
2482 if( !selection.IsHover() && it->IsSelected() )
2483 it->SetFlags( STARTPOINT | ENDPOINT );
2484
2485 it->SetStoredPos( it->GetPosition() );
2486
2487 if( it->Type() == SCH_SHEET_T )
2488 {
2489 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( it )->GetPins() )
2490 pin->SetStoredPos( pin->GetPosition() );
2491 }
2492 }
2493
2494 for( EDA_ITEM* item : selection )
2495 {
2496 if( item->Type() == SCH_LINE_T )
2497 {
2498 SCH_LINE* line = static_cast<SCH_LINE*>( item );
2499 std::vector<int> flags{ STARTPOINT, ENDPOINT };
2500 std::vector<VECTOR2I> pts{ line->GetStartPoint(), line->GetEndPoint() };
2501
2502 for( int ii = 0; ii < 2; ++ii )
2503 {
2504 EDA_ITEMS drag_items{ item };
2505 line->ClearFlags();
2506 line->SetFlags( SELECTED );
2507 line->SetFlags( flags[ii] );
2508 getConnectedDragItems( &commit, line, pts[ii], drag_items );
2509 std::set<EDA_ITEM*> unique_items( drag_items.begin(), drag_items.end() );
2510
2511 VECTOR2I delta = grid.AlignGrid( pts[ii], selectionGrid ) - pts[ii];
2512
2513 if( delta != VECTOR2I( 0, 0 ) )
2514 {
2515 for( EDA_ITEM* dragItem : unique_items )
2516 {
2517 if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
2518 continue;
2519
2520 doMoveItem( dragItem, delta );
2521 }
2522 }
2523 }
2524 }
2525 else if( item->Type() == SCH_FIELD_T || item->Type() == SCH_TEXT_T )
2526 {
2527 VECTOR2I delta = grid.AlignGrid( item->GetPosition(), selectionGrid ) - item->GetPosition();
2528
2529 if( delta != VECTOR2I( 0, 0 ) )
2530 doMoveItem( item, delta );
2531 }
2532 else if( item->Type() == SCH_SHEET_T )
2533 {
2534 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
2535 VECTOR2I topLeft = sheet->GetPosition();
2536 VECTOR2I bottomRight = topLeft + sheet->GetSize();
2537 VECTOR2I tl_delta = grid.AlignGrid( topLeft, selectionGrid ) - topLeft;
2538 VECTOR2I br_delta = grid.AlignGrid( bottomRight, selectionGrid ) - bottomRight;
2539
2540 if( tl_delta != VECTOR2I( 0, 0 ) || br_delta != VECTOR2I( 0, 0 ) )
2541 {
2542 doMoveItem( sheet, tl_delta );
2543
2544 VECTOR2I newSize = (VECTOR2I) sheet->GetSize() - tl_delta + br_delta;
2545 sheet->SetSize( VECTOR2I( newSize.x, newSize.y ) );
2546 updateItem( sheet, true );
2547 }
2548
2549 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
2550 {
2551 VECTOR2I newPos;
2552
2553 if( pin->GetSide() == SHEET_SIDE::TOP || pin->GetSide() == SHEET_SIDE::LEFT )
2554 newPos = pin->GetPosition() + tl_delta;
2555 else
2556 newPos = pin->GetPosition() + br_delta;
2557
2558 VECTOR2I delta = grid.AlignGrid( newPos - pin->GetPosition(), selectionGrid );
2559
2560 if( delta != VECTOR2I( 0, 0 ) )
2561 {
2562 EDA_ITEMS drag_items;
2563 getConnectedDragItems( &commit, pin, pin->GetConnectionPoints()[0],
2564 drag_items );
2565
2566 doMoveItem( pin, delta );
2567
2568 for( EDA_ITEM* dragItem : drag_items )
2569 {
2570 if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
2571 continue;
2572
2573 doMoveItem( dragItem, delta );
2574 }
2575 }
2576 }
2577 }
2578 else
2579 {
2580 SCH_ITEM* schItem = static_cast<SCH_ITEM*>( item );
2581 std::vector<VECTOR2I> connections = schItem->GetConnectionPoints();
2582 EDA_ITEMS drag_items;
2583
2584 for( const VECTOR2I& point : connections )
2585 getConnectedDragItems( &commit, schItem, point, drag_items );
2586
2587 std::map<VECTOR2I, int> shifts;
2588 VECTOR2I most_common( 0, 0 );
2589 int max_count = 0;
2590
2591 for( const VECTOR2I& conn : connections )
2592 {
2593 VECTOR2I gridpt = grid.AlignGrid( conn, selectionGrid ) - conn;
2594
2595 shifts[gridpt]++;
2596
2597 if( shifts[gridpt] > max_count )
2598 {
2599 most_common = gridpt;
2600 max_count = shifts[most_common];
2601 }
2602 }
2603
2604 if( most_common != VECTOR2I( 0, 0 ) )
2605 {
2606 doMoveItem( item, most_common );
2607
2608 for( EDA_ITEM* dragItem : drag_items )
2609 {
2610 if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
2611 continue;
2612
2613 doMoveItem( dragItem, most_common );
2614 }
2615 }
2616 }
2617 }
2618
2620 lwbTool->TrimOverLappingWires( &commit, &selection );
2621 lwbTool->AddJunctionsIfNeeded( &commit, &selection );
2622
2624
2625 m_frame->Schematic().CleanUp( &commit );
2626 commit.Push( _( "Align Items to Grid" ) );
2627 return 0;
2628}
2629
2630
2632{
2633 // Remove new bend lines added during the drag
2634 for( SCH_LINE* newLine : m_newDragLines )
2635 {
2636 m_frame->RemoveFromScreen( newLine, m_frame->GetScreen() );
2637 delete newLine;
2638 }
2639
2640 m_newDragLines.clear();
2641}
2642
2643
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
@ CURSOR_RIGHT
Definition actions.h:311
@ CURSOR_LEFT
Definition actions.h:309
@ CURSOR_UP
Definition actions.h:305
@ CURSOR_DOWN
Definition actions.h:307
static TOOL_ACTION undo
Definition actions.h:75
static TOOL_ACTION duplicate
Definition actions.h:84
static TOOL_ACTION doDelete
Definition actions.h:85
static TOOL_ACTION cursorClick
Definition actions.h:180
static TOOL_ACTION redo
Definition actions.h:76
static TOOL_ACTION increment
Definition actions.h:94
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:224
static TOOL_ACTION refreshPreview
Definition actions.h:159
constexpr const Vec & GetPosition() const
Definition box2.h:211
constexpr coord_type GetY() const
Definition box2.h:208
constexpr size_type GetWidth() const
Definition box2.h:214
constexpr coord_type GetX() const
Definition box2.h:207
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:658
constexpr size_type GetHeight() const
Definition box2.h:215
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:168
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
Definition commit.h:84
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition commit.h:106
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Definition commit.h:96
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
static void sort_dangling_end_items(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos)
Both contain the same information.
Definition sch_item.cpp:953
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition sch_item.h:96
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual VECTOR2I GetPosition() const
Definition eda_item.h:278
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition eda_item.cpp:110
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:148
virtual EDA_GROUP * GetParentGroup() const
Definition eda_item.h:116
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:150
bool IsSelected() const
Definition eda_item.h:127
EDA_ITEM * GetParent() const
Definition eda_item.h:112
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition eda_item.h:152
bool IsNew() const
Definition eda_item.h:124
const VECTOR2I & GetTextPos() const
Definition eda_text.h:273
Implement an R-tree for fast spatial and type indexing of schematic items.
Definition sch_rtree.h:40
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition sch_rtree.h:246
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Definition actions.h:355
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 drag
static TOOL_ACTION toLabel
static TOOL_ACTION alignToGrid
static TOOL_ACTION toDLabel
static TOOL_ACTION slice
static TOOL_ACTION toTextBox
static TOOL_ACTION highlightNet
static TOOL_ACTION repeatDrawItem
static TOOL_ACTION toGLabel
static TOOL_ACTION selectOnPCB
static TOOL_ACTION move
static const std::vector< KICAD_T > MovableItems
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.
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.
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.
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:52
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
void SetStoredPos(const VECTOR2I &aPos)
Definition sch_item.h:304
virtual bool CanConnect(const SCH_ITEM *aItem) const
Definition sch_item.h:521
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode)
Definition sch_item.h:630
int GetBodyStyle() const
Definition sch_item.h:247
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition sch_item.cpp:554
virtual void Move(const VECTOR2I &aMoveVector)
Move the item by aMoveVector to a new position.
Definition sch_item.h:398
void SetLayer(SCH_LAYER_ID aLayer)
Definition sch_item.h:341
void SetConnectivityDirty(bool aDirty=true)
Definition sch_item.h:589
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:626
bool IsConnected(const VECTOR2I &aPoint) const
Test the item to see if it is connected to aPoint.
Definition sch_item.cpp:457
virtual bool IsMovableFromAnchorPoint() const
Check if object is movable from the anchor point.
Definition sch_item.h:301
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition sch_item.cpp:466
VECTOR2I & GetStoredPos()
Definition sch_item.h:303
bool IsGroupableType() const
Definition sch_item.cpp:108
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition sch_item.h:541
void SetLastResolvedState(const SCH_ITEM *aItem) override
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void SetPosition(const VECTOR2I &aPosition) override
bool CanConnect(const SCH_ITEM *aItem) const override
Definition sch_label.h:148
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
int AddJunctionsIfNeeded(SCH_COMMIT *aCommit, SCH_SELECTION *aSelection)
Handle the addition of junctions to a selection of objects.
SCH_JUNCTION * AddJunction(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen, const VECTOR2I &aPos)
int TrimOverLappingWires(SCH_COMMIT *aCommit, SCH_SELECTION *aSelection)
Logic to remove wires when overlapping correct items.
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
void BreakSegment(SCH_COMMIT *aCommit, SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment, SCH_SCREEN *aScreen)
Break a single segment into two at the specified point.
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:42
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition sch_line.cpp:816
void StoreAngle()
Save the current line angle.
Definition sch_line.h:115
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition sch_line.cpp:716
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition sch_line.cpp:233
EDA_ANGLE Angle() const
Get the angle between the start and end lines.
Definition sch_line.h:104
VECTOR2I GetEndPoint() const
Definition sch_line.h:148
VECTOR2I GetStartPoint() const
Definition sch_line.h:139
void MoveEnd(const VECTOR2I &aMoveVector)
Definition sch_line.cpp:178
void SetLastResolvedState(const SCH_ITEM *aItem) override
Definition sch_line.h:163
void MoveStart(const VECTOR2I &aMoveVector)
Definition sch_line.cpp:172
double GetLength() const
Definition sch_line.cpp:249
void SetEndPoint(const VECTOR2I &aPosition)
Definition sch_line.h:149
void moveSelectionToSheet(SCH_SELECTION &aSelection, SCH_SHEET *aTarget, SCH_COMMIT *aCommit)
Clears the new drag lines and removes them from the screen.
void refreshSelectionTraits(const SCH_SELECTION &aSelection, bool &aHasSheetPins, bool &aHasGraphicItems, bool &aHasNonGraphicItems, bool &aIsGraphicsOnly)
Initialize the move/drag operation, setting up flags and connections.
bool Init() override
Init() is called once upon a registration of the tool.
VECTOR2I m_cursor
void trimDanglingLines(SCH_COMMIT *aCommit)
Break or slice the current selection before initiating a move, if required.
void orthoLineDrag(SCH_COMMIT *aCommit, SCH_LINE *line, const VECTOR2I &splitDelta, int &xBendCount, int &yBendCount, const EE_GRID_HELPER &grid)
std::unordered_set< SCH_LINE * > m_newDragLines
Lines changed by drag algorithm that weren't selected.
SCH_SHEET * findTargetSheet(const SCH_SELECTION &aSelection, const VECTOR2I &aCursorPos, bool aHasSheetPins, bool aIsGraphicsOnly, bool aCtrlDown)
Perform the actual move of items by delta, handling split moves and orthogonal dragging.
bool handleMoveToolActions(const TOOL_EVENT *aEvent, SCH_COMMIT *aCommit, const SCH_SELECTION &aSelection)
Update stored positions after transformations (rotation, mirroring, etc.) during move.
bool checkMoveInProgress(const TOOL_EVENT &aEvent, SCH_COMMIT *aCommit, bool aCurrentModeIsDragLike, bool aWasDragging)
< Check if a move is already in progress and handle state transitions
void initializeMoveOperation(const TOOL_EVENT &aEvent, SCH_SELECTION &aSelection, SCH_COMMIT *aCommit, std::vector< DANGLING_END_ITEM > &aInternalPoints, GRID_HELPER_GRIDS &aSnapLayer)
Setup items for drag operation, collecting connected items.
OPT_VECTOR2I m_anchorPos
void performItemMove(SCH_SELECTION &aSelection, const VECTOR2I &aDelta, SCH_COMMIT *aCommit, int &aXBendCount, int &aYBendCount, const EE_GRID_HELPER &aGrid)
Handle tool action events during the move operation.
int Main(const TOOL_EVENT &aEvent)
Run an interactive move of the selected items, or the item under the cursor.
SCH_SELECTION & prepareSelection(bool &aUnselect)
Refresh selection traits (sheet pins, graphic items, etc.)
std::vector< SCH_JUNCTION * > m_hiddenJunctions
void setupItemsForMove(SCH_SELECTION &aSelection, std::vector< DANGLING_END_ITEM > &aInternalPoints)
Find the target sheet for dropping items (if any)
bool m_inMoveTool
< Re-entrancy guard
std::vector< KIID > m_dragAdditions
Cache of the line's original connections before dragging started.
void moveItem(EDA_ITEM *aItem, const VECTOR2I &aDelta)
Find additional items for a drag operation.
void setupItemsForDrag(SCH_SELECTION &aSelection, SCH_COMMIT *aCommit)
Setup items for move operation, marking dangling ends.
std::unordered_set< SCH_LINE * > m_changedDragLines
Junctions that were hidden during the move.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void finalizeMoveOperation(SCH_SELECTION &aSelection, SCH_COMMIT *aCommit, bool aUnselect, const std::vector< DANGLING_END_ITEM > &aInternalPoints)
void setTransitions() override
Cleanup dangling lines left after a drag.
void getConnectedItems(SCH_ITEM *aOriginalItem, const VECTOR2I &aPoint, EDA_ITEMS &aList)
std::map< SCH_LINE *, EDA_ITEMS > m_lineConnectionCache
Lines added at bend points dynamically during the move.
OPT_VECTOR2I m_breakPos
void updateStoredPositions(const SCH_SELECTION &aSelection)
Finalize the move operation, updating junctions and cleaning up.
bool doMoveSelection(const TOOL_EVENT &aEvent, SCH_COMMIT *aCommit)
void getConnectedDragItems(SCH_COMMIT *aCommit, SCH_ITEM *fixed, const VECTOR2I &selected, EDA_ITEMS &aList)
VECTOR2I m_moveOffset
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
std::map< SCH_LABEL_BASE *, SPECIAL_CASE_LABEL_INFO > m_specialCaseLabels
int AlignToGrid(const TOOL_EVENT &aEvent)
Align selected elements to the grid.
void clearNewDragLines()
Set up handlers for various events.
MOVE_MODE m_mode
Items (such as wires) which were added to the selection for a drag.
void preprocessBreakOrSliceSelection(SCH_COMMIT *aCommit, const TOOL_EVENT &aEvent)
std::map< SCH_SHEET_PIN *, std::pair< SCH_LINE *, bool > > m_specialCaseSheetPins
void Append(SCH_ITEM *aItem, bool aUpdateLibSymbol=true)
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:118
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 symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
void SetSize(const VECTOR2I &aSize)
Definition sch_sheet.h:148
bool IsTopLevelSheet() const
Check if this sheet is a top-level sheet.
VECTOR2I GetSize() const
Definition sch_sheet.h:147
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:145
VECTOR2I GetPosition() const override
Definition sch_sheet.h:496
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition sch_sheet.h:233
Schematic symbol object.
Definition sch_symbol.h:76
VECTOR2I GetPosition() const override
Definition sch_text.h:147
void updateItem(EDA_ITEM *aItem, bool aUpdateRTree) const
bool Init() override
Init() is called once upon a registration of the tool.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
SCH_TOOL_BASE(const std::string &aName)
SCH_SELECTION_TOOL * m_selectionTool
Definition seg.h:42
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition seg.cpp:633
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)
Definition selection.cpp:42
VECTOR2I GetReferencePoint() const
bool IsHover() const
Definition selection.h:89
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition selection.h:105
EDA_ITEM * Front() const
Definition selection.h:177
int Size() const
Returns the number of selected parts.
Definition selection.h:121
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
Definition selection.h:115
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
Definition selection.h:216
const TRANSFORM & GetTransform() const
Definition symbol.h:247
KIGFX::VIEW_CONTROLS * getViewControls() const
Definition tool_base.cpp:44
KIGFX::VIEW * getView() const
Definition tool_base.cpp:38
Generic, UI-independent tool event.
Definition tool_event.h:171
bool DisableGridSnapping() const
Definition tool_event.h:371
bool HasParameter() const
Definition tool_event.h:464
bool IsCancelInteractive() const
Indicate the event should restart/end an ongoing interactive tool's event loop (eg esc key,...
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition tool_event.h:250
bool IsActivate() const
Definition tool_event.h:345
COMMIT * Commit() const
Definition tool_event.h:283
bool IsClick(int aButtonMask=BUT_ANY) const
TOOL_EVENT_CATEGORY Category() const
Return the category (eg. mouse/keyboard/action) of an event.
Definition tool_event.h:247
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition tool_event.h:315
int Modifier(int aMask=MD_MODIFIER_MASK) const
Return information about key modifiers state (Ctrl, Alt, etc.).
Definition tool_event.h:366
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
T Parameter() const
Return a parameter assigned to the event.
Definition tool_event.h:473
bool IsDblClick(int aButtonMask=BUT_ANY) const
std::atomic< SYNCRONOUS_TOOL_STATE > * SynchronousState() const
Definition tool_event.h:280
std::optional< int > GetCommandId() const
Definition tool_event.h:533
void SetPassEvent(bool aPass=true)
Definition tool_event.h:256
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition tool_event.h:325
bool IsMotion() const
Definition tool_event.h:330
const std::string Format() const
Return information about event in form of a human-readable string.
void Go(int(SCH_EDIT_FRAME::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
std::unique_ptr< TOOL_MENU > m_menu
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:46
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition transform.cpp:59
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition transform.cpp:44
@ CHT_REMOVE
Definition commit.h:43
@ CHT_DONE
Flag to indicate the change is already applied.
Definition commit.h:47
@ CHT_ADD
Definition commit.h:42
KICURSOR
Definition cursors.h:44
@ PLACE
Definition cursors.h:98
@ MOVING
Definition cursors.h:48
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:413
@ RECURSE
Definition eda_item.h:51
@ NO_RECURSE
Definition eda_item.h:52
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition eda_item.h:575
#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.
@ NONE
Definition eda_shape.h:69
@ ID_POPUP_SCH_SELECT_UNIT
Definition eeschema_id.h:89
@ ID_POPUP_SCH_SELECT_BODY_STYLE
Definition eeschema_id.h:99
@ ID_POPUP_SCH_SELECT_BODY_STYLE_END
@ ID_POPUP_SCH_SELECT_UNIT_END
Definition eeschema_id.h:93
@ LINE_MODE_FREE
GRID_HELPER_GRIDS
Definition grid_helper.h:44
@ GRID_CURRENT
Definition grid_helper.h:46
const wxChar *const traceSchMove
Flag to watch how schematic move tool actions are handled.
@ LAYER_WIRE
Definition layer_ids.h:452
@ LAYER_BUS
Definition layer_ids.h:453
@ LAYER_BUS_JUNCTION
Definition layer_ids.h:498
std::vector< SCH_JUNCTION * > PreviewJunctions(const class 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.
Definition view_item.h:58
bool signbit(T v)
Integral version of std::signbit that works all compilers.
Definition kicad_algo.h:176
see class PGM_BASE
Class to handle a set of SCH_ITEMs.
@ AUTOPLACE_NONE
Definition sch_item.h:69
#define QUIET_MODE
static bool isGraphicItemForDrop(const SCH_ITEM *aItem)
static void cloneWireConnection(SCH_LINE *aNewLine, SCH_ITEM *aSource, SCH_EDIT_FRAME *aFrame)
T * GetAppSettings(const char *aFilename)
The EE_TYPE struct provides a type-specific auto-range iterator to the RTree.
Definition sch_rtree.h:195
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.
bool moved
KIBIS_PIN * pin
VECTOR2I end
int delta
@ TA_CHOICE_MENU_CHOICE
Context menu choice.
Definition tool_event.h:98
@ STS_CANCELLED
Definition tool_event.h:164
@ STS_FINISHED
Definition tool_event.h:163
@ STS_RUNNING
Definition tool_event.h:162
@ MD_CTRL
Definition tool_event.h:144
@ MD_SHIFT
Definition tool_event.h:143
@ TC_COMMAND
Definition tool_event.h:57
@ TC_MOUSE
Definition tool_event.h:55
@ TC_KEYBOARD
Definition tool_event.h:56
@ BUT_LEFT
Definition tool_event.h:132
@ BUT_RIGHT
Definition tool_event.h:133
wxLogTrace helper definitions.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:78
@ SCH_LINE_T
Definition typeinfo.h:167
@ SCH_NO_CONNECT_T
Definition typeinfo.h:164
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_FIELD_T
Definition typeinfo.h:154
@ SCH_DIRECTIVE_LABEL_T
Definition typeinfo.h:175
@ SCH_LABEL_T
Definition typeinfo.h:171
@ SCH_SHEET_T
Definition typeinfo.h:179
@ SCH_SHAPE_T
Definition typeinfo.h:153
@ SCH_HIER_LABEL_T
Definition typeinfo.h:173
@ SCH_BUS_BUS_ENTRY_T
Definition typeinfo.h:166
@ SCH_SHEET_PIN_T
Definition typeinfo.h:178
@ SCH_TEXT_T
Definition typeinfo.h:155
@ SCH_BUS_WIRE_ENTRY_T
Definition typeinfo.h:165
@ SCH_BITMAP_T
Definition typeinfo.h:168
@ SCH_TEXTBOX_T
Definition typeinfo.h:156
@ SCH_GLOBAL_LABEL_T
Definition typeinfo.h:172
@ SCH_JUNCTION_T
Definition typeinfo.h:163
@ SCH_PIN_T
Definition typeinfo.h:157
constexpr int sign(T val)
Definition util.h:145
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694