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