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 "sch_move_tool.h"
39 
40 
41 // For adding to or removing from selections
42 #define QUIET_MODE true
43 
44 
46  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveMove" ),
47  m_moveInProgress( false ),
48  m_isDragOperation( false ),
49  m_moveOffset( 0, 0 )
50 {
51 }
52 
53 
55 {
57 
58  auto moveCondition = [] ( const SELECTION& aSel ) {
59  if( aSel.Empty() )
60  return false;
61 
63  return false;
64 
65  return true;
66  };
67 
68  // Add move actions to the selection tool menu
69  //
71 
72  selToolMenu.AddItem( EE_ACTIONS::move, moveCondition, 150 );
73  selToolMenu.AddItem( EE_ACTIONS::drag, moveCondition, 150 );
74 
75  return true;
76 }
77 
78 
79 /* TODO - Tom/Jeff
80  - add preferences option "Move origin: always cursor / item origin"
81  - add preferences option "Default drag action: drag items / move"
82  - add preferences option "Drag always selects"
83  */
84 
85 
86 int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
87 {
88  const KICAD_T movableItems[] =
89  {
95  SCH_LINE_T,
97  SCH_TEXT_T,
101  SCH_FIELD_T,
104  SCH_SHEET_T,
105  EOT
106  };
107 
109  controls->SetSnapping( true );
110 
111  m_anchorPos.reset();
112 
113  if( aEvent.IsAction( &EE_ACTIONS::move ) )
114  m_isDragOperation = false;
115  else if( aEvent.IsAction( &EE_ACTIONS::drag ) )
116  m_isDragOperation = true;
117  else if( aEvent.IsAction( &EE_ACTIONS::moveActivate ) )
119  else
120  return 0;
121 
122  if( m_moveInProgress )
123  {
124  auto sel = m_selectionTool->GetSelection().Front();
125 
126  if( sel && !sel->IsNew() )
127  {
128  // User must have switched from move to drag or vice-versa. Reset the selected
129  // items so we can start again with the current m_isDragOperation.
133  m_moveInProgress = false;
134  controls->SetAutoPan( false );
135 
136  // And give it a kick so it doesn't have to wait for the first mouse movement to
137  // refresh.
139  }
140 
141  return 0;
142  }
143 
144  // Be sure that there is at least one item that we can move. If there's no selection try
145  // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
146  EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
147  bool unselect = selection.IsHover();
148 
149  // Keep an original copy of the starting points for cleanup after the move
150  std::vector<DANGLING_END_ITEM> internalPoints;
151 
152  if( selection.Empty() )
153  return 0;
154 
155  Activate();
156  controls->ShowCursor( true );
157 
158  bool restore_state = false;
159  bool chain_commands = false;
160  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
161  VECTOR2I prevPos;
162 
163  std::string tool = aEvent.GetCommandStr().get();
164  m_frame->PushTool( tool );
165  m_cursor = controls->GetCursorPosition();
166 
167  // Main loop: keep receiving events
168  do
169  {
170  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
171  controls->SetSnapping( !evt->Modifier( MD_ALT ) );
172 
174  || evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag )
175  || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
176  || evt->IsAction( &ACTIONS::refreshPreview ) )
177  {
178  if( !m_moveInProgress ) // Prepare to start moving/dragging
179  {
180  SCH_ITEM* sch_item = (SCH_ITEM*) selection.Front();
181  bool appendUndo = sch_item && sch_item->IsNew();
182  bool placingNewItems = sch_item && sch_item->IsNew();
183 
184  //------------------------------------------------------------------------
185  // Setup a drag or a move
186  //
187  m_dragAdditions.clear();
188  internalPoints.clear();
189 
190 
191  for( auto it : m_frame->GetScreen()->Items() )
192  {
193  it->ClearFlags( TEMP_SELECTED );
194 
195  if( !it->IsSelected() )
196  it->ClearFlags( STARTPOINT | ENDPOINT );
197 
198  if( !selection.IsHover() && it->IsSelected() )
199  it->SetFlags( STARTPOINT | ENDPOINT );
200  }
201 
202  if( m_isDragOperation )
203  {
204  // Add connections to the selection for a drag.
205  //
206  for( EDA_ITEM* item : selection )
207  {
208  if( static_cast<SCH_ITEM*>( item )->IsConnectable() )
209  {
210  std::vector<wxPoint> connections;
211 
212  if( item->Type() == SCH_LINE_T )
213  static_cast<SCH_LINE*>( item )->GetSelectedPoints( connections );
214  else
215  static_cast<SCH_ITEM*>( item )->GetConnectionPoints( connections );
216 
217  for( wxPoint point : connections )
219  }
220  }
221 
223  }
224  else
225  {
226  // Mark the edges of the block with dangling flags for a move.
227  for( EDA_ITEM* item : selection )
228  static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
229 
230  for( EDA_ITEM* item : selection )
231  static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints );
232  }
233  // Generic setup
234  //
235  for( EDA_ITEM* item : selection )
236  {
237  if( item->IsNew() )
238  {
239  if( item->HasFlag( TEMP_SELECTED ) && m_isDragOperation )
240  {
241  // Item was added in getConnectedDragItems
242  saveCopyInUndoList( (SCH_ITEM*) item, UR_NEW, appendUndo );
243  appendUndo = true;
244  }
245  else
246  {
247  // Item was added in a previous command (and saved to undo by
248  // that command)
249  }
250  }
251  else if( item->GetParent() && item->GetParent()->IsSelected() )
252  {
253  // Item will be (or has been) saved to undo by parent
254  }
255  else
256  {
257  saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, appendUndo );
258  appendUndo = true;
259  }
260 
261  SCH_ITEM* schItem = (SCH_ITEM*) item;
262  schItem->SetStoredPos( schItem->GetPosition() );
263  }
264 
265  // Set up the starting position and move/drag offset
266  //
267  m_cursor = controls->GetCursorPosition();
268 
269  if( evt->IsAction( &EE_ACTIONS::restartMove ) )
270  {
271  wxASSERT_MSG( m_anchorPos, "Should be already set from previous cmd" );
272  }
273  else if( placingNewItems )
274  {
275  m_anchorPos = selection.GetReferencePoint();
276  }
277 
278  if( m_anchorPos )
279  {
280  VECTOR2I delta = m_cursor - (*m_anchorPos);
281 
282  // Drag items to the current cursor position
283  for( EDA_ITEM* item : selection )
284  {
285  // Don't double move pins, fields, etc.
286  if( item->GetParent() && item->GetParent()->IsSelected() )
287  continue;
288 
289  moveItem( item, delta, m_isDragOperation );
290  updateView( item );
291  }
292 
294  }
295  // For some items, moving the cursor to anchor is not good (for instance large
296  // hierarchical sheets or components can have the anchor outside the view)
297  else if( selection.Size() == 1 && sch_item->IsMovableFromAnchorPoint()
299  {
300  if( sch_item->Type() == SCH_LINE_T && !sch_item->HasFlag( STARTPOINT ) )
301  m_anchorPos = static_cast<SCH_LINE*>( sch_item )->GetEndPoint();
302  else
303  m_anchorPos = sch_item->GetPosition();
304 
305  getViewControls()->WarpCursor( *m_anchorPos, true, true );
307  }
308  // ...otherwise modify items with regard to the grid-snapped cursor position
309  else
310  {
313  }
314 
315  controls->SetCursorPosition( m_cursor, false );
317 
318  prevPos = m_cursor;
319  controls->SetAutoPan( true );
320  m_moveInProgress = true;
321  }
322 
323  //------------------------------------------------------------------------
324  // Follow the mouse
325  //
326  m_cursor = controls->GetCursorPosition();
327  VECTOR2I delta( m_cursor - prevPos );
329 
330  m_moveOffset += delta;
331  prevPos = m_cursor;
332 
333  for( EDA_ITEM* item : selection )
334  {
335  // Don't double move pins, fields, etc.
336  if( item->GetParent() && item->GetParent()->IsSelected() )
337  continue;
338 
339  moveItem( item, delta, m_isDragOperation );
340  updateView( item );
341  }
342 
345  }
346  //------------------------------------------------------------------------
347  // Handle cancel
348  //
349  else if( evt->IsCancelInteractive() )
350  {
351  if( m_moveInProgress )
352  restore_state = true;
353 
354  break;
355  }
356  //------------------------------------------------------------------------
357  // Handle TOOL_ACTION special cases
358  //
359  else if( evt->Action() == TA_UNDO_REDO_PRE )
360  {
361  unselect = true;
362  break;
363  }
364  else if( evt->Category() == TC_COMMAND )
365  {
366  if( evt->IsAction( &ACTIONS::doDelete ) )
367  {
368  // Exit on a remove operation; there is no further processing for removed items.
369  break;
370  }
371  else if( evt->IsAction( &ACTIONS::duplicate ) )
372  {
373  if( selection.Front()->IsNew() )
374  {
375  // This doesn't really make sense; we'll just end up dragging a stack of
376  // objects so Duplicate() is going to ignore this and we'll just carry on.
377  continue;
378  }
379 
380  // Move original back and exit. The duplicate will run in its own loop.
381  restore_state = true;
382  unselect = false;
383  chain_commands = true;
384  break;
385  }
386  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
387  {
388  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
390  {
391  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
392  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
393 
394  if( component )
395  {
396  m_frame->SelectUnit( component, unit );
398  }
399  }
400  }
401  }
402  //------------------------------------------------------------------------
403  // Handle context menu
404  //
405  else if( evt->IsClick( BUT_RIGHT ) )
406  {
408  }
409  //------------------------------------------------------------------------
410  // Handle drop
411  //
412  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
413  {
414  break; // Finish
415  }
416  else
417  evt->SetPassEvent();
418 
419  controls->SetAutoPan( m_moveInProgress );
420 
421  } while( ( evt = Wait() ) ); //Should be assignment not equality test
422 
423  controls->ForceCursorPosition( false );
424  controls->ShowCursor( false );
425  controls->SetSnapping( false );
426  controls->SetAutoPan( false );
427 
428  if( !chain_commands )
429  m_moveOffset = { 0, 0 };
430 
431  m_anchorPos.reset();
432 
433  for( EDA_ITEM* item : selection )
434  item->ClearEditFlags();
435 
436  if( restore_state )
437  {
440  }
441  else
442  {
443  // Moving items changes the RTree box bounds.
444  for( auto item : selection )
445  {
446  switch( item->Type() )
447  {
448  // Moving sheet pins does not change the BBox.
449  case SCH_SHEET_PIN_T:
450  break;
451 
452  // Moving fields should update the associated component
453  case SCH_FIELD_T:
454  if( item->GetParent() )
455  m_frame->GetScreen()->Update( static_cast<SCH_ITEM*>( item->GetParent() ) );
456 
457  break;
458 
459  default:
460  m_frame->GetScreen()->Update( static_cast<SCH_ITEM*>( item ) );
461  }
462  }
463 
464  // If we move items away from a junction, we _may_ want to add a junction there
465  // to denote the state.
466  for( auto it : internalPoints )
467  {
468  if( m_frame->GetScreen()->IsJunctionNeeded( it.GetPosition(), true ) )
469  m_frame->AddJunction( it.GetPosition(), true, false );
470  }
471 
472  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
474 
477 
478  m_frame->OnModify();
479  }
480 
481  if( unselect )
483  else
484  m_selectionTool->RebuildSelection(); // Schematic cleanup might have merged lines, etc.
485 
486  m_dragAdditions.clear();
487  m_moveInProgress = false;
488  m_frame->PopTool( tool );
489  return 0;
490 }
491 
492 
494  EDA_ITEMS& aList )
495 {
496  for( auto test : m_frame->GetScreen()->Items() )
497  {
498  if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aOriginalItem ) )
499  continue;
500 
501  KICAD_T testType = test->Type();
502 
503  switch( testType )
504  {
505  case SCH_LINE_T:
506  {
507  // Select the connected end of wires/bus connections.
508  SCH_LINE* testLine = static_cast<SCH_LINE*>( test );
509 
510  if( testLine->GetStartPoint() == aPoint )
511  {
512  if( !testLine->HasFlag( TEMP_SELECTED ) )
513  aList.push_back( testLine );
514 
515  testLine->SetFlags( STARTPOINT | TEMP_SELECTED );
516  }
517  else if( testLine->GetEndPoint() == aPoint )
518  {
519  if( !testLine->HasFlag( TEMP_SELECTED ) )
520  aList.push_back( testLine );
521 
522  testLine->SetFlags( ENDPOINT | TEMP_SELECTED );
523  }
524  break;
525  }
526 
527  case SCH_SHEET_T:
528  // Dragging a sheet just because it's connected to something else feels a bit like
529  // the tail wagging the dog, but this could be moved down to the next case.
530  break;
531 
532  case SCH_COMPONENT_T:
533  if( test->IsConnected( aPoint ) )
534  {
535  // Add a new wire between the component and the selected item so the selected
536  // item can be dragged.
537  SCH_LINE* newWire = new SCH_LINE( aPoint, LAYER_WIRE );
538  newWire->SetFlags( IS_NEW );
539  m_frame->AddToScreen( newWire, m_frame->GetScreen() );
540 
541  newWire->SetFlags( TEMP_SELECTED | STARTPOINT );
542  aList.push_back( newWire );
543  }
544  break;
545 
546  case SCH_NO_CONNECT_T:
547  case SCH_JUNCTION_T:
548  // Select no-connects and junctions that are connected to items being moved.
549  if( !test->HasFlag( TEMP_SELECTED ) && test->IsConnected( aPoint ) )
550  {
551  aList.push_back( test );
552  test->SetFlags( TEMP_SELECTED );
553  }
554 
555  break;
556 
557  case SCH_LABEL_T:
558  case SCH_GLOBAL_LABEL_T:
559  case SCH_HIER_LABEL_T:
561  case SCH_BUS_BUS_ENTRY_T:
562  // Performance optimization:
563  if( test->HasFlag( TEMP_SELECTED ) )
564  break;
565 
566  // Select labels and bus entries that are connected to a wire being moved.
567  if( aOriginalItem->Type() == SCH_LINE_T )
568  {
569  std::vector<wxPoint> connections;
570  test->GetConnectionPoints( connections );
571 
572  for( wxPoint& point : connections )
573  {
574  if( aOriginalItem->HitTest( point ) )
575  {
576  test->SetFlags( TEMP_SELECTED );
577  aList.push_back( test );
578 
579  // A bus entry needs its wire & label as well
580  if( testType == SCH_BUS_WIRE_ENTRY_T || testType == SCH_BUS_BUS_ENTRY_T )
581  {
582  std::vector<wxPoint> ends;
583  wxPoint otherEnd;
584 
585  test->GetConnectionPoints( ends );
586 
587  if( ends[0] == point )
588  otherEnd = ends[1];
589  else
590  otherEnd = ends[0];
591 
592  getConnectedDragItems( (SCH_ITEM*) test, otherEnd, m_dragAdditions );
593  }
594  break;
595  }
596  }
597  }
598 
599  break;
600 
601  default:
602  break;
603  }
604  }
605 }
606 
607 
608 void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta, bool isDrag )
609 {
610  switch( aItem->Type() )
611  {
612  case SCH_LINE_T:
613  if( aItem->HasFlag( STARTPOINT ) )
614  static_cast<SCH_LINE*>( aItem )->MoveStart( (wxPoint) aDelta );
615 
616  if( aItem->HasFlag( ENDPOINT ) )
617  static_cast<SCH_LINE*>( aItem )->MoveEnd( (wxPoint) aDelta );
618 
619  break;
620 
621  case SCH_PIN_T:
622  case SCH_FIELD_T:
623  {
624  SCH_ITEM* parent = (SCH_ITEM*) aItem->GetParent();
625  wxPoint delta( aDelta );
626 
627  if( parent && parent->Type() == SCH_COMPONENT_T )
628  {
629  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem->GetParent();
630  TRANSFORM transform = component->GetTransform().InverseTransform();
631 
632  delta = transform.TransformCoordinate( delta );
633  }
634 
635  static_cast<SCH_ITEM*>( aItem )->Move( delta );
636 
637  // If we're moving a field with respect to its parent then it's no longer auto-placed
638  if( aItem->Type() == SCH_FIELD_T && !parent->IsSelected() )
639  parent->ClearFieldsAutoplaced();
640 
641  break;
642  }
643  case SCH_SHEET_PIN_T:
644  {
645  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem;
646  pin->SetStoredPos( pin->GetStoredPos() + (wxPoint) aDelta );
647  pin->ConstrainOnEdge( pin->GetStoredPos() );
648  break;
649  }
650  default:
651  static_cast<SCH_ITEM*>( aItem )->Move( (wxPoint) aDelta );
652  break;
653  }
654 
655  getView()->Hide( aItem, false );
656  aItem->SetFlags( IS_MOVED );
657 }
658 
659 
661 {
663  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
664  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() );
665 }
static TOOL_ACTION moveActivate
Definition: ee_actions.h:114
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
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:128
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
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
bool IsHover() const
Definition: selection.h:70
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:97
bool IsSelected() const
Definition: base_struct.h:225
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()
Virtual function IsMovableFromAnchorPoint.
Definition: sch_item.h:203
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:335
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:76
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:72
static TOOL_ACTION restartMove
Definition: ee_actions.h:185
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:59
TOOL_MENU & GetToolMenu()
bool IsMotion() const
Definition: tool_event.h:306
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
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
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
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:65
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:69
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:205
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:220
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
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:120
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:332
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint & GetStoredPos()
Definition: sch_item.h:205
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
virtual wxPoint GetPosition() const =0
Function GetPosition.
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 SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
bool GetDragActionIsMove() const
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:603
TRANSFORM & GetTransform() const
boost::optional< VECTOR2I > m_anchorPos
Definition: sch_move_tool.h:78
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:409
EDA_ITEM * GetParent() const
Definition: base_struct.h:217
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
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
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:58
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
bool m_isDragOperation
Definition: sch_move_tool.h:66
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:77
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
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
void SelectUnit(SCH_COMPONENT *aComponent, int aUnit)
Definition: getpart.cpp:204
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
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
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
void moveItem(EDA_ITEM *aItem, VECTOR2I aDelta, bool isDrag)
static TOOL_ACTION drag
Definition: ee_actions.h:116
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
EE_RTREE & Items()
Definition: sch_screen.h:127
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
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:166
bool GetMoveWarpsCursor() const
Indicates that a move operation should warp the mouse pointer to the origin of the move object.
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION move
Definition: ee_actions.h:115
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:231
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool HasFlag(STATUS_FLAGS aFlag)
Definition: base_struct.h:260
#define QUIET_MODE
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
void setTransitions() override
Sets up handlers for various events.
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:267
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
void SetStoredPos(wxPoint aPos)
Definition: sch_item.h:206
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
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:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
virtual void UpdateMsgPanel()
Redraw the message panel.
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125
#define IS_MOVED
Item being moved.
Definition: base_struct.h:119
wxPoint GetEndPoint() const
Definition: sch_line.h:100