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>
39#include <string_utils.h>
40#include <wx/msgdlg.h>
42
43static void* g_lastPinWeakPtr;
44
45
47 EE_TOOL_BASE<SYMBOL_EDIT_FRAME>( "eeschema.SymbolDrawing" ),
48 m_lastTextBold( false ),
49 m_lastTextItalic( false ),
50 m_lastTextAngle( ANGLE_HORIZONTAL ),
51 m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ),
52 m_lastFillStyle( FILL_T::NO_FILL ),
53 m_lastFillColor( COLOR4D::UNSPECIFIED ),
54 m_lastStroke( 0, LINE_STYLE::DEFAULT, COLOR4D::UNSPECIFIED ),
55 m_drawSpecificBodyStyle( true ),
56 m_drawSpecificUnit( false ),
57 m_inDrawShape( false ),
58 m_inTwoClickPlace( false )
59{
60}
61
62
64{
66
67 auto isDrawingCondition =
68 [] ( const SELECTION& aSel )
69 {
70 SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aSel.Front() );
71 return item && item->IsNew();
72 };
73
74 m_menu.GetMenu().AddItem( ACTIONS::finishInteractive, isDrawingCondition, 2 );
75
76 return true;
77}
78
79
81{
82 KICAD_T type = aEvent.Parameter<KICAD_T>();
84 auto* pinTool = type == SCH_PIN_T ? m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() : nullptr;
85
87 return 0;
88
90
93 VECTOR2I cursorPos;
94 bool ignorePrimePosition = false;
95 SCH_ITEM* item = nullptr;
96 bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText );
97 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
98
100
101 m_frame->PushTool( aEvent );
102
103 auto setCursor =
104 [&]()
105 {
106 if( item )
107 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PLACE );
108 else if( isText )
109 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
110 else
111 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
112 };
113
114 auto cleanup =
115 [&] ()
116 {
119 delete item;
120 item = nullptr;
121 };
122
123 Activate();
124 // Must be done after Activate() so that it gets set into the correct context
125 controls->ShowCursor( true );
126 // Set initial cursor
127 setCursor();
128
129 if( aEvent.HasPosition() )
130 {
131 m_toolMgr->PrimeTool( aEvent.Position() );
132 }
133 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
134 {
135 m_toolMgr->PrimeTool( { 0, 0 } );
136 ignorePrimePosition = true;
137 }
138
139 // Main loop: keep receiving events
140 while( TOOL_EVENT* evt = Wait() )
141 {
142 setCursor();
143 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
144 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
145
146 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
147 controls->ForceCursorPosition( true, cursorPos );
148
149 // The tool hotkey is interpreted as a click when drawing
150 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
151 && evt->Matches( aEvent );
152
153 if( evt->IsCancelInteractive() )
154 {
156
157 if( item )
158 {
159 cleanup();
160 }
161 else
162 {
163 m_frame->PopTool( aEvent );
164 break;
165 }
166 }
167 else if( evt->IsActivate() && !isSyntheticClick )
168 {
169 if( item && evt->IsMoveTool() )
170 {
171 // we're already moving our own item; ignore the move tool
172 evt->SetPassEvent( false );
173 continue;
174 }
175
176 if( item )
177 {
178 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
179 evt->SetPassEvent( false );
180 continue;
181 }
182
183 if( evt->IsPointEditor() )
184 {
185 // don't exit (the point editor runs in the background)
186 }
187 else if( evt->IsMoveTool() )
188 {
189 break;
190 }
191 else
192 {
193 m_frame->PopTool( aEvent );
194 break;
195 }
196 }
197 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
198 {
199 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
200
201 if( !symbol )
202 continue;
203
204 // First click creates...
205 if( !item )
206 {
208
209 switch( type )
210 {
211 case SCH_PIN_T:
212 {
213 item = pinTool->CreatePin( VECTOR2I( cursorPos.x, -cursorPos.y ), symbol );
214 g_lastPinWeakPtr = item;
215 break;
216 }
217 case SCH_TEXT_T:
218 {
219 SCH_TEXT* text = new SCH_TEXT( VECTOR2I( cursorPos.x, -cursorPos.y ),
220 wxEmptyString, LAYER_DEVICE );
221
222 text->SetParent( symbol );
223
225 text->SetUnit( m_frame->GetUnit() );
226
228 text->SetBodyStyle( m_frame->GetBodyStyle() );
229
230 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
231 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
232 text->SetTextAngle( m_lastTextAngle );
233
235
236 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
237 delete text;
238 else
239 item = text;
240
241 break;
242 }
243 default:
244 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
245 }
246
247 // If we started with a hotkey which has a position then warp back to that.
248 // Otherwise update to the current mouse position pinned inside the autoscroll
249 // boundaries.
250 if( evt->IsPrime() && !ignorePrimePosition )
251 {
252 cursorPos = grid.Align( evt->Position(), grid.GetItemGrid( item ) );
253 getViewControls()->WarpMouseCursor( cursorPos, true );
254 }
255 else
256 {
258 cursorPos = getViewControls()->GetMousePosition();
259 }
260
261 if( item )
262 {
263 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
264
265 item->SetFlags( IS_NEW | IS_MOVING );
267 m_view->AddToPreview( item->Clone() );
269
270 // update the cursor so it looks correct before another event
271 setCursor();
272 }
273
274 controls->SetCursorPosition( cursorPos, false );
275 }
276 // ... and second click places:
277 else
278 {
279 SCH_COMMIT commit( m_toolMgr );
280 commit.Modify( symbol, m_frame->GetScreen() );
281
282 switch( item->Type() )
283 {
284 case SCH_PIN_T:
285 pinTool->PlacePin( static_cast<SCH_PIN*>( item ) );
286 item->ClearEditFlags();
287 commit.Push( _( "Add Pin" ) );
288 break;
289
290 case SCH_TEXT_T:
291 symbol->AddDrawItem( static_cast<SCH_TEXT*>( item ) );
292 item->ClearEditFlags();
293 commit.Push( _( "Add Text" ) );
294 break;
295
296 default:
297 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
298 }
299
300 item = nullptr;
303 }
304 }
305 else if( evt->IsClick( BUT_RIGHT ) )
306 {
307 // Warp after context menu only if dragging...
308 if( !item )
310
312 }
313 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
314 {
315 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
317 m_view->AddToPreview( item->Clone() );
318 }
319 else
320 {
321 evt->SetPassEvent();
322 }
323
324 // Enable autopanning and cursor capture only when there is an item to be placed
325 controls->SetAutoPan( item != nullptr );
326 controls->CaptureCursor( item != nullptr );
327 }
328
329 controls->SetAutoPan( false );
330 controls->CaptureCursor( false );
331 controls->ForceCursorPosition( false );
332 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
333 return 0;
334}
335
336
338{
339 SHAPE_T requestedShape = aEvent.Parameter<SHAPE_T>();
340
341 return doDrawShape( aEvent, requestedShape );
342}
343
344
346{
347 return doDrawShape( aEvent, std::nullopt /* Draw text box */ );
348}
349
350
351int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional<SHAPE_T> aDrawingShape )
352{
353 bool isTextBox = !aDrawingShape.has_value();
354 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
355
357 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
360 VECTOR2I cursorPos;
361 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
362 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
363 SCH_SHAPE* item = nullptr;
364 wxString description;
365
366 if( m_inDrawShape )
367 return 0;
368
370
371 // We might be running as the same shape in another co-routine. Make sure that one
372 // gets whacked.
374
376
377 m_frame->PushTool( aEvent );
378
379 auto setCursor =
380 [&]()
381 {
382 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
383 };
384
385 auto cleanup =
386 [&] ()
387 {
390 delete item;
391 item = nullptr;
392 };
393
394 Activate();
395 // Must be done after Activate() so that it gets set into the correct context
396 controls->ShowCursor( true );
397 // Set initial cursor
398 setCursor();
399
400 if( aEvent.HasPosition() )
401 m_toolMgr->PrimeTool( aEvent.Position() );
402
403 // Main loop: keep receiving events
404 while( TOOL_EVENT* evt = Wait() )
405 {
406 setCursor();
407 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
408 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
409
410 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
411 controls->ForceCursorPosition( true, cursorPos );
412
413 // The tool hotkey is interpreted as a click when drawing
414 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
415 && evt->Matches( aEvent );
416
417 if( evt->IsCancelInteractive() )
418 {
419 if( item )
420 {
421 cleanup();
422 }
423 else
424 {
425 m_frame->PopTool( aEvent );
426 break;
427 }
428 }
429 else if( evt->IsActivate() && !isSyntheticClick )
430 {
431 if( item )
432 cleanup();
433
434 if( evt->IsPointEditor() )
435 {
436 // don't exit (the point editor runs in the background)
437 }
438 else if( evt->IsMoveTool() )
439 {
440 // leave ourselves on the stack so we come back after the move
441 break;
442 }
443 else
444 {
445 m_frame->PopTool( aEvent );
446 break;
447 }
448 }
449 else if( evt->IsClick( BUT_LEFT ) && !item )
450 {
451 // Update in case the symbol was changed while the tool was running
452 symbol = m_frame->GetCurSymbol();
453
454 if( !symbol )
455 continue;
456
458
459 int lineWidth = schIUScale.MilsToIU( settings->m_Defaults.line_width );
460
461 if( isTextBox )
462 {
463 SCH_TEXTBOX* textbox = new SCH_TEXTBOX( LAYER_DEVICE, lineWidth, m_lastFillStyle );
464
465 textbox->SetParent( symbol );
467 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
468
469 // Must be after SetTextSize()
470 textbox->SetBold( m_lastTextBold );
471 textbox->SetItalic( m_lastTextItalic );
472
473 textbox->SetTextAngle( m_lastTextAngle );
475
476 item = textbox;
477 description = _( "Add Text Box" );
478 }
479 else
480 {
481 item = new SCH_SHAPE( shapeType, LAYER_DEVICE, lineWidth, m_lastFillStyle );
482 item->SetParent( symbol );
483 description = wxString::Format( _( "Add %s" ), item->GetFriendlyName() );
484 }
485
486 item->SetStroke( m_lastStroke );
488
489 item->SetFlags( IS_NEW );
490 item->BeginEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
491
493 item->SetUnit( m_frame->GetUnit() );
494
497
499 }
500 else if( item && ( evt->IsClick( BUT_LEFT )
501 || evt->IsDblClick( BUT_LEFT )
502 || isSyntheticClick
503 || evt->IsAction( &ACTIONS::finishInteractive ) ) )
504 {
505 if( symbol != m_frame->GetCurSymbol() )
506 {
507 symbol = m_frame->GetCurSymbol();
508 item->SetParent( symbol );
509 }
510
511 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &ACTIONS::finishInteractive )
512 || !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) )
513 {
514 if( toolType == SHAPE_T::POLY )
515 {
516 item->CalcEdit( item->GetPosition() ); // Close shape
517 item->EndEdit( true );
518 }
519 else
520 {
521 item->EndEdit();
522 }
523
524 item->ClearEditFlags();
525
526 if( isTextBox )
527 {
528 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
529 DIALOG_TEXT_PROPERTIES dlg( m_frame, static_cast<SCH_TEXTBOX*>( item ) );
530
531 // QuasiModal required for syntax help and Scintilla auto-complete
532 if( dlg.ShowQuasiModal() != wxID_OK )
533 {
534 cleanup();
535 continue;
536 }
537
538 m_lastTextBold = textbox->IsBold();
539 m_lastTextItalic = textbox->IsItalic();
540 m_lastTextAngle = textbox->GetTextAngle();
541 m_lastTextJust = textbox->GetHorizJustify();
542 }
543
544 m_lastStroke = item->GetStroke();
547
549
550 SCH_COMMIT commit( m_toolMgr );
551 commit.Modify( symbol, m_frame->GetScreen() );
552
553 symbol->AddDrawItem( item );
554 item = nullptr;
555
556 commit.Push( description );
559 }
560 }
561 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
562 {
563 item->CalcEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
565 m_view->AddToPreview( item->Clone() );
566 }
567 else if( evt->IsDblClick( BUT_LEFT ) && !item )
568 {
570 }
571 else if( evt->IsClick( BUT_RIGHT ) )
572 {
573 // Warp after context menu only if dragging...
574 if( !item )
576
578 }
579 else
580 {
581 evt->SetPassEvent();
582 }
583
584 // Enable autopanning and cursor capture only when there is a shape being drawn
585 controls->SetAutoPan( item != nullptr );
586 controls->CaptureCursor( item != nullptr );
587 }
588
589 controls->SetAutoPan( false );
590 controls->CaptureCursor( false );
591 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
592 return 0;
593}
594
595
597{
598 m_frame->PushTool( aEvent );
599
600 auto setCursor =
601 [&]()
602 {
603 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
604 };
605
606 Activate();
607 // Must be done after Activate() so that it gets set into the correct context
608 getViewControls()->ShowCursor( true );
609 // Set initial cursor
610 setCursor();
611
612 // Main loop: keep receiving events
613 while( TOOL_EVENT* evt = Wait() )
614 {
615 setCursor();
616
617 if( evt->IsCancelInteractive() )
618 {
619 m_frame->PopTool( aEvent );
620 break;
621 }
622 else if( evt->IsActivate() )
623 {
624 m_frame->PopTool( aEvent );
625 break;
626 }
627 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
628 {
629 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
630
631 if( !symbol )
632 continue;
633
634 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
635 VECTOR2I offset( -cursorPos.x, cursorPos.y );
636
637 symbol->Move( offset );
638
639 // Refresh the view without changing the viewport
640 auto center = m_view->GetCenter();
641 center.x += offset.x;
642 center.y -= offset.y;
643 m_view->SetCenter( center );
645 m_frame->OnModify();
646 }
647 else if( evt->IsClick( BUT_RIGHT ) )
648 {
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 = VECTOR2I( cursorPos.x, -cursorPos.y ) - 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 {
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 // See if we have a pin matching our weak ptr
839 for( SCH_PIN* test : symbol->GetAllLibPins() )
840 {
841 if( (void*) test == g_lastPinWeakPtr )
842 {
843 sourcePin = test;
844 break;
845 }
846 }
847
848 if( sourcePin )
849 {
850 SCH_PIN* pin = pinTool->RepeatPin( sourcePin );
852
854
855 if( pin )
857 }
858
859 return 0;
860}
861
862
864{
876}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
static TOOL_ACTION activatePointEditor
Definition: actions.h:205
static TOOL_ACTION refreshPreview
Definition: actions.h:137
static TOOL_ACTION finishInteractive
Definition: actions.h:64
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
std::list< std::unique_ptr< EDA_ITEM > > & GetImportedItems()
int ShowQuasiModal()
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
WX_INFOBAR * GetInfoBar()
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
virtual void ClearEditFlags()
Definition: eda_item.h:140
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:243
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:126
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:375
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:103
virtual wxString GetFriendlyName() const
Definition: eda_item.cpp:329
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
bool IsNew() const
Definition: eda_item.h:106
FILL_T GetFillMode() const
Definition: eda_shape.h:102
void SetFillColor(const COLOR4D &aColor)
Definition: eda_shape.h:107
COLOR4D GetFillColor() const
Definition: eda_shape.h:106
bool IsItalic() const
Definition: eda_text.h:144
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:374
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:164
void SetBold(bool aBold)
Definition: eda_text.cpp:221
bool IsBold() const
Definition: eda_text.h:148
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:205
void SetItalic(bool aItalic)
Definition: eda_text.cpp:213
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:268
static TOOL_ACTION properties
Definition: ee_actions.h:129
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbolAnchor
Definition: ee_actions.h:117
static TOOL_ACTION drawSymbolPolygon
Definition: ee_actions.h:116
static TOOL_ACTION drawCircle
Definition: ee_actions.h:101
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:113
static TOOL_ACTION importGraphics
Definition: ee_actions.h:255
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:100
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:114
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:115
static TOOL_ACTION drawArc
Definition: ee_actions.h:102
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:123
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:112
EE_SELECTION & GetSelection()
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:200
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:64
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void PinCursorInsideNonAutoscrollArea(bool aWarpMouseCursor)=0
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition: view.h:341
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:315
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:354
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:1631
void ClearPreview()
Definition: view.cpp:1653
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1410
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1675
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
Define a library symbol object.
Definition: lib_symbol.h:77
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:969
virtual COMMON_SETTINGS * GetCommonSettings() const
Definition: pgm_base.cpp:678
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
Definition: sch_commit.cpp:405
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:174
virtual void SetBodyStyle(int aBodyStyle)
Definition: sch_item.h:239
virtual void SetUnit(int aUnit)
Definition: sch_item.h:236
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:92
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:216
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Generic, UI-independent tool event.
Definition: tool_event.h:167
bool HasPosition() const
Definition: tool_event.h:256
bool DisableGridSnapping() const
Definition: tool_event.h:363
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:285
bool IsReactivate() const
Definition: tool_event.h:268
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:82
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:460
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
void Activate()
Run the tool.
void DeactivateTool()
Deactivate the currently active tool.
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:145
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:230
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:525
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:57
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: wx_infobar.cpp:187
#define _(s)
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:431
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:532
#define IS_NEW
New item, just created.
#define IS_MOVING
Item being moved.
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:55
@ GRID_GRAPHICS
Definition: grid_helper.h:45
@ LAYER_DEVICE
Definition: layer_ids.h:370
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
static void * g_lastPinWeakPtr
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< int > VECTOR2I
Definition: vector2d.h:588