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-2024 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 <dialogs/dialog_text_properties.h>
34#include <sch_shape.h>
35#include <sch_textbox.h>
36#include <pgm_base.h>
37#include <view/view_controls.h>
40#include <string_utils.h>
41#include <wx/msgdlg.h>
43
44static void* g_lastPinWeakPtr;
45
46
48 EE_TOOL_BASE<SYMBOL_EDIT_FRAME>( "eeschema.SymbolDrawing" ),
49 m_lastTextBold( false ),
50 m_lastTextItalic( false ),
51 m_lastTextAngle( ANGLE_HORIZONTAL ),
52 m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ),
53 m_lastFillStyle( FILL_T::NO_FILL ),
54 m_lastFillColor( COLOR4D::UNSPECIFIED ),
55 m_lastStroke( 0, LINE_STYLE::DEFAULT, COLOR4D::UNSPECIFIED ),
56 m_drawSpecificBodyStyle( true ),
57 m_drawSpecificUnit( false ),
58 m_inDrawShape( false ),
59 m_inTwoClickPlace( false )
60{
61}
62
63
65{
67
68 auto isDrawingCondition =
69 [] ( const SELECTION& aSel )
70 {
71 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSel.Front() );
72 return item && item->IsNew();
73 };
74
75 m_menu.GetMenu().AddItem( ACTIONS::finishInteractive, isDrawingCondition, 2 );
76
77 return true;
78}
79
80
82{
83 KICAD_T type = aEvent.Parameter<KICAD_T>();
85 auto* pinTool = type == SCH_PIN_T ? m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() : nullptr;
86
88 return 0;
89
91
94 VECTOR2I cursorPos;
95 bool ignorePrimePosition = false;
96 SCH_ITEM* item = nullptr;
97 bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText );
98 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
99
101
102 m_frame->PushTool( aEvent );
103
104 auto setCursor =
105 [&]()
106 {
107 if( item )
108 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PLACE );
109 else if( isText )
110 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
111 else
112 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
113 };
114
115 auto cleanup =
116 [&] ()
117 {
120 delete item;
121 item = nullptr;
122 };
123
124 Activate();
125 // Must be done after Activate() so that it gets set into the correct context
126 controls->ShowCursor( true );
127 // Set initial cursor
128 setCursor();
129
130 if( aEvent.HasPosition() )
131 {
132 m_toolMgr->PrimeTool( aEvent.Position() );
133 }
134 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
135 {
136 m_toolMgr->PrimeTool( { 0, 0 } );
137 ignorePrimePosition = true;
138 }
139
140 // Main loop: keep receiving events
141 while( TOOL_EVENT* evt = Wait() )
142 {
143 setCursor();
144 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
145 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
146
147 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
148 controls->ForceCursorPosition( true, cursorPos );
149
150 // The tool hotkey is interpreted as a click when drawing
151 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
152 && evt->Matches( aEvent );
153
154 if( evt->IsCancelInteractive() )
155 {
157
158 if( item )
159 {
160 cleanup();
161 }
162 else
163 {
164 m_frame->PopTool( aEvent );
165 break;
166 }
167 }
168 else if( evt->IsActivate() && !isSyntheticClick )
169 {
170 if( item && evt->IsMoveTool() )
171 {
172 // we're already moving our own item; ignore the move tool
173 evt->SetPassEvent( false );
174 continue;
175 }
176
177 if( item )
178 {
179 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
180 evt->SetPassEvent( false );
181 continue;
182 }
183
184 if( evt->IsPointEditor() )
185 {
186 // don't exit (the point editor runs in the background)
187 }
188 else if( evt->IsMoveTool() )
189 {
190 break;
191 }
192 else
193 {
194 m_frame->PopTool( aEvent );
195 break;
196 }
197 }
198 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
199 {
200 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
201
202 if( !symbol )
203 continue;
204
205 // First click creates...
206 if( !item )
207 {
209
210 switch( type )
211 {
212 case SCH_PIN_T:
213 {
214 item = pinTool->CreatePin( cursorPos, symbol );
215 g_lastPinWeakPtr = item;
216 break;
217 }
218 case SCH_TEXT_T:
219 {
220 SCH_TEXT* text = new SCH_TEXT( cursorPos, wxEmptyString, LAYER_DEVICE );
221
222 text->SetParent( symbol );
223
225 text->SetUnit( m_frame->GetUnit() );
226
228 text->SetBodyStyle( m_frame->GetBodyStyle() );
229
230 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
231 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
232 text->SetTextAngle( m_lastTextAngle );
233
235
236 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
237 delete text;
238 else
239 item = text;
240
241 break;
242 }
243 default:
244 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
245 }
246
247 // If we started with a hotkey which has a position then warp back to that.
248 // Otherwise update to the current mouse position pinned inside the autoscroll
249 // boundaries.
250 if( evt->IsPrime() && !ignorePrimePosition )
251 {
252 cursorPos = grid.Align( evt->Position(), grid.GetItemGrid( item ) );
253 getViewControls()->WarpMouseCursor( cursorPos, true );
254 }
255 else
256 {
258 cursorPos = getViewControls()->GetMousePosition();
259 }
260
261 if( item )
262 {
263 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
264
265 item->SetFlags( IS_NEW | IS_MOVING );
267 m_view->AddToPreview( item->Clone() );
269
270 // update the cursor so it looks correct before another event
271 setCursor();
272 }
273
274 controls->SetCursorPosition( cursorPos, false );
275 }
276 // ... and second click places:
277 else
278 {
279 SCH_COMMIT commit( m_toolMgr );
280 commit.Modify( symbol, m_frame->GetScreen() );
281
282 switch( item->Type() )
283 {
284 case SCH_PIN_T:
285 pinTool->PlacePin( static_cast<SCH_PIN*>( item ) );
286 item->ClearEditFlags();
287 commit.Push( _( "Add Pin" ) );
288 break;
289
290 case SCH_TEXT_T:
291 symbol->AddDrawItem( static_cast<SCH_TEXT*>( item ) );
292 item->ClearEditFlags();
293 commit.Push( _( "Add Text" ) );
294 break;
295
296 default:
297 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
298 }
299
300 item = nullptr;
303 }
304 }
305 else if( evt->IsClick( BUT_RIGHT ) )
306 {
307 // Warp after context menu only if dragging...
308 if( !item )
310
312 }
313 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
314 {
315 item->SetPosition( VECTOR2I( cursorPos.x, cursorPos.y ) );
317 m_view->AddToPreview( item->Clone() );
318 }
319 else
320 {
321 evt->SetPassEvent();
322 }
323
324 // Enable autopanning and cursor capture only when there is an item to be placed
325 controls->SetAutoPan( item != nullptr );
326 controls->CaptureCursor( item != nullptr );
327 }
328
329 controls->SetAutoPan( false );
330 controls->CaptureCursor( false );
331 controls->ForceCursorPosition( false );
332 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
333 return 0;
334}
335
336
338{
339 SHAPE_T requestedShape = aEvent.Parameter<SHAPE_T>();
340
341 return doDrawShape( aEvent, requestedShape );
342}
343
344
346{
347 return doDrawShape( aEvent, std::nullopt /* Draw text box */ );
348}
349
350
351int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional<SHAPE_T> aDrawingShape )
352{
353 bool isTextBox = !aDrawingShape.has_value();
354 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
355
357 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
360 VECTOR2I cursorPos;
361 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
362 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
363 SCH_SHAPE* item = nullptr;
364 wxString description;
365
366 if( m_inDrawShape )
367 return 0;
368
370
371 // We might be running as the same shape in another co-routine. Make sure that one
372 // gets whacked.
374
376
377 m_frame->PushTool( aEvent );
378
379 auto setCursor =
380 [&]()
381 {
382 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
383 };
384
385 auto cleanup =
386 [&] ()
387 {
390 delete item;
391 item = nullptr;
392 };
393
394 Activate();
395 // Must be done after Activate() so that it gets set into the correct context
396 controls->ShowCursor( true );
397 // Set initial cursor
398 setCursor();
399
400 if( aEvent.HasPosition() )
401 m_toolMgr->PrimeTool( aEvent.Position() );
402
403 // Main loop: keep receiving events
404 while( TOOL_EVENT* evt = Wait() )
405 {
406 setCursor();
407 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
408 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
409
410 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
411 controls->ForceCursorPosition( true, cursorPos );
412
413 // The tool hotkey is interpreted as a click when drawing
414 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
415 && evt->Matches( aEvent );
416
417 if( evt->IsCancelInteractive() )
418 {
419 if( item )
420 {
421 cleanup();
422 }
423 else
424 {
425 m_frame->PopTool( aEvent );
426 break;
427 }
428 }
429 else if( evt->IsActivate() && !isSyntheticClick )
430 {
431 if( item )
432 cleanup();
433
434 if( evt->IsPointEditor() )
435 {
436 // don't exit (the point editor runs in the background)
437 }
438 else if( evt->IsMoveTool() )
439 {
440 // leave ourselves on the stack so we come back after the move
441 break;
442 }
443 else
444 {
445 m_frame->PopTool( aEvent );
446 break;
447 }
448 }
449 else if( evt->IsClick( BUT_LEFT ) && !item )
450 {
451 // Update in case the symbol was changed while the tool was running
452 symbol = m_frame->GetCurSymbol();
453
454 if( !symbol )
455 continue;
456
458
459 int lineWidth = schIUScale.MilsToIU( settings->m_Defaults.line_width );
460
461 if( isTextBox )
462 {
463 SCH_TEXTBOX* textbox = new SCH_TEXTBOX( LAYER_DEVICE, lineWidth, m_lastFillStyle );
464
465 textbox->SetParent( symbol );
467 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
468
469 // Must be after SetTextSize()
470 textbox->SetBold( m_lastTextBold );
471 textbox->SetItalic( m_lastTextItalic );
472
473 textbox->SetTextAngle( m_lastTextAngle );
475
476 item = textbox;
477 description = _( "Add Text Box" );
478 }
479 else
480 {
481 item = new SCH_SHAPE( shapeType, LAYER_DEVICE, lineWidth, m_lastFillStyle );
482 item->SetParent( symbol );
483 description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() );
484 }
485
486 item->SetStroke( m_lastStroke );
488
489 item->SetFlags( IS_NEW );
490 item->BeginEdit( cursorPos );
491
493 item->SetUnit( m_frame->GetUnit() );
494
497
499 }
500 else if( item && ( evt->IsClick( BUT_LEFT )
501 || evt->IsDblClick( BUT_LEFT )
502 || isSyntheticClick
503 || evt->IsAction( &ACTIONS::finishInteractive ) ) )
504 {
505 if( symbol != m_frame->GetCurSymbol() )
506 {
507 symbol = m_frame->GetCurSymbol();
508 item->SetParent( symbol );
509 }
510
511 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &ACTIONS::finishInteractive )
512 || !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) )
513 {
514 if( toolType == SHAPE_T::POLY )
515 {
516 item->CalcEdit( item->GetPosition() ); // Close shape
517 item->EndEdit( true );
518 }
519 else
520 {
521 item->EndEdit();
522 }
523
524 item->ClearEditFlags();
525
526 if( isTextBox )
527 {
528 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
529 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( item ) );
530
531 // QuasiModal required for syntax help and Scintilla auto-complete
532 if( dlg.ShowQuasiModal() != wxID_OK )
533 {
534 cleanup();
535 continue;
536 }
537
538 m_lastTextBold = textbox->IsBold();
539 m_lastTextItalic = textbox->IsItalic();
540 m_lastTextAngle = textbox->GetTextAngle();
541 m_lastTextJust = textbox->GetHorizJustify();
542 }
543
544 m_lastStroke = item->GetStroke();
547
549
550 SCH_COMMIT commit( m_toolMgr );
551 commit.Modify( symbol, m_frame->GetScreen() );
552
553 symbol->AddDrawItem( item );
554 item = nullptr;
555
556 commit.Push( description );
559 }
560 }
561 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
562 {
563 item->CalcEdit( cursorPos );
565 m_view->AddToPreview( item->Clone() );
566 }
567 else if( evt->IsDblClick( BUT_LEFT ) && !item )
568 {
570 }
571 else if( evt->IsClick( BUT_RIGHT ) )
572 {
573 // Warp after context menu only if dragging...
574 if( !item )
576
578 }
579 else
580 {
581 evt->SetPassEvent();
582 }
583
584 // Enable autopanning and cursor capture only when there is a shape being drawn
585 controls->SetAutoPan( item != nullptr );
586 controls->CaptureCursor( item != nullptr );
587 }
588
589 controls->SetAutoPan( false );
590 controls->CaptureCursor( false );
591 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
592 return 0;
593}
594
595
597{
598 m_frame->PushTool( aEvent );
599
600 auto setCursor =
601 [&]()
602 {
603 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
604 };
605
606 Activate();
607 // Must be done after Activate() so that it gets set into the correct context
608 getViewControls()->ShowCursor( true );
609 // Set initial cursor
610 setCursor();
611
612 // Main loop: keep receiving events
613 while( TOOL_EVENT* evt = Wait() )
614 {
615 setCursor();
616
617 if( evt->IsCancelInteractive() )
618 {
619 m_frame->PopTool( aEvent );
620 break;
621 }
622 else if( evt->IsActivate() )
623 {
624 m_frame->PopTool( aEvent );
625 break;
626 }
627 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
628 {
629 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
630
631 if( !symbol )
632 continue;
633
634 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
635
636 symbol->Move( -cursorPos );
637
638 // Refresh the view without changing the viewport
639 m_view->SetCenter( m_view->GetCenter() + cursorPos );
641 m_frame->OnModify();
642 }
643 else if( evt->IsClick( BUT_RIGHT ) )
644 {
646 }
647 else
648 {
649 evt->SetPassEvent();
650 }
651 }
652
653 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
654 return 0;
655}
656
657
659{
660 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
661
662 if( !symbol )
663 return 0;
664
665 // Note: PlaceImportedGraphics() will convert PCB_SHAPE_T and PCB_TEXT_T to footprint
666 // items if needed
668 int dlgResult = dlg.ShowModal();
669
670 std::list<std::unique_ptr<EDA_ITEM>>& list = dlg.GetImportedItems();
671
672 if( dlgResult != wxID_OK )
673 return 0;
674
675 // Ensure the list is not empty:
676 if( list.empty() )
677 {
678 wxMessageBox( _( "No graphic items found in file." ) );
679 return 0;
680 }
681
683
685 std::vector<SCH_ITEM*> newItems; // all new items, including group
686 std::vector<SCH_ITEM*> selectedItems; // the group, or newItems if no group
687 EE_SELECTION preview;
688 SCH_COMMIT commit( m_toolMgr );
689
690 for( std::unique_ptr<EDA_ITEM>& ptr : list )
691 {
692 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ptr.get() );
693 wxCHECK2( item, continue );
694
695 newItems.push_back( item );
696 selectedItems.push_back( item );
697 preview.Add( item );
698
699 ptr.release();
700 }
701
702 if( !dlg.IsPlacementInteractive() )
703 {
704 commit.Modify( symbol, m_frame->GetScreen() );
705
706 // Place the imported drawings
707 for( SCH_ITEM* item : newItems )
708 {
709 symbol->AddDrawItem( item );
710 item->ClearEditFlags();
711 }
712
713 commit.Push( _( "Import Graphic" ) );
715
716 return 0;
717 }
718
719 m_view->Add( &preview );
720
721 // Clear the current selection then select the drawings so that edit tools work on them
723
724 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
726
727 m_frame->PushTool( aEvent );
728
729 auto setCursor = [&]()
730 {
731 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
732 };
733
734 Activate();
735 // Must be done after Activate() so that it gets set into the correct context
736 controls->ShowCursor( true );
737 controls->ForceCursorPosition( false );
738 // Set initial cursor
739 setCursor();
740
741 //SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
743
744 // Now move the new items to the current cursor position:
745 VECTOR2I cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
746 VECTOR2I delta = cursorPos;
747 VECTOR2I currentOffset;
748
749 for( SCH_ITEM* item : selectedItems )
750 item->Move( delta );
751
752 currentOffset += delta;
753
754 m_view->Update( &preview );
755
756 // Main loop: keep receiving events
757 while( TOOL_EVENT* evt = Wait() )
758 {
759 setCursor();
760
761 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
762 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
763
764 cursorPos = grid.Align( controls->GetMousePosition(), GRID_GRAPHICS );
765 controls->ForceCursorPosition( true, cursorPos );
766
767 if( evt->IsCancelInteractive() || evt->IsActivate() )
768 {
770
771 for( SCH_ITEM* item : newItems )
772 delete item;
773
774 break;
775 }
776 else if( evt->IsMotion() )
777 {
778 delta = cursorPos - currentOffset;
779
780 for( SCH_ITEM* item : selectedItems )
781 item->Move( delta );
782
783 currentOffset += delta;
784
785 m_view->Update( &preview );
786 }
787 else if( evt->IsClick( BUT_RIGHT ) )
788 {
790 }
791 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
792 {
793 commit.Modify( symbol, m_frame->GetScreen() );
794
795 // Place the imported drawings
796 for( SCH_ITEM* item : newItems )
797 {
798 symbol->AddDrawItem( item );
799 item->ClearEditFlags();
800 }
801
802 commit.Push( _( "Import Graphic" ) );
803 break; // This is a one-shot command, not a tool
804 }
805 else
806 {
807 evt->SetPassEvent();
808 }
809 }
810
811 preview.Clear();
812 m_view->Remove( &preview );
813
815
816 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
817 controls->ForceCursorPosition( false );
818
819 m_frame->PopTool( aEvent );
820
821 return 0;
822}
823
824
826{
828 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
829 SCH_PIN* sourcePin = nullptr;
830
831 if( !symbol )
832 return 0;
833
834 // See if we have a pin matching our weak ptr
835 for( SCH_PIN* test : symbol->GetAllLibPins() )
836 {
837 if( (void*) test == g_lastPinWeakPtr )
838 {
839 sourcePin = test;
840 break;
841 }
842 }
843
844 if( sourcePin )
845 {
846 SCH_PIN* pin = pinTool->RepeatPin( sourcePin );
848
850
851 if( pin )
853 }
854
855 return 0;
856}
857
858
860{
872}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
static TOOL_ACTION cancelInteractive
Definition: actions.h:64
static TOOL_ACTION activatePointEditor
Definition: actions.h:209
static TOOL_ACTION refreshPreview
Definition: actions.h:138
static TOOL_ACTION finishInteractive
Definition: actions.h:65
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
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.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
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:88
virtual void ClearEditFlags()
Definition: eda_item.h:140
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:243
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:126
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:375
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:103
virtual wxString GetFriendlyName() const
Definition: eda_item.cpp:329
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
bool IsNew() const
Definition: eda_item.h:106
FILL_T GetFillMode() const
Definition: eda_shape.h:107
void SetFillColor(const COLOR4D &aColor)
Definition: eda_shape.h:112
COLOR4D GetFillColor() const
Definition: eda_shape.h:111
bool IsItalic() const
Definition: eda_text.h:144
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:372
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:164
void SetBold(bool aBold)
Definition: eda_text.cpp:219
bool IsBold() const
Definition: eda_text.h:148
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:203
void SetItalic(bool aItalic)
Definition: eda_text.cpp:211
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:266
static TOOL_ACTION properties
Definition: ee_actions.h:129
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:117
static TOOL_ACTION drawSymbolPolygon
Definition: ee_actions.h:116
static TOOL_ACTION drawCircle
Definition: ee_actions.h:101
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:113
static TOOL_ACTION importGraphics
Definition: ee_actions.h:254
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:100
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:114
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:115
static TOOL_ACTION drawArc
Definition: ee_actions.h:102
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:123
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:48
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:200
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:341
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:315
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:354
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:1631
void ClearPreview()
Definition: view.cpp:1653
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1410
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1675
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
Define a library symbol object.
Definition: lib_symbol.h:77
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:832
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:678
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
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:406
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
virtual void SetBodyStyle(int aBodyStyle)
Definition: sch_item.h:231
virtual void SetUnit(int aUnit)
Definition: sch_item.h:228
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: sch_shape.h:75
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_shape.cpp:46
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: sch_shape.h:78
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:63
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: sch_shape.h:76
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_shape.h:77
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:55
VECTOR2I GetPosition() const override
Definition: sch_shape.h:70
int AddItemToSel(const TOOL_EVENT &aEvent)
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:42
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:93
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 ImportGraphics(const TOOL_EVENT &aEvent)
int DrawShape(const TOOL_EVENT &aEvent)
int DrawSymbolTextBox(const TOOL_EVENT &aEvent)
int TwoClickPlace(const TOOL_EVENT &aEvent)
SCH_PIN * RepeatPin(const SCH_PIN *aSourcePin)
The symbol library editor main window.
int GetBodyStyle() const
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:217
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
bool DisableGridSnapping() const
Definition: tool_event.h:363
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:82
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:460
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:150
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:235
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:530
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:397
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:532
#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
@ GRID_GRAPHICS
Definition: grid_helper.h:45
@ LAYER_DEVICE
Definition: layer_ids.h:370
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
static void * g_lastPinWeakPtr
constexpr int delta
@ 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
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_PIN_T
Definition: typeinfo.h:153
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:638