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
217 if( item )
218 g_lastPin = item->m_Uuid;
219
220 break;
221 }
222 case SCH_TEXT_T:
223 {
224 SCH_TEXT* text = new SCH_TEXT( cursorPos, wxEmptyString, LAYER_DEVICE );
225
226 text->SetParent( symbol );
227
229 text->SetUnit( m_frame->GetUnit() );
230
232 text->SetBodyStyle( m_frame->GetBodyStyle() );
233
234 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
235 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
236 text->SetTextAngle( m_lastTextAngle );
237
239
240 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
241 delete text;
242 else
243 item = text;
244
245 break;
246 }
247 default:
248 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
249 }
250
251 // If we started with a hotkey which has a position then warp back to that.
252 // Otherwise update to the current mouse position pinned inside the autoscroll
253 // boundaries.
254 if( evt->IsPrime() && !ignorePrimePosition )
255 {
256 cursorPos = grid.Align( evt->Position(), grid.GetItemGrid( item ) );
257 getViewControls()->WarpMouseCursor( cursorPos, true );
258 }
259 else
260 {
262 cursorPos = getViewControls()->GetMousePosition();
263 }
264
265 if( item )
266 {
267 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
268
269 item->SetFlags( IS_NEW | IS_MOVING );
271 m_view->AddToPreview( item->Clone() );
273
274 // update the cursor so it looks correct before another event
275 setCursor();
276 }
277
278 controls->SetCursorPosition( cursorPos, false );
279 }
280 // ... and second click places:
281 else
282 {
283 SCH_COMMIT commit( m_toolMgr );
284 commit.Modify( symbol, m_frame->GetScreen() );
285
286 switch( item->Type() )
287 {
288 case SCH_PIN_T:
289 pinTool->PlacePin( static_cast<SCH_PIN*>( item ) );
290 item->ClearEditFlags();
291 commit.Push( _( "Place Pin" ) );
292 break;
293
294 case SCH_TEXT_T:
295 symbol->AddDrawItem( static_cast<SCH_TEXT*>( item ) );
296 item->ClearEditFlags();
297 commit.Push( _( "Draw Text" ) );
298 break;
299
300 default:
301 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
302 }
303
304 item = nullptr;
307 }
308 }
309 else if( evt->IsClick( BUT_RIGHT ) )
310 {
311 // Warp after context menu only if dragging...
312 if( !item )
314
315 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
316 }
317 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
318 {
319 item->SetPosition( VECTOR2I( cursorPos.x, cursorPos.y ) );
321 m_view->AddToPreview( item->Clone() );
322 }
323 else
324 {
325 evt->SetPassEvent();
326 }
327
328 // Enable autopanning and cursor capture only when there is an item to be placed
329 controls->SetAutoPan( item != nullptr );
330 controls->CaptureCursor( item != nullptr );
331 }
332
333 controls->SetAutoPan( false );
334 controls->CaptureCursor( false );
335 controls->ForceCursorPosition( false );
336 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
337 return 0;
338}
339
340
342{
343 SHAPE_T requestedShape = aEvent.Parameter<SHAPE_T>();
344
345 return doDrawShape( aEvent, requestedShape );
346}
347
348
350{
351 return doDrawShape( aEvent, std::nullopt /* Draw text box */ );
352}
353
354
355int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional<SHAPE_T> aDrawingShape )
356{
357 bool isTextBox = !aDrawingShape.has_value();
358 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
359
361 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
364 VECTOR2I cursorPos;
365 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
366 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
367 SCH_SHAPE* item = nullptr;
368 wxString description;
369
370 if( m_inDrawShape )
371 return 0;
372
374
375 // We might be running as the same shape in another co-routine. Make sure that one
376 // gets whacked.
378
380
381 m_frame->PushTool( aEvent );
382
383 auto setCursor =
384 [&]()
385 {
386 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
387 };
388
389 auto cleanup =
390 [&] ()
391 {
394 delete item;
395 item = nullptr;
396 };
397
398 Activate();
399 // Must be done after Activate() so that it gets set into the correct context
400 controls->ShowCursor( true );
401 // Set initial cursor
402 setCursor();
403
404 if( aEvent.HasPosition() )
405 m_toolMgr->PrimeTool( aEvent.Position() );
406
407 // Main loop: keep receiving events
408 while( TOOL_EVENT* evt = Wait() )
409 {
410 setCursor();
411 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
412 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
413
414 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
415 controls->ForceCursorPosition( true, cursorPos );
416
417 // The tool hotkey is interpreted as a click when drawing
418 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
419 && evt->Matches( aEvent );
420
421 if( evt->IsCancelInteractive() )
422 {
423 if( item )
424 {
425 cleanup();
426 }
427 else
428 {
429 m_frame->PopTool( aEvent );
430 break;
431 }
432 }
433 else if( evt->IsActivate() && !isSyntheticClick )
434 {
435 if( item )
436 cleanup();
437
438 if( evt->IsPointEditor() )
439 {
440 // don't exit (the point editor runs in the background)
441 }
442 else if( evt->IsMoveTool() )
443 {
444 // leave ourselves on the stack so we come back after the move
445 break;
446 }
447 else
448 {
449 m_frame->PopTool( aEvent );
450 break;
451 }
452 }
453 else if( evt->IsClick( BUT_LEFT ) && !item )
454 {
455 // Update in case the symbol was changed while the tool was running
456 symbol = m_frame->GetCurSymbol();
457
458 if( !symbol )
459 continue;
460
462
463 int lineWidth = schIUScale.MilsToIU( settings->m_Defaults.line_width );
464
465 if( isTextBox )
466 {
467 SCH_TEXTBOX* textbox = new SCH_TEXTBOX( LAYER_DEVICE, lineWidth, m_lastFillStyle );
468
469 textbox->SetParent( symbol );
471 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
472
473 // Must be after SetTextSize()
474 textbox->SetBold( m_lastTextBold );
475 textbox->SetItalic( m_lastTextItalic );
476
477 textbox->SetTextAngle( m_lastTextAngle );
479
480 item = textbox;
481 description = _( "Add Text Box" );
482 }
483 else
484 {
485 item = new SCH_SHAPE( shapeType, LAYER_DEVICE, lineWidth, m_lastFillStyle );
486 item->SetParent( symbol );
487 description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() );
488 }
489
490 item->SetStroke( m_lastStroke );
492
493 item->SetFlags( IS_NEW );
494 item->BeginEdit( cursorPos );
495
497 item->SetUnit( m_frame->GetUnit() );
498
501
503 }
504 else if( item && ( evt->IsClick( BUT_LEFT )
505 || evt->IsDblClick( BUT_LEFT )
506 || isSyntheticClick
507 || evt->IsAction( &ACTIONS::finishInteractive ) ) )
508 {
509 if( symbol != m_frame->GetCurSymbol() )
510 {
511 symbol = m_frame->GetCurSymbol();
512 item->SetParent( symbol );
513 }
514
515 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &ACTIONS::finishInteractive )
516 || !item->ContinueEdit( VECTOR2I( cursorPos.x, cursorPos.y ) ) )
517 {
518 if( toolType == SHAPE_T::POLY )
519 {
520 item->CalcEdit( item->GetPosition() ); // Close shape
521 item->EndEdit( true );
522 }
523 else
524 {
525 item->EndEdit();
526 }
527
528 item->ClearEditFlags();
529
530 if( isTextBox )
531 {
532 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
533 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( item ) );
534
535 // QuasiModal required for syntax help and Scintilla auto-complete
536 if( dlg.ShowQuasiModal() != wxID_OK )
537 {
538 cleanup();
539 continue;
540 }
541
542 m_lastTextBold = textbox->IsBold();
543 m_lastTextItalic = textbox->IsItalic();
544 m_lastTextAngle = textbox->GetTextAngle();
545 m_lastTextJust = textbox->GetHorizJustify();
546 }
547
548 m_lastStroke = item->GetStroke();
551
553
554 SCH_COMMIT commit( m_toolMgr );
555 commit.Modify( symbol, m_frame->GetScreen() );
556
557 symbol->AddDrawItem( item );
558 item = nullptr;
559
560 commit.Push( description );
563 }
564 }
565 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
566 {
567 item->CalcEdit( cursorPos );
569 m_view->AddToPreview( item->Clone() );
570 }
571 else if( evt->IsDblClick( BUT_LEFT ) && !item )
572 {
574 }
575 else if( evt->IsClick( BUT_RIGHT ) )
576 {
577 // Warp after context menu only if dragging...
578 if( !item )
580
581 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
582 }
583 else
584 {
585 evt->SetPassEvent();
586 }
587
588 // Enable autopanning and cursor capture only when there is a shape being drawn
589 controls->SetAutoPan( item != nullptr );
590 controls->CaptureCursor( item != nullptr );
591 }
592
593 controls->SetAutoPan( false );
594 controls->CaptureCursor( false );
595 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
596 return 0;
597}
598
599
601{
602 m_frame->PushTool( aEvent );
603
604 auto setCursor =
605 [&]()
606 {
607 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
608 };
609
610 Activate();
611 // Must be done after Activate() so that it gets set into the correct context
612 getViewControls()->ShowCursor( true );
613 // Set initial cursor
614 setCursor();
615
616 // Main loop: keep receiving events
617 while( TOOL_EVENT* evt = Wait() )
618 {
619 setCursor();
620
621 if( evt->IsCancelInteractive() )
622 {
623 m_frame->PopTool( aEvent );
624 break;
625 }
626 else if( evt->IsActivate() )
627 {
628 m_frame->PopTool( aEvent );
629 break;
630 }
631 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
632 {
633 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
634
635 if( !symbol )
636 continue;
637
638 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
639
640 symbol->Move( -cursorPos );
641
642 // Refresh the view without changing the viewport
643 m_view->SetCenter( m_view->GetCenter() + cursorPos );
645 m_frame->OnModify();
646 }
647 else if( evt->IsClick( BUT_RIGHT ) )
648 {
649 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
650 }
651 else
652 {
653 evt->SetPassEvent();
654 }
655 }
656
657 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
658 return 0;
659}
660
661
663{
664 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
665
666 if( !symbol )
667 return 0;
668
669 // Note: PlaceImportedGraphics() will convert PCB_SHAPE_T and PCB_TEXT_T to footprint
670 // items if needed
672 int dlgResult = dlg.ShowModal();
673
674 std::list<std::unique_ptr<EDA_ITEM>>& list = dlg.GetImportedItems();
675
676 if( dlgResult != wxID_OK )
677 return 0;
678
679 // Ensure the list is not empty:
680 if( list.empty() )
681 {
682 wxMessageBox( _( "No graphic items found in file." ) );
683 return 0;
684 }
685
687
689 std::vector<SCH_ITEM*> newItems; // all new items, including group
690 std::vector<SCH_ITEM*> selectedItems; // the group, or newItems if no group
691 EE_SELECTION preview;
692 SCH_COMMIT commit( m_toolMgr );
693
694 for( std::unique_ptr<EDA_ITEM>& ptr : list )
695 {
696 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ptr.get() );
697 wxCHECK2( item, continue );
698
699 newItems.push_back( item );
700 selectedItems.push_back( item );
701 preview.Add( item );
702
703 ptr.release();
704 }
705
706 if( !dlg.IsPlacementInteractive() )
707 {
708 commit.Modify( symbol, m_frame->GetScreen() );
709
710 // Place the imported drawings
711 for( SCH_ITEM* item : newItems )
712 {
713 symbol->AddDrawItem( item );
714 item->ClearEditFlags();
715 }
716
717 commit.Push( _( "Import Graphic" ) );
719
720 return 0;
721 }
722
723 m_view->Add( &preview );
724
725 // Clear the current selection then select the drawings so that edit tools work on them
727
728 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
730
731 m_frame->PushTool( aEvent );
732
733 auto setCursor = [&]()
734 {
735 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
736 };
737
738 Activate();
739 // Must be done after Activate() so that it gets set into the correct context
740 controls->ShowCursor( true );
741 controls->ForceCursorPosition( false );
742 // Set initial cursor
743 setCursor();
744
745 //SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
747
748 // Now move the new items to the current cursor position:
749 VECTOR2I cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
750 VECTOR2I delta = cursorPos;
751 VECTOR2I currentOffset;
752
753 for( SCH_ITEM* item : selectedItems )
754 item->Move( delta );
755
756 currentOffset += delta;
757
758 m_view->Update( &preview );
759
760 // Main loop: keep receiving events
761 while( TOOL_EVENT* evt = Wait() )
762 {
763 setCursor();
764
765 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
766 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
767
768 cursorPos = grid.Align( controls->GetMousePosition(), GRID_GRAPHICS );
769 controls->ForceCursorPosition( true, cursorPos );
770
771 if( evt->IsCancelInteractive() || evt->IsActivate() )
772 {
774
775 for( SCH_ITEM* item : newItems )
776 delete item;
777
778 break;
779 }
780 else if( evt->IsMotion() )
781 {
782 delta = cursorPos - currentOffset;
783
784 for( SCH_ITEM* item : selectedItems )
785 item->Move( delta );
786
787 currentOffset += delta;
788
789 m_view->Update( &preview );
790 }
791 else if( evt->IsClick( BUT_RIGHT ) )
792 {
793 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
794 }
795 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
796 {
797 commit.Modify( symbol, m_frame->GetScreen() );
798
799 // Place the imported drawings
800 for( SCH_ITEM* item : newItems )
801 {
802 symbol->AddDrawItem( item );
803 item->ClearEditFlags();
804 }
805
806 commit.Push( _( "Import Graphic" ) );
807 break; // This is a one-shot command, not a tool
808 }
809 else
810 {
811 evt->SetPassEvent();
812 }
813 }
814
815 preview.Clear();
816 m_view->Remove( &preview );
817
819
820 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
821 controls->ForceCursorPosition( false );
822
823 m_frame->PopTool( aEvent );
824
825 return 0;
826}
827
828
830{
832 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
833 SCH_PIN* sourcePin = nullptr;
834
835 if( !symbol )
836 return 0;
837
838 for( SCH_PIN* test : symbol->GetAllLibPins() )
839 {
840 if( test->m_Uuid == g_lastPin )
841 {
842 sourcePin = test;
843 break;
844 }
845 }
846
847 if( sourcePin )
848 {
849 SCH_PIN* pin = pinTool->RepeatPin( sourcePin );
850
851 if( pin )
852 g_lastPin = pin->m_Uuid;
853
855
856 if( pin )
858 }
859
860 return 0;
861}
862
863
865{
866 // clang-format off
879 // clang-format on
880}
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
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: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: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:152
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:130
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:404
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:183
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition: eda_text.cpp:240
bool IsBold() const
Definition: eda_text.h:167
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:204
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:212
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:298
static TOOL_ACTION properties
Definition: ee_actions.h:133
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:62
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:55
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:121
static TOOL_ACTION drawSymbolPolygon
Definition: ee_actions.h:120
static TOOL_ACTION drawCircle
Definition: ee_actions.h:104
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:117
static TOOL_ACTION importGraphics
Definition: ee_actions.h:267
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:58
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:103
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:118
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:119
static TOOL_ACTION drawArc
Definition: ee_actions.h:105
static TOOL_ACTION drawBezier
Definition: ee_actions.h:106
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:127
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:116
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: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()
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:530
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:50
@ LAYER_DEVICE
Definition: layer_ids.h:369
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:47
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