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-2021 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 <macros.h>
34 #include <view/view.h>
35 #include <math/util.h> // for KiROUND
36 
38 #include "tools/pl_actions.h"
39 #include "tools/pl_edit_tool.h"
40 #include "pl_draw_panel_gal.h"
41 #include "pl_editor_frame.h"
42 #include "pl_editor_id.h"
43 
45  TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ),
46  m_frame( nullptr ),
47  m_selectionTool( nullptr ),
48  m_moveInProgress( false ),
49  m_moveOffset( 0, 0 ),
50  m_cursor( 0, 0 ),
51  m_pickerItem( nullptr )
52 {
53 }
54 
55 
57 {
58  m_frame = getEditFrame<PL_EDITOR_FRAME>();
60 
61  wxASSERT_MSG( m_selectionTool, "plEditor.InteractiveSelection tool is not available" );
62 
63  CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
64 
65  // cancel current tool goes in main context menu at the top if present
67 
68  ctxMenu.AddSeparator( 200 );
70 
71  // Finally, add the standard zoom/grid items
73 
74  //
75  // Add editing actions to the selection tool menu
76  //
78 
80 
81  selToolMenu.AddSeparator( 250 );
86 
87  return true;
88 }
89 
90 
92 {
93  if( aReason == MODEL_RELOAD )
94  m_frame = getEditFrame<PL_EDITOR_FRAME>();
95 }
96 
97 
98 int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
99 {
101 
102  VECTOR2I originalCursorPos = controls->GetCursorPosition();
103 
104  // Be sure that there is at least one item that we can move. If there's no selection try
105  // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
107  bool unselect = selection.IsHover();
108 
109  if( selection.Empty() || m_moveInProgress )
110  return 0;
111 
112  std::set<DS_DATA_ITEM*> unique_peers;
113 
114  for( EDA_ITEM* item : selection )
115  {
116  DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( item );
117  unique_peers.insert( drawItem->GetPeer() );
118  }
119 
120  std::string tool = aEvent.GetCommandStr().get();
121  m_frame->PushTool( tool );
122 
123  Activate();
124  // Must be done after Activate() so that it gets set into the correct context
125  controls->ShowCursor( true );
126  controls->SetAutoPan( true );
127 
128  bool restore_state = false;
129  bool chain_commands = false;
130  TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
131  VECTOR2I prevPos;
132 
133  if( !selection.Front()->IsNew() )
135 
136  // Main loop: keep receiving events
137  do
138  {
140 
141  if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
142  || evt->IsAction( &ACTIONS::refreshPreview ) )
143  {
144  //------------------------------------------------------------------------
145  // Start a move operation
146  //
147  if( !m_moveInProgress )
148  {
149  // Apply any initial offset in case we're coming from a previous command.
150  //
151  for( DS_DATA_ITEM* item : unique_peers )
152  moveItem( item, m_moveOffset );
153 
154  // Set up the starting position and move/drag offset
155  //
156  m_cursor = controls->GetCursorPosition();
157 
158  if( selection.HasReferencePoint() )
159  {
160  VECTOR2I delta = m_cursor - selection.GetReferencePoint();
161 
162  // Drag items to the current cursor position
163  for( DS_DATA_ITEM* item : unique_peers )
164  moveItem( item, delta );
165 
166  selection.SetReferencePoint( m_cursor );
167  }
168  else if( selection.Size() == 1 )
169  {
170  // Set the current cursor position to the first dragged item origin,
171  // so the movement vector can be computed later
172  updateModificationPoint( selection );
173  m_cursor = originalCursorPos;
174  }
175  else
176  {
177  updateModificationPoint( selection );
178  }
179 
180  controls->SetCursorPosition( m_cursor, false );
181 
182  prevPos = m_cursor;
183  controls->SetAutoPan( true );
184  m_moveInProgress = true;
185  }
186 
187  //------------------------------------------------------------------------
188  // Follow the mouse
189  //
190  m_cursor = controls->GetCursorPosition();
191  VECTOR2I delta( m_cursor - prevPos );
192  selection.SetReferencePoint( m_cursor );
193 
194  m_moveOffset += delta;
195  prevPos = m_cursor;
196 
197  for( DS_DATA_ITEM* item : unique_peers )
198  moveItem( item, delta );
199 
201  }
202  //------------------------------------------------------------------------
203  // Handle cancel
204  //
205  else if( evt->IsCancelInteractive() || evt->IsActivate() )
206  {
207  if( evt->IsCancelInteractive() )
208  m_frame->GetInfoBar()->Dismiss();
209 
210  if( m_moveInProgress )
211  {
212  if( evt->IsActivate() )
213  {
214  // Allowing other tools to activate during a move runs the risk of race
215  // conditions in which we try to spool up both event loops at once.
216 
217  m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel move." ) );
218 
219  evt->SetPassEvent( false );
220  continue;
221  }
222 
223  evt->SetPassEvent( false );
224  restore_state = true;
225  }
226 
227  break;
228  }
229  //------------------------------------------------------------------------
230  // Handle TOOL_ACTION special cases
231  //
232  else if( evt->Action() == TA_UNDO_REDO_PRE )
233  {
234  unselect = true;
235  break;
236  }
237  else if( evt->IsAction( &ACTIONS::doDelete ) )
238  {
239  evt->SetPassEvent();
240  // Exit on a delete; there will no longer be anything to drag.
241  break;
242  }
243  else if( evt->IsAction( &ACTIONS::duplicate ) )
244  {
245  if( selection.Front()->IsNew() )
246  {
247  // This doesn't really make sense; we'll just end up dragging a stack of
248  // objects so we ignore the duplicate and just carry on.
249  continue;
250  }
251 
252  // Move original back and exit. The duplicate will run in its own loop.
253  restore_state = true;
254  unselect = false;
255  chain_commands = true;
256  break;
257  }
258  //------------------------------------------------------------------------
259  // Handle context menu
260  //
261  else if( evt->IsClick( BUT_RIGHT ) )
262  {
264  }
265  //------------------------------------------------------------------------
266  // Handle drop
267  //
268  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
269  {
270  break; // Finish
271  }
272  else
273  {
274  evt->SetPassEvent();
275  }
276 
277  controls->SetAutoPan( m_moveInProgress );
278 
279  } while( ( evt = Wait() ) ); //Should be assignment not equality test
280 
281  controls->ForceCursorPosition( false );
282  controls->ShowCursor( false );
283  controls->SetAutoPan( false );
284 
285  if( !chain_commands )
286  m_moveOffset = { 0, 0 };
287 
288  selection.ClearReferencePoint();
289 
290  for( EDA_ITEM* item : selection )
291  item->ClearEditFlags();
292 
293  if( restore_state )
295  else
296  m_frame->OnModify();
297 
298  if( unselect )
300  else
302 
303  m_moveInProgress = false;
304  m_frame->PopTool( tool );
305  return 0;
306 }
307 
308 
309 void PL_EDIT_TOOL::moveItem( DS_DATA_ITEM* aItem, const VECTOR2I& aDelta )
310 {
311  aItem->MoveToUi( aItem->GetStartPosUi() + (wxPoint) aDelta );
312 
313  for( DS_DRAW_ITEM_BASE* item : aItem->GetDrawItems() )
314  {
315  getView()->Update( item );
316  item->SetFlags( IS_MOVING );
317  }
318 }
319 
320 
322 {
323  if( m_moveInProgress && aSelection.HasReferencePoint() )
324  return false;
325 
326  // When there is only one item selected, the reference point is its position...
327  if( aSelection.Size() == 1 )
328  {
329  aSelection.SetReferencePoint( aSelection.Front()->GetPosition() );
330  }
331  // ...otherwise modify items with regard to the grid-snapped cursor position
332  else
333  {
335  aSelection.SetReferencePoint( m_cursor );
336  }
337 
338  return true;
339 }
340 
341 
343 {
345 
346  wxCommandEvent evt( wxEVT_NULL, ID_APPEND_DESCR_FILE );
347  m_frame->Files_io( evt );
348 
349  return 0;
350 }
351 
352 
353 int PL_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent )
354 {
356 
357  if( selection.Size() == 0 )
358  return 0;
359 
361 
362  while( selection.Front() )
363  {
364  DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() );
365  DS_DATA_ITEM* dataItem = drawItem->GetPeer();
367 
368  for( DS_DRAW_ITEM_BASE* item : dataItem->GetDrawItems() )
369  {
370  // Note: repeat items won't be selected but must be removed & deleted
371 
372  if( item->IsSelected() )
374 
375  getView()->Remove( item );
376  }
377 
378  delete dataItem;
379  }
380 
381  m_frame->OnModify();
382 
383  return 0;
384 }
385 
386 
387 #define HITTEST_THRESHOLD_PIXELS 5
388 
389 
391 {
392  std::string tool = aEvent.GetCommandStr().get();
394 
395  // Deactivate other tools; particularly important if another PICKER is currently running
396  Activate();
397 
398  picker->SetCursor( KICURSOR::REMOVE );
399  m_pickerItem = nullptr;
400 
401  picker->SetClickHandler(
402  [this] ( const VECTOR2D& aPosition ) -> bool
403  {
404  if( m_pickerItem )
405  {
407  selectionTool->UnbrightenItem( m_pickerItem );
408  selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
410  m_pickerItem = nullptr;
411  }
412 
413  return true;
414  } );
415 
416  picker->SetMotionHandler(
417  [this] ( const VECTOR2D& aPos )
418  {
419  int threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
420  EDA_ITEM* item = nullptr;
421 
422  for( DS_DATA_ITEM* dataItem : DS_DATA_MODEL::GetTheInstance().GetItems() )
423  {
424  for( DS_DRAW_ITEM_BASE* drawItem : dataItem->GetDrawItems() )
425  {
426  if( drawItem->HitTest( (wxPoint) aPos, threshold ) )
427  {
428  item = drawItem;
429  break;
430  }
431  }
432  }
433 
434  if( m_pickerItem != item )
435  {
437 
438  if( m_pickerItem )
439  selectionTool->UnbrightenItem( m_pickerItem );
440 
441  m_pickerItem = item;
442 
443  if( m_pickerItem )
444  selectionTool->BrightenItem( m_pickerItem );
445  }
446  } );
447 
448  picker->SetFinalizeHandler(
449  [this] ( const int& aFinalState )
450  {
451  if( m_pickerItem )
453 
454  // Wake the selection tool after exiting to ensure the cursor gets updated
456  } );
457 
458  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
459 
460  return 0;
461 }
462 
463 
464 int PL_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
465 {
467  return 0;
468 }
469 
470 
471 int PL_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
472 {
474  return 0;
475 }
476 
477 
478 int PL_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
479 {
480  int retVal = Copy( aEvent );
481 
482  if( retVal == 0 )
483  retVal = DoDelete( aEvent );
484 
485  return retVal;
486 }
487 
488 
489 int PL_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
490 {
492  std::vector<DS_DATA_ITEM*> items;
494  wxString sexpr;
495 
496  if( selection.GetSize() == 0 )
497  return 0;
498 
499  for( EDA_ITEM* item : selection.GetItems() )
500  items.push_back( static_cast<DS_DRAW_ITEM_BASE*>( item )->GetPeer() );
501 
502  try
503  {
504  model.SaveInString( items, &sexpr );
505  }
506  catch( const IO_ERROR& ioe )
507  {
508  wxMessageBox( ioe.What(), _( "Error writing objects to clipboard" ) );
509  }
510 
511  if( m_toolMgr->SaveClipboard( TO_UTF8( sexpr ) ) )
512  return 0;
513  else
514  return -1;
515 }
516 
517 
518 int PL_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
519 {
520  PL_SELECTION& selection = m_selectionTool->GetSelection();
522  std::string sexpr = m_toolMgr->GetClipboardUTF8();
523 
525 
526  model.SetPageLayout( sexpr.c_str(), true, wxT( "clipboard" ) );
527 
528  // Build out draw items and select the first of each data item
529  for( DS_DATA_ITEM* dataItem : model.GetItems() )
530  {
531  if( dataItem->GetDrawItems().empty() )
532  {
533  dataItem->SyncDrawItems( nullptr, getView() );
534  dataItem->GetDrawItems().front()->SetSelected();
535  }
536  }
537 
539 
540  if( !selection.Empty() )
541  {
542  selection.SetReferencePoint( selection.GetTopLeftItem()->GetPosition() );
544  }
545 
546  return 0;
547 }
548 
549 
551 {
552  Go( &PL_EDIT_TOOL::Main, PL_ACTIONS::move.MakeEvent() );
553 
555 
556  Go( &PL_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
557  Go( &PL_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
558 
559  Go( &PL_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
560  Go( &PL_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
561  Go( &PL_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
563 
565 }
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....
static const TOOL_EVENT SelectedEvent
Definition: actions.h:200
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:74
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
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:236
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:80
int DeleteItemCursor(const TOOL_EVENT &aEvent)
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:72
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:230
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:199
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:214
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
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:350
int ClearSelection(const TOOL_EVENT &aEvent)
TOOL_MENU & GetToolMenu()
bool IsMotion() const
Definition: tool_event.h:300
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
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:65
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:102
virtual wxPoint GetPosition() const
Definition: eda_item.h:251
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)
PL_SELECTION & GetSelection()
Return the set of currently selected items.
bool IsCancelInteractive() const
Indicate the event should restart/end an ongoing interactive tool's event loop (eg esc key,...
Definition: tool_event.cpp:211
bool Init() override
Init() is called once upon a registration of the tool.
This file contains miscellaneous commonly used macros and functions.
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:88
static TOOL_ACTION pickerTool
Definition: actions.h:155
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.
int ImportDrawingSheetContent(const TOOL_EVENT &aEvent)
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
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: pl_actions.h:40
static TOOL_ACTION copy
Definition: actions.h:67
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:192
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:285
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
#define IS_MOVING
Item being moved.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
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:152
int Undo(const TOOL_EVENT &aEvent)
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:82
PL_EDITOR_FRAME * m_frame
Definition: pl_edit_tool.h:79
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:109
static TOOL_ACTION cut
Definition: actions.h:66
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems() const
Definition: ds_data_item.h:110
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Definition: actions.h:208
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:295
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
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:98
static TOOL_ACTION clearSelection
Clear the current selection.
Definition: pl_actions.h:43
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
#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:88
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
static TOOL_ACTION redo
Definition: actions.h:65
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:315
bool HasReferencePoint() const
Definition: selection.h:179
Drawing sheet structure type definitions.
Definition: ds_data_item.h:95
static TOOL_ACTION appendImportedDrawingSheet
Definition: pl_actions.h:62
void UnbrightenItem(EDA_ITEM *aItem)
int Size() const
Returns the number of selected parts.
Definition: selection.h:104
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:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:77
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
void Activate()
Run the tool.
WX_INFOBAR * GetInfoBar()
static TOOL_ACTION deleteTool
Definition: actions.h:73
constexpr int delta
static TOOL_ACTION undo
Definition: actions.h:64
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 MoveToUi(const wxPoint &aPosition)
Move item to a new position.
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.
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 moveItem(DS_DATA_ITEM *aItem, const VECTOR2I &aDelta)
Return the right modification point (e.g.
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:68
PL_SELECTION & RequestSelection()
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
static TOOL_ACTION duplicate
Definition: actions.h:71
static TOOL_ACTION refreshPreview
Definition: actions.h:106
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:145
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:1570
const wxPoint GetStartPosUi(int ii=0) const
int Redo(const TOOL_EVENT &aEvent)
void Files_io(wxCommandEvent &event)