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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <wx/log.h>
22#include <wx/msgdlg.h>
23#include <fmt/format.h>
24
25#include <widgets/wx_infobar.h>
26#include <tool/tool_manager.h>
27#include <tool/picker_tool.h>
31#include <bitmaps.h>
32#include <clipboard.h>
33#include <confirm.h>
34#include <core/kicad_algo.h>
35#include <eda_item.h>
36#include <macros.h>
37#include <string_utils.h>
38#include <view/view.h>
39#include <view/view_controls.h>
40#include <math/util.h> // for KiROUND
41
43#include "tools/pl_actions.h"
44#include "tools/pl_edit_tool.h"
45#include "pl_draw_panel_gal.h"
46#include "pl_editor_frame.h"
47#include "pl_editor_id.h"
48
50 TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ),
51 m_frame( nullptr ),
52 m_selectionTool( nullptr ),
53 m_moveInProgress( false ),
54 m_moveOffset( 0, 0 ),
55 m_cursor( 0, 0 ),
56 m_pickerItem( nullptr )
57{
58}
59
60
62{
65
66 wxASSERT_MSG( m_selectionTool, "plEditor.InteractiveSelection tool is not available" );
67
68 CONDITIONAL_MENU& ctxMenu = m_menu->GetMenu();
69
70 // cancel current tool goes in main context menu at the top if present
72
73 ctxMenu.AddSeparator( 200 );
75
76 // Finally, add the standard zoom/grid items
77 m_frame->AddStandardSubMenus( *m_menu.get() );
78
79 //
80 // Add editing actions to the selection tool menu
81 //
82 CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
83
85
86 selToolMenu.AddSeparator( 250 );
91
92 return true;
93}
94
95
97{
98 if( aReason == MODEL_RELOAD )
100}
101
102
103int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
104{
106
107 VECTOR2I originalCursorPos = controls->GetCursorPosition();
108
109 // Be sure that there is at least one item that we can move. If there's no selection try
110 // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection).
111 PL_SELECTION& selection = m_selectionTool->RequestSelection();
112 bool unselect = selection.IsHover();
113
114 if( selection.Empty() || m_moveInProgress )
115 return 0;
116
117 std::set<DS_DATA_ITEM*> unique_peers;
118
119 for( EDA_ITEM* item : selection )
120 {
121 DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( item );
122 unique_peers.insert( drawItem->GetPeer() );
123 }
124
125 SCOPED_TOOL_PUSHER raii( m_frame, aEvent );
126
127 Activate();
128 // Must be done after Activate() so that it gets set into the correct context
129 controls->ShowCursor( true );
130 controls->SetAutoPan( true );
131
132 bool restore_state = false;
133 bool chain_commands = false;
134 TOOL_EVENT copy = aEvent;
135 TOOL_EVENT* evt = &copy;
136 VECTOR2I prevPos;
137
138 if( !selection.Front()->IsNew() )
139 {
140 try
141 {
142 m_frame->SaveCopyInUndoList();
143 }
144 catch( const fmt::format_error& exc )
145 {
146 wxLogWarning( wxS( "Exception \"%s\" serializing string ocurred." ), exc.what() );
147 return 1;
148 }
149 }
150
151 // Main loop: keep receiving events
152 do
153 {
154 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
155
156 if( evt->IsAction( &PL_ACTIONS::move )
157 || evt->IsMotion()
158 || evt->IsDrag( BUT_LEFT )
160 {
161 //------------------------------------------------------------------------
162 // Start a move operation
163 //
164 if( !m_moveInProgress )
165 {
166 // Apply any initial offset in case we're coming from a previous command.
167 //
168 for( DS_DATA_ITEM* item : unique_peers )
169 moveItem( item, m_moveOffset );
170
171 // Set up the starting position and move/drag offset
172 //
173 m_cursor = controls->GetCursorPosition();
174
175 if( selection.HasReferencePoint() )
176 {
178
179 // Drag items to the current cursor position
180 for( DS_DATA_ITEM* item : unique_peers )
181 moveItem( item, delta );
182
183 selection.SetReferencePoint( m_cursor );
184 }
185 else if( selection.Size() == 1 )
186 {
187 // Set the current cursor position to the first dragged item origin,
188 // so the movement vector can be computed later
189 updateModificationPoint( selection );
190 m_cursor = originalCursorPos;
191 }
192 else
193 {
194 updateModificationPoint( selection );
195 }
196
197 controls->SetCursorPosition( m_cursor, false );
198
199 prevPos = m_cursor;
200 controls->SetAutoPan( true );
201 m_moveInProgress = true;
202 }
203
204 //------------------------------------------------------------------------
205 // Follow the mouse
206 //
207 m_cursor = controls->GetCursorPosition();
208 VECTOR2I delta( m_cursor - prevPos );
209 selection.SetReferencePoint( m_cursor );
210
212 prevPos = m_cursor;
213
214 for( DS_DATA_ITEM* item : unique_peers )
215 moveItem( item, delta );
216
218 }
219 //------------------------------------------------------------------------
220 // Handle cancel
221 //
222 else if( evt->IsCancelInteractive() || evt->IsActivate() )
223 {
224 if( evt->IsCancelInteractive() )
225 m_frame->GetInfoBar()->Dismiss();
226
227 if( m_moveInProgress )
228 {
229 if( evt->IsActivate() )
230 {
231 // Allowing other tools to activate during a move runs the risk of race
232 // conditions in which we try to spool up both event loops at once.
233
234 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel move." ) );
235
236 evt->SetPassEvent( false );
237 continue;
238 }
239
240 evt->SetPassEvent( false );
241 restore_state = true;
242 }
243
244 break;
245 }
246 //------------------------------------------------------------------------
247 // Handle TOOL_ACTION special cases
248 //
249 else if( evt->Action() == TA_UNDO_REDO_PRE )
250 {
251 unselect = true;
252 break;
253 }
254 else if( evt->IsAction( &ACTIONS::doDelete ) )
255 {
256 evt->SetPassEvent();
257 // Exit on a delete; there will no longer be anything to drag.
258 break;
259 }
260 else if( evt->IsAction( &ACTIONS::duplicate ) )
261 {
262 if( selection.Front()->IsNew() )
263 {
264 // This doesn't really make sense; we'll just end up dragging a stack of
265 // objects so we ignore the duplicate and just carry on.
266 continue;
267 }
268
269 // Move original back and exit. The duplicate will run in its own loop.
270 restore_state = true;
271 unselect = false;
272 chain_commands = true;
273 break;
274 }
275 //------------------------------------------------------------------------
276 // Handle context menu
277 //
278 else if( evt->IsClick( BUT_RIGHT ) )
279 {
280 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
281 }
282 //------------------------------------------------------------------------
283 // Handle drop
284 //
285 else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACTIONS::cursorClick ) )
286 {
287 break; // Finish
288 }
289 else
290 {
291 evt->SetPassEvent();
292 }
293
294 controls->SetAutoPan( m_moveInProgress );
295
296 } while( ( evt = Wait() ) ); //Should be assignment not equality test
297
298 controls->ForceCursorPosition( false );
299 controls->ShowCursor( false );
300 controls->SetAutoPan( false );
301
302 if( !chain_commands )
303 m_moveOffset = { 0, 0 };
304
305 selection.ClearReferencePoint();
306
307 for( EDA_ITEM* item : selection )
308 item->ClearEditFlags();
309
310 if( restore_state )
311 m_frame->RollbackFromUndo();
312 else
313 m_frame->OnModify();
314
315 if( unselect )
317 else
318 m_toolMgr->PostEvent( EVENTS::SelectedEvent );
319
320 m_moveInProgress = false;
321 return 0;
322}
323
324
325void PL_EDIT_TOOL::moveItem( DS_DATA_ITEM* aItem, const VECTOR2I& aDelta )
326{
327 aItem->MoveToIU( aItem->GetStartPosIU() + aDelta );
328
329 for( DS_DRAW_ITEM_BASE* item : aItem->GetDrawItems() )
330 {
331 getView()->Update( item );
332 item->SetFlags( IS_MOVING );
333 }
334}
335
336
338{
339 if( m_moveInProgress && aSelection.HasReferencePoint() )
340 return false;
341
342 // When there is only one item selected, the reference point is its position...
343 if( aSelection.Size() == 1 )
344 {
345 aSelection.SetReferencePoint( aSelection.Front()->GetPosition() );
346 }
347 // ...otherwise modify items with regard to the grid-snapped cursor position
348 else
349 {
351 aSelection.SetReferencePoint( m_cursor );
352 }
353
354 return true;
355}
356
357
359{
361
362 wxCommandEvent evt( wxEVT_NULL, ID_APPEND_DESCR_FILE );
363 m_frame->Files_io( evt );
364
365 return 0;
366}
367
368
370{
371 PL_SELECTION& selection = m_selectionTool->RequestSelection();
372
373 if( selection.Size() == 0 )
374 return 0;
375
376
377 // Do not delete an item if it is currently a new item being created to avoid a crash
378 // In this case the selection contains only one item.
379 DS_DRAW_ITEM_BASE* currItem = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() );
380
381 if( currItem->GetFlags() & ( IS_NEW ) )
382 return 0;
383
384 m_frame->SaveCopyInUndoList();
385
386 while( selection.Front() )
387 {
388 DS_DRAW_ITEM_BASE* drawItem = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() );
389 DS_DATA_ITEM* dataItem = drawItem->GetPeer();
391
392 for( DS_DRAW_ITEM_BASE* item : dataItem->GetDrawItems() )
393 {
394 // Note: repeat items won't be selected but must be removed & deleted
395
396 if( item->IsSelected() )
397 m_selectionTool->RemoveItemFromSel( item );
398
399 getView()->Remove( item );
400 }
401
402 delete dataItem;
403 }
404
405 m_frame->OnModify();
406
407 return 0;
408}
409
410
411#define HITTEST_THRESHOLD_PIXELS 5
412
413
415{
416 PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
417
418 // Deactivate other tools; particularly important if another PICKER is currently running
419 Activate();
420
421 picker->SetCursor( KICURSOR::REMOVE );
422 m_pickerItem = nullptr;
423
424 picker->SetClickHandler(
425 [this] ( const VECTOR2D& aPosition ) -> bool
426 {
427 if( m_pickerItem )
428 {
429 PL_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
430 selectionTool->UnbrightenItem( m_pickerItem );
431 selectionTool->AddItemToSel( m_pickerItem, true /*quiet mode*/ );
432 m_toolMgr->RunAction( ACTIONS::doDelete );
433 m_pickerItem = nullptr;
434 }
435
436 return true;
437 } );
438
439 picker->SetMotionHandler(
440 [this] ( const VECTOR2D& aPos )
441 {
442 int threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
443 EDA_ITEM* item = nullptr;
444
445 for( DS_DATA_ITEM* dataItem : DS_DATA_MODEL::GetTheInstance().GetItems() )
446 {
447 for( DS_DRAW_ITEM_BASE* drawItem : dataItem->GetDrawItems() )
448 {
449 if( drawItem->HitTest( aPos, threshold ) )
450 {
451 item = drawItem;
452 break;
453 }
454 }
455 }
456
457 if( m_pickerItem != item )
458 {
459 PL_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PL_SELECTION_TOOL>();
460
461 if( m_pickerItem )
462 selectionTool->UnbrightenItem( m_pickerItem );
463
464 m_pickerItem = item;
465
466 if( m_pickerItem )
467 selectionTool->BrightenItem( m_pickerItem );
468 }
469 } );
470
471 picker->SetFinalizeHandler(
472 [this] ( const int& aFinalState )
473 {
474 if( m_pickerItem )
475 m_toolMgr->GetTool<PL_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
476
477 // Wake the selection tool after exiting to ensure the cursor gets updated
479 } );
480
481 m_toolMgr->RunAction( ACTIONS::pickerTool, &aEvent );
482
483 return 0;
484}
485
486
487int PL_EDIT_TOOL::Undo( const TOOL_EVENT& aEvent )
488{
489 m_frame->GetLayoutFromUndoList();
490 return 0;
491}
492
493
494int PL_EDIT_TOOL::Redo( const TOOL_EVENT& aEvent )
495{
496 m_frame->GetLayoutFromRedoList();
497 return 0;
498}
499
500
501int PL_EDIT_TOOL::Cut( const TOOL_EVENT& aEvent )
502{
503 int retVal = Copy( aEvent );
504
505 if( retVal == 0 )
506 retVal = DoDelete( aEvent );
507
508 return retVal;
509}
510
511
512int PL_EDIT_TOOL::Copy( const TOOL_EVENT& aEvent )
513{
514 PL_SELECTION& selection = m_selectionTool->RequestSelection();
515 std::vector<DS_DATA_ITEM*> items;
517 wxString sexpr;
518
519 if( selection.GetSize() == 0 )
520 return 0;
521
522 // A repeated data item generates one draw item per repeat, but must be copied only once.
523 for( EDA_ITEM* item : selection.GetItems() )
524 {
525 DS_DATA_ITEM* peer = static_cast<DS_DRAW_ITEM_BASE*>( item )->GetPeer();
526
527 if( !alg::contains( items, peer ) )
528 items.push_back( peer );
529 }
530
531 try
532 {
533 model.SaveInString( items, &sexpr );
534 }
535 catch( const IO_ERROR& ioe )
536 {
537 wxMessageBox( ioe.What(), _( "Error writing objects to clipboard" ) );
538 }
539
540 if( SaveClipboard( TO_UTF8( sexpr ) ) )
541 return 0;
542 else
543 return -1;
544}
545
546
547int PL_EDIT_TOOL::Paste( const TOOL_EVENT& aEvent )
548{
549 PL_SELECTION& selection = m_selectionTool->GetSelection();
551
552 if( std::unique_ptr<wxBitmap> clipImg = GetImageFromClipboard() )
553 {
554 auto image = std::make_unique<BITMAP_BASE>();
555 image->SetImage( clipImg->ConvertToImage() );
556 auto dataItem = std::make_unique<DS_DATA_ITEM_BITMAP>( image.release() );
557 model.Append( dataItem.release() );
558 }
559 else
560 {
561 m_selectionTool->ClearSelection();
562
563 const std::string clipText = GetClipboardUTF8();
564 model.SetPageLayout( clipText.c_str(), true, wxT( "clipboard" ) );
565 }
566
567 // Build out draw items and select the first of each data item
568 for( DS_DATA_ITEM* dataItem : model.GetItems() )
569 {
570 if( dataItem->GetDrawItems().empty() )
571 {
572 m_frame->SyncDataItem( dataItem );
573 dataItem->GetDrawItems().front()->SetSelected();
574 }
575 }
576
577 m_selectionTool->RebuildSelection();
578
579 if( !selection.Empty() )
580 {
581 selection.SetReferencePoint( selection.GetTopLeftItem()->GetPosition() );
582 m_toolMgr->PostAction( PL_ACTIONS::move );
583 }
584
585 return 0;
586}
587
588
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:982
static TOOL_ACTION paste
Definition actions.h:76
static TOOL_ACTION cancelInteractive
Definition actions.h:68
static TOOL_ACTION copy
Definition actions.h:74
static TOOL_ACTION pickerTool
Definition actions.h:249
static TOOL_ACTION undo
Definition actions.h:71
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition actions.h:210
static TOOL_ACTION duplicate
Definition actions.h:80
static TOOL_ACTION doDelete
Definition actions.h:81
static TOOL_ACTION cursorClick
Definition actions.h:176
static TOOL_ACTION redo
Definition actions.h:72
static TOOL_ACTION deleteTool
Definition actions.h:82
static TOOL_ACTION selectionClear
Clear the current selection.
Definition actions.h:220
static TOOL_ACTION cut
Definition actions.h:73
static TOOL_ACTION refreshPreview
Definition actions.h:155
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.
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
Handle the graphic items list to draw/plot the frame and title block.
static DS_DATA_MODEL & GetTheInstance()
Return the instance of DS_DATA_MODEL used in the application.
void Remove(DS_DATA_ITEM *aItem)
Base class to handle basic graphic items.
DS_DATA_ITEM * GetPeer() const
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual VECTOR2I GetPosition() const
Definition eda_item.h:348
EDA_ITEM_FLAGS GetFlags() const
Definition eda_item.h:167
bool IsNew() const
Definition eda_item.h:131
static const TOOL_EVENT SelectedEvent
Definition actions.h:345
static const TOOL_EVENT SelectedItemsMoved
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition actions.h:355
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
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:412
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:1892
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition picker_tool.h:92
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition picker_tool.h:81
void SetCursor(KICURSOR aCursor)
Definition picker_tool.h:63
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
static TOOL_ACTION appendImportedDrawingSheet
Definition pl_actions.h:40
static TOOL_ACTION move
Definition pl_actions.h:43
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
Flag determining if anything is being dragged right now.
int Main(const TOOL_EVENT &aEvent)
The "move" event loop.
int Cut(const TOOL_EVENT &aEvent)
bool updateModificationPoint(PL_SELECTION &aSelection)
Return the right modification point (e.g.
PL_SELECTION_TOOL * m_selectionTool
void moveItem(DS_DATA_ITEM *aItem, const VECTOR2I &aDelta)
int InteractiveDelete(const TOOL_EVENT &aEvent)
Run the deletion tool.
VECTOR2I m_moveOffset
Used for chaining commands.
VECTOR2I m_cursor
Last cursor position (needed for getModificationPoint() to avoid changes of edit reference point).
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int Paste(const TOOL_EVENT &aEvent)
void setTransitions() override
Set up handlers for various events.
EDA_ITEM * m_pickerItem
int Undo(const TOOL_EVENT &aEvent)
PL_EDITOR_FRAME * m_frame
int Copy(const TOOL_EVENT &aEvent)
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).
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:125
VECTOR2I GetReferencePoint() const
bool IsHover() const
Definition selection.h:85
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition selection.h:104
EDA_ITEM * Front() const
Definition selection.h:176
int Size() const
Returns the number of selected parts.
Definition selection.h:120
void ClearReferencePoint()
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
Definition selection.h:114
bool HasReferencePoint() const
Definition selection.h:215
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:182
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition tool_base.cpp:40
TOOL_MANAGER * m_toolMgr
Definition tool_base.h:220
KIGFX::VIEW * getView() const
Return the instance of KIGFX::VIEW object used in the application.
Definition tool_base.cpp:34
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
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,...
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition tool_event.h:246
bool IsActivate() const
Definition tool_event.h:341
bool IsClick(int aButtonMask=BUT_ANY) const
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition tool_event.h:311
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
void SetPassEvent(bool aPass=true)
Definition tool_event.h:252
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition tool_event.h:321
bool IsMotion() const
Definition tool_event.h:326
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).
std::unique_ptr< TOOL_MENU > m_menu
The functions below are not yet implemented - their interface may change.
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
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.
std::unique_ptr< wxBitmap > GetImageFromClipboard()
Get image data from the clipboard, if there is any.
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
Definition clipboard.cpp:32
std::string GetClipboardUTF8()
Return the information currently stored in the system clipboard.
This file is part of the common library.
@ REMOVE
Definition cursors.h:50
@ MOVING
Definition cursors.h:44
#define _(s)
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition idf_helpers.h:37
This file contains miscellaneous commonly used macros and functions.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
@ ID_APPEND_DESCR_FILE
#define HITTEST_THRESHOLD_PIXELS
KIBIS_MODEL * model
int delta
@ TA_UNDO_REDO_PRE
This event is sent before undo/redo command is performed.
Definition tool_event.h:102
@ BUT_LEFT
Definition tool_event.h:128
@ BUT_RIGHT
Definition tool_event.h:129
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707