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