KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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 <wx/log.h>
26#include <wx/msgdlg.h>
27#include <fmt/format.h>
28
29#include <tool/tool_manager.h>
30#include <tool/picker_tool.h>
34#include <bitmaps.h>
35#include <clipboard.h>
36#include <confirm.h>
37#include <eda_item.h>
38#include <macros.h>
39#include <string_utils.h>
40#include <view/view.h>
41#include <view/view_controls.h>
42#include <math/util.h> // for KiROUND
43
45#include "tools/pl_actions.h"
46#include "tools/pl_edit_tool.h"
47#include "pl_draw_panel_gal.h"
48#include "pl_editor_frame.h"
49#include "pl_editor_id.h"
50
52 TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ),
53 m_frame( nullptr ),
54 m_selectionTool( nullptr ),
55 m_moveInProgress( false ),
56 m_moveOffset( 0, 0 ),
57 m_cursor( 0, 0 ),
58 m_pickerItem( nullptr )
59{
60}
61
62
64{
65 m_frame = getEditFrame<PL_EDITOR_FRAME>();
67
68 wxASSERT_MSG( m_selectionTool, "plEditor.InteractiveSelection tool is not available" );
69
70 CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
71
72 // cancel current tool goes in main context menu at the top if present
74
75 ctxMenu.AddSeparator( 200 );
77
78 // Finally, add the standard zoom/grid items
80
81 //
82 // Add editing actions to the selection tool menu
83 //
85
87
88 selToolMenu.AddSeparator( 250 );
93
94 return true;
95}
96
97
99{
100 if( aReason == MODEL_RELOAD )
101 m_frame = getEditFrame<PL_EDITOR_FRAME>();
102}
103
104
105int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
106{
108
109 VECTOR2I originalCursorPos = controls->GetCursorPosition();
110
111 // Be sure that there is at least one item that we can move. If there's no selection try
112 // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
114 bool unselect = selection.IsHover();
115
116 if( selection.Empty() || m_moveInProgress )
117 return 0;
118
119 std::set<DS_DATA_ITEM*> unique_peers;
120
121 for( EDA_ITEM* item : selection )
122 {
123 DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( item );
124 unique_peers.insert( drawItem->GetPeer() );
125 }
126
127 m_frame->PushTool( aEvent );
128
129 Activate();
130 // Must be done after Activate() so that it gets set into the correct context
131 controls->ShowCursor( true );
132 controls->SetAutoPan( true );
133
134 bool restore_state = false;
135 bool chain_commands = false;
136 TOOL_EVENT copy = aEvent;
137 TOOL_EVENT* evt = &copy;
138 VECTOR2I prevPos;
139
140 if( !selection.Front()->IsNew() )
141 {
142 try
143 {
145 }
146 catch( const fmt::format_error& exc )
147 {
148 wxLogWarning( wxS( "Exception \"%s\" serializing string ocurred." ),
149 exc.what() );
150 return 1;
151 }
152 }
153
154 // Main loop: keep receiving events
155 do
156 {
157 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
158
159 if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
161 {
162 //------------------------------------------------------------------------
163 // Start a move operation
164 //
165 if( !m_moveInProgress )
166 {
167 // Apply any initial offset in case we're coming from a previous command.
168 //
169 for( DS_DATA_ITEM* item : unique_peers )
170 moveItem( item, m_moveOffset );
171
172 // Set up the starting position and move/drag offset
173 //
174 m_cursor = controls->GetCursorPosition();
175
176 if( selection.HasReferencePoint() )
177 {
179
180 // Drag items to the current cursor position
181 for( DS_DATA_ITEM* item : unique_peers )
182 moveItem( item, delta );
183
184 selection.SetReferencePoint( m_cursor );
185 }
186 else if( selection.Size() == 1 )
187 {
188 // Set the current cursor position to the first dragged item origin,
189 // so the movement vector can be computed later
190 updateModificationPoint( selection );
191 m_cursor = originalCursorPos;
192 }
193 else
194 {
195 updateModificationPoint( selection );
196 }
197
198 controls->SetCursorPosition( m_cursor, false );
199
200 prevPos = m_cursor;
201 controls->SetAutoPan( true );
202 m_moveInProgress = true;
203 }
204
205 //------------------------------------------------------------------------
206 // Follow the mouse
207 //
208 m_cursor = controls->GetCursorPosition();
209 VECTOR2I delta( m_cursor - prevPos );
210 selection.SetReferencePoint( m_cursor );
211
213 prevPos = m_cursor;
214
215 for( DS_DATA_ITEM* item : unique_peers )
216 moveItem( item, delta );
217
219 }
220 //------------------------------------------------------------------------
221 // Handle cancel
222 //
223 else if( evt->IsCancelInteractive() || evt->IsActivate() )
224 {
225 if( evt->IsCancelInteractive() )
227
228 if( m_moveInProgress )
229 {
230 if( evt->IsActivate() )
231 {
232 // Allowing other tools to activate during a move runs the risk of race
233 // conditions in which we try to spool up both event loops at once.
234
235 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel move." ) );
236
237 evt->SetPassEvent( false );
238 continue;
239 }
240
241 evt->SetPassEvent( false );
242 restore_state = true;
243 }
244
245 break;
246 }
247 //------------------------------------------------------------------------
248 // Handle TOOL_ACTION special cases
249 //
250 else if( evt->Action() == TA_UNDO_REDO_PRE )
251 {
252 unselect = true;
253 break;
254 }
255 else if( evt->IsAction( &ACTIONS::doDelete ) )
256 {
257 evt->SetPassEvent();
258 // Exit on a delete; there will no longer be anything to drag.
259 break;
260 }
261 else if( evt->IsAction( &ACTIONS::duplicate ) )
262 {
263 if( selection.Front()->IsNew() )
264 {
265 // This doesn't really make sense; we'll just end up dragging a stack of
266 // objects so we ignore the duplicate and just carry on.
267 continue;
268 }
269
270 // Move original back and exit. The duplicate will run in its own loop.
271 restore_state = true;
272 unselect = false;
273 chain_commands = true;
274 break;
275 }
276 //------------------------------------------------------------------------
277 // Handle context menu
278 //
279 else if( evt->IsClick( BUT_RIGHT ) )
280 {
281 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
282 }
283 //------------------------------------------------------------------------
284 // Handle drop
285 //
286 else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
287 {
288 break; // Finish
289 }
290 else
291 {
292 evt->SetPassEvent();
293 }
294
295 controls->SetAutoPan( m_moveInProgress );
296
297 } while( ( evt = Wait() ) ); //Should be assignment not equality test
298
299 controls->ForceCursorPosition( false );
300 controls->ShowCursor( false );
301 controls->SetAutoPan( false );
302
303 if( !chain_commands )
304 m_moveOffset = { 0, 0 };
305
306 selection.ClearReferencePoint();
307
308 for( EDA_ITEM* item : selection )
309 item->ClearEditFlags();
310
311 if( restore_state )
313 else
314 m_frame->OnModify();
315
316 if( unselect )
318 else
320
321 m_moveInProgress = false;
322 m_frame->PopTool( aEvent );
323 return 0;
324}
325
326
327void PL_EDIT_TOOL::moveItem( DS_DATA_ITEM* aItem, const VECTOR2I& aDelta )
328{
329 aItem->MoveToIU( aItem->GetStartPosIU() + aDelta );
330
331 for( DS_DRAW_ITEM_BASE* item : aItem->GetDrawItems() )
332 {
333 getView()->Update( item );
334 item->SetFlags( IS_MOVING );
335 }
336}
337
338
340{
341 if( m_moveInProgress && aSelection.HasReferencePoint() )
342 return false;
343
344 // When there is only one item selected, the reference point is its position...
345 if( aSelection.Size() == 1 )
346 {
347 aSelection.SetReferencePoint( aSelection.Front()->GetPosition() );
348 }
349 // ...otherwise modify items with regard to the grid-snapped cursor position
350 else
351 {
353 aSelection.SetReferencePoint( m_cursor );
354 }
355
356 return true;
357}
358
359
361{
363
364 wxCommandEvent evt( wxEVT_NULL, ID_APPEND_DESCR_FILE );
365 m_frame->Files_io( evt );
366
367 return 0;
368}
369
370
372{
374
375 if( selection.Size() == 0 )
376 return 0;
377
378
379 // Do not delete an item if it is currently a new item being created to avoid a crash
380 // In this case the selection contains only one item.
381 DS_DRAW_ITEM_BASE* currItem = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() );
382
383 if( currItem->GetFlags() & ( IS_NEW ) )
384 return 0;
385
387
388 while( selection.Front() )
389 {
390 DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() );
391 DS_DATA_ITEM* dataItem = drawItem->GetPeer();
393
394 for( DS_DRAW_ITEM_BASE* item : dataItem->GetDrawItems() )
395 {
396 // Note: repeat items won't be selected but must be removed & deleted
397
398 if( item->IsSelected() )
400
401 getView()->Remove( item );
402 }
403
404 delete dataItem;
405 }
406
407 m_frame->OnModify();
408
409 return 0;
410}
411
412
413#define HITTEST_THRESHOLD_PIXELS 5
414
415
417{
419
420 // Deactivate other tools; particularly important if another PICKER is currently running
421 Activate();
422
423 picker->SetCursor( KICURSOR::REMOVE );
424 m_pickerItem = nullptr;
425
426 picker->SetClickHandler(
427 [this] ( const VECTOR2D& aPosition ) -> bool
428 {
429 if( m_pickerItem )
430 {
432 selectionTool->UnbrightenItem( m_pickerItem );
433 selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
435 m_pickerItem = nullptr;
436 }
437
438 return true;
439 } );
440
441 picker->SetMotionHandler(
442 [this] ( const VECTOR2D& aPos )
443 {
444 int threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
445 EDA_ITEM* item = nullptr;
446
447 for( DS_DATA_ITEM* dataItem : DS_DATA_MODEL::GetTheInstance().GetItems() )
448 {
449 for( DS_DRAW_ITEM_BASE* drawItem : dataItem->GetDrawItems() )
450 {
451 if( drawItem->HitTest( aPos, threshold ) )
452 {
453 item = drawItem;
454 break;
455 }
456 }
457 }
458
459 if( m_pickerItem != item )
460 {
462
463 if( m_pickerItem )
464 selectionTool->UnbrightenItem( m_pickerItem );
465
466 m_pickerItem = item;
467
468 if( m_pickerItem )
469 selectionTool->BrightenItem( m_pickerItem );
470 }
471 } );
472
473 picker->SetFinalizeHandler(
474 [this] ( const int& aFinalState )
475 {
476 if( m_pickerItem )
477 m_toolMgr->GetTool<PL_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
478
479 // Wake the selection tool after exiting to ensure the cursor gets updated
481 } );
482
484
485 return 0;
486}
487
488
489int PL_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
490{
492 return 0;
493}
494
495
496int PL_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
497{
499 return 0;
500}
501
502
503int PL_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
504{
505 int retVal = Copy( aEvent );
506
507 if( retVal == 0 )
508 retVal = DoDelete( aEvent );
509
510 return retVal;
511}
512
513
514int PL_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
515{
517 std::vector<DS_DATA_ITEM*> items;
519 wxString sexpr;
520
521 if( selection.GetSize() == 0 )
522 return 0;
523
524 for( EDA_ITEM* item : selection.GetItems() )
525 items.push_back( static_cast<DS_DRAW_ITEM_BASE*>( item )->GetPeer() );
526
527 try
528 {
529 model.SaveInString( items, &sexpr );
530 }
531 catch( const IO_ERROR& ioe )
532 {
533 wxMessageBox( ioe.What(), _( "Error writing objects to clipboard" ) );
534 }
535
536 if( SaveClipboard( TO_UTF8( sexpr ) ) )
537 return 0;
538 else
539 return -1;
540}
541
542
543int PL_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
544{
547 bool createdAnything = false;
548
549 if( std::unique_ptr<wxImage> clipImg = GetImageFromClipboard() )
550 {
551 auto image = std::make_unique<BITMAP_BASE>();
552 image->SetImage( *clipImg );
553 auto dataItem = std::make_unique<DS_DATA_ITEM_BITMAP>( image.release() );
554 model.Append( dataItem.release() );
555
556 createdAnything = true;
557 }
558 else
559 {
561
562 const std::string clipText = GetClipboardUTF8();
563 model.SetPageLayout( clipText.c_str(), true, wxT( "clipboard" ) );
564 createdAnything = true;
565 }
566
567 // Nothing pasteable
568 if( !createdAnything )
569 return 0;
570
571 // Build out draw items and select the first of each data item
572 for( DS_DATA_ITEM* dataItem : model.GetItems() )
573 {
574 if( dataItem->GetDrawItems().empty() )
575 {
576 dataItem->SyncDrawItems( nullptr, getView() );
577 dataItem->GetDrawItems().front()->SetSelected();
578 }
579 }
580
582
583 if( !selection.Empty() )
584 {
585 selection.SetReferencePoint( selection.GetTopLeftItem()->GetPosition() );
587 }
588
589 return 0;
590}
591
592
594{
595 Go( &PL_EDIT_TOOL::Main, PL_ACTIONS::move.MakeEvent() );
596
598
599 Go( &PL_EDIT_TOOL::Undo, ACTIONS::undo.MakeEvent() );
600 Go( &PL_EDIT_TOOL::Redo, ACTIONS::redo.MakeEvent() );
601
602 Go( &PL_EDIT_TOOL::Cut, ACTIONS::cut.MakeEvent() );
603 Go( &PL_EDIT_TOOL::Copy, ACTIONS::copy.MakeEvent() );
604 Go( &PL_EDIT_TOOL::Paste, ACTIONS::paste.MakeEvent() );
606
608}
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
static TOOL_ACTION paste
Definition: actions.h:73
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION copy
Definition: actions.h:71
static TOOL_ACTION pickerTool
Definition: actions.h:204
static TOOL_ACTION undo
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:77
static TOOL_ACTION doDelete
Definition: actions.h:78
static TOOL_ACTION redo
Definition: actions.h:69
static TOOL_ACTION deleteTool
Definition: actions.h:79
static TOOL_ACTION cut
Definition: actions.h:70
static TOOL_ACTION refreshPreview
Definition: actions.h:149
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.
void AddSeparator(int aOrder=ANY_ORDER)
Add a separator to the menu.
Drawing sheet structure type definitions.
Definition: ds_data_item.h:96
void MoveToIU(const VECTOR2I &aPosition)
Move item to a new position.
const VECTOR2I GetStartPosIU(int ii=0) const
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems() const
Definition: ds_data_item.h:110
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void Append(DS_DATA_ITEM *aItem)
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
void Remove(DS_DATA_ITEM *aItem)
std::vector< DS_DATA_ITEM * > & GetItems()
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.
Base class to handle basic graphic items.
Definition: ds_draw_item.h:59
DS_DATA_ITEM * GetPeer() const
Definition: ds_draw_item.h:63
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...
WX_INFOBAR * GetInfoBar()
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:243
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:130
bool IsNew() const
Definition: eda_item.h:107
static const TOOL_EVENT SelectedEvent
Definition: actions.h:292
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Definition: actions.h:302
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:77
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:334
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:1669
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:84
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:73
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:64
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:104
static TOOL_ACTION clearSelection
Clear the current selection.
Definition: pl_actions.h:43
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: pl_actions.h:40
static TOOL_ACTION appendImportedDrawingSheet
Definition: pl_actions.h:62
static TOOL_ACTION move
Definition: pl_actions.h:65
void OnModify() override
Must be called after a change in order to set the "modify" flag.
void Files_io(wxCommandEvent &event)
void GetLayoutFromRedoList()
Redo the last edit:
void GetLayoutFromUndoList()
Undo the last edit:
void RollbackFromUndo()
Apply the last command in Undo List without stacking a Redo.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool Init() override
Init() is called once upon a registration of the tool.
int Redo(const TOOL_EVENT &aEvent)
int DoDelete(const TOOL_EVENT &aEvent)
Delete the selected items, or the item under the cursor.
int ImportDrawingSheetContent(const TOOL_EVENT &aEvent)
bool m_moveInProgress
Used for chaining commands.
Definition: pl_edit_tool.h:83
int Main(const TOOL_EVENT &aEvent)
The "move" event loop.
int Cut(const TOOL_EVENT &aEvent)
bool updateModificationPoint(PL_SELECTION &aSelection)
Set up handlers for various events.
PL_SELECTION_TOOL * m_selectionTool
Flag determining if anything is being dragged right now.
Definition: pl_edit_tool.h:80
void moveItem(DS_DATA_ITEM *aItem, const VECTOR2I &aDelta)
Return the right modification point (e.g.
int InteractiveDelete(const TOOL_EVENT &aEvent)
VECTOR2I m_moveOffset
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
Definition: pl_edit_tool.h:86
VECTOR2I m_cursor
Definition: pl_edit_tool.h:90
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int Paste(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
EDA_ITEM * m_pickerItem
Definition: pl_edit_tool.h:92
int Undo(const TOOL_EVENT &aEvent)
PL_EDITOR_FRAME * m_frame
Definition: pl_edit_tool.h:79
int Copy(const TOOL_EVENT &aEvent)
int ClearSelection(const TOOL_EVENT &aEvent)
PL_SELECTION & GetSelection()
Return the set of currently selected items.
PL_SELECTION & RequestSelection()
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
void RebuildSelection()
Rebuild the selection from the flags in the view items.
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
void BrightenItem(EDA_ITEM *aItem)
int AddItemToSel(const TOOL_EVENT &aEvent)
void UnbrightenItem(EDA_ITEM *aItem)
const std::deque< EDA_ITEM * > GetItems() const
Definition: selection.h:121
VECTOR2I GetReferencePoint() const
Definition: selection.cpp:171
bool IsHover() const
Definition: selection.h:84
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:100
EDA_ITEM * Front() const
Definition: selection.h:172
int Size() const
Returns the number of selected parts.
Definition: selection.h:116
void ClearReferencePoint()
Definition: selection.cpp:186
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.cpp:180
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
bool HasReferencePoint() const
Definition: selection.h:211
virtual void PopTool(const TOOL_EVENT &aEvent)
Pops a tool from the stack.
virtual void PushTool(const TOOL_EVENT &aEvent)
NB: the definition of "tool" is different at the user level.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition: tool_base.h:80
Generic, UI-independent tool event.
Definition: tool_event.h:167
bool IsCancelInteractive() const
Indicate the event should restart/end an ongoing interactive tool's event loop (eg esc key,...
Definition: tool_event.cpp:221
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:246
bool IsActivate() const
Definition: tool_event.h:337
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:209
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:307
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:82
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:252
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:317
bool IsMotion() const
Definition: tool_event.h:322
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).
TOOL_MENU & GetToolMenu()
std::unique_ptr< TOOL_MENU > m_menu
The functions below are not yet implemented - their interface may change.
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.
void Activate()
Run the tool.
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:150
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:190
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
Definition: clipboard.cpp:31
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
Definition: clipboard.cpp:51
std::unique_ptr< wxImage > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
Definition: clipboard.cpp:77
This file is part of the common library.
#define _(s)
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
#define HITTEST_THRESHOLD_PIXELS
This file contains miscellaneous commonly used macros and functions.
@ ID_APPEND_DESCR_FILE
Definition: pl_editor_id.h:41
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:398
constexpr int delta
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:105
@ BUT_LEFT
Definition: tool_event.h:131
@ BUT_RIGHT
Definition: tool_event.h:132