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