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
219 text->SetUnit( m_frame->GetUnit() );
220
222 text->SetConvert( m_frame->GetConvert() );
223
224 text->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
225 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
226 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
227 text->SetTextAngle( m_lastTextAngle );
228
230
231 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
232 delete text;
233 else
234 item = text;
235
236 break;
237 }
238 default:
239 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
240 }
241
242 // If we started with a hotkey which has a position then warp back to that.
243 // Otherwise update to the current mouse position pinned inside the autoscroll
244 // boundaries.
245 if( evt->IsPrime() && !ignorePrimePosition )
246 {
247 cursorPos = grid.Align( evt->Position() );
248 getViewControls()->WarpMouseCursor( cursorPos, true );
249 }
250 else
251 {
253 cursorPos = getViewControls()->GetMousePosition();
254 }
255
256 if( item )
257 {
258 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
259
260 item->SetFlags( IS_NEW | IS_MOVING );
262 m_view->AddToPreview( item->Clone() );
264
265 // update the cursor so it looks correct before another event
266 setCursor();
267 }
268
269 controls->SetCursorPosition( cursorPos, false );
270 }
271 // ... and second click places:
272 else
273 {
274 m_frame->SaveCopyInUndoList( symbol );
275
276 switch( item->Type() )
277 {
278 case LIB_PIN_T:
279 pinTool->PlacePin( (LIB_PIN*) item );
280 break;
281 case LIB_TEXT_T:
282 symbol->AddDrawItem( (LIB_TEXT*) item );
283 break;
284 default:
285 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
286 }
287
288 item->ClearEditFlags();
289 item = nullptr;
291
293 m_frame->OnModify();
294 }
295 }
296 else if( evt->IsClick( BUT_RIGHT ) )
297 {
298 // Warp after context menu only if dragging...
299 if( !item )
301
303 }
304 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
305 {
306 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
308 m_view->AddToPreview( item->Clone() );
309 }
310 else
311 {
312 evt->SetPassEvent();
313 }
314
315 // Enable autopanning and cursor capture only when there is an item to be placed
316 controls->SetAutoPan( item != nullptr );
317 controls->CaptureCursor( item != nullptr );
318 }
319
320 controls->SetAutoPan( false );
321 controls->CaptureCursor( false );
322 controls->ForceCursorPosition( false );
324 return 0;
325}
326
327
329{
330 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
332 SHAPE_T type = aEvent.Parameter<SHAPE_T>();
333 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
334 LIB_SHAPE* item = nullptr;
335 bool isTextBox = aEvent.IsAction( &EE_ACTIONS::drawSymbolTextBox );
336
337 if( m_inDrawShape )
338 return 0;
339
341
342 // We might be running as the same shape in another co-routine. Make sure that one
343 // gets whacked.
345
347
348 m_frame->PushTool( aEvent );
349
350 auto setCursor =
351 [&]()
352 {
354 };
355
356 auto cleanup =
357 [&] ()
358 {
361 delete item;
362 item = nullptr;
363 };
364
365 Activate();
366 // Must be done after Activate() so that it gets set into the correct context
367 getViewControls()->ShowCursor( true );
368 // Set initial cursor
369 setCursor();
370
371 if( aEvent.HasPosition() )
372 m_toolMgr->PrimeTool( aEvent.Position() );
373
374 // Main loop: keep receiving events
375 while( TOOL_EVENT* evt = Wait() )
376 {
377 setCursor();
378
379 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
380
381 // The tool hotkey is interpreted as a click when drawing
382 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
383 && evt->Matches( aEvent );
384
385 if( evt->IsCancelInteractive() )
386 {
387 if( item )
388 {
389 cleanup();
390 }
391 else
392 {
393 m_frame->PopTool( aEvent );
394 break;
395 }
396 }
397 else if( evt->IsActivate() && !isSyntheticClick )
398 {
399 if( item )
400 cleanup();
401
402 if( evt->IsPointEditor() )
403 {
404 // don't exit (the point editor runs in the background)
405 }
406 else if( evt->IsMoveTool() )
407 {
408 // leave ourselves on the stack so we come back after the move
409 break;
410 }
411 else
412 {
413 m_frame->PopTool( aEvent );
414 break;
415 }
416 }
417 else if( evt->IsClick( BUT_LEFT ) && !item )
418 {
419 // Update in case the symbol was changed while the tool was running
420 symbol = m_frame->GetCurSymbol();
421
422 if( !symbol )
423 continue;
424
426
427 int lineWidth = schIUScale.MilsToIU( settings->m_Defaults.line_width );
428
429 if( isTextBox )
430 {
431 LIB_TEXTBOX* textbox = new LIB_TEXTBOX( symbol, lineWidth, m_lastFillStyle );
432
433 textbox->SetBold( m_lastTextBold );
434 textbox->SetItalic( m_lastTextItalic );
436 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
437 textbox->SetTextAngle( m_lastTextAngle );
439
440 item = textbox;
441 }
442 else
443 {
444 item = new LIB_SHAPE( symbol, type, lineWidth, m_lastFillStyle );
445 }
446
447 item->SetStroke( m_lastStroke );
449
450 item->SetFlags( IS_NEW );
451 item->BeginEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
452
454 item->SetUnit( m_frame->GetUnit() );
455
457 item->SetConvert( m_frame->GetConvert() );
458
460 }
461 else if( item && ( evt->IsClick( BUT_LEFT )
462 || evt->IsDblClick( BUT_LEFT )
463 || isSyntheticClick
464 || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
465 {
466 if( symbol != m_frame->GetCurSymbol() )
467 {
468 symbol = m_frame->GetCurSymbol();
469 item->SetParent( symbol );
470 }
471
472 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing )
473 || !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) )
474 {
475 item->EndEdit();
476 item->ClearEditFlags();
477
478 if( isTextBox )
479 {
480 LIB_TEXTBOX* textbox = static_cast<LIB_TEXTBOX*>( item );
481 DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast<LIB_TEXTBOX*>( item ) );
482
483 if( dlg.ShowQuasiModal() != wxID_OK )
484 {
485 cleanup();
486 continue;
487 }
488
489 m_lastTextBold = textbox->IsBold();
490 m_lastTextItalic = textbox->IsItalic();
491 m_lastTextAngle = textbox->GetTextAngle();
492 m_lastTextJust = textbox->GetHorizJustify();
493 }
494
495 m_lastStroke = item->GetStroke();
498
500
501 m_frame->SaveCopyInUndoList( symbol );
502 symbol->AddDrawItem( item );
503 item = nullptr;
504
506 m_frame->OnModify();
508 }
509 }
510 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
511 {
512 item->CalcEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
514 m_view->AddToPreview( item->Clone() );
515 }
516 else if( evt->IsDblClick( BUT_LEFT ) && !item )
517 {
519 }
520 else if( evt->IsClick( BUT_RIGHT ) )
521 {
522 // Warp after context menu only if dragging...
523 if( !item )
525
527 }
528 else
529 {
530 evt->SetPassEvent();
531 }
532
533 // Enable autopanning and cursor capture only when there is a shape being drawn
534 getViewControls()->SetAutoPan( item != nullptr );
535 getViewControls()->CaptureCursor( item != nullptr );
536 }
537
538 getViewControls()->SetAutoPan( false );
539 getViewControls()->CaptureCursor( false );
541 return 0;
542}
543
544
546{
547 m_frame->PushTool( aEvent );
548
549 auto setCursor =
550 [&]()
551 {
553 };
554
555 Activate();
556 // Must be done after Activate() so that it gets set into the correct context
557 getViewControls()->ShowCursor( true );
558 // Set initial cursor
559 setCursor();
560
561 // Main loop: keep receiving events
562 while( TOOL_EVENT* evt = Wait() )
563 {
564 setCursor();
565
566 if( evt->IsCancelInteractive() )
567 {
568 m_frame->PopTool( aEvent );
569 break;
570 }
571 else if( evt->IsActivate() )
572 {
573 m_frame->PopTool( aEvent );
574 break;
575 }
576 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
577 {
578 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
579
580 if( !symbol )
581 continue;
582
583 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
584 VECTOR2I offset( -cursorPos.x, cursorPos.y );
585
586 symbol->SetOffset( offset );
587
588 // Refresh the view without changing the viewport
589 auto center = m_view->GetCenter();
590 center.x += offset.x;
591 center.y -= offset.y;
592 m_view->SetCenter( center );
594 m_frame->OnModify();
595 }
596 else if( evt->IsClick( BUT_RIGHT ) )
597 {
599 }
600 else
601 {
602 evt->SetPassEvent();
603 }
604 }
605
607 return 0;
608}
609
610
612{
614 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
615 LIB_PIN* sourcePin = nullptr;
616
617 if( !symbol )
618 return 0;
619
620 // See if we have a pin matching our weak ptr
621 std::vector<LIB_PIN*> pins = symbol->GetAllLibPins();
622
623 for( LIB_PIN* test : pins )
624 {
625 if( (void*) test == g_lastPinWeakPtr )
626 {
627 sourcePin = test;
628 break;
629 }
630 }
631
632 if( sourcePin )
633 {
634 LIB_PIN* pin = pinTool->RepeatPin( sourcePin );
636
638
639 if( pin )
641 }
642
643 return 0;
644}
645
646
648{
658}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static TOOL_ACTION activatePointEditor
Definition: actions.h:173
static TOOL_ACTION refreshPreview
Definition: actions.h:110
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:139
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:158
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:106
COLOR4D GetFillColor() const
Definition: eda_shape.h:105
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
void SetBold(bool aBold)
Definition: eda_text.cpp:211
bool IsBold() const
Definition: eda_text.h:133
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:349
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:195
void SetItalic(bool aItalic)
Definition: eda_text.cpp:203
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:242
static TOOL_ACTION properties
Definition: ee_actions.h:128
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:113
static TOOL_ACTION drawCircle
Definition: ee_actions.h:96
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:110
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:95
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:111
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:112
static TOOL_ACTION finishDrawing
Definition: ee_actions.h:114
static TOOL_ACTION drawArc
Definition: ee_actions.h:97
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:122
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:109
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:191
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:102
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:1635
void ClearPreview()
Definition: view.cpp:1613
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1384
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:577
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:99
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:820
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:215
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:81
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: wx_infobar.cpp:175
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:425
#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:200
@ LIB_PIN_T
Definition: typeinfo.h:202
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590