KiCad PCB EDA Suite
sch_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
28#include <ee_actions.h>
29#include <sch_edit_frame.h>
30#include <project.h>
31#include <pgm_base.h>
32#include <eeschema_id.h>
33#include <confirm.h>
34#include <view/view_controls.h>
35#include <view/view.h>
36#include <sch_symbol.h>
37#include <sch_no_connect.h>
38#include <sch_line.h>
39#include <sch_junction.h>
40#include <sch_bus_entry.h>
41#include <sch_text.h>
42#include <sch_textbox.h>
43#include <sch_sheet.h>
44#include <sch_sheet_pin.h>
45#include <sch_bitmap.h>
46#include <schematic.h>
48#include <eeschema_settings.h>
50#include <dialogs/dialog_text_properties.h>
54#include <string_utils.h>
56#include <wx/filedlg.h>
57
59 EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
60 m_lastSheetPinType( LABEL_FLAG_SHAPE::L_INPUT ),
61 m_lastGlobalLabelShape( LABEL_FLAG_SHAPE::L_INPUT ),
62 m_lastNetClassFlagShape( LABEL_FLAG_SHAPE::F_ROUND ),
63 m_lastTextOrientation( TEXT_SPIN_STYLE::RIGHT ),
64 m_lastTextBold( false ),
65 m_lastTextItalic( false ),
66 m_lastTextAngle( ANGLE_0 ),
67 m_lastTextJust( GR_TEXT_H_ALIGN_LEFT ),
68 m_lastFillStyle( FILL_T::NO_FILL ),
69 m_lastTextboxFillStyle( FILL_T::NO_FILL ),
70 m_lastFillColor( COLOR4D::UNSPECIFIED ),
71 m_lastTextboxFillColor( COLOR4D::UNSPECIFIED ),
72 m_lastStroke( 0, PLOT_DASH_TYPE::DEFAULT, COLOR4D::UNSPECIFIED ),
73 m_lastTextboxStroke( 0, PLOT_DASH_TYPE::DEFAULT, COLOR4D::UNSPECIFIED ),
74 m_mruPath( wxEmptyString ),
75 m_lastAutoLabelRotateOnPlacement( false ),
76 m_inPlaceSymbol( false ),
77 m_inDrawShape( false ),
78 m_inPlaceImage( false ),
79 m_inSingleClickPlace( false ),
80 m_inTwoClickPlace( false ),
81 m_inDrawSheet( false )
82{
83}
84
85
87{
89
90 auto belowRootSheetCondition =
91 [&]( const SELECTION& aSel )
92 {
93 return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
94 };
95
96 CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
97 ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
98
99 return true;
100}
101
102
104{
105 SCH_SYMBOL* symbol = aEvent.Parameter<SCH_SYMBOL*>();
107 std::vector<PICKED_SYMBOL>* historyList = nullptr;
108 bool ignorePrimePosition = false;
109 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
111
112 if( m_inPlaceSymbol )
113 return 0;
114
116
117 // First we need to get all instances of this sheet so we can annotate
118 // whatever symbols we place on all copies
119 SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
120 SCH_SHEET_LIST newInstances =
122 newInstances.SortByPageNumbers();
123
124 // Get a list of all references in the schematic to avoid duplicates wherever
125 // they're placed
126 SCH_REFERENCE_LIST existingRefs;
127 hierarchy.GetSymbols( existingRefs );
128 existingRefs.SortByReferenceOnly();
129
130 if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
131 {
132 historyList = &m_symbolHistoryList;
133 }
134 else if (aEvent.IsAction( &EE_ACTIONS::placePower ) )
135 {
136 historyList = &m_powerHistoryList;
137 filter.FilterPowerSymbols( true );
138 }
139 else
140 {
141 wxFAIL_MSG( "PlaceSymbol(): unexpected request" );
142 }
143
144 m_frame->PushTool( aEvent );
145
146 auto addSymbol =
147 [&]( SCH_SYMBOL* aSymbol )
148 {
149 m_frame->SaveCopyForRepeatItem( aSymbol );
150
152 m_selectionTool->AddItemToSel( aSymbol );
153
154 aSymbol->SetParent( m_frame->GetScreen() );
155 aSymbol->SetFlags( IS_NEW | IS_MOVING );
157
158 // Set IS_MOVING again, as AddItemToScreenAndUndoList() will have cleared it.
159 aSymbol->SetFlags( IS_MOVING );
161 };
162
163 auto setCursor =
164 [&]()
165 {
168 };
169
170 auto cleanup =
171 [&]()
172 {
175 existingRefs.Clear();
176 hierarchy.GetSymbols( existingRefs );
177 existingRefs.SortByReferenceOnly();
178 symbol = nullptr;
179 };
180
181 auto annotate =
182 [&]()
183 {
185
186 // Then we need to annotate all instances by sheet
187 for( SCH_SHEET_PATH& instance : newInstances )
188 {
189 SCH_REFERENCE newReference( symbol, symbol->GetLibSymbolRef().get(), instance );
191 refs.AddItem( newReference );
192
193 if( symbol->GetLibSymbolRef()->IsPower() )
194 {
195 refs.ReannotateByOptions( UNSORTED, INCREMENTAL_BY_REF, 1, existingRefs,
196 true, nullptr );
197 }
198 else if( cfg->m_AnnotatePanel.automatic )
199 {
203 m_frame->Schematic().Settings().m_AnnotateStartNum, existingRefs,
204 false, &hierarchy );
205
206 refs.UpdateAnnotation();
207
208 // Update existing refs for next iteration
209 for( size_t i = 0; i < refs.GetCount(); i++ )
210 existingRefs.AddItem( refs[i] );
211 }
212 }
213
215 };
216
217 Activate();
218
219 // Must be done after Activate() so that it gets set into the correct context
220 getViewControls()->ShowCursor( true );
221
222 // Set initial cursor
223 setCursor();
224
225 // Prime the pump
226 if( symbol )
227 {
228 addSymbol( symbol );
229 annotate();
230 getViewControls()->WarpMouseCursor( getViewControls()->GetMousePosition( false ) );
231 }
232 else if( aEvent.HasPosition() )
233 {
234 m_toolMgr->PrimeTool( aEvent.Position() );
235 }
236 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
237 {
238 m_toolMgr->PrimeTool( { 0, 0 } );
239 ignorePrimePosition = true;
240 }
241
242 // Main loop: keep receiving events
243 while( TOOL_EVENT* evt = Wait() )
244 {
245 setCursor();
246 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
247 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
248
249 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
250
251 // The tool hotkey is interpreted as a click when drawing
252 bool isSyntheticClick = symbol && evt->IsActivate() && evt->HasPosition()
253 && evt->Matches( aEvent );
254
255 if( evt->IsCancelInteractive() )
256 {
258
259 if( symbol )
260 {
261 cleanup();
262 }
263 else
264 {
265 m_frame->PopTool( aEvent );
266 break;
267 }
268 }
269 else if( evt->IsActivate() && !isSyntheticClick )
270 {
271 if( symbol && evt->IsMoveTool() )
272 {
273 // we're already moving our own item; ignore the move tool
274 evt->SetPassEvent( false );
275 continue;
276 }
277
278 if( symbol )
279 {
280 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel symbol creation." ) );
281 evt->SetPassEvent( false );
282 continue;
283 }
284
285 if( evt->IsMoveTool() )
286 {
287 // leave ourselves on the stack so we come back after the move
288 break;
289 }
290 else
291 {
292 m_frame->PopTool( aEvent );
293 break;
294 }
295 }
296 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
297 {
298 if( !symbol )
299 {
301
302 // Pick the footprint to be placed
303 bool footprintPreviews = m_frame->eeconfig()->m_Appearance.footprint_preview;
304 PICKED_SYMBOL sel = m_frame->PickSymbolFromLibTree( &filter, *historyList, true,
305 1, 1, footprintPreviews );
306
307 LIB_SYMBOL* libSymbol = sel.LibId.IsValid() ? m_frame->GetLibSymbol( sel.LibId )
308 : nullptr;
309
310 if( !libSymbol )
311 continue;
312
313 // If we started with a hotkey which has a position then warp back to that.
314 // Otherwise update to the current mouse position pinned inside the autoscroll
315 // boundaries.
316 if( evt->IsPrime() && !ignorePrimePosition )
317 {
318 cursorPos = grid.Align( evt->Position() );
319 getViewControls()->WarpMouseCursor( cursorPos, true );
320 }
321 else
322 {
324 cursorPos = getViewControls()->GetMousePosition();
325 }
326
327 symbol = new SCH_SYMBOL( *libSymbol, &m_frame->GetCurrentSheet(), sel, cursorPos,
328 &m_frame->Schematic() );
329 addSymbol( symbol );
330 annotate();
331
333 symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
334
335 // Update cursor now that we have a symbol
336 setCursor();
337 }
338 else
339 {
341 symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
342
343 symbol->ClearEditFlags();
344 m_view->Update( symbol );
345 m_frame->GetScreen()->Update( symbol );
346
351
352 m_frame->OnModify();
353
354 SCH_SYMBOL* nextSymbol = nullptr;
355
358 {
359 int new_unit = symbol->GetUnit();
360
362 && symbol->GetUnit() < symbol->GetUnitCount() )
363 {
364 new_unit++;
365 }
366 else
367 {
368 new_unit = 1;
369 }
370
371 // We are either stepping to the next unit or next symbol
372 if( m_frame->eeconfig()->m_SymChooserPanel.keep_symbol || new_unit > 1 )
373 {
374 nextSymbol = static_cast<SCH_SYMBOL*>( symbol->Duplicate() );
375 nextSymbol->SetUnit( new_unit );
376 nextSymbol->SetUnitSelection( new_unit );
377
378 // Start new annotation sequence at first unit
379 if( new_unit == 1 )
380 nextSymbol->ClearAnnotation( nullptr, false );
381
382 addSymbol( nextSymbol );
383 symbol = nextSymbol; // annotate() looks at symbol, update it
384 annotate();
385 }
386 }
387
388 symbol = nextSymbol;
389 }
390 }
391 else if( evt->IsClick( BUT_RIGHT ) )
392 {
393 // Warp after context menu only if dragging...
394 if( !symbol )
396
398 }
399 else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
400 {
401 if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT_CMP
402 && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
403 {
404 int unit = *evt->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT_CMP;
405
406 if( symbol )
407 {
408 m_frame->SelectUnit( symbol, unit );
410 }
411 }
412 }
413 else if( symbol && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
414 {
415 symbol->SetPosition( cursorPos );
416 m_view->Update( symbol );
417 m_frame->SetMsgPanel( symbol );
418 }
419 else if( symbol && evt->IsAction( &ACTIONS::doDelete ) )
420 {
421 cleanup();
422 }
423 else
424 {
425 evt->SetPassEvent();
426 }
427
428 // Enable autopanning and cursor capture only when there is a symbol to be placed
429 getViewControls()->SetAutoPan( symbol != nullptr );
430 getViewControls()->CaptureCursor( symbol != nullptr );
431 }
432
433 getViewControls()->SetAutoPan( false );
434 getViewControls()->CaptureCursor( false );
436
437 return 0;
438}
439
440
442{
443 SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
444 bool immediateMode = image != nullptr;
446 bool ignorePrimePosition = false;
447 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
448
449 if( m_inPlaceImage )
450 return 0;
451
453
455
456 // Add all the drawable symbols to preview
457 if( image )
458 {
459 image->SetPosition( getViewControls()->GetCursorPosition() );
461 m_view->AddToPreview( image, false ); // Add, but not give ownership
462 }
463
464 m_frame->PushTool( aEvent );
465
466 auto setCursor =
467 [&]()
468 {
469 if( image )
471 else
473 };
474
475 auto cleanup =
476 [&] ()
477 {
480 delete image;
481 image = nullptr;
482 };
483
484 Activate();
485
486 // Must be done after Activate() so that it gets set into the correct context
487 getViewControls()->ShowCursor( true );
488
489 // Set initial cursor
490 setCursor();
491
492 // Prime the pump
493 if( image )
494 {
496 }
497 else if( aEvent.HasPosition() )
498 {
499 m_toolMgr->PrimeTool( aEvent.Position() );
500 }
501 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate() )
502 {
503 m_toolMgr->PrimeTool( { 0, 0 } );
504 ignorePrimePosition = true;
505 }
506
507 // Main loop: keep receiving events
508 while( TOOL_EVENT* evt = Wait() )
509 {
510 setCursor();
511 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
512
513 // The tool hotkey is interpreted as a click when drawing
514 bool isSyntheticClick = image && evt->IsActivate() && evt->HasPosition()
515 && evt->Matches( aEvent );
516
517 if( evt->IsCancelInteractive() )
518 {
520
521 if( image )
522 {
523 cleanup();
524 }
525 else
526 {
527 m_frame->PopTool( aEvent );
528 break;
529 }
530
531 if( immediateMode )
532 {
533 m_frame->PopTool( aEvent );
534 break;
535 }
536 }
537 else if( evt->IsActivate() && !isSyntheticClick )
538 {
539 if( image && evt->IsMoveTool() )
540 {
541 // we're already moving our own item; ignore the move tool
542 evt->SetPassEvent( false );
543 continue;
544 }
545
546 if( image )
547 {
548 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel image creation." ) );
549 evt->SetPassEvent( false );
550 continue;
551 }
552
553 if( evt->IsMoveTool() )
554 {
555 // leave ourselves on the stack so we come back after the move
556 break;
557 }
558 else
559 {
560 m_frame->PopTool( aEvent );
561 break;
562 }
563 }
564 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
565 {
566 if( !image )
567 {
569
570 wxFileDialog dlg( m_frame, _( "Choose Image" ), m_mruPath, wxEmptyString,
571 _( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
572 wxFD_OPEN );
573
574 if( dlg.ShowModal() != wxID_OK )
575 continue;
576
577 // If we started with a hotkey which has a position then warp back to that.
578 // Otherwise update to the current mouse position pinned inside the autoscroll
579 // boundaries.
580 if( evt->IsPrime() && !ignorePrimePosition )
581 {
582 cursorPos = grid.Align( evt->Position() );
583 getViewControls()->WarpMouseCursor( cursorPos, true );
584 }
585 else
586 {
588 cursorPos = getViewControls()->GetMousePosition();
589 }
590
591 wxString fullFilename = dlg.GetPath();
592 m_mruPath = wxPathOnly( fullFilename );
593
594 if( wxFileExists( fullFilename ) )
595 image = new SCH_BITMAP( cursorPos );
596
597 if( !image || !image->ReadImageFile( fullFilename ) )
598 {
599 wxMessageBox( _( "Could not load image from '%s'." ), fullFilename );
600 delete image;
601 image = nullptr;
602 continue;
603 }
604
605 image->SetFlags( IS_NEW | IS_MOVING );
606
608
610 m_view->AddToPreview( image, false ); // Add, but not give ownership
611 m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
612
614
615 getViewControls()->SetCursorPosition( cursorPos, false );
616 setCursor();
617 }
618 else
619 {
621 image = nullptr;
623
625
626 if( immediateMode )
627 {
628 m_frame->PopTool( aEvent );
629 break;
630 }
631 }
632 }
633 else if( evt->IsClick( BUT_RIGHT ) )
634 {
635 // Warp after context menu only if dragging...
636 if( !image )
638
640 }
641 else if( image && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
642 {
643 image->SetPosition( cursorPos );
645 m_view->AddToPreview( image, false ); // Add, but not give ownership
646 m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
648 }
649 else if( image && evt->IsAction( &ACTIONS::doDelete ) )
650 {
651 cleanup();
652 }
653 else
654 {
655 evt->SetPassEvent();
656 }
657
658 // Enable autopanning and cursor capture only when there is an image to be placed
659 getViewControls()->SetAutoPan( image != nullptr );
660 getViewControls()->CaptureCursor( image != nullptr );
661 }
662
663 getViewControls()->SetAutoPan( false );
664 getViewControls()->CaptureCursor( false );
666
667 return 0;
668}
669
670
672{
673 VECTOR2I cursorPos;
674 KICAD_T type = aEvent.Parameter<KICAD_T>();
677 SCH_ITEM* previewItem;
678 bool loggedInfoBarError = false;
679
681 return 0;
682
684
685 if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
686 {
688 SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
689
690 if( wire )
691 {
692 SEG seg( wire->GetStartPoint(), wire->GetEndPoint() );
693 VECTOR2I nearest = seg.NearestPoint( getViewControls()->GetCursorPosition() );
694 getViewControls()->SetCrossHairCursorPosition( nearest, false );
695 getViewControls()->WarpMouseCursor( getViewControls()->GetCursorPosition(), true );
696 }
697 }
698
699 switch( type )
700 {
701 case SCH_NO_CONNECT_T:
702 previewItem = new SCH_NO_CONNECT( cursorPos );
703 previewItem->SetParent( m_frame->GetScreen() );
704 break;
705
706 case SCH_JUNCTION_T:
707 previewItem = new SCH_JUNCTION( cursorPos );
708 previewItem->SetParent( m_frame->GetScreen() );
709 break;
710
712 previewItem = new SCH_BUS_WIRE_ENTRY( cursorPos );
713 previewItem->SetParent( m_frame->GetScreen() );
714 break;
715
716 case SCH_SHEET_PIN_T:
717 {
719 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() );
720
721 if( !sheet )
722 return 0;
723
724 SCH_HIERLABEL* label = importHierLabel( sheet );
725
726 if( !label )
727 {
729 m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
730 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
731 m_statusPopup->PopupFor( 2000 );
732 return 0;
733 }
734
735 previewItem = createSheetPin( sheet, label );
736 }
737 break;
738
739 default:
740 wxASSERT_MSG( false, "Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
741 return 0;
742 }
743
745
746 cursorPos = static_cast<wxPoint>( aEvent.HasPosition() ?
747 aEvent.Position() :
748 controls->GetMousePosition() );
749
750 m_frame->PushTool( aEvent );
751
752 auto setCursor =
753 [&]()
754 {
756 };
757
758 Activate();
759
760 // Must be done after Activate() so that it gets set into the correct context
761 getViewControls()->ShowCursor( true );
762
763 // Set initial cursor
764 setCursor();
765
767 m_view->AddToPreview( previewItem->Clone() );
768
769 // Prime the pump
770 if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T )
771 m_toolMgr->PrimeTool( aEvent.Position() );
772 else
774
775 // Main loop: keep receiving events
776 while( TOOL_EVENT* evt = Wait() )
777 {
778 setCursor();
779 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
780 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
781
782 cursorPos = evt->IsPrime() ? evt->Position() : controls->GetMousePosition();
783 cursorPos = grid.BestSnapAnchor( cursorPos, LAYER_CONNECTABLE, nullptr );
784 controls->ForceCursorPosition( true, cursorPos );
785
786 if( evt->IsCancelInteractive() )
787 {
788 m_frame->PopTool( aEvent );
789 break;
790 }
791 else if( evt->IsActivate() )
792 {
793 if( evt->IsMoveTool() )
794 {
795 // leave ourselves on the stack so we come back after the move
796 break;
797 }
798 else
799 {
800 m_frame->PopTool( aEvent );
801 break;
802 }
803 }
804 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
805 {
806 if( !m_frame->GetScreen()->GetItem( cursorPos, 0, type ) )
807 {
808 if( type == SCH_JUNCTION_T )
809 {
810 if( !m_frame->GetScreen()->IsExplicitJunctionAllowed( cursorPos ) )
811 {
812 m_frame->ShowInfoBarError( _( "Junction location contains no joinable "
813 "wires and/or pins." ) );
814 loggedInfoBarError = true;
815 continue;
816 }
817 else if( loggedInfoBarError )
818 {
820 }
821 }
822
823 SCH_ITEM* newItem = static_cast<SCH_ITEM*>( previewItem->Clone() );
824 const_cast<KIID&>( newItem->m_Uuid ) = KIID();
825 newItem->SetPosition( cursorPos );
826 newItem->SetFlags( IS_NEW );
827
829
830 if( type == SCH_JUNCTION_T )
832 else
834
835 m_frame->OnModify();
836 }
837
838 if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
839 {
840 m_frame->PopTool( aEvent );
841 break;
842 }
843 }
844 else if( evt->IsClick( BUT_RIGHT ) )
845 {
847 }
848 else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
849 {
850 previewItem->SetPosition( cursorPos );
852 m_view->AddToPreview( previewItem->Clone() );
853 m_frame->SetMsgPanel( previewItem );
854 }
855 else if( evt->Category() == TC_COMMAND )
856 {
857 if( ( type == SCH_BUS_WIRE_ENTRY_T ) && ( evt->IsAction( &EE_ACTIONS::rotateCW )
858 || evt->IsAction( &EE_ACTIONS::rotateCCW )
859 || evt->IsAction( &EE_ACTIONS::mirrorV )
860 || evt->IsAction( &EE_ACTIONS::mirrorH ) ) )
861 {
862 SCH_BUS_ENTRY_BASE* busItem = static_cast<SCH_BUS_ENTRY_BASE*>( previewItem );
863
864 // The bus entries only rotate in one direction
865 if( evt->IsAction( &EE_ACTIONS::rotateCW )
866 || evt->IsAction( &EE_ACTIONS::rotateCCW ) )
867 {
868 busItem->Rotate( busItem->GetPosition() );
869 }
870 else if( evt->IsAction( &EE_ACTIONS::mirrorV ) )
871 {
872 busItem->MirrorVertically( busItem->GetPosition().x );
873 }
874 else if( evt->IsAction( &EE_ACTIONS::mirrorH ) )
875 {
876 busItem->MirrorHorizontally( busItem->GetPosition().y );
877 }
878
880 m_view->AddToPreview( previewItem->Clone() );
881 }
882 else if( evt->IsAction( &EE_ACTIONS::properties ) )
883 {
884 switch( type )
885 {
887 {
888 std::deque<SCH_ITEM*> strokeItems;
889 strokeItems.push_back( previewItem );
890
891 DIALOG_WIRE_BUS_PROPERTIES dlg( m_frame, strokeItems );
892
893 if( dlg.ShowModal() == wxID_OK )
894 {
896 m_frame->OnModify();
897 }
898 }
899 break;
900
901 case SCH_JUNCTION_T:
902 {
903 std::deque<SCH_JUNCTION*> junctions;
904 junctions.push_back( static_cast<SCH_JUNCTION*>( previewItem ) );
905
906 DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
907
908 if( dlg.ShowModal() == wxID_OK )
909 {
911 m_frame->OnModify();
912 }
913 }
914 break;
915 default:
916 // Do nothing
917 break;
918 }
919
921 m_view->AddToPreview( previewItem->Clone() );
922 }
923 else
924 {
925 evt->SetPassEvent();
926 }
927 }
928 else
929 {
930 evt->SetPassEvent();
931 }
932 }
933
934 delete previewItem;
936
938 controls->ForceCursorPosition( false );
939
940 return 0;
941}
942
943
945{
946 SCHEMATIC* schematic = getModel<SCHEMATIC>();
947 SCHEMATIC_SETTINGS& settings = schematic->Settings();
948 SCH_TEXT* textItem = nullptr;
949 SCH_LABEL_BASE* labelItem = nullptr;
950
951 switch( aType )
952 {
953 case LAYER_NOTES:
954 textItem = new SCH_TEXT( aPosition );
955 break;
956
957 case LAYER_LOCLABEL:
958 labelItem = new SCH_LABEL( aPosition );
959 textItem = labelItem;
960 break;
961
963 labelItem = new SCH_DIRECTIVE_LABEL( aPosition );
964 labelItem->SetShape( m_lastNetClassFlagShape );
965 labelItem->GetFields().emplace_back( SCH_FIELD( {0,0}, 0, labelItem, wxT( "Netclass" ) ) );
966 labelItem->GetFields().back().SetItalic( true );
967 labelItem->GetFields().back().SetVisible( true );
968 textItem = labelItem;
969 break;
970
971 case LAYER_HIERLABEL:
972 labelItem = new SCH_HIERLABEL( aPosition );
973 labelItem->SetShape( m_lastGlobalLabelShape );
975 textItem = labelItem;
976 break;
977
978 case LAYER_GLOBLABEL:
979 labelItem = new SCH_GLOBALLABEL( aPosition );
980 labelItem->SetShape( m_lastGlobalLabelShape );
981 labelItem->GetFields()[0].SetVisible( settings.m_IntersheetRefsShow );
983 textItem = labelItem;
984 break;
985
986 default:
987 wxFAIL_MSG( "SCH_EDIT_FRAME::CreateNewText() unknown layer type" );
988 return nullptr;
989 }
990
991 textItem->SetParent( schematic );
992
993 if( aType != LAYER_NETCLASS_REFS )
994 {
995 textItem->SetBold( m_lastTextBold );
996 textItem->SetItalic( m_lastTextItalic );
997 }
998
1000 textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
1001 textItem->SetFlags( IS_NEW | IS_MOVING );
1002
1003 if( !labelItem )
1004 {
1005 DIALOG_TEXT_PROPERTIES dlg( m_frame, textItem );
1006
1007 // Must be quasi modal for syntax help
1008 if( dlg.ShowQuasiModal() != wxID_OK )
1009 {
1010 delete textItem;
1011 return nullptr;
1012 }
1013 }
1014 else
1015 {
1016 DIALOG_LABEL_PROPERTIES dlg( m_frame, static_cast<SCH_LABEL_BASE*>( textItem ) );
1017
1018 // Must be quasi modal for syntax help
1019 if( dlg.ShowQuasiModal() != wxID_OK )
1020 {
1021 delete labelItem;
1022 return nullptr;
1023 }
1024 }
1025
1026 wxString text = textItem->GetText();
1027
1028 if( textItem->Type() != SCH_DIRECTIVE_LABEL_T && NoPrintableChars( text ) )
1029 {
1030 delete textItem;
1031 return nullptr;
1032 }
1033
1034 if( aType != LAYER_NETCLASS_REFS )
1035 {
1036 m_lastTextBold = textItem->IsBold();
1037 m_lastTextItalic = textItem->IsItalic();
1038 }
1039
1041
1042 if( aType == LAYER_GLOBLABEL || aType == LAYER_HIERLABEL )
1043 {
1044 m_lastGlobalLabelShape = labelItem->GetShape();
1046 }
1047 else if( aType == LAYER_NETCLASS_REFS )
1048 {
1049 m_lastNetClassFlagShape = labelItem->GetShape();
1050 }
1051
1052 return textItem;
1053}
1054
1055
1057{
1058 if( !aSheet->GetScreen() )
1059 return nullptr;
1060
1061 for( EDA_ITEM* item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
1062 {
1063 SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
1064
1065 /* A global label has been found: check if there a corresponding sheet label. */
1066 if( !aSheet->HasPin( label->GetText() ) )
1067 return label;
1068 }
1069
1070 return nullptr;
1071}
1072
1073
1075{
1076 SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
1077 wxString text;
1078 SCH_SHEET_PIN* sheetPin;
1079
1080 if( aLabel )
1081 {
1082 text = aLabel->GetText();
1083 m_lastSheetPinType = aLabel->GetShape();
1084 }
1085
1086 sheetPin = new SCH_SHEET_PIN( aSheet, VECTOR2I( 0, 0 ), text );
1087 sheetPin->SetFlags( IS_NEW );
1088 sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
1089 sheetPin->SetShape( m_lastSheetPinType );
1090
1091 if( !aLabel )
1092 {
1093 DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
1094
1095 if( dlg.ShowModal() != wxID_OK || NoPrintableChars( sheetPin->GetText() ) )
1096 {
1097 delete sheetPin;
1098 return nullptr;
1099 }
1100 }
1101
1102 m_lastSheetPinType = sheetPin->GetShape();
1103
1104 sheetPin->SetPosition( (VECTOR2I) getViewControls()->GetCursorPosition() );
1105
1106 return sheetPin;
1107}
1108
1109
1111{
1112 SCH_ITEM* item = nullptr;
1115 bool ignorePrimePosition = false;
1116 COMMON_SETTINGS* common_settings = Pgm().GetCommonSettings();
1117
1118 if( m_inTwoClickPlace )
1119 return 0;
1120
1122
1123 bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText );
1124 bool isGlobalLabel = aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel );
1125 bool isHierLabel = aEvent.IsAction( &EE_ACTIONS::placeHierLabel );
1126 bool isClassLabel = aEvent.IsAction( &EE_ACTIONS::placeClassLabel );
1127 bool isNetLabel = aEvent.IsAction( &EE_ACTIONS::placeLabel );
1128 bool isSheetPin = aEvent.IsAction( &EE_ACTIONS::importSheetPin );
1129 int snapLayer = isText ? LAYER_GRAPHICS : LAYER_CONNECTABLE;
1130
1132
1133 m_frame->PushTool( aEvent );
1134 auto setCursor =
1135 [&]()
1136 {
1137 if( item )
1139 else if( isText )
1141 else if( isGlobalLabel )
1143 else if( isNetLabel )
1145 else if( isClassLabel )
1146 m_frame->GetCanvas()->SetCurrentCursor( KICURSOR::LABEL_NET ); // JEY TODO: netclass directive cursor
1147 else if( isHierLabel )
1149 else
1151 };
1152
1153 auto updatePreview =
1154 [&]()
1155 {
1157 m_view->AddToPreview( item->Clone() );
1158 item->RunOnChildren( [&]( SCH_ITEM* aChild )
1159 {
1160 m_view->AddToPreview( aChild->Clone() );
1161 } );
1162 m_frame->SetMsgPanel( item );
1163 };
1164
1165 auto cleanup =
1166 [&]()
1167 {
1170 delete item;
1171 item = nullptr;
1172 };
1173
1174 Activate();
1175
1176 // Must be done after Activate() so that it gets set into the correct context
1177 controls->ShowCursor( true );
1178
1179 // Set initial cursor
1180 setCursor();
1181
1182 if( aEvent.HasPosition() )
1183 {
1184 m_toolMgr->PrimeTool( aEvent.Position() );
1185 }
1186 else if( common_settings->m_Input.immediate_actions && !aEvent.IsReactivate()
1187 && ( isText || isGlobalLabel || isHierLabel || isClassLabel || isNetLabel ) )
1188 {
1189 m_toolMgr->PrimeTool( { 0, 0 } );
1190 ignorePrimePosition = true;
1191 }
1192
1193 // Main loop: keep receiving events
1194 while( TOOL_EVENT* evt = Wait() )
1195 {
1196 setCursor();
1197 grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1198 grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
1199
1200 VECTOR2I cursorPos = controls->GetMousePosition();
1201 cursorPos = grid.BestSnapAnchor( cursorPos, snapLayer, item );
1202 controls->ForceCursorPosition( true, cursorPos );
1203
1204 // The tool hotkey is interpreted as a click when drawing
1205 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
1206 && evt->Matches( aEvent );
1207
1208 if( evt->IsCancelInteractive() )
1209 {
1211
1212 if( item )
1213 {
1214 cleanup();
1215 }
1216 else
1217 {
1218 m_frame->PopTool( aEvent );
1219 break;
1220 }
1221 }
1222 else if( evt->IsActivate() && !isSyntheticClick )
1223 {
1224 if( item && evt->IsMoveTool() )
1225 {
1226 // we're already moving our own item; ignore the move tool
1227 evt->SetPassEvent( false );
1228 continue;
1229 }
1230
1231 if( item )
1232 {
1233 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel item creation." ) );
1234 evt->SetPassEvent( false );
1235 continue;
1236 }
1237
1238 if( evt->IsPointEditor() )
1239 {
1240 // don't exit (the point editor runs in the background)
1241 }
1242 else if( evt->IsMoveTool() )
1243 {
1244 break;
1245 }
1246 else
1247 {
1248 m_frame->PopTool( aEvent );
1249 break;
1250 }
1251 }
1252 else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) || isSyntheticClick )
1253 {
1254 // First click creates...
1255 if( !item )
1256 {
1258
1259 if( isText )
1260 {
1261 item = createNewText( cursorPos, LAYER_NOTES );
1262 }
1263 else if( isHierLabel )
1264 {
1265 item = createNewText( cursorPos, LAYER_HIERLABEL );
1266 }
1267 else if( isNetLabel || isGlobalLabel )
1268 {
1269 wxString netName;
1270
1271 for( SCH_ITEM* overlapItem :
1272 m_frame->GetScreen()->Items().Overlapping( cursorPos ) )
1273 {
1274 if( overlapItem->GetEditFlags() & STRUCT_DELETED )
1275 continue;
1276
1277 if( overlapItem->Type() == SCH_LINE_T )
1278 {
1279 SCH_LINE* line = static_cast<SCH_LINE*>( overlapItem );
1280 if( line->IsWire() )
1281 {
1282 netName = line->GetNetname(m_frame->GetCurrentSheet());
1283 break;
1284 }
1285 }
1286 }
1287
1288 if( netName.IsEmpty() )
1289 {
1290 // no connected net label found -> open up the new label dialog
1291 if( isGlobalLabel )
1292 item = createNewText( cursorPos, LAYER_GLOBLABEL );
1293 else
1294 item = createNewText( cursorPos, LAYER_LOCLABEL );
1295 }
1296 else
1297 {
1298 // connected net label found -> create the label immediately
1299 SCHEMATIC* schematic = getModel<SCHEMATIC>();
1300 SCHEMATIC_SETTINGS& sch_settings = schematic->Settings();
1301 SCH_LABEL_BASE* labelItem = nullptr;
1302
1303 if( isGlobalLabel )
1304 {
1305 labelItem = new SCH_GLOBALLABEL( cursorPos );
1306 labelItem->SetShape( m_lastGlobalLabelShape );
1307 // make intersheets reference visible based on settings
1308 labelItem->GetFields()[0].SetVisible( sch_settings.m_IntersheetRefsShow );
1309 }
1310 else
1311 {
1312 labelItem = new SCH_LABEL( cursorPos );
1313 }
1314
1315 labelItem->SetParent( getModel<SCHEMATIC>() );
1316 labelItem->SetBold( m_lastTextBold );
1317 labelItem->SetItalic( m_lastTextItalic );
1319 labelItem->SetTextSize( wxSize( sch_settings.m_DefaultTextSize,
1320 sch_settings.m_DefaultTextSize ) );
1321 labelItem->SetFlags( IS_NEW | IS_MOVING );
1322 labelItem->SetText( netName );
1323 item = labelItem;
1324 }
1325 }
1326 else if( isClassLabel )
1327 {
1328 item = createNewText( cursorPos, LAYER_NETCLASS_REFS );
1329 }
1330 else if( isSheetPin )
1331 {
1332 EDA_ITEM* i;
1333 SCH_HIERLABEL* label = nullptr;
1334 SCH_SHEET* sheet = nullptr;
1335
1336 if( m_selectionTool->SelectPoint( cursorPos, { SCH_SHEET_T }, &i ) )
1337 sheet = dynamic_cast<SCH_SHEET*>( i );
1338
1340
1341 if( !sheet )
1342 {
1343 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1344 m_statusPopup->SetText( _( "Click over a sheet." ) );
1345 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1346 m_statusPopup->PopupFor( 2000 );
1347 item = nullptr;
1348 }
1349 else
1350 {
1351 label = importHierLabel( sheet );
1352
1353 if( !label )
1354 {
1355 m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1356 m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
1357 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1358 m_statusPopup->PopupFor( 2000 );
1359 item = nullptr;
1360 }
1361 else
1362 {
1363 item = createSheetPin( sheet, label );
1364
1365 if( item->Type() == SCH_SHEET_PIN_T )
1366 {
1367 item->ClearSelected();
1368 }
1369 }
1370 }
1371 }
1372
1373 // If we started with a hotkey which has a position then warp back to that.
1374 // Otherwise update to the current mouse position pinned inside the autoscroll
1375 // boundaries.
1376 if( evt->IsPrime() && !ignorePrimePosition )
1377 {
1378 cursorPos = grid.Align( evt->Position() );
1379 getViewControls()->WarpMouseCursor( cursorPos, true );
1380 }
1381 else
1382 {
1384 cursorPos = getViewControls()->GetMousePosition();
1385 }
1386
1387 if( item )
1388 {
1389 item->SetPosition( cursorPos );
1390
1391 item->SetFlags( IS_NEW | IS_MOVING );
1392 item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1393 updatePreview();
1394
1395 if( item->Type() != SCH_SHEET_PIN_T )
1397
1399
1400 // update the cursor so it looks correct before another event
1401 setCursor();
1402 }
1403
1404 controls->SetCursorPosition( cursorPos, false );
1405 }
1406 else // ... and second click places:
1407 {
1408 item->ClearFlags( IS_MOVING );
1410 item = nullptr;
1411
1413 }
1414 }
1415 else if( evt->IsClick( BUT_RIGHT ) )
1416 {
1417 // Warp after context menu only if dragging...
1418 if( !item )
1420
1422 }
1423 else if( item && evt->IsSelectionEvent() )
1424 {
1425 // This happens if our text was replaced out from under us by ConvertTextType()
1427
1428 if( selection.GetSize() == 1 )
1429 {
1430 item = (SCH_ITEM*) selection.Front();
1431 updatePreview();
1432 }
1433 else
1434 {
1435 item = nullptr;
1436 }
1437 }
1438 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1439 {
1440 item->SetPosition( cursorPos );
1441 item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1442 updatePreview();
1443 }
1444 else if( item && evt->IsAction( &ACTIONS::doDelete ) )
1445 {
1446 cleanup();
1447 }
1448 else
1449 {
1450 evt->SetPassEvent();
1451 }
1452
1453 // Enable autopanning and cursor capture only when there is an item to be placed
1454 controls->SetAutoPan( item != nullptr );
1455 controls->CaptureCursor( item != nullptr );
1456 }
1457
1458 controls->SetAutoPan( false );
1459 controls->CaptureCursor( false );
1460 controls->ForceCursorPosition( false );
1462 return 0;
1463}
1464
1465
1467{
1468 SCHEMATIC* schematic = getModel<SCHEMATIC>();
1469 SCHEMATIC_SETTINGS& sch_settings = schematic->Settings();
1470 SCH_SHAPE* item = nullptr;
1471 bool isTextBox = aEvent.IsAction( &EE_ACTIONS::drawTextBox );
1472 SHAPE_T type = aEvent.Parameter<SHAPE_T>();
1473
1474 if( m_inDrawShape )
1475 return 0;
1476
1478
1479 // We might be running as the same shape in another co-routine. Make sure that one
1480 // gets whacked.
1482
1484
1485 m_frame->PushTool( aEvent );
1486
1487 auto setCursor =
1488 [&]()
1489 {
1491 };
1492
1493 auto cleanup =
1494 [&] ()
1495 {
1498 delete item;
1499 item = nullptr;
1500 };
1501
1502 Activate();
1503
1504 // Must be done after Activate() so that it gets set into the correct context
1505 getViewControls()->ShowCursor( true );
1506
1507 // Set initial cursor
1508 setCursor();
1509
1510 if( aEvent.HasPosition() )
1511 m_toolMgr->PrimeTool( aEvent.Position() );
1512
1513 // Main loop: keep receiving events
1514 while( TOOL_EVENT* evt = Wait() )
1515 {
1516 setCursor();
1517
1518 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
1519
1520 // The tool hotkey is interpreted as a click when drawing
1521 bool isSyntheticClick = item && evt->IsActivate() && evt->HasPosition()
1522 && evt->Matches( aEvent );
1523
1524 if( evt->IsCancelInteractive() )
1525 {
1526 if( item )
1527 {
1528 cleanup();
1529 }
1530 else
1531 {
1532 m_frame->PopTool( aEvent );
1533 break;
1534 }
1535 }
1536 else if( evt->IsActivate() && !isSyntheticClick )
1537 {
1538 if( item && evt->IsMoveTool() )
1539 {
1540 // we're already drawing our own item; ignore the move tool
1541 evt->SetPassEvent( false );
1542 continue;
1543 }
1544
1545 if( item )
1546 cleanup();
1547
1548 if( evt->IsPointEditor() )
1549 {
1550 // don't exit (the point editor runs in the background)
1551 }
1552 else if( evt->IsMoveTool() )
1553 {
1554 // leave ourselves on the stack so we come back after the move
1555 break;
1556 }
1557 else
1558 {
1559 m_frame->PopTool( aEvent );
1560 break;
1561 }
1562 }
1563 else if( evt->IsClick( BUT_LEFT ) && !item )
1564 {
1566
1567 if( isTextBox )
1568 {
1569 SCH_TEXTBOX* textbox = new SCH_TEXTBOX( 0, m_lastTextboxFillStyle );
1570
1571 textbox->SetBold( m_lastTextBold );
1572 textbox->SetItalic( m_lastTextItalic );
1573 textbox->SetTextSize( wxSize( sch_settings.m_DefaultTextSize,
1574 sch_settings.m_DefaultTextSize ) );
1575 textbox->SetTextAngle( m_lastTextAngle );
1576 textbox->SetHorizJustify( m_lastTextJust );
1577 textbox->SetStroke( m_lastTextboxStroke );
1579
1580 item = textbox;
1581 }
1582 else
1583 {
1584 item = new SCH_SHAPE( type, 0, m_lastFillStyle );
1585
1586 item->SetStroke( m_lastStroke );
1588 }
1589
1590 item->SetFlags( IS_NEW );
1591 item->BeginEdit( cursorPos );
1592
1594 m_view->AddToPreview( item->Clone() );
1595 }
1596 else if( item && ( evt->IsClick( BUT_LEFT )
1597 || evt->IsDblClick( BUT_LEFT )
1598 || isSyntheticClick
1599 || evt->IsAction( &EE_ACTIONS::finishDrawing ) ) )
1600 {
1601 if( evt->IsDblClick( BUT_LEFT )
1602 || evt->IsAction( &EE_ACTIONS::finishDrawing )
1603 || !item->ContinueEdit( cursorPos ) )
1604 {
1605 item->EndEdit();
1606 item->ClearEditFlags();
1607 item->SetFlags( IS_NEW );
1608
1609 if( isTextBox )
1610 {
1611 SCH_TEXTBOX* textbox = static_cast<SCH_TEXTBOX*>( item );
1612 DIALOG_TEXT_PROPERTIES dlg( m_frame, textbox );
1613
1614 // This is modal not quasi to protect against place symbol calls starting
1615 // TwoClickPlace wait routines in the middle
1616 if( dlg.ShowModal() != wxID_OK )
1617 {
1618 cleanup();
1619 continue;
1620 }
1621
1622 m_lastTextBold = textbox->IsBold();
1623 m_lastTextItalic = textbox->IsItalic();
1624 m_lastTextAngle = textbox->GetTextAngle();
1625 m_lastTextJust = textbox->GetHorizJustify();
1626 m_lastTextboxStroke = textbox->GetStroke();
1629 }
1630 else
1631 {
1632 m_lastStroke = item->GetStroke();
1633 m_lastFillStyle = item->GetFillMode();
1634 m_lastFillColor = item->GetFillColor();
1635 }
1636
1639 item = nullptr;
1640
1643 }
1644 }
1645 else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1646 {
1647 item->CalcEdit( cursorPos );
1649 m_view->AddToPreview( item->Clone() );
1650 m_frame->SetMsgPanel( item );
1651 }
1652 else if( evt->IsDblClick( BUT_LEFT ) && !item )
1653 {
1655 }
1656 else if( evt->IsClick( BUT_RIGHT ) )
1657 {
1658 // Warp after context menu only if dragging...
1659 if( !item )
1661
1663 }
1664 else
1665 {
1666 evt->SetPassEvent();
1667 }
1668
1669 // Enable autopanning and cursor capture only when there is a shape being drawn
1670 getViewControls()->SetAutoPan( item != nullptr );
1671 getViewControls()->CaptureCursor( item != nullptr );
1672 }
1673
1674 getViewControls()->SetAutoPan( false );
1675 getViewControls()->CaptureCursor( false );
1677 return 0;
1678}
1679
1680
1682{
1683 SCH_SHEET* sheet = nullptr;
1684
1685 if( m_inDrawSheet )
1686 return 0;
1687
1689
1691
1692 m_frame->PushTool( aEvent );
1693
1694 auto setCursor =
1695 [&]()
1696 {
1698 };
1699
1700 auto cleanup =
1701 [&] ()
1702 {
1705 delete sheet;
1706 sheet = nullptr;
1707 };
1708
1709 Activate();
1710
1711 // Must be done after Activate() so that it gets set into the correct context
1712 getViewControls()->ShowCursor( true );
1713
1714 // Set initial cursor
1715 setCursor();
1716
1717 if( aEvent.HasPosition() )
1718 m_toolMgr->PrimeTool( aEvent.Position() );
1719
1720 // Main loop: keep receiving events
1721 while( TOOL_EVENT* evt = Wait() )
1722 {
1723 setCursor();
1724
1725 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->DisableGridSnapping() );
1726
1727 // The tool hotkey is interpreted as a click when drawing
1728 bool isSyntheticClick = sheet && evt->IsActivate() && evt->HasPosition()
1729 && evt->Matches( aEvent );
1730
1731 if( evt->IsCancelInteractive() )
1732 {
1734
1735 if( sheet )
1736 {
1737 cleanup();
1738 }
1739 else
1740 {
1741 m_frame->PopTool( aEvent );
1742 break;
1743 }
1744 }
1745 else if( evt->IsActivate() && !isSyntheticClick )
1746 {
1747 if( sheet && evt->IsMoveTool() )
1748 {
1749 // we're already drawing our own item; ignore the move tool
1750 evt->SetPassEvent( false );
1751 continue;
1752 }
1753
1754 if( sheet )
1755 {
1756 m_frame->ShowInfoBarMsg( _( "Press <ESC> to cancel sheet creation." ) );
1757 evt->SetPassEvent( false );
1758 continue;
1759 }
1760
1761 if( evt->IsPointEditor() )
1762 {
1763 // don't exit (the point editor runs in the background)
1764 }
1765 else if( evt->IsMoveTool() )
1766 {
1767 // leave ourselves on the stack so we come back after the move
1768 break;
1769 }
1770 else
1771 {
1772 m_frame->PopTool( aEvent );
1773 break;
1774 }
1775 }
1776 else if( !sheet && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) )
1777 {
1780
1781 if( selection.Size() == 1
1782 && selection.Front()->Type() == SCH_SHEET_T
1783 && selection.Front()->GetBoundingBox().Contains( cursorPos ) )
1784 {
1785 if( evt->IsClick( BUT_LEFT ) )
1786 {
1787 // sheet already selected
1788 continue;
1789 }
1790 else if( evt->IsDblClick( BUT_LEFT ) )
1791 {
1793 break;
1794 }
1795 }
1796
1798
1799 sheet = new SCH_SHEET( m_frame->GetCurrentSheet().Last(), cursorPos );
1800 sheet->SetFlags( IS_NEW | IS_RESIZING );
1801 sheet->SetScreen( nullptr );
1805 sheet->GetFields()[ SHEETNAME ].SetText( "Untitled Sheet" );
1806 sheet->GetFields()[ SHEETFILENAME ].SetText( "untitled." + KiCadSchematicFileExtension );
1807 sizeSheet( sheet, cursorPos );
1808
1810 m_view->AddToPreview( sheet->Clone() );
1811 }
1812 else if( sheet && ( evt->IsClick( BUT_LEFT )
1813 || evt->IsDblClick( BUT_LEFT )
1814 || isSyntheticClick
1815 || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
1816 {
1818 getViewControls()->SetAutoPan( false );
1819 getViewControls()->CaptureCursor( false );
1820
1821 // Find the list of paths in the hierarchy that refer to the destination sheet where
1822 // the new sheet will be drawn
1823 SCH_SCREEN* currentScreen = m_frame->GetCurrentSheet().LastScreen();
1824 SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1825 SCH_SHEET_LIST instances = hierarchy.FindAllSheetsForScreen( currentScreen );
1826 instances.SortByPageNumbers();
1827
1828 int pageNum = static_cast<int>( hierarchy.size() ) + 1;
1829
1830 // Set a page number for all the instances of the new sheet in the hierarchy
1831 for( SCH_SHEET_PATH& instance : instances )
1832 {
1833 SCH_SHEET_PATH sheetPath = instance;
1834 sheetPath.push_back( sheet );
1835 instance.SetPageNumber( wxString::Format( "%d", pageNum++ ) );
1836 }
1837
1838 if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
1839 &m_frame->GetCurrentSheet(), nullptr ) )
1840 {
1841 sheet->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1842
1845 m_selectionTool->AddItemToSel( sheet );
1846 }
1847 else
1848 {
1849 delete sheet;
1850 }
1851
1852 sheet = nullptr;
1853 }
1854 else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1855 {
1856 sizeSheet( sheet, cursorPos );
1858 m_view->AddToPreview( sheet->Clone() );
1859 m_frame->SetMsgPanel( sheet );
1860 }
1861 else if( evt->IsClick( BUT_RIGHT ) )
1862 {
1863 // Warp after context menu only if dragging...
1864 if( !sheet )
1866
1868 }
1869 else
1870 {
1871 evt->SetPassEvent();
1872 }
1873
1874 // Enable autopanning and cursor capture only when there is a sheet to be placed
1875 getViewControls()->SetAutoPan( sheet != nullptr );
1876 getViewControls()->CaptureCursor( sheet != nullptr );
1877 }
1878
1879 getViewControls()->SetAutoPan( false );
1880 getViewControls()->CaptureCursor( false );
1882
1883 return 0;
1884}
1885
1886
1888{
1889 VECTOR2I pos = aSheet->GetPosition();
1890 VECTOR2I size = aPos - pos;
1891
1892 size.x = std::max( size.x, schIUScale.MilsToIU( MIN_SHEET_WIDTH ) );
1893 size.y = std::max( size.y, schIUScale.MilsToIU( MIN_SHEET_HEIGHT ) );
1894
1896 aSheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
1897}
1898
1899
1901{
1920}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static TOOL_ACTION activatePointEditor
Definition: actions.h:172
static TOOL_ACTION doDelete
Definition: actions.h:73
static TOOL_ACTION refreshPreview
Definition: actions.h:109
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
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.
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...
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
WX_INFOBAR * GetInfoBar()
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
VECTOR2I GetNearestGridPosition(const VECTOR2I &aPosition) const
Return the nearest aGridSize location to aPosition.
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
virtual void SetPosition(const VECTOR2I &aPos)
Definition: eda_item.h:252
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
const KIID m_Uuid
Definition: eda_item.h:494
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void ClearSelected()
Definition: eda_item.h:121
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:143
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:384
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:160
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:123
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:142
void SetBold(bool aBold)
Definition: eda_text.cpp:209
bool IsBold() const
Definition: eda_text.h:126
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
void SetItalic(bool aItalic)
Definition: eda_text.cpp:201
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
PANEL_ANNOTATE m_AnnotatePanel
PANEL_SYM_CHOOSER m_SymChooserPanel
AUTOPLACE_FIELDS m_AutoplaceFields
static TOOL_ACTION mirrorV
Definition: ee_actions.h:128
static TOOL_ACTION properties
Definition: ee_actions.h:131
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:81
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:90
static TOOL_ACTION drawCircle
Definition: ee_actions.h:99
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:127
static TOOL_ACTION placePower
Definition: ee_actions.h:82
static TOOL_ACTION mirrorH
Definition: ee_actions.h:129
static TOOL_ACTION rotateCW
Definition: ee_actions.h:126
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:95
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:202
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:91
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:92
static TOOL_ACTION trimOverlappingWires
Definition: ee_actions.h:79
static TOOL_ACTION drawTextBox
Definition: ee_actions.h:97
static TOOL_ACTION drawRectangle
Definition: ee_actions.h:98
static TOOL_ACTION placeImage
Definition: ee_actions.h:102
static TOOL_ACTION enterSheet
Definition: ee_actions.h:201
static TOOL_ACTION finishSheet
Definition: ee_actions.h:109
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:96
static TOOL_ACTION importSingleSheetPin
Definition: ee_actions.h:94
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:78
static TOOL_ACTION finishDrawing
Definition: ee_actions.h:117
static TOOL_ACTION drawArc
Definition: ee_actions.h:100
static TOOL_ACTION drawSheet
Definition: ee_actions.h:93
static TOOL_ACTION placeLabel
Definition: ee_actions.h:89
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:88
static TOOL_ACTION placeJunction
Definition: ee_actions.h:87
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:86
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition: sch_rtree.h:243
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
bool SelectPoint(const VECTOR2I &aWhere, const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
Perform a click-type selection at a point (usually the cursor position).
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
EE_SELECTION & GetSelection()
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:50
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:184
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:66
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:213
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 (.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
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
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:1575
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1619
void ClearPreview()
Definition: view.cpp:1597
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1381
Definition: kiid.h:48
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:165
Define a library symbol object.
Definition: lib_symbol.h:98
These settings were stored in SCH_BASE_FRAME previously.
Holds all the data relating to one schematic.
Definition: schematic.h:61
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:86
SCH_SHEET & Root() const
Definition: schematic.h:91
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PICKED_SYMBOL PickSymbolFromLibTree(const SYMBOL_LIBRARY_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Call the library viewer to select symbol to import into schematic.
Definition: picksymbol.cpp:93
EESCHEMA_SETTINGS * eeconfig() const
LIB_SYMBOL * GetLibSymbol(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
VECTOR2I GetPosition() const override
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Class for a wire to bus entry.
STROKE_PARAMS m_lastTextboxStroke
int DrawSheet(const TOOL_EVENT &aEvent)
STROKE_PARAMS m_lastStroke
SCH_TEXT * createNewText(const VECTOR2I &aPosition, int aType)
Get the next queued text item.
GR_TEXT_H_ALIGN_T m_lastTextJust
std::vector< PICKED_SYMBOL > m_powerHistoryList
bool m_lastAutoLabelRotateOnPlacement
Re-entrancy guards.
int SingleClickPlace(const TOOL_EVENT &aEvent)
void sizeSheet(SCH_SHEET *aSheet, const VECTOR2I &aPos)
Set up handlers for various events.
LABEL_FLAG_SHAPE m_lastGlobalLabelShape
LABEL_FLAG_SHAPE m_lastNetClassFlagShape
COLOR4D m_lastTextboxFillColor
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
int TwoClickPlace(const TOOL_EVENT &aEvent)
LABEL_FLAG_SHAPE m_lastSheetPinType
int DrawShape(const TOOL_EVENT &aEvent)
TEXT_SPIN_STYLE m_lastTextOrientation
bool Init() override
Init() is called once upon a registration of the tool.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int PlaceSymbol(const TOOL_EVENT &aEvent)
int PlaceImage(const TOOL_EVENT &aEvent)
std::vector< PICKED_SYMBOL > m_symbolHistoryList
SCH_HIERLABEL * importHierLabel(SCH_SHEET *aSheet)
SCH_SHEET_PIN * createSheetPin(SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
Schematic editor (Eeschema) main window.
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void SelectUnit(SCH_SYMBOL *aSymbol, int aUnit)
Definition: picksymbol.cpp:239
bool EditSheetProperties(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:524
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:50
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:442
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:93
bool AutoRotateOnPlacement() const
autoRotateOnPlacement
Definition: sch_label.cpp:1014
void SetAutoRotateOnPlacement(bool autoRotate=true)
setAutoRotateOnPlacement
Definition: sch_label.cpp:1019
void SetShape(LABEL_FLAG_SHAPE aShape) override
Definition: sch_label.h:74
LABEL_FLAG_SHAPE GetShape() const override
Definition: sch_label.h:73
std::vector< SCH_FIELD > & GetFields()
Definition: sch_label.h:90
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
bool IsWire() const
Return true if the line is a wire.
Definition: sch_line.cpp:925
VECTOR2I GetEndPoint() const
Definition: sch_line.h:143
VECTOR2I GetStartPoint() const
Definition: sch_line.h:138
wxString GetNetname(const SCH_SHEET_PATH &aSheet)
This function travel though all the connected wire segments to look for connected labels.
Definition: sch_line.cpp:90
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void SortByReferenceOnly()
Sort the list of references by reference.
void ReannotateByOptions(ANNOTATE_ORDER_T aSortOption, ANNOTATE_ALGO_T aAlgoOption, int aStartNumber, const SCH_REFERENCE_LIST &aAdditionalRefs, bool aStartAtCurrent, SCH_SHEET_LIST *aHierarchy)
Forces reannotation of the provided references.
size_t GetCount() const
void AddItem(const SCH_REFERENCE &aItem)
void UpdateAnnotation()
Update the symbol references for the schematic project (or the current sheet).
A helper to define a symbol's reference designator in a schematic.
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:261
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
SCH_ITEM * GetItem(const VECTOR2I &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:337
bool IsExplicitJunctionAllowed(const VECTOR2I &aPosition) const
Indicates that a juction dot may be placed at the given location.
Definition: sch_screen.cpp:666
void CalcEdit(const VECTOR2I &aPosition)
Definition: sch_shape.h:84
bool ContinueEdit(const VECTOR2I &aPosition)
Definition: sch_shape.h:83
void BeginEdit(const VECTOR2I &aStartPoint)
Definition: sch_shape.h:82
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_shape.cpp:46
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:61
void EndEdit()
Definition: sch_shape.h:85
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:64
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
void SetPosition(const VECTOR2I &aPosition) override
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:113
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:156
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_sheet.cpp:916
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:91
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:116
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:104
VECTOR2I GetPosition() const override
Definition: sch_sheet.h:366
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:381
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:899
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:162
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:590
void SetBorderWidth(int aWidth)
Definition: sch_sheet.h:110
Schematic symbol object.
Definition: sch_symbol.h:80
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:419
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_symbol.h:698
int GetUnit() const
Definition: sch_symbol.h:227
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:380
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:732
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:191
TEXT_SPIN_STYLE GetTextSpinStyle() const
Definition: sch_text.h:148
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:188
Definition: seg.h:42
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
Definition: seg.cpp:261
int AddItemToSel(const TOOL_EVENT &aEvent)
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:97
EDA_ITEM * Front() const
Definition: selection.h:206
int Size() const
Returns the number of selected parts.
Definition: selection.h:113
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:83
Helper object to filter a list of libraries.
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:214
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:156
bool HasPosition() const
Definition: tool_event.h:243
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:266
bool IsReactivate() const
Definition: tool_event.h:255
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:88
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 PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
void DeactivateTool()
Deactivate the currently active tool.
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...
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:424
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: infobar.cpp:175
This file is part of the common library.
#define _(s)
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
#define IS_NEW
New item, just created.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.
#define IS_RESIZING
Item being resized.
SHAPE_T
Definition: eda_shape.h:41
FILL_T
Definition: eda_shape.h:54
@ LAYER_CONNECTABLE
@ LAYER_GRAPHICS
@ ID_POPUP_SCH_SELECT_UNIT_CMP
Definition: eeschema_id.h:94
@ ID_POPUP_SCH_SELECT_UNIT_SYM_MAX
Definition: eeschema_id.h:98
const std::string KiCadSchematicFileExtension
@ LAYER_HIERLABEL
Definition: layer_ids.h:349
@ LAYER_GLOBLABEL
Definition: layer_ids.h:348
@ LAYER_NOTES
Definition: layer_ids.h:358
@ LAYER_LOCLABEL
Definition: layer_ids.h:347
@ LAYER_NETCLASS_REFS
Definition: layer_ids.h:356
see class PGM_BASE
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
ANNOTATE_ORDER_T
Schematic annotation order options.
@ UNSORTED
Annotate by position of symbol in the schematic sheet object list.
ANNOTATE_ALGO_T
Schematic annotation type options.
@ INCREMENTAL_BY_REF
Annotate incrementally using the first free reference number.
@ SHEETNAME
Definition: sch_sheet.h:43
@ SHEETFILENAME
Definition: sch_sheet.h:44
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:38
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:37
LABEL_FLAG_SHAPE
Definition: sch_text.h:96
@ F_ROUND
Definition: sch_text.h:105
@ L_INPUT
Definition: sch_text.h:97
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
bool NoPrintableChars(const wxString &aString)
Return true if the string is empty or contains only whitespace.
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94
LIB_ID LibId
Definition: sch_screen.h:80
@ GR_TEXT_H_ALIGN_LEFT
@ TA_CHOICE_MENU_CHOICE
Definition: tool_event.h:93
@ TC_COMMAND
Definition: tool_event.h:52
@ MD_SHIFT
Definition: tool_event.h:138
@ BUT_LEFT
Definition: tool_event.h:127
@ BUT_RIGHT
Definition: tool_event.h:128
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LINE_T
Definition: typeinfo.h:146
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:143
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:154
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:144
@ SCH_JUNCTION_T
Definition: typeinfo.h:142
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618
Definition of file extensions used in Kicad.