KiCad PCB EDA Suite
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 (C) 2019 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 <tool/tool_manager.h>
28 #include <ee_actions.h>
29 #include <bitmaps.h>
30 #include <base_struct.h>
31 #include <sch_item.h>
32 #include <sch_component.h>
33 #include <sch_sheet.h>
34 #include <sch_view.h>
35 #include <sch_line.h>
36 #include <sch_edit_frame.h>
37 #include <eeschema_id.h>
38 #include <pgm_base.h>
40 #include "sch_move_tool.h"
41 
42 
43 // For adding to or removing from selections
44 #define QUIET_MODE true
45 
46 
48  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveMove" ),
49  m_moveInProgress( false ),
50  m_isDragOperation( false ),
51  m_moveOffset( 0, 0 )
52 {
53 }
54 
55 
57 {
59 
60  auto moveCondition = [] ( const SELECTION& aSel ) {
61  if( aSel.Empty() )
62  return false;
63 
65  return false;
66 
67  return true;
68  };
69 
70  // Add move actions to the selection tool menu
71  //
73 
74  selToolMenu.AddItem( EE_ACTIONS::move, moveCondition, 150 );
75  selToolMenu.AddItem( EE_ACTIONS::drag, moveCondition, 150 );
76 
77  return true;
78 }
79 
80 
81 /* TODO - Tom/Jeff
82  - add preferences option "Move origin: always cursor / item origin"
83  - add preferences option "Default drag action: drag items / move"
84  - add preferences option "Drag always selects"
85  */
86 
87 
88 int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
89 {
90  const KICAD_T movableItems[] =
91  {
97  SCH_LINE_T,
99  SCH_TEXT_T,
100  SCH_LABEL_T,
103  SCH_FIELD_T,
106  SCH_SHEET_T,
107  EOT
108  };
109 
110  EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
112  controls->SetSnapping( true );
113 
114  m_anchorPos.reset();
115 
116  if( aEvent.IsAction( &EE_ACTIONS::move ) )
117  m_isDragOperation = false;
118  else if( aEvent.IsAction( &EE_ACTIONS::drag ) )
119  m_isDragOperation = true;
120  else if( aEvent.IsAction( &EE_ACTIONS::moveActivate ) )
122  else
123  return 0;
124 
125  if( m_moveInProgress )
126  {
127  auto sel = m_selectionTool->GetSelection().Front();
128 
129  if( sel && !sel->IsNew() )
130  {
131  // User must have switched from move to drag or vice-versa. Reset the selected
132  // items so we can start again with the current m_isDragOperation.
136  m_moveInProgress = false;
137  controls->SetAutoPan( false );
138 
139  // And give it a kick so it doesn't have to wait for the first mouse movement to
140  // refresh.
142  }
143 
144  return 0;
145  }
146 
147  // Be sure that there is at least one item that we can move. If there's no selection try
148  // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
149  EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
150  bool unselect = selection.IsHover();
151 
152  // Keep an original copy of the starting points for cleanup after the move
153  std::vector<DANGLING_END_ITEM> internalPoints;
154 
155  if( selection.Empty() )
156  return 0;
157 
158  Activate();
159  controls->ShowCursor( true );
160 
161  bool restore_state = false;
162  bool chain_commands = false;
163  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
164  VECTOR2I prevPos;
165 
166  std::string tool = aEvent.GetCommandStr().get();
167  m_frame->PushTool( tool );
168  m_cursor = controls->GetCursorPosition();
169 
170  // Main loop: keep receiving events
171  do
172  {
173  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
174  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
175 
177  || evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag )
178  || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
179  || evt->IsAction( &ACTIONS::refreshPreview ) )
180  {
181  if( !m_moveInProgress ) // Prepare to start moving/dragging
182  {
183  SCH_ITEM* sch_item = (SCH_ITEM*) selection.Front();
184  bool appendUndo = sch_item && sch_item->IsNew();
185  bool placingNewItems = sch_item && sch_item->IsNew();
186 
187  //------------------------------------------------------------------------
188  // Setup a drag or a move
189  //
190  m_dragAdditions.clear();
191  m_specialCaseLabels.clear();
192  internalPoints.clear();
193 
194 
195  for( auto it : m_frame->GetScreen()->Items() )
196  {
197  it->ClearFlags( TEMP_SELECTED );
198 
199  if( !it->IsSelected() )
200  it->ClearFlags( STARTPOINT | ENDPOINT );
201 
202  if( !selection.IsHover() && it->IsSelected() )
203  it->SetFlags( STARTPOINT | ENDPOINT );
204  }
205 
206  if( m_isDragOperation )
207  {
208  // Add connections to the selection for a drag.
209  //
210  for( EDA_ITEM* item : selection )
211  {
212  if( static_cast<SCH_ITEM*>( item )->IsConnectable() )
213  {
214  std::vector<wxPoint> connections;
215 
216  if( item->Type() == SCH_LINE_T )
217  static_cast<SCH_LINE*>( item )->GetSelectedPoints( connections );
218  else
219  static_cast<SCH_ITEM*>( item )->GetConnectionPoints( connections );
220 
221  for( wxPoint point : connections )
223  }
224  }
225 
227  }
228  else
229  {
230  // Mark the edges of the block with dangling flags for a move.
231  for( EDA_ITEM* item : selection )
232  static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
233 
234  for( EDA_ITEM* item : selection )
235  static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints );
236  }
237  // Generic setup
238  //
239  for( EDA_ITEM* item : selection )
240  {
241  if( item->IsNew() )
242  {
243  if( item->HasFlag( TEMP_SELECTED ) && m_isDragOperation )
244  {
245  // Item was added in getConnectedDragItems
246  saveCopyInUndoList( (SCH_ITEM*) item, UR_NEW, appendUndo );
247  appendUndo = true;
248  }
249  else
250  {
251  // Item was added in a previous command (and saved to undo by
252  // that command)
253  }
254  }
255  else if( item->GetParent() && item->GetParent()->IsSelected() )
256  {
257  // Item will be (or has been) saved to undo by parent
258  }
259  else
260  {
261  saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, appendUndo );
262  appendUndo = true;
263  }
264 
265  SCH_ITEM* schItem = (SCH_ITEM*) item;
266  schItem->SetStoredPos( schItem->GetPosition() );
267  }
268 
269  // Set up the starting position and move/drag offset
270  //
271  m_cursor = controls->GetCursorPosition();
272 
273  if( evt->IsAction( &EE_ACTIONS::restartMove ) )
274  {
275  wxASSERT_MSG( m_anchorPos, "Should be already set from previous cmd" );
276  }
277  else if( placingNewItems )
278  {
279  m_anchorPos = selection.GetReferencePoint();
280  }
281 
282  if( m_anchorPos )
283  {
284  VECTOR2I delta = m_cursor - (*m_anchorPos);
285 
286  // Drag items to the current cursor position
287  for( EDA_ITEM* item : selection )
288  {
289  // Don't double move pins, fields, etc.
290  if( item->GetParent() && item->GetParent()->IsSelected() )
291  continue;
292 
293  moveItem( item, delta );
294  updateView( item );
295  }
296 
298  }
299  // For some items, moving the cursor to anchor is not good (for instance large
300  // hierarchical sheets or components can have the anchor outside the view)
301  else if( selection.Size() == 1 && sch_item->IsMovableFromAnchorPoint()
303  {
304  if( sch_item->Type() == SCH_LINE_T && !sch_item->HasFlag( STARTPOINT ) )
305  m_anchorPos = static_cast<SCH_LINE*>( sch_item )->GetEndPoint();
306  else
307  m_anchorPos = sch_item->GetPosition();
308 
309  getViewControls()->WarpCursor( *m_anchorPos, true, true );
311  }
312  // ...otherwise modify items with regard to the grid-snapped cursor position
313  else
314  {
317  }
318 
319  controls->SetCursorPosition( m_cursor, false );
321 
322  prevPos = m_cursor;
323  controls->SetAutoPan( true );
324  m_moveInProgress = true;
325  }
326 
327  //------------------------------------------------------------------------
328  // Follow the mouse
329  //
330  m_cursor = controls->GetCursorPosition();
331  VECTOR2I delta( m_cursor - prevPos );
333 
334  m_moveOffset += delta;
335  prevPos = m_cursor;
336 
337  for( EDA_ITEM* item : selection )
338  {
339  // Don't double move pins, fields, etc.
340  if( item->GetParent() && item->GetParent()->IsSelected() )
341  continue;
342 
343  moveItem( item, delta );
344  updateView( item );
345  }
346 
349  }
350  //------------------------------------------------------------------------
351  // Handle cancel
352  //
353  else if( evt->IsCancelInteractive() )
354  {
355  if( m_moveInProgress )
356  restore_state = true;
357 
358  break;
359  }
360  //------------------------------------------------------------------------
361  // Handle TOOL_ACTION special cases
362  //
363  else if( evt->Action() == TA_UNDO_REDO_PRE )
364  {
365  unselect = true;
366  break;
367  }
368  else if( evt->Category() == TC_COMMAND )
369  {
370  if( evt->IsAction( &ACTIONS::doDelete ) )
371  {
372  // Exit on a remove operation; there is no further processing for removed items.
373  break;
374  }
375  else if( evt->IsAction( &ACTIONS::duplicate ) )
376  {
377  if( selection.Front()->IsNew() )
378  {
379  // This doesn't really make sense; we'll just end up dragging a stack of
380  // objects so Duplicate() is going to ignore this and we'll just carry on.
381  continue;
382  }
383 
384  // Move original back and exit. The duplicate will run in its own loop.
385  restore_state = true;
386  unselect = false;
387  chain_commands = true;
388  break;
389  }
390  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
391  {
392  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
394  {
395  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
396  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
397 
398  if( component )
399  {
400  m_frame->SelectUnit( component, unit );
402  }
403  }
404  }
405  }
406  //------------------------------------------------------------------------
407  // Handle context menu
408  //
409  else if( evt->IsClick( BUT_RIGHT ) )
410  {
412  }
413  //------------------------------------------------------------------------
414  // Handle drop
415  //
416  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
417  {
418  break; // Finish
419  }
420  else
421  evt->SetPassEvent();
422 
423  controls->SetAutoPan( m_moveInProgress );
424 
425  } while( ( evt = Wait() ) ); //Should be assignment not equality test
426 
427  controls->ForceCursorPosition( false );
428  controls->ShowCursor( false );
429  controls->SetSnapping( false );
430  controls->SetAutoPan( false );
431 
432  if( !chain_commands )
433  m_moveOffset = { 0, 0 };
434 
435  m_anchorPos.reset();
436 
437  for( EDA_ITEM* item : selection )
438  item->ClearEditFlags();
439 
440  if( restore_state )
441  {
444  }
445  else
446  {
447  // Moving items changes the RTree box bounds.
448  for( auto item : selection )
449  {
450  switch( item->Type() )
451  {
452  // Moving sheet pins does not change the BBox.
453  case SCH_SHEET_PIN_T:
454  break;
455 
456  // Moving fields should update the associated component
457  case SCH_FIELD_T:
458  if( item->GetParent() )
459  m_frame->GetScreen()->Update( static_cast<SCH_ITEM*>( item->GetParent() ) );
460 
461  break;
462 
463  default:
464  m_frame->GetScreen()->Update( static_cast<SCH_ITEM*>( item ) );
465  }
466  }
467 
468  // If we move items away from a junction, we _may_ want to add a junction there
469  // to denote the state.
470  for( auto it : internalPoints )
471  {
472  if( m_frame->GetScreen()->IsJunctionNeeded( it.GetPosition(), true ) )
473  m_frame->AddJunction( it.GetPosition(), true, false );
474  }
475 
476  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
478 
481 
482  m_frame->OnModify();
483  }
484 
485  if( unselect )
487  else
488  m_selectionTool->RebuildSelection(); // Schematic cleanup might have merged lines, etc.
489 
490  m_dragAdditions.clear();
491  m_moveInProgress = false;
492  m_frame->PopTool( tool );
493  return 0;
494 }
495 
496 
498  EDA_ITEMS& aList )
499 {
500  for( SCH_ITEM* test : m_frame->GetScreen()->Items() )
501  {
502  if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aOriginalItem ) )
503  continue;
504 
505  KICAD_T testType = test->Type();
506 
507  switch( testType )
508  {
509  case SCH_LINE_T:
510  {
511  // Select the connected end of wires/bus connections.
512  SCH_LINE* testLine = static_cast<SCH_LINE*>( test );
513  wxPoint otherEnd;
514 
515  if( testLine->GetStartPoint() == aPoint )
516  {
517  if( !testLine->HasFlag( TEMP_SELECTED ) )
518  aList.push_back( testLine );
519 
520  testLine->SetFlags( STARTPOINT | TEMP_SELECTED );
521  otherEnd = testLine->GetEndPoint();
522  }
523  else if( testLine->GetEndPoint() == aPoint )
524  {
525  if( !testLine->HasFlag( TEMP_SELECTED ) )
526  aList.push_back( testLine );
527 
528  testLine->SetFlags( ENDPOINT | TEMP_SELECTED );
529  otherEnd = testLine->GetStartPoint();
530  }
531  else
532  {
533  break;
534  }
535 
536  // Since only one end is going to move, the movement vector of any labels attached
537  // to it is scaled by the proportion of the line length the label is from the moving
538  // end.
539  for( SCH_ITEM* item : m_frame->GetScreen()->Items().OfType( SCH_LABEL_T ) )
540  {
541  if( item->IsSelected() )
542  continue; // These will be moved on their own because they're selected
543 
544  if( item->CanConnect( testLine ) && testLine->HitTest( item->GetPosition(), 1 ) )
545  {
546  SCH_TEXT* label = static_cast<SCH_TEXT*>( item );
547 
548  if( !label->HasFlag( TEMP_SELECTED ) )
549  aList.push_back( label );
550 
552  info.attachedLine = testLine;
553  info.originalLabelPos = label->GetPosition();
554  m_specialCaseLabels[label] = info;
555  }
556  }
557 
558  break;
559  }
560 
561  case SCH_SHEET_T:
562  // Dragging a sheet just because it's connected to something else feels a bit like
563  // the tail wagging the dog, but this could be moved down to the next case.
564  break;
565 
566  case SCH_COMPONENT_T:
567  if( test->IsConnected( aPoint ) )
568  {
569  // Add a new wire between the component and the selected item so the selected
570  // item can be dragged.
571  SCH_LINE* newWire = new SCH_LINE( aPoint, LAYER_WIRE );
572  newWire->SetFlags( IS_NEW );
573  m_frame->AddToScreen( newWire, m_frame->GetScreen() );
574 
575  newWire->SetFlags( TEMP_SELECTED | STARTPOINT );
576  aList.push_back( newWire );
577  }
578  break;
579 
580  case SCH_NO_CONNECT_T:
581  case SCH_JUNCTION_T:
582  // Select no-connects and junctions that are connected to items being moved.
583  if( !test->HasFlag( TEMP_SELECTED ) && test->IsConnected( aPoint ) )
584  {
585  aList.push_back( test );
586  test->SetFlags( TEMP_SELECTED );
587  }
588 
589  break;
590 
591  case SCH_LABEL_T:
592  case SCH_GLOBAL_LABEL_T:
593  case SCH_HIER_LABEL_T:
595  case SCH_BUS_BUS_ENTRY_T:
596  // Performance optimization:
597  if( test->HasFlag( TEMP_SELECTED ) )
598  break;
599 
600  // Select labels and bus entries that are connected to a wire being moved.
601  if( aOriginalItem->Type() == SCH_LINE_T )
602  {
603  std::vector<wxPoint> connections;
604  test->GetConnectionPoints( connections );
605 
606  for( wxPoint& point : connections )
607  {
608  if( aOriginalItem->HitTest( point, 1 ) )
609  {
610  test->SetFlags( TEMP_SELECTED );
611  aList.push_back( test );
612 
613  // A bus entry needs its wire & label as well
614  if( testType == SCH_BUS_WIRE_ENTRY_T || testType == SCH_BUS_BUS_ENTRY_T )
615  {
616  std::vector<wxPoint> ends;
617  wxPoint otherEnd;
618 
619  test->GetConnectionPoints( ends );
620 
621  if( ends[0] == point )
622  otherEnd = ends[1];
623  else
624  otherEnd = ends[0];
625 
626  getConnectedDragItems( (SCH_ITEM*) test, otherEnd, m_dragAdditions );
627  }
628  break;
629  }
630  }
631  }
632 
633  break;
634 
635  default:
636  break;
637  }
638  }
639 }
640 
641 
642 void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, const VECTOR2I& aDelta )
643 {
644  switch( aItem->Type() )
645  {
646  case SCH_LINE_T:
647  {
648  SCH_LINE* line = static_cast<SCH_LINE*>( aItem );
649 
650  if( aItem->HasFlag( STARTPOINT ) )
651  line->MoveStart( (wxPoint) aDelta );
652 
653  if( aItem->HasFlag( ENDPOINT ) )
654  line->MoveEnd( (wxPoint) aDelta );
655 
656  }
657  break;
658 
659  case SCH_PIN_T:
660  case SCH_FIELD_T:
661  {
662  SCH_ITEM* parent = (SCH_ITEM*) aItem->GetParent();
663  wxPoint delta( aDelta );
664 
665  if( parent && parent->Type() == SCH_COMPONENT_T )
666  {
667  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem->GetParent();
668  TRANSFORM transform = component->GetTransform().InverseTransform();
669 
670  delta = transform.TransformCoordinate( delta );
671  }
672 
673  static_cast<SCH_ITEM*>( aItem )->Move( delta );
674 
675  // If we're moving a field with respect to its parent then it's no longer auto-placed
676  if( aItem->Type() == SCH_FIELD_T && parent && !parent->IsSelected() )
677  parent->ClearFieldsAutoplaced();
678 
679  break;
680  }
681  case SCH_SHEET_PIN_T:
682  {
683  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem;
684  pin->SetStoredPos( pin->GetStoredPos() + (wxPoint) aDelta );
685  pin->ConstrainOnEdge( pin->GetStoredPos() );
686  break;
687  }
688  case SCH_LABEL_T:
689  {
690  SCH_TEXT* label = static_cast<SCH_TEXT*>( aItem );
691 
692  if( m_specialCaseLabels.count( label ) )
693  {
695  SEG currentLine( info.attachedLine->GetStartPoint(), info.attachedLine->GetEndPoint() );
696  label->SetPosition( (wxPoint) currentLine.NearestPoint( info.originalLabelPos ) );
697  }
698  else
699  label->Move( (wxPoint) aDelta );
700 
701  break;
702  }
703  default:
704  static_cast<SCH_ITEM*>( aItem )->Move( (wxPoint) aDelta );
705  break;
706  }
707 
708  getView()->Hide( aItem, false );
709  aItem->SetFlags( IS_MOVED );
710 }
711 
712 
714 {
716  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
717  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() );
718 }
static TOOL_ACTION moveActivate
Definition: ee_actions.h:112
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
OPT< int > GetCommandId() const
Definition: tool_event.h:458
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:125
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
bool IsHover() const
Definition: selection.h:71
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void getConnectedDragItems(SCH_ITEM *aOriginalItem, wxPoint aPoint, EDA_ITEMS &aList)
Finds additional items for a drag operation.
wxPoint GetStartPoint() const
Definition: sch_line.h:94
bool IsSelected() const
Definition: base_struct.h:203
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
virtual bool IsMovableFromAnchorPoint()
Definition: sch_item.h:240
static TOOL_ACTION doDelete
Definition: actions.h:74
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:372
int Main(const TOOL_EVENT &aEvent)
Function Main()
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: sch_move_tool.h:83
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:250
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:178
VECTOR2I m_moveOffset
Used for chaining commands
Definition: sch_move_tool.h:79
static TOOL_ACTION restartMove
Definition: ee_actions.h:185
void MoveStart(const wxPoint &aMoveVector)
Definition: sch_line.cpp:138
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:59
TOOL_MENU & GetToolMenu()
bool IsMotion() const
Definition: tool_event.h:306
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
int AddItemsToSel(const TOOL_EVENT &aEvent)
TOOL_EVENT_CATEGORY Category() const
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:247
Schematic editor (Eeschema) main window.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
bool m_moveInProgress
Flag determining if anything is being dragged right now
Definition: sch_move_tool.h:72
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
EDA_ITEMS m_dragAdditions
Items (such as wires) which were added to the selection for a drag
Definition: sch_move_tool.h:76
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:206
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_line.cpp:671
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
bool IsNew() const
Definition: base_struct.h:199
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
virtual const wxPoint GetPosition() const
Definition: base_struct.h:337
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: base_struct.h:307
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint & GetStoredPos()
Definition: sch_item.h:242
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:296
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_text.h:276
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
std::map< SCH_TEXT *, SPECIAL_CASE_LABEL_INFO > m_specialCaseLabels
Definition: sch_move_tool.h:89
const wxPoint GetPosition() const override
Definition: sch_text.h:313
virtual void PopTool(const std::string &actionName)
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:587
TRANSFORM & GetTransform() const
boost::optional< VECTOR2I > m_anchorPos
Definition: sch_move_tool.h:85
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_EVENT.
Definition: tool_event.h:171
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
void ClearFieldsAutoplaced()
Set fields automatically placed flag false.
Definition: sch_item.h:437
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
void SetPassEvent()
Definition: tool_event.h:256
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
bool m_isDragOperation
Definition: sch_move_tool.h:73
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:301
void ConstrainOnEdge(wxPoint Pos)
Adjust label position to edge based on proximity to vertical or horizontal edge of the parent sheet.
bool IsCancelInteractive()
Function IsCancelInteractive()
Definition: tool_event.cpp:190
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
void SelectUnit(SCH_COMPONENT *aComponent, int aUnit)
Definition: getpart.cpp:196
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
Definition: seg.h:39
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static bool IsDrawingLineWireOrBus(const SELECTION &aSelection)
void updateView(EDA_ITEM *aItem) const
Similar to getView()->Update(), but handles items that are redrawn by their parents.
Definition: ee_tool_base.h:104
see class PGM_BASE
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void MoveEnd(const wxPoint &aMoveVector)
Definition: sch_line.cpp:148
void moveItem(EDA_ITEM *aItem, const VECTOR2I &aDelta)
static TOOL_ACTION drag
Definition: ee_actions.h:114
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
EE_RTREE & Items()
Definition: sch_screen.h:162
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:123
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
Schematic symbol object.
Definition: sch_component.h:88
void saveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO_T aType, bool aAppend=false)
Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.
Definition: ee_tool_base.h:117
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
bool GetMoveWarpsCursor() const
Indicates that a move operation should warp the mouse pointer to the origin of the move object.
Definition: tools_holder.h:107
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION move
Definition: ee_actions.h:113
EE_TOOL_BASE.
Definition: ee_tool_base.h:50
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void Update(SCH_ITEM *aItem)
Updates aItem's bounding box in the tree.
Definition: sch_screen.cpp:238
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:235
#define QUIET_MODE
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
void setTransitions() override
Sets up handlers for various events.
void SetPosition(const wxPoint &aPosition) override
Set the schematic item position to aPosition.
Definition: sch_text.h:314
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:268
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
void SetStoredPos(wxPoint aPos)
Definition: sch_item.h:243
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:186
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION duplicate
Definition: actions.h:73
static TOOL_ACTION refreshPreview
Definition: actions.h:101
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
virtual void UpdateMsgPanel()
Redraw the message panel.
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:122
#define IS_MOVED
Item being moved.
Definition: base_struct.h:116
wxPoint GetEndPoint() const
Definition: sch_line.h:97