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 #define STD_VECTOR_REMOVE( v, item ) v.erase( std::remove( v.begin(), v.end(), item ), v.end() )
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 
111  controls->SetSnapping( true );
112 
113  m_anchorPos.reset();
114 
115  if( aEvent.IsAction( &EE_ACTIONS::move ) )
116  m_isDragOperation = false;
117  else if( aEvent.IsAction( &EE_ACTIONS::drag ) )
118  m_isDragOperation = true;
119  else if( aEvent.IsAction( &EE_ACTIONS::moveActivate ) )
121  else
122  return 0;
123 
124  std::string tool = aEvent.GetCommandStr().get();
125  m_frame->PushTool( tool );
126 
127  if( m_moveInProgress )
128  {
129  auto sel = m_selectionTool->GetSelection().Front();
130 
131  if( sel && !sel->IsNew() )
132  {
133  // User must have switched from move to drag or vice-versa. Reset the selected
134  // items so we can start again with the current m_isDragOperation.
138  m_moveInProgress = false;
139  controls->SetAutoPan( false );
140 
141  // And give it a kick so it doesn't have to wait for the first mouse movement to
142  // refresh.
144  }
145 
146  return 0;
147  }
148 
149  // Be sure that there is at least one item that we can move. If there's no selection try
150  // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
151  EE_SELECTION& selection = m_selectionTool->RequestSelection( movableItems );
152  bool unselect = selection.IsHover();
153 
154  if( selection.Empty() )
155  return 0;
156 
157  Activate();
158  controls->ShowCursor( true );
159 
160  bool restore_state = false;
161  bool chain_commands = false;
162  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
163  VECTOR2I prevPos;
164 
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 
183  //------------------------------------------------------------------------
184  // Setup a drag or a move
185  //
186  for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() )
187  {
188  if( !it->IsSelected() )
189  it->ClearFlags( STARTPOINT | ENDPOINT | SELECTEDNODE );
190 
191  if( !selection.IsHover() && it->IsSelected() )
192  it->SetFlags( STARTPOINT | ENDPOINT );
193  }
194 
195  if( m_isDragOperation )
196  {
197  // Add connections to the selection for a drag.
198  //
199  for( EDA_ITEM* item : selection )
200  {
201  if( static_cast<SCH_ITEM*>( item )->IsConnectable() )
202  {
203  std::vector<wxPoint> connections;
204 
205  if( item->Type() == SCH_LINE_T )
206  static_cast<SCH_LINE*>( item )->GetSelectedPoints( connections );
207  else
208  static_cast<SCH_ITEM*>( item )->GetConnectionPoints( connections );
209 
210  for( wxPoint point : connections )
212  }
213  }
214 
216  }
217  else
218  {
219  // Mark the edges of the block with dangling flags for a move.
220  //
221  std::vector<DANGLING_END_ITEM> internalPoints;
222 
223  for( EDA_ITEM* item : selection )
224  static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
225 
226  for( EDA_ITEM* item : selection )
227  static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints );
228  }
229  // Generic setup
230  //
231  for( EDA_ITEM* item : selection )
232  {
233  if( item->IsNew() )
234  {
235  if( ( item->GetFlags() & SELECTEDNODE ) != 0 && m_isDragOperation )
236  {
237  // Item was added in getConnectedDragItems
238  saveCopyInUndoList( (SCH_ITEM*) item, UR_NEW, appendUndo );
240  appendUndo = true;
241  }
242  else
243  {
244  // Item was added in a previous command (and saved to undo by
245  // that command)
246  }
247  }
248  else if( item->GetParent() && item->GetParent()->IsSelected() )
249  {
250  // Item will be (or has been) saved to undo by parent
251  }
252  else
253  {
254  saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, appendUndo );
255  appendUndo = true;
256  }
257 
258  SCH_ITEM* schItem = (SCH_ITEM*) item;
259  schItem->SetStoredPos( schItem->GetPosition() );
260  }
261 
262  // Set up the starting position and move/drag offset
263  //
264  m_cursor = controls->GetCursorPosition();
265 
266  if( evt->IsAction( &EE_ACTIONS::restartMove ) )
267  {
268  wxASSERT_MSG( m_anchorPos, "Should be already set from previous cmd" );
269  }
270  else if( selection.Front()->GetFlags() & IS_NEW )
271  {
272  m_anchorPos = selection.GetReferencePoint();
273  }
274 
275  if( m_anchorPos )
276  {
277  VECTOR2I delta = m_cursor - (*m_anchorPos);
278 
279  // Drag items to the current cursor position
280  for( EDA_ITEM* item : selection )
281  {
282  // Don't double move pins, fields, etc.
283  if( item->GetParent() && item->GetParent()->IsSelected() )
284  continue;
285 
286  moveItem( item, delta, m_isDragOperation );
287  updateView( item );
288  }
289 
291  }
292  // For some items, moving the cursor to anchor is not good (for instance large
293  // hierarchical sheets or components can have the anchor outside the view)
294  else if( selection.Size() == 1 && sch_item->IsMovableFromAnchorPoint()
296  {
297  if( sch_item->Type() == SCH_LINE_T && !( sch_item->GetFlags() & STARTPOINT ) )
298  m_anchorPos = static_cast<SCH_LINE*>( sch_item )->GetEndPoint();
299  else
300  m_anchorPos = sch_item->GetPosition();
301 
302  getViewControls()->WarpCursor( *m_anchorPos, true, true );
304  }
305  // ...otherwise modify items with regard to the grid-snapped cursor position
306  else
307  {
310  }
311 
312  controls->SetCursorPosition( m_cursor, false );
314 
315  prevPos = m_cursor;
316  controls->SetAutoPan( true );
317  m_moveInProgress = true;
318  }
319 
320  //------------------------------------------------------------------------
321  // Follow the mouse
322  //
323  m_cursor = controls->GetCursorPosition();
324  VECTOR2I delta( m_cursor - prevPos );
326 
327  m_moveOffset += delta;
328  prevPos = m_cursor;
329 
330  for( EDA_ITEM* item : selection )
331  {
332  // Don't double move pins, fields, etc.
333  if( item->GetParent() && item->GetParent()->IsSelected() )
334  continue;
335 
336  moveItem( item, delta, m_isDragOperation );
337  updateView( item );
338  }
339 
342  }
343  //------------------------------------------------------------------------
344  // Handle cancel
345  //
346  else if( evt->IsCancelInteractive() )
347  {
348  if( m_moveInProgress )
349  restore_state = true;
350 
351  break;
352  }
353  //------------------------------------------------------------------------
354  // Handle TOOL_ACTION special cases
355  //
356  else if( evt->Action() == TA_UNDO_REDO_PRE )
357  {
358  unselect = true;
359  break;
360  }
361  else if( evt->Category() == TC_COMMAND )
362  {
363  if( evt->IsAction( &ACTIONS::doDelete ) )
364  {
365  // Exit on a remove operation; there is no further processing for removed items.
366  break;
367  }
368  else if( evt->IsAction( &ACTIONS::duplicate ) )
369  {
370  if( selection.Front()->IsNew() )
371  {
372  // This doesn't really make sense; we'll just end up dragging a stack of
373  // objects so Duplicate() is going to ignore this and we'll just carry on.
374  continue;
375  }
376 
377  // Move original back and exit. The duplicate will run in its own loop.
378  restore_state = true;
379  unselect = false;
380  chain_commands = true;
381  break;
382  }
383  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
384  {
385  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
387  {
388  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( selection.Front() );
389  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
390 
391  if( component )
392  {
393  m_frame->SelectUnit( component, unit );
395  }
396  }
397  }
398  }
399  //------------------------------------------------------------------------
400  // Handle context menu
401  //
402  else if( evt->IsClick( BUT_RIGHT ) )
403  {
405  }
406  //------------------------------------------------------------------------
407  // Handle drop
408  //
409  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
410  {
411  break; // Finish
412  }
413  else
414  evt->SetPassEvent();
415 
416  controls->SetAutoPan( m_moveInProgress );
417 
418  } while( ( evt = Wait() ) ); //Should be assignment not equality test
419 
420  controls->ForceCursorPosition( false );
421  controls->ShowCursor( false );
422  controls->SetSnapping( false );
423  controls->SetAutoPan( false );
424 
425  if( !chain_commands )
426  m_moveOffset = { 0, 0 };
427 
428  m_anchorPos.reset();
429 
430  for( EDA_ITEM* item : selection )
431  item->ClearEditFlags();
432 
433  if( restore_state )
434  {
436 
437  if( unselect )
439  else
441  }
442  else
443  {
444  m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
447 
448  if( unselect )
450  else
452 
453  m_frame->OnModify();
454  }
455 
456  m_dragAdditions.clear();
457  m_moveInProgress = false;
458  m_frame->PopTool( tool );
459  return 0;
460 }
461 
462 
463 void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoint,
464  EDA_ITEMS& aList )
465 {
466  for( SCH_ITEM* test = m_frame->GetScreen()->GetDrawItems(); test; test = test->Next() )
467  {
468  if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aOriginalItem ) )
469  continue;
470 
471  switch( test->Type() )
472  {
473  case SCH_LINE_T:
474  {
475  // Select the connected end of wires/bus connections.
476  SCH_LINE* testLine = (SCH_LINE*) test;
477 
478  if( testLine->GetStartPoint() == aPoint )
479  {
480  if( !( testLine->GetFlags() & SELECTEDNODE ) )
481  aList.push_back( testLine );
482 
483  testLine->SetFlags( STARTPOINT | SELECTEDNODE );
484  }
485  else if( testLine->GetEndPoint() == aPoint )
486  {
487  if( !( testLine->GetFlags() & SELECTEDNODE ) )
488  aList.push_back( testLine );
489 
490  testLine->SetFlags( ENDPOINT | SELECTEDNODE );
491  }
492  break;
493  }
494 
495  case SCH_SHEET_T:
496  // Dragging a sheet just because it's connected to something else feels a bit like
497  // the tail wagging the dog, but this could be moved down to the next case.
498  break;
499 
500  case SCH_COMPONENT_T:
501  if( test->IsConnected( aPoint ) )
502  {
503  // Add a new wire between the component and the selected item so the selected
504  // item can be dragged.
505  SCH_LINE* newWire = new SCH_LINE( aPoint, LAYER_WIRE );
506  newWire->SetFlags( IS_NEW );
507  m_frame->AddToScreen( newWire, m_frame->GetScreen() );
508 
509  newWire->SetFlags( SELECTEDNODE | STARTPOINT );
510  aList.push_back( newWire );
511  }
512  break;
513 
514  case SCH_NO_CONNECT_T:
515  case SCH_JUNCTION_T:
516  // Select no-connects and junctions that are connected to items being moved.
517  if( test->IsConnected( aPoint ) )
518  aList.push_back( test );
519 
520  break;
521 
522  case SCH_LABEL_T:
523  case SCH_GLOBAL_LABEL_T:
524  case SCH_HIER_LABEL_T:
526  case SCH_BUS_BUS_ENTRY_T:
527  // Select labels and bus entries that are connected to a wire being moved.
528  if( aOriginalItem->Type() == SCH_LINE_T )
529  {
530  std::vector<wxPoint> connections;
531  test->GetConnectionPoints( connections );
532 
533  for( wxPoint& point : connections )
534  {
535  if( aOriginalItem->HitTest( point ) )
536  aList.push_back( test );
537  }
538  }
539  break;
540 
541  default:
542  break;
543  }
544  }
545 }
546 
547 
548 void SCH_MOVE_TOOL::moveItem( EDA_ITEM* aItem, VECTOR2I aDelta, bool isDrag )
549 {
550  switch( aItem->Type() )
551  {
552  case SCH_LINE_T:
553  if( aItem->GetFlags() & STARTPOINT )
554  static_cast<SCH_LINE*>( aItem )->MoveStart( (wxPoint) aDelta );
555 
556  if( aItem->GetFlags() & ENDPOINT )
557  static_cast<SCH_LINE*>( aItem )->MoveEnd( (wxPoint) aDelta );
558 
559  break;
560 
561  case SCH_PIN_T:
562  case SCH_FIELD_T:
563  {
564  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem->GetParent();
565  TRANSFORM transform = component->GetTransform().InverseTransform();
566  wxPoint transformedDelta = transform.TransformCoordinate( (wxPoint) aDelta );
567 
568  static_cast<SCH_ITEM*>( aItem )->Move( transformedDelta );
569  break;
570  }
571  case SCH_SHEET_PIN_T:
572  {
573  SCH_SHEET_PIN* pin = (SCH_SHEET_PIN*) aItem;
574  pin->SetStoredPos( pin->GetStoredPos() + (wxPoint) aDelta );
575  pin->ConstrainOnEdge( pin->GetStoredPos() );
576  break;
577  }
578  default:
579  static_cast<SCH_ITEM*>( aItem )->Move( (wxPoint) aDelta );
580  break;
581  }
582 
583  aItem->SetFlags( IS_MOVED );
584 }
585 
586 
588 {
590  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::move.MakeEvent() );
591  Go( &SCH_MOVE_TOOL::Main, EE_ACTIONS::drag.MakeEvent() );
592 }
static TOOL_ACTION moveActivate
Definition: ee_actions.h:114
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
OPT< int > GetCommandId() const
Definition: tool_event.h:450
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 ...
static const TOOL_EVENT SelectedEvent
Definition: actions.h:196
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
bool IsHover() const
Definition: selection.h:69
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:90
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:172
static TOOL_ACTION doDelete
Definition: actions.h:73
SCH_ITEM * Next() const
Definition: sch_item.h:153
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:247
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:174
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:219
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:58
#define SELECTEDNODE
flag indicating that the structure has already selected
Definition: base_struct.h:128
TOOL_MENU & GetToolMenu()
bool IsMotion() const
Definition: tool_event.h:303
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:109
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:244
#define STD_VECTOR_REMOVE(v, item)
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:200
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
bool IsNew() const
Definition: base_struct.h:228
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:63
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:339
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPoint & GetStoredPos()
Definition: sch_item.h:174
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:293
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
bool GetDragActionIsMove() const
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:622
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.
Class TOOL_EVENT.
Definition: tool_event.h:168
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
void SetPassEvent()
Definition: tool_event.h:253
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
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:75
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:298
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:186
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:206
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:334
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:455
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:37
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.
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
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
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
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
Class 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...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
#define QUIET_MODE
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:267
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:228
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
void SetStoredPos(wxPoint aPos)
Definition: sch_item.h:175
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION duplicate
Definition: actions.h:72
static TOOL_ACTION refreshPreview
Definition: actions.h:100
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false)=0
Moves cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:182
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
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
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:147
wxPoint GetEndPoint() const
Definition: sch_line.h:93