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 <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 SCH_COMMIT commit( m_toolMgr );
145
146 // Main loop: keep receiving events
147 while( TOOL_EVENT* evt = Wait() )
148 {
149 setCursor();
150 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
151 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
152
153 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
154 controls->ForceCursorPosition( true, cursorPos );
155
156 // The tool hotkey is interpreted as a click when drawing
157 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
158 && evt->Matches( aEvent );
159
160 if( evt->IsCancelInteractive() )
161 {
163
164 if( item )
165 {
166 cleanup();
167 }
168 else
169 {
170 m_frame->PopTool( aEvent );
171 break;
172 }
173 }
174 else if( evt->IsActivate() && !isSyntheticClick )
175 {
176 if( item && evt->IsMoveTool() )
177 {
178 // we're already moving our own item; ignore the move tool
179 evt->SetPassEvent( false );
180 continue;
181 }
182
183 if( item )
184 {
185 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
186 evt->SetPassEvent( false );
187 continue;
188 }
189
190 if( evt->IsPointEditor() )
191 {
192 // don't exit (the point editor runs in the background)
193 }
194 else if( evt->IsMoveTool() )
195 {
196 break;
197 }
198 else
199 {
200 m_frame->PopTool( aEvent );
201 break;
202 }
203 }
204 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
205 {
206 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
207
208 if( !symbol )
209 continue;
210
211 // First click creates...
212 if( !item )
213 {
215
216 switch( type )
217 {
218 case SCH_PIN_T:
219 {
220 item = pinTool->CreatePin( cursorPos, symbol );
221
222 if( item )
223 g_lastPin = item->m_Uuid;
224
225 break;
226 }
227 case SCH_TEXT_T:
228 {
229 SCH_TEXT* text = new SCH_TEXT( cursorPos, wxEmptyString, LAYER_DEVICE );
230
231 text->SetParent( symbol );
232
234 text->SetUnit( m_frame->GetUnit() );
235
237 text->SetBodyStyle( m_frame->GetBodyStyle() );
238
239 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( cfg->m_Defaults.text_size ),
241 text->SetTextAngle( m_lastTextAngle );
242
244
245 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
246 delete text;
247 else
248 item = text;
249
250 break;
251 }
252 default:
253 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
254 }
255
256 // If we started with a hotkey which has a position then warp back to that.
257 // Otherwise update to the current mouse position pinned inside the autoscroll
258 // boundaries.
259 if( evt->IsPrime() && !ignorePrimePosition )
260 {
261 cursorPos = grid.Align( evt->Position(), grid.GetItemGrid( item ) );
262 getViewControls()->WarpMouseCursor( cursorPos, true );
263 }
264 else
265 {
267 cursorPos = getViewControls()->GetMousePosition();
268 }
269
270 if( item )
271 {
272 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
273
274 item->SetFlags( IS_NEW | IS_MOVING );
276 m_view->AddToPreview( item, false );
278
279 // update the cursor so it looks correct before another event
280 setCursor();
281 }
282
283 controls->SetCursorPosition( cursorPos, false );
284 }
285 // ... and second click places:
286 else
287 {
288 commit.Modify( symbol, m_frame->GetScreen() );
289
290 switch( item->Type() )
291 {
292 case SCH_PIN_T:
293 pinTool->PlacePin( static_cast<SCH_PIN*>( item ) );
294 item->ClearEditFlags();
295 commit.Push( _( "Place Pin" ) );
296 break;
297
298 case SCH_TEXT_T:
299 symbol->AddDrawItem( static_cast<SCH_TEXT*>( item ) );
300 item->ClearEditFlags();
301 commit.Push( _( "Draw Text" ) );
302 break;
303
304 default:
305 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
306 }
307
308 item = nullptr;
311 }
312 }
313 else if( evt->IsClick( BUT_RIGHT ) )
314 {
315 // Warp after context menu only if dragging...
316 if( !item )
318
319 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
320 }
321 else if( evt->IsAction( &ACTIONS::increment ) )
322 {
324 evt->Parameter<ACTIONS::INCREMENT>() );
325 }
326 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
327 {
328 item->SetPosition( VECTOR2I( cursorPos.x, cursorPos.y ) );
330 m_view->AddToPreview( item, false );
331 }
332 else
333 {
334 evt->SetPassEvent();
335 }
336
337 // Enable autopanning and cursor capture only when there is an item to be placed
338 controls->SetAutoPan( item != nullptr );
339 controls->CaptureCursor( item != nullptr );
340 }
341
342 controls->SetAutoPan( false );
343 controls->CaptureCursor( false );
344 controls->ForceCursorPosition( false );
345 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
346 return 0;
347}
348
349
351{
352 SHAPE_T requestedShape = aEvent.Parameter<SHAPE_T>();
353
354 return doDrawShape( aEvent, requestedShape );
355}
356
357
359{
360 return doDrawShape( aEvent, std::nullopt /* Draw text box */ );
361}
362
363
364int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional<SHAPE_T> aDrawingShape )
365{
366 bool isTextBox = !aDrawingShape.has_value();
367 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
368
371 SYMBOL_EDITOR_SETTINGS* cfg = mgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>( "symbol_editor" );
373 VECTOR2I cursorPos;
374 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
375 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
376 SCH_SHAPE* item = nullptr;
377 wxString description;
378
379 if( m_inDrawShape )
380 return 0;
381
383
384 // We might be running as the same shape in another co-routine. Make sure that one
385 // gets whacked.
387
389
390 m_frame->PushTool( aEvent );
391
392 auto setCursor =
393 [&]()
394 {
395 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
396 };
397
398 auto cleanup =
399 [&] ()
400 {
403 delete item;
404 item = nullptr;
405 };
406
407 Activate();
408 // Must be done after Activate() so that it gets set into the correct context
409 controls->ShowCursor( true );
410 // Set initial cursor
411 setCursor();
412
413 if( aEvent.HasPosition() )
414 m_toolMgr->PrimeTool( aEvent.Position() );
415
416 // Main loop: keep receiving events
417 while( TOOL_EVENT* evt = Wait() )
418 {
419 setCursor();
420 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
421 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
422
423 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
424 controls->ForceCursorPosition( true, cursorPos );
425
426 // The tool hotkey is interpreted as a click when drawing
427 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
428 && evt->Matches( aEvent );
429
430 if( evt->IsCancelInteractive() )
431 {
432 if( item )
433 {
434 cleanup();
435 }
436 else
437 {
438 m_frame->PopTool( aEvent );
439 break;
440 }
441 }
442 else if( evt->IsActivate() && !isSyntheticClick )
443 {
444 if( item )
445 cleanup();
446
447 if( evt->IsPointEditor() )
448 {
449 // don't exit (the point editor runs in the background)
450 }
451 else if( evt->IsMoveTool() )
452 {
453 // leave ourselves on the stack so we come back after the move
454 break;
455 }
456 else
457 {
458 m_frame->PopTool( aEvent );
459 break;
460 }
461 }
462 else if( evt->IsClick( BUT_LEFT ) && !item )
463 {
464 // Update in case the symbol was changed while the tool was running
465 symbol = m_frame->GetCurSymbol();
466
467 if( !symbol )
468 continue;
469
471
472 int lineWidth = schIUScale.MilsToIU( cfg->m_Defaults.line_width );
473
474 if( isTextBox )
475 {
476 SCH_TEXTBOX* textbox = new SCH_TEXTBOX( LAYER_DEVICE, lineWidth, m_lastFillStyle );
477
478 textbox->SetParent( symbol );
481
482 // Must be after SetTextSize()
483 textbox->SetBold( m_lastTextBold );
484 textbox->SetItalic( m_lastTextItalic );
485
486 textbox->SetTextAngle( m_lastTextAngle );
488
489 item = textbox;
490 description = _( "Add Text Box" );
491 }
492 else
493 {
494 item = new SCH_SHAPE( shapeType, LAYER_DEVICE, lineWidth, m_lastFillStyle );
495 item->SetParent( symbol );
496 description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() );
497 }
498
499 item->SetStroke( m_lastStroke );
501
502 item->SetFlags( IS_NEW );
503 item->BeginEdit( cursorPos );
504
506 item->SetUnit( m_frame->GetUnit() );
507
510
512 }
513 else if( item && ( evt->IsClick( BUT_LEFT )
514 || evt->IsDblClick( BUT_LEFT )
515 || isSyntheticClick
516 || evt->IsAction( &ACTIONS::finishInteractive ) ) )
517 {
518 if( symbol != m_frame->GetCurSymbol() )
519 {
520 symbol = m_frame->GetCurSymbol();
521 item->SetParent( symbol );
522 }
523
524 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &ACTIONS::finishInteractive )
525 || !item->ContinueEdit( VECTOR2I( cursorPos.x, cursorPos.y ) ) )
526 {
527 if( toolType == SHAPE_T::POLY )
528 {
529 item->CalcEdit( item->GetPosition() ); // Close shape
530 item->EndEdit( true );
531 }
532 else
533 {
534 item->EndEdit();
535 }
536
537 item->ClearEditFlags();
538
539 if( isTextBox )
540 {
541 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
542 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( item ) );
543
544 // QuasiModal required for syntax help and Scintilla auto-complete
545 if( dlg.ShowQuasiModal() != wxID_OK )
546 {
547 cleanup();
548 continue;
549 }
550
551 m_lastTextBold = textbox->IsBold();
552 m_lastTextItalic = textbox->IsItalic();
553 m_lastTextAngle = textbox->GetTextAngle();
554 m_lastTextJust = textbox->GetHorizJustify();
555 }
556
557 m_lastStroke = item->GetStroke();
560
562
563 SCH_COMMIT commit( m_toolMgr );
564 commit.Modify( symbol, m_frame->GetScreen() );
565
566 symbol->AddDrawItem( item );
567 item = nullptr;
568
569 commit.Push( description );
572 }
573 }
574 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
575 {
576 item->CalcEdit( cursorPos );
578 m_view->AddToPreview( item->Clone() );
579 }
580 else if( evt->IsDblClick( BUT_LEFT ) && !item )
581 {
583 }
584 else if( evt->IsClick( BUT_RIGHT ) )
585 {
586 // Warp after context menu only if dragging...
587 if( !item )
589
590 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
591 }
592 else
593 {
594 evt->SetPassEvent();
595 }
596
597 // Enable autopanning and cursor capture only when there is a shape being drawn
598 controls->SetAutoPan( item != nullptr );
599 controls->CaptureCursor( item != nullptr );
600 }
601
602 controls->SetAutoPan( false );
603 controls->CaptureCursor( false );
604 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
605 return 0;
606}
607
608
610{
611 m_frame->PushTool( aEvent );
612
613 auto setCursor =
614 [&]()
615 {
616 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
617 };
618
619 Activate();
620 // Must be done after Activate() so that it gets set into the correct context
621 getViewControls()->ShowCursor( true );
622 // Set initial cursor
623 setCursor();
624
625 // Main loop: keep receiving events
626 while( TOOL_EVENT* evt = Wait() )
627 {
628 setCursor();
629
630 if( evt->IsCancelInteractive() )
631 {
632 m_frame->PopTool( aEvent );
633 break;
634 }
635 else if( evt->IsActivate() )
636 {
637 m_frame->PopTool( aEvent );
638 break;
639 }
640 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
641 {
642 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
643
644 if( !symbol )
645 continue;
646
647 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
648
649 symbol->Move( -cursorPos );
650
651 // Refresh the view without changing the viewport
652 m_view->SetCenter( m_view->GetCenter() + cursorPos );
654 m_frame->OnModify();
655 }
656 else if( evt->IsClick( BUT_RIGHT ) )
657 {
658 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
659 }
660 else
661 {
662 evt->SetPassEvent();
663 }
664 }
665
666 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
667 return 0;
668}
669
670
672{
673 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
674
675 if( !symbol )
676 return 0;
677
678 // Note: PlaceImportedGraphics() will convert PCB_SHAPE_T and PCB_TEXT_T to footprint
679 // items if needed
681 int dlgResult = dlg.ShowModal();
682
683 std::list<std::unique_ptr<EDA_ITEM>>& list = dlg.GetImportedItems();
684
685 if( dlgResult != wxID_OK )
686 return 0;
687
688 // Ensure the list is not empty:
689 if( list.empty() )
690 {
691 wxMessageBox( _( "No graphic items found in file." ) );
692 return 0;
693 }
694
696
698 std::vector<SCH_ITEM*> newItems; // all new items, including group
699 std::vector<SCH_ITEM*> selectedItems; // the group, or newItems if no group
700 EE_SELECTION preview;
701 SCH_COMMIT commit( m_toolMgr );
702
703 for( std::unique_ptr<EDA_ITEM>& ptr : list )
704 {
705 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( ptr.get() );
706 wxCHECK2( item, continue );
707
708 newItems.push_back( item );
709 selectedItems.push_back( item );
710 preview.Add( item );
711
712 ptr.release();
713 }
714
715 if( !dlg.IsPlacementInteractive() )
716 {
717 commit.Modify( symbol, m_frame->GetScreen() );
718
719 // Place the imported drawings
720 for( SCH_ITEM* item : newItems )
721 {
722 symbol->AddDrawItem( item );
723 item->ClearEditFlags();
724 }
725
726 commit.Push( _( "Import Graphic" ) );
728
729 return 0;
730 }
731
732 m_view->Add( &preview );
733
734 // Clear the current selection then select the drawings so that edit tools work on them
736
737 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
739
740 m_frame->PushTool( aEvent );
741
742 auto setCursor = [&]()
743 {
744 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
745 };
746
747 Activate();
748 // Must be done after Activate() so that it gets set into the correct context
749 controls->ShowCursor( true );
750 controls->ForceCursorPosition( false );
751 // Set initial cursor
752 setCursor();
753
754 //SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
756
757 // Now move the new items to the current cursor position:
758 VECTOR2I cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
759 VECTOR2I delta = cursorPos;
760 VECTOR2I currentOffset;
761
762 for( SCH_ITEM* item : selectedItems )
763 item->Move( delta );
764
765 currentOffset += delta;
766
767 m_view->Update( &preview );
768
769 // Main loop: keep receiving events
770 while( TOOL_EVENT* evt = Wait() )
771 {
772 setCursor();
773
774 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
775 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
776
777 cursorPos = grid.Align( controls->GetMousePosition(), GRID_GRAPHICS );
778 controls->ForceCursorPosition( true, cursorPos );
779
780 if( evt->IsCancelInteractive() || evt->IsActivate() )
781 {
783
784 for( SCH_ITEM* item : newItems )
785 delete item;
786
787 break;
788 }
789 else if( evt->IsMotion() )
790 {
791 delta = cursorPos - currentOffset;
792
793 for( SCH_ITEM* item : selectedItems )
794 item->Move( delta );
795
796 currentOffset += delta;
797
798 m_view->Update( &preview );
799 }
800 else if( evt->IsClick( BUT_RIGHT ) )
801 {
802 m_menu->ShowContextMenu( m_selectionTool->GetSelection() );
803 }
804 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
805 {
806 commit.Modify( symbol, m_frame->GetScreen() );
807
808 // Place the imported drawings
809 for( SCH_ITEM* item : newItems )
810 {
811 symbol->AddDrawItem( item );
812 item->ClearEditFlags();
813 }
814
815 commit.Push( _( "Import Graphic" ) );
816 break; // This is a one-shot command, not a tool
817 }
818 else
819 {
820 evt->SetPassEvent();
821 }
822 }
823
824 preview.Clear();
825 m_view->Remove( &preview );
826
828
829 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
830 controls->ForceCursorPosition( false );
831
832 m_frame->PopTool( aEvent );
833
834 return 0;
835}
836
837
839{
841 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
842 SCH_PIN* sourcePin = nullptr;
843
844 if( !symbol )
845 return 0;
846
847 for( SCH_PIN* test : symbol->GetPins() )
848 {
849 if( test->m_Uuid == g_lastPin )
850 {
851 sourcePin = test;
852 break;
853 }
854 }
855
856 if( sourcePin )
857 {
858 SCH_PIN* pin = pinTool->RepeatPin( sourcePin );
859
860 if( pin )
861 g_lastPin = pin->m_Uuid;
862
864
865 if( pin )
867 }
868
869 return 0;
870}
871
872
874{
875 // clang-format off
888 // clang-format on
889}
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 increment
Definition: actions.h:87
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)
Modify a given item in the model.
Definition: commit.h:108
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:245
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
const KIID m_Uuid
Definition: eda_item.h:490
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:378
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
virtual wxString GetFriendlyName() const
Definition: eda_item.cpp:332
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:524
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:326
bool IsBold() const
Definition: eda_text.h:171
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:290
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:298
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:342
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:297
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:332
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:1673
void ClearPreview()
Definition: view.cpp:1695
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1439
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1717
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:586
Definition: kiid.h:49
Define a library symbol object.
Definition: lib_symbol.h:84
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:837
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:689
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
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:432
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
virtual void SetBodyStyle(int aBodyStyle)
Definition: sch_item.h:232
virtual void SetUnit(int aUnit)
Definition: sch_item.h:229
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: sch_shape.h:77
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:80
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:78
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_shape.h:79
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:55
VECTOR2I GetPosition() const override
Definition: sch_shape.h:72
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)
Return a handle to the a given settings by type.
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: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:511
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:189
#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:538
#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:418
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1073
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: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:151
@ SCH_PIN_T
Definition: typeinfo.h:153
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695