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-2022 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 <lib_text.h>
35#include <lib_shape.h>
36#include <lib_textbox.h>
37#include <pgm_base.h>
40#include <string_utils.h>
42#include <wx/msgdlg.h>
45
46static void* g_lastPinWeakPtr;
47
48
50 EE_TOOL_BASE<SYMBOL_EDIT_FRAME>( "eeschema.SymbolDrawing" ),
51 m_lastTextBold( false ),
52 m_lastTextItalic( false ),
53 m_lastTextAngle( ANGLE_HORIZONTAL ),
54 m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ),
55 m_lastFillStyle( FILL_T::NO_FILL ),
56 m_lastFillColor( COLOR4D::UNSPECIFIED ),
57 m_lastStroke( 0, LINE_STYLE::DEFAULT, COLOR4D::UNSPECIFIED ),
58 m_drawSpecificBodyStyle( true ),
59 m_drawSpecificUnit( false ),
60 m_inDrawShape( false ),
61 m_inTwoClickPlace( false )
62{
63}
64
65
67{
69
70 auto isDrawingCondition =
71 [] ( const SELECTION& aSel )
72 {
73 LIB_ITEM* item = (LIB_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 auto* settings = Pgm().GetSettingsManager().GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
87 auto* pinTool = type == LIB_PIN_T ? m_toolMgr->GetTool<SYMBOL_EDITOR_PIN_TOOL>() : nullptr;
88
90 return 0;
91
93
96 VECTOR2I cursorPos;
97 bool ignorePrimePosition = false;
98 LIB_ITEM* item = nullptr;
99 bool isText = aEvent.IsAction( &EE_ACTIONS::placeSymbolText );
100 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
101
103
104 m_frame->PushTool( aEvent );
105
106 auto setCursor =
107 [&]()
108 {
109 if( item )
110 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PLACE );
111 else if( isText )
112 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::TEXT );
113 else
114 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
115 };
116
117 auto cleanup =
118 [&] ()
119 {
122 delete item;
123 item = nullptr;
124 };
125
126 Activate();
127 // Must be done after Activate() so that it gets set into the correct context
128 controls->ShowCursor( true );
129 // Set initial cursor
130 setCursor();
131
132 if( aEvent.HasPosition() )
133 {
134 m_toolMgr->PrimeTool( aEvent.Position() );
135 }
136 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
137 {
138 m_toolMgr->PrimeTool( { 0, 0 } );
139 ignorePrimePosition = true;
140 }
141
142 // Main loop: keep receiving events
143 while( TOOL_EVENT* evt = Wait() )
144 {
145 setCursor();
146 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
147 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
148
149 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
150 controls->ForceCursorPosition( true, cursorPos );
151
152 // The tool hotkey is interpreted as a click when drawing
153 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
154 && evt->Matches( aEvent );
155
156 if( evt->IsCancelInteractive() )
157 {
159
160 if( item )
161 {
162 cleanup();
163 }
164 else
165 {
166 m_frame->PopTool( aEvent );
167 break;
168 }
169 }
170 else if( evt->IsActivate() && !isSyntheticClick )
171 {
172 if( item && evt->IsMoveTool() )
173 {
174 // we're already moving our own item; ignore the move tool
175 evt->SetPassEvent( false );
176 continue;
177 }
178
179 if( item )
180 {
181 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
182 evt->SetPassEvent( false );
183 continue;
184 }
185
186 if( evt->IsPointEditor() )
187 {
188 // don't exit (the point editor runs in the background)
189 }
190 else if( evt->IsMoveTool() )
191 {
192 break;
193 }
194 else
195 {
196 m_frame->PopTool( aEvent );
197 break;
198 }
199 }
200 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
201 {
202 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
203
204 if( !symbol )
205 continue;
206
207 // First click creates...
208 if( !item )
209 {
211
212 switch( type )
213 {
214 case LIB_PIN_T:
215 {
216 item = pinTool->CreatePin( VECTOR2I( cursorPos.x, -cursorPos.y ), symbol );
217 g_lastPinWeakPtr = item;
218 break;
219 }
220 case LIB_TEXT_T:
221 {
222 LIB_TEXT* text = new LIB_TEXT( symbol );
223
225 text->SetUnit( m_frame->GetUnit() );
226
228 text->SetBodyStyle( m_frame->GetBodyStyle() );
229
230 text->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
231 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( settings->m_Defaults.text_size ),
232 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
233 text->SetTextAngle( m_lastTextAngle );
234
236
237 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( text->GetText() ) )
238 delete text;
239 else
240 item = text;
241
242 break;
243 }
244 default:
245 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
246 }
247
248 // If we started with a hotkey which has a position then warp back to that.
249 // Otherwise update to the current mouse position pinned inside the autoscroll
250 // boundaries.
251 if( evt->IsPrime() && !ignorePrimePosition )
252 {
253 cursorPos = grid.Align( evt->Position(), grid.GetItemGrid( item ) );
254 getViewControls()->WarpMouseCursor( cursorPos, true );
255 }
256 else
257 {
259 cursorPos = getViewControls()->GetMousePosition();
260 }
261
262 if( item )
263 {
264 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
265
266 item->SetFlags( IS_NEW | IS_MOVING );
268 m_view->AddToPreview( item->Clone() );
270
271 // update the cursor so it looks correct before another event
272 setCursor();
273 }
274
275 controls->SetCursorPosition( cursorPos, false );
276 }
277 // ... and second click places:
278 else
279 {
280 SCH_COMMIT commit( m_toolMgr );
281 commit.Modify( symbol, m_frame->GetScreen() );
282
283 switch( item->Type() )
284 {
285 case LIB_PIN_T:
286 pinTool->PlacePin( (LIB_PIN*) item );
287 item->ClearEditFlags();
288 commit.Push( _( "Add Pin" ) );
289 break;
290
291 case LIB_TEXT_T:
292 symbol->AddDrawItem( (LIB_TEXT*) item );
293 item->ClearEditFlags();
294 commit.Push( _( "Add Text" ) );
295 break;
296
297 default:
298 wxFAIL_MSG( "TwoClickPlace(): unknown type" );
299 }
300
301 item = nullptr;
304 }
305 }
306 else if( evt->IsClick( BUT_RIGHT ) )
307 {
308 // Warp after context menu only if dragging...
309 if( !item )
311
313 }
314 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
315 {
316 item->SetPosition( VECTOR2I( cursorPos.x, -cursorPos.y ) );
318 m_view->AddToPreview( item->Clone() );
319 }
320 else
321 {
322 evt->SetPassEvent();
323 }
324
325 // Enable autopanning and cursor capture only when there is an item to be placed
326 controls->SetAutoPan( item != nullptr );
327 controls->CaptureCursor( item != nullptr );
328 }
329
330 controls->SetAutoPan( false );
331 controls->CaptureCursor( false );
332 controls->ForceCursorPosition( false );
333 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
334 return 0;
335}
336
337
339{
340 SHAPE_T requestedShape = aEvent.Parameter<SHAPE_T>();
341
342 return doDrawShape( aEvent, requestedShape );
343}
344
345
347{
348 return doDrawShape( aEvent, std::nullopt /* Draw text box */ );
349}
350
351
352int SYMBOL_EDITOR_DRAWING_TOOLS::doDrawShape( const TOOL_EVENT& aEvent, std::optional<SHAPE_T> aDrawingShape )
353{
354 bool isTextBox = !aDrawingShape.has_value();
355 SHAPE_T toolType = aDrawingShape.value_or( SHAPE_T::SEGMENT );
356
358 SETTINGS_MANAGER& settingsMgr = Pgm().GetSettingsManager();
361 VECTOR2I cursorPos;
362 SHAPE_T shapeType = toolType == SHAPE_T::SEGMENT ? SHAPE_T::POLY : toolType;
363 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
364 LIB_SHAPE* item = nullptr;
365 wxString description;
366
367 if( m_inDrawShape )
368 return 0;
369
371
372 // We might be running as the same shape in another co-routine. Make sure that one
373 // gets whacked.
375
377
378 m_frame->PushTool( aEvent );
379
380 auto setCursor =
381 [&]()
382 {
383 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::PENCIL );
384 };
385
386 auto cleanup =
387 [&] ()
388 {
391 delete item;
392 item = nullptr;
393 };
394
395 Activate();
396 // Must be done after Activate() so that it gets set into the correct context
397 controls->ShowCursor( true );
398 // Set initial cursor
399 setCursor();
400
401 if( aEvent.HasPosition() )
402 m_toolMgr->PrimeTool( aEvent.Position() );
403
404 // Main loop: keep receiving events
405 while( TOOL_EVENT* evt = Wait() )
406 {
407 setCursor();
408 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
409 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
410
411 cursorPos = grid.Align( controls->GetMousePosition(), grid.GetItemGrid( item ) );
412 controls->ForceCursorPosition( true, cursorPos );
413
414 // The tool hotkey is interpreted as a click when drawing
415 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
416 && evt->Matches( aEvent );
417
418 if( evt->IsCancelInteractive() )
419 {
420 if( item )
421 {
422 cleanup();
423 }
424 else
425 {
426 m_frame->PopTool( aEvent );
427 break;
428 }
429 }
430 else if( evt->IsActivate() && !isSyntheticClick )
431 {
432 if( item )
433 cleanup();
434
435 if( evt->IsPointEditor() )
436 {
437 // don't exit (the point editor runs in the background)
438 }
439 else if( evt->IsMoveTool() )
440 {
441 // leave ourselves on the stack so we come back after the move
442 break;
443 }
444 else
445 {
446 m_frame->PopTool( aEvent );
447 break;
448 }
449 }
450 else if( evt->IsClick( BUT_LEFT ) && !item )
451 {
452 // Update in case the symbol was changed while the tool was running
453 symbol = m_frame->GetCurSymbol();
454
455 if( !symbol )
456 continue;
457
459
460 int lineWidth = schIUScale.MilsToIU( settings->m_Defaults.line_width );
461
462 if( isTextBox )
463 {
464 LIB_TEXTBOX* textbox = new LIB_TEXTBOX( symbol, lineWidth, m_lastFillStyle );
465
466 textbox->SetBold( m_lastTextBold );
467 textbox->SetItalic( m_lastTextItalic );
469 schIUScale.MilsToIU( settings->m_Defaults.text_size ) ) );
470 textbox->SetTextAngle( m_lastTextAngle );
472
473 item = textbox;
474 description = _( "Add Text Box" );
475 }
476 else
477 {
478 item = new LIB_SHAPE( symbol, shapeType, lineWidth, m_lastFillStyle );
479 description = wxString::Format( _( "Add %s" ), item->EDA_SHAPE::GetFriendlyName() );
480 }
481
482 item->SetStroke( m_lastStroke );
484
485 item->SetFlags( IS_NEW );
486 item->BeginEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
487
489 item->SetUnit( m_frame->GetUnit() );
490
493
495 }
496 else if( item && ( evt->IsClick( BUT_LEFT )
497 || evt->IsDblClick( BUT_LEFT )
498 || isSyntheticClick
499 || evt->IsAction( &ACTIONS::finishInteractive ) ) )
500 {
501 if( symbol != m_frame->GetCurSymbol() )
502 {
503 symbol = m_frame->GetCurSymbol();
504 item->SetParent( symbol );
505 }
506
507 if( evt->IsDblClick( BUT_LEFT ) || evt->IsAction( &ACTIONS::finishInteractive )
508 || !item->ContinueEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) ) )
509 {
510 if( toolType == SHAPE_T::POLY )
511 {
512 item->CalcEdit( item->GetPosition() ); // Close shape
513 item->EndEdit( true );
514 }
515 else
516 {
517 item->EndEdit();
518 }
519
520 item->ClearEditFlags();
521
522 if( isTextBox )
523 {
524 LIB_TEXTBOX* textbox = static_cast<LIB_TEXTBOX*>( item );
525 DIALOG_LIB_TEXTBOX_PROPERTIES dlg( m_frame, static_cast<LIB_TEXTBOX*>( item ) );
526
527 if( dlg.ShowQuasiModal() != wxID_OK )
528 {
529 cleanup();
530 continue;
531 }
532
533 m_lastTextBold = textbox->IsBold();
534 m_lastTextItalic = textbox->IsItalic();
535 m_lastTextAngle = textbox->GetTextAngle();
536 m_lastTextJust = textbox->GetHorizJustify();
537 }
538
539 m_lastStroke = item->GetStroke();
542
544
545 SCH_COMMIT commit( m_toolMgr );
546 commit.Modify( symbol, m_frame->GetScreen() );
547
548 symbol->AddDrawItem( item );
549 item = nullptr;
550
551 commit.Push( description );
554 }
555 }
556 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
557 {
558 item->CalcEdit( VECTOR2I( cursorPos.x, -cursorPos.y ) );
560 m_view->AddToPreview( item->Clone() );
561 }
562 else if( evt->IsDblClick( BUT_LEFT ) && !item )
563 {
565 }
566 else if( evt->IsClick( BUT_RIGHT ) )
567 {
568 // Warp after context menu only if dragging...
569 if( !item )
571
573 }
574 else
575 {
576 evt->SetPassEvent();
577 }
578
579 // Enable autopanning and cursor capture only when there is a shape being drawn
580 controls->SetAutoPan( item != nullptr );
581 controls->CaptureCursor( item != nullptr );
582 }
583
584 controls->SetAutoPan( false );
585 controls->CaptureCursor( false );
586 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
587 return 0;
588}
589
590
592{
593 m_frame->PushTool( aEvent );
594
595 auto setCursor =
596 [&]()
597 {
598 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
599 };
600
601 Activate();
602 // Must be done after Activate() so that it gets set into the correct context
603 getViewControls()->ShowCursor( true );
604 // Set initial cursor
605 setCursor();
606
607 // Main loop: keep receiving events
608 while( TOOL_EVENT* evt = Wait() )
609 {
610 setCursor();
611
612 if( evt->IsCancelInteractive() )
613 {
614 m_frame->PopTool( aEvent );
615 break;
616 }
617 else if( evt->IsActivate() )
618 {
619 m_frame->PopTool( aEvent );
620 break;
621 }
622 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
623 {
624 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
625
626 if( !symbol )
627 continue;
628
629 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
630 VECTOR2I offset( -cursorPos.x, cursorPos.y );
631
632 symbol->SetOffset( offset );
633
634 // Refresh the view without changing the viewport
635 auto center = m_view->GetCenter();
636 center.x += offset.x;
637 center.y -= offset.y;
638 m_view->SetCenter( center );
640 m_frame->OnModify();
641 }
642 else if( evt->IsClick( BUT_RIGHT ) )
643 {
645 }
646 else
647 {
648 evt->SetPassEvent();
649 }
650 }
651
652 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
653 return 0;
654}
655
656
658{
659 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
660
661 if( !symbol )
662 return 0;
663
664 // Note: PlaceImportedGraphics() will convert PCB_SHAPE_T and PCB_TEXT_T to footprint
665 // items if needed
667 int dlgResult = dlg.ShowModal();
668
669 std::list<std::unique_ptr<EDA_ITEM>>& list = dlg.GetImportedItems();
670
671 if( dlgResult != wxID_OK )
672 return 0;
673
674 // Ensure the list is not empty:
675 if( list.empty() )
676 {
677 wxMessageBox( _( "No graphic items found in file." ) );
678 return 0;
679 }
680
682
684 std::vector<LIB_ITEM*> newItems; // all new items, including group
685 std::vector<LIB_ITEM*> selectedItems; // the group, or newItems if no group
686 EE_SELECTION preview;
687 SCH_COMMIT commit( m_toolMgr );
688
689 for( std::unique_ptr<EDA_ITEM>& ptr : list )
690 {
691 LIB_ITEM* item = dynamic_cast<LIB_ITEM*>( ptr.get() );
692 wxCHECK2( item, continue );
693
694 newItems.push_back( item );
695 selectedItems.push_back( item );
696 preview.Add( item );
697
698 ptr.release();
699 }
700
701 if( !dlg.IsPlacementInteractive() )
702 {
703 commit.Modify( symbol, m_frame->GetScreen() );
704
705 // Place the imported drawings
706 for( LIB_ITEM* item : newItems )
707 {
708 symbol->AddDrawItem( item );
709 item->ClearEditFlags();
710 }
711
712 commit.Push( _( "Import Graphic" ) );
714
715 return 0;
716 }
717
718 m_view->Add( &preview );
719
720 // Clear the current selection then select the drawings so that edit tools work on them
722
723 EDA_ITEMS selItems( selectedItems.begin(), selectedItems.end() );
725
726 m_frame->PushTool( aEvent );
727
728 auto setCursor = [&]()
729 {
730 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::MOVING );
731 };
732
733 Activate();
734 // Must be done after Activate() so that it gets set into the correct context
735 controls->ShowCursor( true );
736 controls->ForceCursorPosition( false );
737 // Set initial cursor
738 setCursor();
739
740 //SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
742
743 // Now move the new items to the current cursor position:
744 VECTOR2I cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
745 VECTOR2I delta = cursorPos;
746 VECTOR2I currentOffset;
747
748 for( LIB_ITEM* item : selectedItems )
749 item->Offset( delta );
750
751 currentOffset += delta;
752
753 m_view->Update( &preview );
754
755 // Main loop: keep receiving events
756 while( TOOL_EVENT* evt = Wait() )
757 {
758 setCursor();
759
760 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
761 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
762
763 cursorPos = grid.Align( controls->GetMousePosition(), GRID_GRAPHICS );
764 controls->ForceCursorPosition( true, cursorPos );
765
766 if( evt->IsCancelInteractive() || evt->IsActivate() )
767 {
769
770 for( LIB_ITEM* item : newItems )
771 delete item;
772
773 break;
774 }
775 else if( evt->IsMotion() )
776 {
777 delta = VECTOR2I( cursorPos.x, -cursorPos.y ) - currentOffset;
778
779 for( LIB_ITEM* item : selectedItems )
780 item->Offset( delta );
781
782 currentOffset += delta;
783
784 m_view->Update( &preview );
785 }
786 else if( evt->IsClick( BUT_RIGHT ) )
787 {
789 }
790 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
791 {
792 commit.Modify( symbol, m_frame->GetScreen() );
793
794 // Place the imported drawings
795 for( LIB_ITEM* item : newItems )
796 {
797 symbol->AddDrawItem( item );
798 item->ClearEditFlags();
799 }
800
801 commit.Push( _( "Import Graphic" ) );
802 break; // This is a one-shot command, not a tool
803 }
804 else
805 {
806 evt->SetPassEvent();
807 }
808 }
809
810 preview.Clear();
811 m_view->Remove( &preview );
812
814
815 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
816 controls->ForceCursorPosition( false );
817
818 m_frame->PopTool( aEvent );
819
820 return 0;
821}
822
823
825{
827 LIB_SYMBOL* symbol = m_frame->GetCurSymbol();
828 LIB_PIN* sourcePin = nullptr;
829
830 if( !symbol )
831 return 0;
832
833 // See if we have a pin matching our weak ptr
834 std::vector<LIB_PIN*> pins = symbol->GetAllLibPins();
835
836 for( LIB_PIN* test : pins )
837 {
838 if( (void*) test == g_lastPinWeakPtr )
839 {
840 sourcePin = test;
841 break;
842 }
843 }
844
845 if( sourcePin )
846 {
847 LIB_PIN* pin = pinTool->RepeatPin( sourcePin );
849
851
852 if( pin )
854 }
855
856 return 0;
857}
858
859
861{
873}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
static TOOL_ACTION activatePointEditor
Definition: actions.h:182
static TOOL_ACTION refreshPreview
Definition: actions.h:114
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:85
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:123
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:372
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
void ClearEditFlags()
Definition: eda_item.h:137
bool IsNew() const
Definition: eda_item.h:103
FILL_T GetFillMode() const
Definition: eda_shape.h:101
void SetFillColor(const COLOR4D &aColor)
Definition: eda_shape.h:106
COLOR4D GetFillColor() const
Definition: eda_shape.h:105
bool IsItalic() const
Definition: eda_text.h:141
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:358
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:160
void SetBold(bool aBold)
Definition: eda_text.cpp:221
bool IsBold() const
Definition: eda_text.h:144
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:252
static TOOL_ACTION properties
Definition: ee_actions.h:121
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:109
static TOOL_ACTION drawSymbolPolygon
Definition: ee_actions.h:108
static TOOL_ACTION drawCircle
Definition: ee_actions.h:96
static TOOL_ACTION placeSymbolText
Definition: ee_actions.h:105
static TOOL_ACTION importGraphics
Definition: ee_actions.h:243
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:95
static TOOL_ACTION drawSymbolTextBox
Definition: ee_actions.h:106
static TOOL_ACTION drawSymbolLines
Definition: ee_actions.h:107
static TOOL_ACTION drawArc
Definition: ee_actions.h:97
static TOOL_ACTION repeatDrawItem
Definition: ee_actions.h:115
static TOOL_ACTION placeSymbolPin
Definition: ee_actions.h:104
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:197
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:313
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:350
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:1619
void ClearPreview()
Definition: view.cpp:1641
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1401
void AddToPreview(VIEW_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1663
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:573
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_item.h:304
void SetBodyStyle(int aBodyStyle)
Definition: lib_item.h:345
void SetUnit(int aUnit)
Definition: lib_item.h:342
STROKE_PARAMS GetStroke() const
Definition: lib_shape.h:57
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_shape.h:77
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: lib_shape.h:81
void SetStroke(const STROKE_PARAMS &aStroke)
Definition: lib_shape.h:58
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_shape.cpp:64
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: lib_shape.h:78
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_shape.h:79
VECTOR2I GetPosition() const override
Definition: lib_shape.h:90
Define a library symbol object.
Definition: lib_symbol.h:99
void AddDrawItem(LIB_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
void SetOffset(const VECTOR2I &aOffset)
Move the symbol aOffset.
Define a symbol library graphical text item.
Definition: lib_text.h:40
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:367
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)
LIB_PIN * RepeatPin(const LIB_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:517
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:529
#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:54
a few functions useful in geometry calculations.
@ GRID_GRAPHICS
Definition: grid_helper.h:45
see class PGM_BASE
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:119
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:94
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
@ LIB_TEXT_T
Definition: typeinfo.h:200
@ LIB_PIN_T
Definition: typeinfo.h:202
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588