KiCad PCB EDA Suite
symbol_editor_drawing_tools.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-2022 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 <ee_actions.h>
26#include <symbol_edit_frame.h>
30#include <lib_text.h>
32#include <lib_shape.h>
33#include <lib_textbox.h>
34#include <pgm_base.h>
37#include <string_utils.h>
39
40static void* g_lastPinWeakPtr;
41
42
44 EE_TOOL_BASE<SYMBOL_EDIT_FRAME>( "eeschema.SymbolDrawing" ),
45 m_lastTextBold( false ),
46 m_lastTextItalic( false ),
47 m_lastTextAngle( ANGLE_HORIZONTAL ),
48 m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ),
49 m_lastFillStyle( FILL_T::NO_FILL ),
50 m_lastFillColor( COLOR4D::UNSPECIFIED ),
51 m_lastStroke( 0, PLOT_DASH_TYPE::DEFAULT, COLOR4D::UNSPECIFIED ),
52 m_drawSpecificConvert( true ),
53 m_drawSpecificUnit( false ),
54 m_inDrawShape( false ),
55 m_inTwoClickPlace( false )
56{
57}
58
59
61{
63
64 auto isDrawingCondition =
65 [] ( const SELECTION& aSel )
66 {
67 LIB_ITEM* item = (LIB_ITEM*) aSel.Front();
68 return item && item->IsNew();
69 };
70
71 m_menu.GetMenu().AddItem( EE_ACTIONS::finishDrawing, isDrawingCondition, 2 );
72
73 return true;
74}
75
76
78{
79 KICAD_T type = aEvent.Parameter<KICAD_T>();
80 auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
81 auto* pinTool = type == LIB_PIN_T ? m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() : nullptr;
82
84 return 0;
85
87
90 VECTOR2I cursorPos;
91 bool ignorePrimePosition = false;
92 LIB_ITEM* item = nullptr;
93 bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText );
94 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
95
97
98 m_frame->PushTool( aEvent );
99
100 auto setCursor =
101 [&]()
102 {
103 if( item )
105 else if( isText )
107 else
109 };
110
111 auto cleanup =
112 [&] ()
113 {
116 delete item;
117 item = nullptr;
118 };
119
120 Activate();
121 // Must be done after Activate() so that it gets set into the correct context
122 controls->ShowCursor( true );
123 // Set initial cursor
124 setCursor();
125
126 if( aEvent.HasPosition() )
127 {
128 m_toolMgr->PrimeTool( aEvent.Position() );
129 }
130 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
131 {
132 m_toolMgr->PrimeTool( { 0, 0 } );
133 ignorePrimePosition = true;
134 }
135
136 // Main loop: keep receiving events
137 while( TOOL_EVENT* evt = Wait() )
138 {
139 setCursor();
140 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
141 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
142
143 cursorPos = grid.Align( controls->GetMousePosition() );
144 controls->ForceCursorPosition( true, cursorPos );
145
146 // The tool hotkey is interpreted as a click when drawing
147 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
148 && evt->Matches( aEvent );
149
150 if( evt->IsCancelInteractive() )
151 {
153
154 if( item )
155 {
156 cleanup();
157 }
158 else
159 {
160 m_frame->PopTool( aEvent );
161 break;
162 }
163 }
164 else if( evt->IsActivate() && !isSyntheticClick )
165 {
166 if( item && evt->IsMoveTool() )
167 {
168 // we're already moving our own item; ignore the move tool
169 evt->SetPassEvent( false );
170 continue;
171 }
172
173 if( item )
174 {
175 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
176 evt->SetPassEvent( false );
177 continue;
178 }
179
180 if( evt->IsPointEditor() )
181 {
182 // don't exit (the point editor runs in the background)
183 }
184 else if( evt->IsMoveTool() )
185 {
186 break;
187 }
188 else
189 {
190 m_frame->PopTool( aEvent );
191 break;
192 }
193 }
194 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
195 {
196 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
197
198 if( !symbol )
199 continue;
200
201 // First click creates...
202 if( !item )
203 {
205
206 switch( type )
207 {
208 case LIB_PIN_T:
209 {
210 item = pinTool->CreatePin( VECTOR2I( cursorPos.x, -cursorPos.y ), symbol );
211 g_lastPinWeakPtr = item;
212 break;
213 }
214 case LIB_TEXT_T:
215 {
216 LIB_TEXT* text = new LIB_TEXT( symbol );
217
218 text->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
219 text->SetTextSize( wxSize( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
220 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
221 text->SetTextAngle( m_lastTextAngle );
222
224
225 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
226 delete text;
227 else
228 item = text;
229
230 break;
231 }
232 default:
233 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
234 }
235
236 // If we started with a hotkey which has a position then warp back to that.
237 // Otherwise update to the current mouse position pinned inside the autoscroll
238 // boundaries.
239 if( evt->IsPrime() && !ignorePrimePosition )
240 {
241 cursorPos = grid.Align( evt->Position() );
242 getViewControls()->WarpMouseCursor( cursorPos, true );
243 }
244 else
245 {
247 cursorPos = getViewControls()->GetMousePosition();
248 }
249
250 if( item )
251 {
252 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
253
254 item->SetFlags( IS_NEW | IS_MOVING );
256 m_view->AddToPreview( item->Clone() );
258
259 // update the cursor so it looks correct before another event
260 setCursor();
261 }
262
263 controls->SetCursorPosition( cursorPos, false );
264 }
265 // ... and second click places:
266 else
267 {
268 m_frame->SaveCopyInUndoList( symbol );
269
270 switch( item->Type() )
271 {
272 case LIB_PIN_T:
273 pinTool->PlacePin( (LIB_PIN*) item );
274 break;
275 case LIB_TEXT_T:
276 symbol->AddDrawItem( (LIB_TEXT*) item );
277 break;
278 default:
279 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
280 }
281
282 item->ClearEditFlags();
283 item = nullptr;
285
287 m_frame->OnModify();
288 }
289 }
290 else if( evt->IsClick( BUT_RIGHT ) )
291 {
292 // Warp after context menu only if dragging...
293 if( !item )
295
297 }
298 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
299 {
300 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
302 m_view->AddToPreview( item->Clone() );
303 }
304 else
305 {
306 evt->SetPassEvent();
307 }
308
309 // Enable autopanning and cursor capture only when there is an item to be placed
310 controls->SetAutoPan( item != nullptr );
311 controls->CaptureCursor( item != nullptr );
312 }
313
314 controls->SetAutoPan( false );
315 controls->CaptureCursor( false );
316 controls->ForceCursorPosition( false );
318 return 0;
319}
320
321
323{
324 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
326 SHAPE_T type = aEvent.Parameter<SHAPE_T>();
327 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
328 LIB_SHAPE* item = nullptr;
329 bool isTextBox = aEvent.IsAction( &EE_ACTIONS::drawSymbolTextBox );
330
331 if( m_inDrawShape )
332 return 0;
333
335
336 // We might be running as the same shape in another co-routine. Make sure that one
337 // gets whacked.
339
341
342 m_frame->PushTool( aEvent );
343
344 auto setCursor =
345 [&]()
346 {
348 };
349
350 auto cleanup =
351 [&] ()
352 {
355 delete item;
356 item = nullptr;
357 };
358
359 Activate();
360 // Must be done after Activate() so that it gets set into the correct context
361 getViewControls()->ShowCursor( true );
362 // Set initial cursor
363 setCursor();
364
365 if( aEvent.HasPosition() )
366 m_toolMgr->PrimeTool( aEvent.Position() );
367
368 // Main loop: keep receiving events
369 while( TOOL_EVENT* evt = Wait() )
370 {
371 setCursor();
372
373 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
374
375 // The tool hotkey is interpreted as a click when drawing
376 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
377 && evt->Matches( aEvent );
378
379 if( evt->IsCancelInteractive() )
380 {
381 if( item )
382 {
383 cleanup();
384 }
385 else
386 {
387 m_frame->PopTool( aEvent );
388 break;
389 }
390 }
391 else if( evt->IsActivate() && !isSyntheticClick )
392 {
393 if( item )
394 cleanup();
395
396 if( evt->IsPointEditor() )
397 {
398 // don't exit (the point editor runs in the background)
399 }
400 else if( evt->IsMoveTool() )
401 {
402 // leave ourselves on the stack so we come back after the move
403 break;
404 }
405 else
406 {
407 m_frame->PopTool( aEvent );
408 break;
409 }
410 }
411 else if( evt->IsClick( BUT_LEFT ) && !item )
412 {
413 // Update in case the symbol was changed while the tool was running
414 symbol = m_frame->GetCurSymbol();
415
416 if( !symbol )
417 continue;
418
420
421 int lineWidth = schIUScale.MilsToIU( settings->m_Defaults.line_width );
422
423 if( isTextBox )
424 {
425 LIB_TEXTBOX* textbox = new LIB_TEXTBOX( symbol, lineWidth, m_lastFillStyle );
426
427 textbox->SetBold( m_lastTextBold );
428 textbox->SetItalic( m_lastTextItalic );
429 textbox->SetTextSize( wxSize( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
430 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
431 textbox->SetTextAngle( m_lastTextAngle );
433
434 item = textbox;
435 }
436 else
437 {
438 item = new LIB_SHAPE( symbol, type, lineWidth, m_lastFillStyle );
439 }
440
441 item->SetStroke( m_lastStroke );
443
444 item->SetFlags( IS_NEW );
445 item->BeginEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
446
448 item->SetUnit( m_frame->GetUnit() );
449
451 item->SetConvert( m_frame->GetConvert() );
452
454 }
455 else if( item && ( evt->IsClick( BUT_LEFT )
456 || evt->IsDblClick( BUT_LEFT )
457 || isSyntheticClick
458 || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
459 {
460 if( symbol != m_frame->GetCurSymbol() )
461 {
462 symbol = m_frame->GetCurSymbol();
463 item->SetParent( symbol );
464 }
465
466 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing )
467 || !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) )
468 {
469 item->EndEdit();
470 item->ClearEditFlags();
471
472 if( isTextBox )
473 {
474 LIB_TEXTBOX* textbox = static_cast<LIB_TEXTBOX*>( item );
475 DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast<LIB_TEXTBOX*>( item ) );
476
477 if( dlg.ShowQuasiModal() != wxID_OK )
478 {
479 cleanup();
480 continue;
481 }
482
483 m_lastTextBold = textbox->IsBold();
484 m_lastTextItalic = textbox->IsItalic();
485 m_lastTextAngle = textbox->GetTextAngle();
486 m_lastTextJust = textbox->GetHorizJustify();
487 }
488
489 m_lastStroke = item->GetStroke();
492
494
495 m_frame->SaveCopyInUndoList( symbol );
496 symbol->AddDrawItem( item );
497 item = nullptr;
498
500 m_frame->OnModify();
502 }
503 }
504 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
505 {
506 item->CalcEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
508 m_view->AddToPreview( item->Clone() );
509 }
510 else if( evt->IsDblClick( BUT_LEFT ) && !item )
511 {
513 }
514 else if( evt->IsClick( BUT_RIGHT ) )
515 {
516 // Warp after context menu only if dragging...
517 if( !item )
519
521 }
522 else
523 {
524 evt->SetPassEvent();
525 }
526
527 // Enable autopanning and cursor capture only when there is a shape being drawn
528 getViewControls()->SetAutoPan( item != nullptr );
529 getViewControls()->CaptureCursor( item != nullptr );
530 }
531
532 getViewControls()->SetAutoPan( false );
533 getViewControls()->CaptureCursor( false );
535 return 0;
536}
537
538
540{
541 m_frame->PushTool( aEvent );
542
543 auto setCursor =
544 [&]()
545 {
547 };
548
549 Activate();
550 // Must be done after Activate() so that it gets set into the correct context
551 getViewControls()->ShowCursor( true );
552 // Set initial cursor
553 setCursor();
554
555 // Main loop: keep receiving events
556 while( TOOL_EVENT* evt = Wait() )
557 {
558 setCursor();
559
560 if( evt->IsCancelInteractive() )
561 {
562 m_frame->PopTool( aEvent );
563 break;
564 }
565 else if( evt->IsActivate() )
566 {
567 m_frame->PopTool( aEvent );
568 break;
569 }
570 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
571 {
572 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
573
574 if( !symbol )
575 continue;
576
577 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
578 VECTOR2I offset( -cursorPos.x, cursorPos.y );
579
580 symbol->SetOffset( offset );
581
582 // Refresh the view without changing the viewport
583 auto center = m_view->GetCenter();
584 center.x += offset.x;
585 center.y -= offset.y;
586 m_view->SetCenter( center );
588 m_frame->OnModify();
589 }
590 else if( evt->IsClick( BUT_RIGHT ) )
591 {
593 }
594 else
595 {
596 evt->SetPassEvent();
597 }
598 }
599
601 return 0;
602}
603
604
606{
608 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
609 LIB_PIN* sourcePin = nullptr;
610
611 if( !symbol )
612 return 0;
613
614 // See if we have a pin matching our weak ptr
615 for( LIB_PIN* test = symbol->GetNextPin(); test; test = symbol->GetNextPin( test ) )
616 {
617 if( (void*) test == g_lastPinWeakPtr )
618 sourcePin = test;
619 }
620
621 if( sourcePin )
622 {
623 LIB_PIN* pin = pinTool->RepeatPin( sourcePin );
625
627
628 if( pin )
630 }
631
632 return 0;
633}
634
635
637{
647}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static TOOL_ACTION activatePointEditor
Definition: actions.h:172
static TOOL_ACTION refreshPreview
Definition: actions.h:109
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.
int ShowQuasiModal()
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 SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:382
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
void ClearEditFlags()
Definition: eda_item.h:160
bool IsNew() const
Definition: eda_item.h:103
FILL_T GetFillMode() const
Definition: eda_shape.h:101
void SetFillColor(const COLOR4D &aColor)
Definition: eda_shape.h:104
COLOR4D GetFillColor() const
Definition: eda_shape.h:103
bool IsItalic() const
Definition: eda_text.h:123
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:142
void SetBold(bool aBold)
Definition: eda_text.cpp:209
bool IsBold() const
Definition: eda_text.h:126
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
void SetItalic(bool aItalic)
Definition: eda_text.cpp:201
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
static TOOL_ACTION properties
Definition: ee_actions.h:131
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:116
static TOOL_ACTION drawCircle
Definition: ee_actions.h:99
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:113
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:98
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:114
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:115
static TOOL_ACTION finishDrawing
Definition: ee_actions.h:117
static TOOL_ACTION drawArc
Definition: ee_actions.h:100
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:125
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:112
EE_SELECTION & GetSelection()
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:50
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:184
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:66
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
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.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
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 PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition: view.h:339
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1618
void ClearPreview()
Definition: view.cpp:1596
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1381
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:574
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_item.h:234
void SetConvert(int aConvert)
Definition: lib_item.h:275
void SetUnit(int aUnit)
Definition: lib_item.h:272
STROKE_PARAMS GetStroke() const
Definition: lib_shape.h:52
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_shape.h:72
void SetStroke(const STROKE_PARAMS &aStroke)
Definition: lib_shape.h:53
void EndEdit() override
End an object editing action.
Definition: lib_shape.h:76
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_shape.cpp:64
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: lib_shape.h:73
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_shape.h:74
Define a library symbol object.
Definition: lib_symbol.h:98
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:816
void SetOffset(const VECTOR2I &aOffset)
Move the symbol aOffset.
Define a symbol library graphical text item.
Definition: lib_text.h:40
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int AddItemToSel(const TOOL_EVENT &aEvent)
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
int PlaceAnchor(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
bool m_drawSpecificUnit
Re-entrancy guards.
int RepeatDrawItem(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int DrawShape(const TOOL_EVENT &aEvent)
int TwoClickPlace(const TOOL_EVENT &aEvent)
LIB_PIN * RepeatPin(const LIB_PIN *aSourcePin)
The symbol library editor main window.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current symbol.
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
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:214
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Generic, UI-independent tool event.
Definition: tool_event.h:156
bool HasPosition() const
Definition: tool_event.h:243
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:266
bool IsReactivate() const
Definition: tool_event.h:255
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
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 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.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
void DeactivateTool()
Deactivate the currently active tool.
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:424
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:57
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:408
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
SHAPE_T
Definition: eda_shape.h:41
FILL_T
Definition: eda_shape.h:54
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
static void * g_lastPinWeakPtr
@ GR_TEXT_H_ALIGN_LEFT
@ MD_SHIFT
Definition: tool_event.h:138
@ BUT_LEFT
Definition: tool_event.h:127
@ BUT_RIGHT
Definition: tool_event.h:128
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ LIB_TEXT_T
Definition: typeinfo.h:201
@ LIB_PIN_T
Definition: typeinfo.h:203
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618