KiCad PCB EDA Suite
pl_edit_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>
26 #include <tool/picker_tool.h>
30 #include <bitmaps.h>
31 #include <confirm.h>
32 #include <eda_item.h>
33 #include <view/view.h>
34 #include <math/util.h> // for KiROUND
35 
37 #include "tools/pl_actions.h"
38 #include "tools/pl_edit_tool.h"
39 #include "pl_draw_panel_gal.h"
40 #include "pl_editor_frame.h"
41 #include "pl_editor_id.h"
42 
44  TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ),
45  m_frame( nullptr ),
46  m_selectionTool( nullptr ),
47  m_moveInProgress( false ),
48  m_moveOffset( 0, 0 ),
49  m_cursor( 0, 0 ),
50  m_pickerItem( nullptr )
51 {
52 }
53 
54 
56 {
57  m_frame = getEditFrame<PL_EDITOR_FRAME>();
59 
60  wxASSERT_MSG( m_selectionTool, "plEditor.InteractiveSelection tool is not available" );
61 
62  CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
63 
64  // cancel current tool goes in main context menu at the top if present
66 
67  ctxMenu.AddSeparator( 200 );
69 
70  // Finally, add the standard zoom/grid items
72 
73  //
74  // Add editing actions to the selection tool menu
75  //
77 
79 
80  selToolMenu.AddSeparator( 250 );
85 
86  return true;
87 }
88 
89 
91 {
92  if( aReason == MODEL_RELOAD )
93  m_frame = getEditFrame<PL_EDITOR_FRAME>();
94 }
95 
96 
97 int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
98 {
100 
101  VECTOR2I originalCursorPos = controls->GetCursorPosition();
102 
103  // Be sure that there is at least one item that we can move. If there's no selection try
104  // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
106  bool unselect = selection.IsHover();
107 
108  if( selection.Empty() || m_moveInProgress )
109  return 0;
110 
111  std::set<DS_DATA_ITEM*> unique_peers;
112 
113  for( EDA_ITEM* item : selection )
114  {
115  DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( item );
116  unique_peers.insert( drawItem->GetPeer() );
117  }
118 
119  std::string tool = aEvent.GetCommandStr().get();
120  m_frame->PushTool( tool );
121  Activate();
122 
123  controls->ShowCursor( true );
124  controls->SetAutoPan( true );
125 
126  bool restore_state = false;
127  bool chain_commands = false;
128  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
129  VECTOR2I prevPos;
130 
131  if( !selection.Front()->IsNew() )
133 
134  // Main loop: keep receiving events
135  do
136  {
138 
139  if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
140  || evt->IsAction( &ACTIONS::refreshPreview ) )
141  {
142  //------------------------------------------------------------------------
143  // Start a move operation
144  //
145  if( !m_moveInProgress )
146  {
147  // Apply any initial offset in case we're coming from a previous command.
148  //
149  for( DS_DATA_ITEM* item : unique_peers )
150  moveItem( item, m_moveOffset );
151 
152  // Set up the starting position and move/drag offset
153  //
154  m_cursor = controls->GetCursorPosition();
155 
156  if( selection.HasReferencePoint() )
157  {
158  VECTOR2I delta = m_cursor - selection.GetReferencePoint();
159 
160  // Drag items to the current cursor position
161  for( DS_DATA_ITEM* item : unique_peers )
162  moveItem( item, delta );
163 
164  selection.SetReferencePoint( m_cursor );
165  }
166  else if( selection.Size() == 1 )
167  {
168  // Set the current cursor position to the first dragged item origin,
169  // so the movement vector can be computed later
170  updateModificationPoint( selection );
171  m_cursor = originalCursorPos;
172  }
173  else
174  {
175  updateModificationPoint( selection );
176  }
177 
178  controls->SetCursorPosition( m_cursor, false );
179 
180  prevPos = m_cursor;
181  controls->SetAutoPan( true );
182  m_moveInProgress = true;
183  }
184 
185  //------------------------------------------------------------------------
186  // Follow the mouse
187  //
188  m_cursor = controls->GetCursorPosition();
189  VECTOR2I delta( m_cursor - prevPos );
190  selection.SetReferencePoint( m_cursor );
191 
192  m_moveOffset += delta;
193  prevPos = m_cursor;
194 
195  for( DS_DATA_ITEM* item : unique_peers )
196  moveItem( item, delta );
197 
199  }
200  //------------------------------------------------------------------------
201  // Handle cancel
202  //
203  else if( evt->IsCancelInteractive() || evt->IsActivate() )
204  {
205  if( m_moveInProgress )
206  {
207  evt->SetPassEvent( false );
208  restore_state = true;
209  }
210 
211  break;
212  }
213  //------------------------------------------------------------------------
214  // Handle TOOL_ACTION special cases
215  //
216  else if( evt->Action() == TA_UNDO_REDO_PRE )
217  {
218  unselect = true;
219  break;
220  }
221  else if( evt->Category() == TC_COMMAND )
222  {
223  if( evt->IsAction( &ACTIONS::doDelete ) )
224  {
225  // Exit on a remove operation; there is no further processing for removed items.
226  break;
227  }
228  }
229  //------------------------------------------------------------------------
230  // Handle context menu
231  //
232  else if( evt->IsClick( BUT_RIGHT ) )
233  {
235  }
236  //------------------------------------------------------------------------
237  // Handle drop
238  //
239  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
240  {
241  break; // Finish
242  }
243  else
244  evt->SetPassEvent();
245 
246  } while( ( evt = Wait() ) ); //Should be assignment not equality test
247 
248  controls->ForceCursorPosition( false );
249  controls->ShowCursor( false );
250  controls->SetAutoPan( false );
251 
252  if( !chain_commands )
253  m_moveOffset = { 0, 0 };
254 
255  selection.ClearReferencePoint();
256 
257  for( auto item : selection )
258  item->ClearEditFlags();
259 
260  if( unselect )
262 
263  if( restore_state )
265  else
266  m_frame->OnModify();
267 
268  m_moveInProgress = false;
269  m_frame->PopTool( tool );
270  return 0;
271 }
272 
273 
275 {
276  aItem->MoveToUi( aItem->GetStartPosUi() + (wxPoint) aDelta );
277 
278  for( DS_DRAW_ITEM_BASE* item : aItem->GetDrawItems() )
279  {
280  getView()->Update( item );
281  item->SetFlags( IS_MOVED );
282  }
283 }
284 
285 
287 {
288  if( m_moveInProgress && aSelection.HasReferencePoint() )
289  return false;
290 
291  // When there is only one item selected, the reference point is its position...
292  if( aSelection.Size() == 1 )
293  {
294  aSelection.SetReferencePoint( aSelection.Front()->GetPosition() );
295  }
296  // ...otherwise modify items with regard to the grid-snapped cursor position
297  else
298  {
300  aSelection.SetReferencePoint( m_cursor );
301  }
302 
303  return true;
304 }
305 
306 
308 {
310 
311  wxCommandEvent evt( wxEVT_NULL, ID_APPEND_DESCR_FILE );
312  m_frame->Files_io( evt );
313 
314  return 0;
315 }
316 
317 
318 int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
319 {
321 
322  if( selection.Size() == 0 )
323  return 0;
324 
326 
327  while( selection.Front() )
328  {
329  DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() );
330  DS_DATA_ITEM* dataItem = drawItem->GetPeer();
332 
333  for( DS_DRAW_ITEM_BASE* item : dataItem->GetDrawItems() )
334  {
335  // Note: repeat items won't be selected but must be removed & deleted
336 
337  if( item->IsSelected() )
339 
340  getView()->Remove( item );
341  }
342 
343  delete dataItem;
344  }
345 
346  m_frame->OnModify();
347 
348  return 0;
349 }
350 
351 
352 #define HITTEST_THRESHOLD_PIXELS 5
353 
354 
356 {
357  std::string tool = aEvent.GetCommandStr().get();
359 
360  // Deactivate other tools; particularly important if another PICKER is currently running
361  Activate();
362 
363  picker->SetCursor( KICURSOR::REMOVE );
364  m_pickerItem = nullptr;
365 
366  picker->SetClickHandler(
367  [this] ( const VECTOR2D& aPosition ) -> bool
368  {
369  if( m_pickerItem )
370  {
372  selectionTool->UnbrightenItem( m_pickerItem );
373  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
375  m_pickerItem = nullptr;
376  }
377 
378  return true;
379  } );
380 
381  picker->SetMotionHandler(
382  [this] ( const VECTOR2D& aPos )
383  {
384  int threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
385  EDA_ITEM* item = nullptr;
386 
387  for( DS_DATA_ITEM* dataItem : DS_DATA_MODEL::GetTheInstance().GetItems() )
388  {
389  for( DS_DRAW_ITEM_BASE* drawItem : dataItem->GetDrawItems() )
390  {
391  if( drawItem->HitTest( (wxPoint) aPos, threshold ) )
392  {
393  item = drawItem;
394  break;
395  }
396  }
397  }
398 
399  if( m_pickerItem != item )
400  {
402 
403  if( m_pickerItem )
404  selectionTool->UnbrightenItem( m_pickerItem );
405 
406  m_pickerItem = item;
407 
408  if( m_pickerItem )
409  selectionTool->BrightenItem( m_pickerItem );
410  }
411  } );
412 
413  picker->SetFinalizeHandler(
414  [this] ( const int& aFinalState )
415  {
416  if( m_pickerItem )
418 
419  // Wake the selection tool after exiting to ensure the cursor gets updated
421  } );
422 
423  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
424 
425  return 0;
426 }
427 
428 
429 int PL_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
430 {
432  return 0;
433 }
434 
435 
436 int PL_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
437 {
439  return 0;
440 }
441 
442 
443 int PL_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
444 {
445  int retVal = Copy( aEvent );
446 
447  if( retVal == 0 )
448  retVal = DoDelete( aEvent );
449 
450  return retVal;
451 }
452 
453 
454 int PL_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
455 {
457  std::vector<DS_DATA_ITEM*> items;
459  wxString sexpr;
460 
461  if( selection.GetSize() == 0 )
462  return 0;
463 
464  for( EDA_ITEM* item : selection.GetItems() )
465  items.push_back( static_cast<DS_DRAW_ITEM_BASE*>( item )->GetPeer() );
466 
467  try
468  {
469  model.SaveInString( items, sexpr );
470  }
471  catch( const IO_ERROR& ioe )
472  {
473  wxMessageBox( ioe.What(), _( "Error writing objects to clipboard" ) );
474  }
475 
476  if( m_toolMgr->SaveClipboard( TO_UTF8( sexpr ) ) )
477  return 0;
478  else
479  return -1;
480 }
481 
482 
483 int PL_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
484 {
485  PL_SELECTION& selection = m_selectionTool->GetSelection();
487  std::string sexpr = m_toolMgr->GetClipboardUTF8();
488 
490 
491  model.SetPageLayout( sexpr.c_str(), true, wxT( "clipboard" ) );
492 
493  // Build out draw items and select the first of each data item
494  for( DS_DATA_ITEM* dataItem : model.GetItems() )
495  {
496  if( dataItem->GetDrawItems().empty() )
497  {
498  dataItem->SyncDrawItems( nullptr, getView() );
499  dataItem->GetDrawItems().front()->SetSelected();
500  }
501  }
502 
504 
505  if( !selection.Empty() )
506  {
507  selection.SetReferencePoint( selection.GetTopLeftItem()->GetPosition() );
509  }
510 
511  return 0;
512 }
513 
514 
516 {
517  Go( &PL_EDIT_TOOL::Main, PL_ACTIONS::move.MakeEvent() );
518 
520 
521  Go( &PL_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
522  Go( &PL_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
523 
524  Go( &PL_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
525  Go( &PL_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
526  Go( &PL_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
528 
530 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:38
void RebuildSelection()
Rebuild the selection from the flags in the view items.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
bool IsHover() const
Definition: selection.h:72
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetPassEvent(bool aPass=true)
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:257
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
bool updateModificationPoint(PL_SELECTION &aSelection)
Set up handlers for various events.
Model changes (required full reload)
Definition: tool_base.h:81
int DeleteItemCursor(const TOOL_EVENT &aEvent)
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:75
int Paste(const TOOL_EVENT &aEvent)
PL_SELECTION_TOOL * m_selectionTool
Flag determining if anything is being dragged right now.
Definition: pl_edit_tool.h:80
TOOL_ACTIONS Action() const
These give a tool a method of informing the TOOL_MANAGER that a particular event should be passed on ...
Definition: tool_event.h:251
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:181
void BrightenItem(EDA_ITEM *aItem)
int Cut(const TOOL_EVENT &aEvent)
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
int ClearSelection(const TOOL_EVENT &aEvent)
TOOL_MENU & GetToolMenu()
bool IsMotion() const
Definition: tool_event.h:316
void moveItem(DS_DATA_ITEM *aItem, VECTOR2I aDelta)
Return the right modification point (e.g.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
VECTOR2I m_cursor
Definition: pl_edit_tool.h:90
void GetLayoutFromRedoList()
Redo the last edit:
std::vector< DS_DATA_ITEM * > & GetItems()
static TOOL_ACTION move
Definition: pl_actions.h:69
TOOL_EVENT_CATEGORY Category() const
Returns more specific information about the type of an event.
Definition: tool_event.h:248
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.
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:100
virtual wxPoint GetPosition() const
Definition: eda_item.h:301
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
int AddItemToSel(const TOOL_EVENT &aEvent)
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
PL_SELECTION & GetSelection()
Return the set of currently selected items.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
bool IsCancelInteractive() const
Indicate the event should restart/end an ongoing interactive tool's event loop (eg esc key,...
Definition: tool_event.cpp:193
bool Init() override
Init() is called once upon a registration of the tool.
EDA_ITEM * m_pickerItem
Definition: pl_edit_tool.h:92
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:70
static TOOL_ACTION pickerTool
Definition: actions.h:158
void OnModify()
Must be called after a change in order to set the "modify" flag.
int Main(const TOOL_EVENT &aEvent)
The "move" event loop.
Base class to handle basic graphic items.
Definition: ds_draw_item.h:58
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: pl_actions.h:44
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:264
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:306
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
virtual void PopTool(const std::string &actionName)
VECTOR2I m_moveOffset
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: pl_edit_tool.h:86
std::string GetClipboardUTF8() const
Return the information currently stored in the system clipboard.
Generic, UI-independent tool event.
Definition: tool_event.h:173
int Undo(const TOOL_EVENT &aEvent)
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:80
PL_EDITOR_FRAME * m_frame
Definition: pl_edit_tool.h:79
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:133
static TOOL_ACTION cut
Definition: actions.h:69
An interface for classes handling user events controlling the view behavior such as zooming,...
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems() const
Definition: ds_data_item.h:111
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
int Copy(const TOOL_EVENT &aEvent)
bool m_moveInProgress
Used for chaining commands.
Definition: pl_edit_tool.h:83
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:311
#define IS_MOVED
Item being moved.
Definition: eda_item.h:105
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void SaveInString(wxString &aOutputString)
Save the description in a buffer.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
static TOOL_ACTION clearSelection
Clear the current selection.
Definition: pl_actions.h:47
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:60
#define HITTEST_THRESHOLD_PIXELS
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:69
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
static TOOL_ACTION redo
Definition: actions.h:68
void SetPageLayout(const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
Populate the list from a S expr description stored in a string.
int DoDelete(const TOOL_EVENT &aEvent)
Delete the selected items, or the item under the cursor.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
DS_DATA_ITEM * GetPeer() const
Definition: ds_draw_item.h:63
bool IsActivate() const
Definition: tool_event.h:331
bool HasReferencePoint() const
Definition: selection.h:254
int ImportWorksheetContent(const TOOL_EVENT &aEvent)
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
#define _(s)
Definition: 3d_actions.cpp:33
void UnbrightenItem(EDA_ITEM *aItem)
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
static TOOL_ACTION appendImportedWorksheet
Definition: pl_actions.h:66
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
void Activate()
Run the tool.
void MoveToUi(wxPoint aPosition)
Move item to a new position.
static TOOL_ACTION deleteTool
Definition: actions.h:76
static TOOL_ACTION undo
Definition: actions.h:67
void Remove(DS_DATA_ITEM *aItem)
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
void RollbackFromUndo()
Apply the last command in Undo List without stacking a Redo.
void PostEvent(const TOOL_EVENT &aEvent)
Put 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)
Add a menu entry to run a TOOL_ACTION on selected items.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
void GetLayoutFromUndoList()
Undo the last edit:
static TOOL_ACTION paste
Definition: actions.h:71
PL_SELECTION & RequestSelection()
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
static TOOL_ACTION refreshPreview
Definition: actions.h:109
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:203
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1508
const wxPoint GetStartPosUi(int ii=0) const
int Redo(const TOOL_EVENT &aEvent)
void Files_io(wxCommandEvent &event)