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 The 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 <sch_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 SCH_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_inPlaceAnchor( false ),
61 m_inTwoClickPlace( false )
62{
63}
64
65
67{
69
70 auto isDrawingCondition =
71 [] ( const SELECTION& aSel )
72 {
73 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSel.Front() );
74 return item && item->IsNew();
75 };
76
77 m_menu->GetMenu().AddItem( ACTIONS::finishInteractive, isDrawingCondition, 2 );
78
79 return true;
80}
81
82
84{
85 KICAD_T type = aEvent.Parameter<KICAD_T>();
86 SYMBOL_EDITOR_SETTINGS* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
88 : nullptr;
89
91 return 0;
92
94
97 VECTOR2I cursorPos;
98 bool ignorePrimePosition = false;
99 SCH_ITEM* item = nullptr;
100 bool isText = aEvent.IsAction( &SCH_ACTIONS::placeSymbolText );
101 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
102
104
105 m_frame->PushTool( aEvent );
106
107 auto setCursor =
108 [&]()
109 {
110 if( item )
111 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PLACE );
112 else if( isText )
113 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
114 else
115 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
116 };
117
118 auto cleanup =
119 [&] ()
120 {
123 delete item;
124 item = nullptr;
125 };
126
127 Activate();
128 // Must be done after Activate() so that it gets set into the correct context
129 controls->ShowCursor( true );
130 // Set initial cursor
131 setCursor();
132
133 if( aEvent.HasPosition() )
134 {
135 m_toolMgr->PrimeTool( aEvent.Position() );
136 }
137 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
138 {
139 m_toolMgr->PrimeTool( { 0, 0 } );
140 ignorePrimePosition = true;
141 }
142
143 SCH_COMMIT commit( m_toolMgr );
144
145 // Main loop: keep receiving events
146 while( TOOL_EVENT* evt = Wait() )
147 {
148 setCursor();
149 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
150 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
151
152 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
153 controls->ForceCursorPosition( true, cursorPos );
154
155 // The tool hotkey is interpreted as a click when drawing
156 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
157 && evt->Matches( aEvent );
158
159 if( evt->IsCancelInteractive() )
160 {
162
163 if( item )
164 {
165 cleanup();
166 }
167 else
168 {
169 m_frame->PopTool( aEvent );
170 break;
171 }
172 }
173 else if( evt->IsActivate() && !isSyntheticClick )
174 {
175 if( item && evt->IsMoveTool() )
176 {
177 // we're already moving our own item; ignore the move tool
178 evt->SetPassEvent( false );
179 continue;
180 }
181
182 if( item )
183 {
184 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
185 evt->SetPassEvent( false );
186 continue;
187 }
188
189 if( evt->IsPointEditor() )
190 {
191 // don't exit (the point editor runs in the background)
192 }
193 else if( evt->IsMoveTool() )
194 {
195 break;
196 }
197 else
198 {
199 m_frame->PopTool( aEvent );
200 break;
201 }
202 }
203 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
204 {
205 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
206
207 if( !symbol )
208 continue;
209
210 // First click creates...
211 if( !item )
212 {
214
215 switch( type )
216 {
217 case SCH_PIN_T:
218 {
219 item = pinTool->CreatePin( cursorPos, symbol );
220
221 if( item )
222 g_lastPin = item->m_Uuid;
223
224 break;
225 }
226 case SCH_TEXT_T:
227 {
228 SCH_TEXT* text = new SCH_TEXT( cursorPos, wxEmptyString, LAYER_DEVICE );
229
230 text->SetParent( symbol );
231
233 text->SetUnit( m_frame->GetUnit() );
234
236 text->SetBodyStyle( m_frame->GetBodyStyle() );
237
238 if( cfg )
239 {
240 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( cfg->m_Defaults.text_size ),
241 schIUScale.MilsToIU( cfg->m_Defaults.text_size ) ) );
242 }
243
244 text->SetTextAngle( m_lastTextAngle );
245
247
248 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
249 delete text;
250 else
251 item = text;
252
253 break;
254 }
255 default:
256 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
257 }
258
259 // If we started with a hotkey which has a position then warp back to that.
260 // Otherwise update to the current mouse position pinned inside the autoscroll
261 // boundaries.
262 if( evt->IsPrime() && !ignorePrimePosition )
263 {
264 cursorPos = grid.Align( evt->Position(), grid.GetItemGrid( item ) );
265 getViewControls()->WarpMouseCursor( cursorPos, true );
266 }
267 else
268 {
270 cursorPos = getViewControls()->GetMousePosition();
271 }
272
273 if( item )
274 {
275 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
276
277 item->SetFlags( IS_NEW | IS_MOVING );
279 m_view->AddToPreview( item, false );
281
282 // update the cursor so it looks correct before another event
283 setCursor();
284 }
285
286 controls->SetCursorPosition( cursorPos, false );
287 }
288 // ... and second click places:
289 else
290 {
291 commit.Modify( symbol, m_frame->GetScreen() );
292
293 switch( item->Type() )
294 {
295 case SCH_PIN_T:
296 pinTool->PlacePin( &commit, static_cast<SCH_PIN*>( item ) );
297 item->ClearEditFlags();
298 commit.Push( _( "Place Pin" ) );
299 break;
300
301 case SCH_TEXT_T:
302 symbol->AddDrawItem( static_cast<SCH_TEXT*>( item ) );
303 item->ClearEditFlags();
304 commit.Push( _( "Draw Text" ) );
305 break;
306
307 default:
308 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
309 }
310
311 item = nullptr;
314 }
315 }
316 else if( evt->IsClick( BUT_RIGHT ) )
317 {
318 // Warp after context menu only if dragging...
319 if( !item )
321
322 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
323 }
324 else if( evt->IsAction( &ACTIONS::increment ) )
325 {
327 evt->Parameter<ACTIONS::INCREMENT>() );
328 }
329 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
330 {
331 item->SetPosition( VECTOR2I( cursorPos.x, cursorPos.y ) );
333 m_view->AddToPreview( item, false );
334 }
335 else
336 {
337 evt->SetPassEvent();
338 }
339
340 // Enable autopanning and cursor capture only when there is an item to be placed
341 controls->SetAutoPan( item != nullptr );
342 controls->CaptureCursor( item != nullptr );
343 }
344
345 controls->SetAutoPan( false );
346 controls->CaptureCursor( false );
347 controls->ForceCursorPosition( false );
348 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
349 return 0;
350}
351
352
354{
355 SHAPE_T requestedShape = aEvent.Parameter<SHAPE_T>();
356
357 return doDrawShape( aEvent, requestedShape );
358}
359
360
362{
363 return doDrawShape( aEvent, std::nullopt /* Draw text box */ );
364}
365
366
367int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional<SHAPE_T> aDrawingShape )
368{
369 bool isTextBox = !aDrawingShape.has_value();
370 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
371
373 SYMBOL_EDITOR_SETTINGS* cfg = GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
375 VECTOR2I cursorPos;
376 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
377 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
378 SCH_SHAPE* item = nullptr;
379 wxString description;
380
381 if( m_inDrawShape )
382 return 0;
383
385
386 // We might be running as the same shape in another co-routine. Make sure that one
387 // gets whacked.
389
391
392 m_frame->PushTool( aEvent );
393
394 auto setCursor =
395 [&]()
396 {
397 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
398 };
399
400 auto cleanup =
401 [&] ()
402 {
405 delete item;
406 item = nullptr;
407 };
408
409 Activate();
410 // Must be done after Activate() so that it gets set into the correct context
411 controls->ShowCursor( true );
412 // Set initial cursor
413 setCursor();
414
415 if( aEvent.HasPosition() )
416 m_toolMgr->PrimeTool( aEvent.Position() );
417
418 // Main loop: keep receiving events
419 while( TOOL_EVENT* evt = Wait() )
420 {
421 setCursor();
422 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
423 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
424
425 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
426 controls->ForceCursorPosition( true, cursorPos );
427
428 // The tool hotkey is interpreted as a click when drawing
429 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
430 && evt->Matches( aEvent );
431
432 if( evt->IsCancelInteractive() )
433 {
434 if( item )
435 {
436 cleanup();
437 }
438 else
439 {
440 m_frame->PopTool( aEvent );
441 break;
442 }
443 }
444 else if( evt->IsActivate() && !isSyntheticClick )
445 {
446 if( item )
447 cleanup();
448
449 if( evt->IsPointEditor() )
450 {
451 // don't exit (the point editor runs in the background)
452 }
453 else if( evt->IsMoveTool() )
454 {
455 // leave ourselves on the stack so we come back after the move
456 break;
457 }
458 else
459 {
460 m_frame->PopTool( aEvent );
461 break;
462 }
463 }
464 else if( evt->IsClick( BUT_LEFT ) && !item )
465 {
466 // Update in case the symbol was changed while the tool was running
467 symbol = m_frame->GetCurSymbol();
468
469 if( !symbol )
470 continue;
471
473
474 int lineWidth = schIUScale.MilsToIU( cfg ? cfg->m_Defaults.line_width : DEFAULT_LINE_WIDTH_MILS );
475
476 if( isTextBox )
477 {
478 SCH_TEXTBOX* textbox = new SCH_TEXTBOX( LAYER_DEVICE, lineWidth, m_lastFillStyle );
479
480 textbox->SetParent( symbol );
481
482 if( cfg )
483 {
486 }
487
488 // Must be after SetTextSize()
489 textbox->SetBold( m_lastTextBold );
490 textbox->SetItalic( m_lastTextItalic );
491
492 textbox->SetTextAngle( m_lastTextAngle );
494
495 item = textbox;
496 description = _( "Add Text Box" );
497 }
498 else
499 {
500 item = new SCH_SHAPE( shapeType, LAYER_DEVICE, lineWidth, m_lastFillStyle );
501 item->SetParent( symbol );
502 description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() );
503 }
504
505 item->SetStroke( m_lastStroke );
507
508 item->SetFlags( IS_NEW );
509 item->BeginEdit( cursorPos );
510
512 item->SetUnit( m_frame->GetUnit() );
513
516
518 }
519 else if( item && ( evt->IsClick( BUT_LEFT )
520 || evt->IsDblClick( BUT_LEFT )
521 || isSyntheticClick
522 || evt->IsAction( &ACTIONS::finishInteractive ) ) )
523 {
524 if( symbol != m_frame->GetCurSymbol() )
525 {
526 symbol = m_frame->GetCurSymbol();
527 item->SetParent( symbol );
528 }
529
530 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &ACTIONS::finishInteractive )
531 || !item->ContinueEdit( VECTOR2I( cursorPos.x, cursorPos.y ) ) )
532 {
533 if( toolType == SHAPE_T::POLY )
534 {
535 item->CalcEdit( item->GetPosition() ); // Close shape
536 item->EndEdit( true );
537 }
538 else
539 {
540 item->EndEdit();
541 }
542
543 item->ClearEditFlags();
544
545 if( isTextBox )
546 {
547 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
548 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( item ) );
549
550 // QuasiModal required for syntax help and Scintilla auto-complete
551 if( dlg.ShowQuasiModal() != wxID_OK )
552 {
553 cleanup();
554 continue;
555 }
556
557 m_lastTextBold = textbox->IsBold();
558 m_lastTextItalic = textbox->IsItalic();
559 m_lastTextAngle = textbox->GetTextAngle();
560 m_lastTextJust = textbox->GetHorizJustify();
561 }
562
563 m_lastStroke = item->GetStroke();
566
568
569 SCH_COMMIT commit( m_toolMgr );
570 commit.Modify( symbol, m_frame->GetScreen() );
571
572 symbol->AddDrawItem( item );
573 item = nullptr;
574
575 commit.Push( description );
578 }
579 }
580 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
581 {
582 item->CalcEdit( cursorPos );
584 m_view->AddToPreview( item->Clone() );
585 }
586 else if( evt->IsDblClick( BUT_LEFT ) && !item )
587 {
589 }
590 else if( evt->IsClick( BUT_RIGHT ) )
591 {
592 // Warp after context menu only if dragging...
593 if( !item )
595
596 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
597 }
598 else
599 {
600 evt->SetPassEvent();
601 }
602
603 // Enable autopanning and cursor capture only when there is a shape being drawn
604 controls->SetAutoPan( item != nullptr );
605 controls->CaptureCursor( item != nullptr );
606 }
607
608 controls->SetAutoPan( false );
609 controls->CaptureCursor( false );
610 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
611 return 0;
612}
613
614
616{
617 if( m_inPlaceAnchor )
618 return 0;
619
621
622 m_frame->PushTool( aEvent );
623
624 auto setCursor =
625 [&]()
626 {
627 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
628 };
629
630 Activate();
631 // Must be done after Activate() so that it gets set into the correct context
632 getViewControls()->ShowCursor( true );
633 // Set initial cursor
634 setCursor();
635
636 // Main loop: keep receiving events
637 while( TOOL_EVENT* evt = Wait() )
638 {
639 setCursor();
640
641 if( evt->IsCancelInteractive() )
642 {
643 m_frame->PopTool( aEvent );
644 break;
645 }
646 else if( evt->IsActivate() )
647 {
648 m_frame->PopTool( aEvent );
649 break;
650 }
651 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
652 {
653 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
654
655 if( !symbol )
656 continue;
657
658 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
659
660 symbol->Move( -cursorPos );
661
662 // Refresh the view without changing the viewport
663 m_view->SetCenter( m_view->GetCenter() + cursorPos );
665 m_frame->OnModify();
666 }
667 else if( evt->IsClick( BUT_RIGHT ) )
668 {
669 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
670 }
671 else
672 {
673 evt->SetPassEvent();
674 }
675 }
676
677 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
678 return 0;
679}
680
681
683{
684 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
685
686 if( !symbol )
687 return 0;
688
689 // Note: PlaceImportedGraphics() will convert PCB_SHAPE_T and PCB_TEXT_T to footprint
690 // items if needed
692 int dlgResult = dlg.ShowModal();
693
694 std::list<std::unique_ptr<EDA_ITEM>>& list = dlg.GetImportedItems();
695
696 if( dlgResult != wxID_OK )
697 return 0;
698
699 // Ensure the list is not empty:
700 if( list.empty() )
701 {
702 wxMessageBox( _( "No graphic items found in file." ) );
703 return 0;
704 }
705
707
709 std::vector<SCH_ITEM*> newItems; // all new items, including group
710 std::vector<SCH_ITEM*> selectedItems; // the group, or newItems if no group
711 SCH_SELECTION preview;
712 SCH_COMMIT commit( m_toolMgr );
713
714 for( std::unique_ptr<EDA_ITEM>& ptr : list )
715 {
716 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ptr.get() );
717 wxCHECK2( item, continue );
718
719 newItems.push_back( item );
720 selectedItems.push_back( item );
721 preview.Add( item );
722
723 ptr.release();
724 }
725
726 if( !dlg.IsPlacementInteractive() )
727 {
728 commit.Modify( symbol, m_frame->GetScreen() );
729
730 // Place the imported drawings
731 for( SCH_ITEM* item : newItems )
732 {
733 symbol->AddDrawItem( item );
734 item->ClearEditFlags();
735 }
736
737 commit.Push( _( "Import Graphic" ) );
739
740 return 0;
741 }
742
743 m_view->Add( &preview );
744
745 // Clear the current selection then select the drawings so that edit tools work on them
747
748 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
750
751 m_frame->PushTool( aEvent );
752
753 auto setCursor = [&]()
754 {
755 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
756 };
757
758 Activate();
759 // Must be done after Activate() so that it gets set into the correct context
760 controls->ShowCursor( true );
761 controls->ForceCursorPosition( false );
762 // Set initial cursor
763 setCursor();
764
765 //SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
767
768 // Now move the new items to the current cursor position:
769 VECTOR2I cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
770 VECTOR2I delta = cursorPos;
771 VECTOR2I currentOffset;
772
773 for( SCH_ITEM* item : selectedItems )
774 item->Move( delta );
775
776 currentOffset += delta;
777
778 m_view->Update( &preview );
779
780 // Main loop: keep receiving events
781 while( TOOL_EVENT* evt = Wait() )
782 {
783 setCursor();
784
785 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
786 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
787
788 cursorPos = grid.Align( controls->GetMousePosition(), GRID_GRAPHICS );
789 controls->ForceCursorPosition( true, cursorPos );
790
791 if( evt->IsCancelInteractive() || evt->IsActivate() )
792 {
794
795 for( SCH_ITEM* item : newItems )
796 delete item;
797
798 break;
799 }
800 else if( evt->IsMotion() )
801 {
802 delta = cursorPos - currentOffset;
803
804 for( SCH_ITEM* item : selectedItems )
805 item->Move( delta );
806
807 currentOffset += delta;
808
809 m_view->Update( &preview );
810 }
811 else if( evt->IsClick( BUT_RIGHT ) )
812 {
813 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
814 }
815 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
816 {
817 commit.Modify( symbol, m_frame->GetScreen() );
818
819 // Place the imported drawings
820 for( SCH_ITEM* item : newItems )
821 {
822 symbol->AddDrawItem( item );
823 item->ClearEditFlags();
824 }
825
826 commit.Push( _( "Import Graphic" ) );
827 break; // This is a one-shot command, not a tool
828 }
829 else
830 {
831 evt->SetPassEvent();
832 }
833 }
834
835 preview.Clear();
836 m_view->Remove( &preview );
837
839
840 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
841 controls->ForceCursorPosition( false );
842
843 m_frame->PopTool( aEvent );
844
845 return 0;
846}
847
848
850{
852 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
853 SCH_PIN* sourcePin = nullptr;
854
855 if( !symbol )
856 return 0;
857
858 for( SCH_PIN* test : symbol->GetPins() )
859 {
860 if( test->m_Uuid == g_lastPin )
861 {
862 sourcePin = test;
863 break;
864 }
865 }
866
867 if( sourcePin )
868 {
869 SCH_PIN* pin = pinTool->RepeatPin( sourcePin );
870
871 if( pin )
872 g_lastPin = pin->m_Uuid;
873
875
876 if( pin )
878 }
879
880 return 0;
881}
882
883
885{
886 // clang-format off
899 // clang-format on
900}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
static TOOL_ACTION cancelInteractive
Definition: actions.h:72
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
Definition: actions.h:224
static TOOL_ACTION activatePointEditor
Definition: actions.h:268
static TOOL_ACTION increment
Definition: actions.h:94
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: actions.h:221
static TOOL_ACTION refreshPreview
Definition: actions.h:156
static TOOL_ACTION finishInteractive
Definition: actions.h:73
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
Definition: actions.h:229
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
Definition: commit.h:107
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:98
virtual void ClearEditFlags()
Definition: eda_item.h:156
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:273
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
const KIID m_Uuid
Definition: eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:110
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:401
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:113
virtual wxString GetFriendlyName() const
Definition: eda_item.cpp:402
bool IsNew() const
Definition: eda_item.h:124
FILL_T GetFillMode() const
Definition: eda_shape.h:142
void SetFillColor(const COLOR4D &aColor)
Definition: eda_shape.h:153
COLOR4D GetFillColor() const
Definition: eda_shape.h:152
bool IsItalic() const
Definition: eda_text.h:166
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:533
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:197
void SetBold(bool aBold)
Set the text to be bold - this will also update the font if needed.
Definition: eda_text.cpp:335
bool IsBold() const
Definition: eda_text.h:181
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:299
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:307
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:409
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
void Update(const KIGFX::VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: sch_view.cpp:60
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:346
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:298
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:341
void ClearPreview()
Definition: view.cpp:1707
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1451
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1729
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:596
Definition: kiid.h:49
Define a library symbol object.
Definition: lib_symbol.h:85
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:785
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:565
static TOOL_ACTION drawArc
Definition: sch_actions.h:97
static TOOL_ACTION drawSymbolLines
Definition: sch_actions.h:111
static TOOL_ACTION placeSymbolPin
Definition: sch_actions.h:108
static TOOL_ACTION drawSymbolTextBox
Definition: sch_actions.h:110
static TOOL_ACTION properties
Definition: sch_actions.h:125
static TOOL_ACTION drawRectangle
Definition: sch_actions.h:95
static TOOL_ACTION drawCircle
Definition: sch_actions.h:96
static TOOL_ACTION importGraphics
Definition: sch_actions.h:255
static TOOL_ACTION drawBezier
Definition: sch_actions.h:98
static TOOL_ACTION drawSymbolPolygon
Definition: sch_actions.h:112
static TOOL_ACTION placeSymbolAnchor
Definition: sch_actions.h:113
static TOOL_ACTION placeSymbolText
Definition: sch_actions.h:109
static TOOL_ACTION repeatDrawItem
Definition: sch_actions.h:119
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
Execute the changes.
Definition: sch_commit.cpp:489
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
virtual void SetBodyStyle(int aBodyStyle)
Definition: sch_item.h:247
virtual void SetUnit(int aUnit)
Definition: sch_item.h:238
SCH_SELECTION & GetSelection()
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: sch_shape.h:89
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:92
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:61
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: sch_shape.h:90
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_shape.h:91
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:57
VECTOR2I GetPosition() const override
Definition: sch_shape.h:84
A foundation class for a tool operating on a schematic or symbol.
Definition: sch_tool_base.h:49
bool Init() override
Init() is called once upon a registration of the tool.
Definition: sch_tool_base.h:65
SCH_SELECTION_TOOL * m_selectionTool
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:98
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)
SCH_PIN * CreatePin(const VECTOR2I &aPosition, LIB_SYMBOL *aSymbol)
bool PlacePin(SCH_COMMIT *aCommit, SCH_PIN *aPin)
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:44
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:38
Generic, UI-independent tool event.
Definition: tool_event.h:168
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:257
bool DisableGridSnapping() const
Definition: tool_event.h:368
const VECTOR2D Position() const
Return mouse cursor position in world coordinates.
Definition: tool_event.h:290
bool IsReactivate() const
Control whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition: tool_event.h:270
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:465
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
bool RunSynchronousAction(const TOOL_ACTION &aAction, COMMIT *aCommit, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:197
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:515
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:192
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _(s)
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:407
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:566
#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:51
@ LAYER_DEVICE
Definition: layer_ids.h:456
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:902
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:97
int delta
@ GR_TEXT_H_ALIGN_LEFT
@ MD_SHIFT
Definition: tool_event.h:143
@ BUT_LEFT
Definition: tool_event.h:132
@ BUT_RIGHT
Definition: tool_event.h:133
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_TEXT_T
Definition: typeinfo.h:152
@ SCH_PIN_T
Definition: typeinfo.h:154
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695