KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <optional>
27#include <symbol_edit_frame.h>
28#include <sch_commit.h>
33#include <lib_text.h>
35#include <lib_shape.h>
36#include <lib_textbox.h>
37#include <pgm_base.h>
40#include <string_utils.h>
42
43static void* g_lastPinWeakPtr;
44
45
47 EE_TOOL_BASE<SYMBOL_EDIT_FRAME>( "eeschema.SymbolDrawing" ),
48 m_lastTextBold( false ),
49 m_lastTextItalic( false ),
50 m_lastTextAngle( ANGLE_HORIZONTAL ),
51 m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ),
52 m_lastFillStyle( FILL_T::NO_FILL ),
53 m_lastFillColor( COLOR4D::UNSPECIFIED ),
54 m_lastStroke( 0, PLOT_DASH_TYPE::DEFAULT, COLOR4D::UNSPECIFIED ),
55 m_drawSpecificConvert( true ),
56 m_drawSpecificUnit( false ),
57 m_inDrawShape( false ),
58 m_inTwoClickPlace( false )
59{
60}
61
62
64{
66
67 auto isDrawingCondition =
68 [] ( const SELECTION& aSel )
69 {
70 LIB_ITEM* item = (LIB_ITEM*) aSel.Front();
71 return item && item->IsNew();
72 };
73
74 m_menu.GetMenu().AddItem( EE_ACTIONS::finishDrawing, isDrawingCondition, 2 );
75
76 return true;
77}
78
79
81{
82 KICAD_T type = aEvent.Parameter<KICAD_T>();
83 auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
84 auto* pinTool = type == LIB_PIN_T ? m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() : nullptr;
85
87 return 0;
88
90
93 VECTOR2I cursorPos;
94 bool ignorePrimePosition = false;
95 LIB_ITEM* item = nullptr;
96 bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText );
97 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
98
100
101 m_frame->PushTool( aEvent );
102
103 auto setCursor =
104 [&]()
105 {
106 if( item )
107 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PLACE );
108 else if( isText )
109 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
110 else
111 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
112 };
113
114 auto cleanup =
115 [&] ()
116 {
119 delete item;
120 item = nullptr;
121 };
122
123 Activate();
124 // Must be done after Activate() so that it gets set into the correct context
125 controls->ShowCursor( true );
126 // Set initial cursor
127 setCursor();
128
129 if( aEvent.HasPosition() )
130 {
131 m_toolMgr->PrimeTool( aEvent.Position() );
132 }
133 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
134 {
135 m_toolMgr->PrimeTool( { 0, 0 } );
136 ignorePrimePosition = true;
137 }
138
139 // Main loop: keep receiving events
140 while( TOOL_EVENT* evt = Wait() )
141 {
142 setCursor();
143 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
144 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
145
146 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
147 controls->ForceCursorPosition( true, cursorPos );
148
149 // The tool hotkey is interpreted as a click when drawing
150 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
151 && evt->Matches( aEvent );
152
153 if( evt->IsCancelInteractive() )
154 {
156
157 if( item )
158 {
159 cleanup();
160 }
161 else
162 {
163 m_frame->PopTool( aEvent );
164 break;
165 }
166 }
167 else if( evt->IsActivate() && !isSyntheticClick )
168 {
169 if( item && evt->IsMoveTool() )
170 {
171 // we're already moving our own item; ignore the move tool
172 evt->SetPassEvent( false );
173 continue;
174 }
175
176 if( item )
177 {
178 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
179 evt->SetPassEvent( false );
180 continue;
181 }
182
183 if( evt->IsPointEditor() )
184 {
185 // don't exit (the point editor runs in the background)
186 }
187 else if( evt->IsMoveTool() )
188 {
189 break;
190 }
191 else
192 {
193 m_frame->PopTool( aEvent );
194 break;
195 }
196 }
197 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
198 {
199 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
200
201 if( !symbol )
202 continue;
203
204 // First click creates...
205 if( !item )
206 {
208
209 switch( type )
210 {
211 case LIB_PIN_T:
212 {
213 item = pinTool->CreatePin( VECTOR2I( cursorPos.x, -cursorPos.y ), symbol );
214 g_lastPinWeakPtr = item;
215 break;
216 }
217 case LIB_TEXT_T:
218 {
219 LIB_TEXT* text = new LIB_TEXT( symbol );
220
222 text->SetUnit( m_frame->GetUnit() );
223
225 text->SetConvert( m_frame->GetConvert() );
226
227 text->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
228 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
229 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
230 text->SetTextAngle( m_lastTextAngle );
231
233
234 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
235 delete text;
236 else
237 item = text;
238
239 break;
240 }
241 default:
242 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
243 }
244
245 // If we started with a hotkey which has a position then warp back to that.
246 // Otherwise update to the current mouse position pinned inside the autoscroll
247 // boundaries.
248 if( evt->IsPrime() && !ignorePrimePosition )
249 {
250 cursorPos = grid.Align( evt->Position(), grid.GetItemGrid( item ) );
251 getViewControls()->WarpMouseCursor( cursorPos, true );
252 }
253 else
254 {
256 cursorPos = getViewControls()->GetMousePosition();
257 }
258
259 if( item )
260 {
261 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
262
263 item->SetFlags( IS_NEW | IS_MOVING );
265 m_view->AddToPreview( item->Clone() );
267
268 // update the cursor so it looks correct before another event
269 setCursor();
270 }
271
272 controls->SetCursorPosition( cursorPos, false );
273 }
274 // ... and second click places:
275 else
276 {
277 SCH_COMMIT commit( m_toolMgr );
278 commit.Modify( symbol, m_frame->GetScreen() );
279
280 switch( item->Type() )
281 {
282 case LIB_PIN_T:
283 pinTool->PlacePin( (LIB_PIN*) item );
284 item->ClearEditFlags();
285 commit.Push( _( "Add Pin" ) );
286 break;
287
288 case LIB_TEXT_T:
289 symbol->AddDrawItem( (LIB_TEXT*) item );
290 item->ClearEditFlags();
291 commit.Push( _( "Add Text" ) );
292 break;
293
294 default:
295 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
296 }
297
298 item = nullptr;
301 }
302 }
303 else if( evt->IsClick( BUT_RIGHT ) )
304 {
305 // Warp after context menu only if dragging...
306 if( !item )
308
310 }
311 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
312 {
313 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
315 m_view->AddToPreview( item->Clone() );
316 }
317 else
318 {
319 evt->SetPassEvent();
320 }
321
322 // Enable autopanning and cursor capture only when there is an item to be placed
323 controls->SetAutoPan( item != nullptr );
324 controls->CaptureCursor( item != nullptr );
325 }
326
327 controls->SetAutoPan( false );
328 controls->CaptureCursor( false );
329 controls->ForceCursorPosition( false );
330 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
331 return 0;
332}
333
334
336{
337 SHAPE_T requestedShape = aEvent.Parameter<SHAPE_T>();
338
339 return doDrawShape( aEvent, requestedShape );
340}
341
342
344{
345 return doDrawShape( aEvent, std::nullopt /* Draw text box */ );
346}
347
348
349int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional<SHAPE_T> aDrawingShape )
350{
351 bool isTextBox = !aDrawingShape.has_value();
352 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
353
355 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
358 VECTOR2I cursorPos;
359 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
360 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
361 LIB_SHAPE* item = nullptr;
362 wxString description;
363
364 if( m_inDrawShape )
365 return 0;
366
368
369 // We might be running as the same shape in another co-routine. Make sure that one
370 // gets whacked.
372
374
375 m_frame->PushTool( aEvent );
376
377 auto setCursor =
378 [&]()
379 {
380 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
381 };
382
383 auto cleanup =
384 [&] ()
385 {
388 delete item;
389 item = nullptr;
390 };
391
392 Activate();
393 // Must be done after Activate() so that it gets set into the correct context
394 controls->ShowCursor( true );
395 // Set initial cursor
396 setCursor();
397
398 if( aEvent.HasPosition() )
399 m_toolMgr->PrimeTool( aEvent.Position() );
400
401 // Main loop: keep receiving events
402 while( TOOL_EVENT* evt = Wait() )
403 {
404 setCursor();
405 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
406 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
407
408 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
409 controls->ForceCursorPosition( true, cursorPos );
410
411 // The tool hotkey is interpreted as a click when drawing
412 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
413 && evt->Matches( aEvent );
414
415 if( evt->IsCancelInteractive() )
416 {
417 if( item )
418 {
419 cleanup();
420 }
421 else
422 {
423 m_frame->PopTool( aEvent );
424 break;
425 }
426 }
427 else if( evt->IsActivate() && !isSyntheticClick )
428 {
429 if( item )
430 cleanup();
431
432 if( evt->IsPointEditor() )
433 {
434 // don't exit (the point editor runs in the background)
435 }
436 else if( evt->IsMoveTool() )
437 {
438 // leave ourselves on the stack so we come back after the move
439 break;
440 }
441 else
442 {
443 m_frame->PopTool( aEvent );
444 break;
445 }
446 }
447 else if( evt->IsClick( BUT_LEFT ) && !item )
448 {
449 // Update in case the symbol was changed while the tool was running
450 symbol = m_frame->GetCurSymbol();
451
452 if( !symbol )
453 continue;
454
456
457 int lineWidth = schIUScale.MilsToIU( settings->m_Defaults.line_width );
458
459 if( isTextBox )
460 {
461 LIB_TEXTBOX* textbox = new LIB_TEXTBOX( symbol, lineWidth, m_lastFillStyle );
462
463 textbox->SetBold( m_lastTextBold );
464 textbox->SetItalic( m_lastTextItalic );
466 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
467 textbox->SetTextAngle( m_lastTextAngle );
469
470 item = textbox;
471 description = _( "Add Text Box" );
472 }
473 else
474 {
475 item = new LIB_SHAPE( symbol, shapeType, lineWidth, m_lastFillStyle );
476 description = wxString::Format( _( "Add %s" ), item->EDA_SHAPE::GetFriendlyName() );
477 }
478
479 item->SetStroke( m_lastStroke );
481
482 item->SetFlags( IS_NEW );
483 item->BeginEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
484
486 item->SetUnit( m_frame->GetUnit() );
487
489 item->SetConvert( m_frame->GetConvert() );
490
492 }
493 else if( item && ( evt->IsClick( BUT_LEFT )
494 || evt->IsDblClick( BUT_LEFT )
495 || isSyntheticClick
496 || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
497 {
498 if( symbol != m_frame->GetCurSymbol() )
499 {
500 symbol = m_frame->GetCurSymbol();
501 item->SetParent( symbol );
502 }
503
504 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &EE_ACTIONS::finishDrawing )
505 || !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) )
506 {
507 if( toolType == SHAPE_T::POLY )
508 {
509 item->CalcEdit( item->GetPosition() ); // Close shape
510 item->EndEdit( true );
511 }
512 else
513 {
514 item->EndEdit();
515 }
516
517 item->ClearEditFlags();
518
519 if( isTextBox )
520 {
521 LIB_TEXTBOX* textbox = static_cast<LIB_TEXTBOX*>( item );
522 DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast<LIB_TEXTBOX*>( item ) );
523
524 if( dlg.ShowQuasiModal() != wxID_OK )
525 {
526 cleanup();
527 continue;
528 }
529
530 m_lastTextBold = textbox->IsBold();
531 m_lastTextItalic = textbox->IsItalic();
532 m_lastTextAngle = textbox->GetTextAngle();
533 m_lastTextJust = textbox->GetHorizJustify();
534 }
535
536 m_lastStroke = item->GetStroke();
539
541
542 SCH_COMMIT commit( m_toolMgr );
543 commit.Modify( symbol, m_frame->GetScreen() );
544
545 symbol->AddDrawItem( item );
546 item = nullptr;
547
548 commit.Push( description );
551 }
552 }
553 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
554 {
555 item->CalcEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
557 m_view->AddToPreview( item->Clone() );
558 }
559 else if( evt->IsDblClick( BUT_LEFT ) && !item )
560 {
562 }
563 else if( evt->IsClick( BUT_RIGHT ) )
564 {
565 // Warp after context menu only if dragging...
566 if( !item )
568
570 }
571 else
572 {
573 evt->SetPassEvent();
574 }
575
576 // Enable autopanning and cursor capture only when there is a shape being drawn
577 controls->SetAutoPan( item != nullptr );
578 controls->CaptureCursor( item != nullptr );
579 }
580
581 controls->SetAutoPan( false );
582 controls->CaptureCursor( false );
583 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
584 return 0;
585}
586
587
589{
590 m_frame->PushTool( aEvent );
591
592 auto setCursor =
593 [&]()
594 {
595 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
596 };
597
598 Activate();
599 // Must be done after Activate() so that it gets set into the correct context
600 getViewControls()->ShowCursor( true );
601 // Set initial cursor
602 setCursor();
603
604 // Main loop: keep receiving events
605 while( TOOL_EVENT* evt = Wait() )
606 {
607 setCursor();
608
609 if( evt->IsCancelInteractive() )
610 {
611 m_frame->PopTool( aEvent );
612 break;
613 }
614 else if( evt->IsActivate() )
615 {
616 m_frame->PopTool( aEvent );
617 break;
618 }
619 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
620 {
621 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
622
623 if( !symbol )
624 continue;
625
626 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
627 VECTOR2I offset( -cursorPos.x, cursorPos.y );
628
629 symbol->SetOffset( offset );
630
631 // Refresh the view without changing the viewport
632 auto center = m_view->GetCenter();
633 center.x += offset.x;
634 center.y -= offset.y;
635 m_view->SetCenter( center );
637 m_frame->OnModify();
638 }
639 else if( evt->IsClick( BUT_RIGHT ) )
640 {
642 }
643 else
644 {
645 evt->SetPassEvent();
646 }
647 }
648
649 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
650 return 0;
651}
652
653
655{
657 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
658 LIB_PIN* sourcePin = nullptr;
659
660 if( !symbol )
661 return 0;
662
663 // See if we have a pin matching our weak ptr
664 std::vector<LIB_PIN*> pins = symbol->GetAllLibPins();
665
666 for( LIB_PIN* test : pins )
667 {
668 if( (void*) test == g_lastPinWeakPtr )
669 {
670 sourcePin = test;
671 break;
672 }
673 }
674
675 if( sourcePin )
676 {
677 LIB_PIN* pin = pinTool->RepeatPin( sourcePin );
679
681
682 if( pin )
684 }
685
686 return 0;
687}
688
689
691{
702}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static TOOL_ACTION activatePointEditor
Definition: actions.h:178
static TOOL_ACTION refreshPreview
Definition: actions.h:111
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
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.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:123
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:372
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:137
bool IsNew() const
Definition: eda_item.h:103
FILL_T GetFillMode() const
Definition: eda_shape.h:102
void SetFillColor(const COLOR4D &aColor)
Definition: eda_shape.h:107
COLOR4D GetFillColor() const
Definition: eda_shape.h:106
void SetTextSize(VECTOR2I aNewSize)
Definition: eda_text.cpp:355
bool IsItalic() const
Definition: eda_text.h:141
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:160
void SetBold(bool aBold)
Definition: eda_text.cpp:218
bool IsBold() const
Definition: eda_text.h:144
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:202
void SetItalic(bool aItalic)
Definition: eda_text.cpp:210
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:249
static TOOL_ACTION properties
Definition: ee_actions.h:127
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:114
static TOOL_ACTION drawSymbolPolygon
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:115
static TOOL_ACTION drawArc
Definition: ee_actions.h:97
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:121
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:48
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:197
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:64
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:1652
void ClearPreview()
Definition: view.cpp:1630
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1401
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:68
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_item.h:268
void SetConvert(int aConvert)
Definition: lib_item.h:309
void SetUnit(int aUnit)
Definition: lib_item.h:306
STROKE_PARAMS GetStroke() const
Definition: lib_shape.h:57
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_shape.h:77
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: lib_shape.h:81
void SetStroke(const STROKE_PARAMS &aStroke)
Definition: lib_shape.h:58
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:78
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_shape.h:79
VECTOR2I GetPosition() const override
Definition: lib_shape.h:90
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.
void SetOffset(const VECTOR2I &aOffset)
Move the symbol aOffset.
Define a symbol library graphical text item.
Definition: lib_text.h:40
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:350
int AddItemToSel(const TOOL_EVENT &aEvent)
T * GetAppSettings()
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)
int doDrawShape(const TOOL_EVENT &aEvent, std::optional< SHAPE_T > aDrawingShape)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int DrawShape(const TOOL_EVENT &aEvent)
int DrawSymbolTextBox(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.
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:216
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:167
bool HasPosition() const
Definition: tool_event.h:256
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:285
bool IsReactivate() const
Definition: tool_event.h:268
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
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:461
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.
void DeactivateTool()
Deactivate the currently active tool.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:145
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...
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:230
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:517
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:187
#define _(s)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
Definition: eda_angle.h:433
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:55
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
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:142
@ BUT_LEFT
Definition: tool_event.h:131
@ BUT_RIGHT
Definition: tool_event.h:132
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ LIB_TEXT_T
Definition: typeinfo.h:199
@ LIB_PIN_T
Definition: typeinfo.h:201
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588