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-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include "sch_drawing_tools.h"
26 #include "ee_selection_tool.h"
27 #include "ee_point_editor.h"
28 #include <ee_actions.h>
29 #include <sch_edit_frame.h>
30 #include <project.h>
31 #include <id.h>
32 #include <eeschema_id.h>
33 #include <confirm.h>
34 #include <view/view_controls.h>
35 #include <view/view.h>
36 #include <sch_component.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_sheet.h>
43 #include <sch_bitmap.h>
44 #include <schematic.h>
45 #include <class_library.h>
46 #include <eeschema_settings.h>
51 
53  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
54  m_lastSheetPinType( PINSHEETLABEL_SHAPE::PS_INPUT ),
55  m_lastGlobalLabelShape( PINSHEETLABEL_SHAPE::PS_INPUT ),
56  m_lastTextOrientation( LABEL_SPIN_STYLE::LEFT ),
57  m_lastTextBold( false ),
58  m_lastTextItalic( false )
59 {
60 }
61 
62 
64 {
66 
67  auto belowRootSheetCondition =
68  [&]( const SELECTION& aSel )
69  {
70  return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
71  };
72 
73  CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
74  ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
75 
76  return true;
77 }
78 
79 
81 {
82  SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
83  SCHLIB_FILTER filter;
84  std::vector<PICKED_SYMBOL>* historyList = nullptr;
85 
86  if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
87  {
88  historyList = &m_symbolHistoryList;
89  }
90  else if (aEvent.IsAction( &EE_ACTIONS::placePower ) )
91  {
92  historyList = &m_powerHistoryList;
93  filter.FilterPowerParts( true );
94  }
95  else
96  {
97  wxFAIL_MSG( "PlaceCompontent(): unexpected request" );
98  }
99 
100  getViewControls()->ShowCursor( true );
101 
102  // If a component was passed in get it ready for placement.
103  if( component )
104  {
105  component->SetFlags( IS_NEW | IS_MOVED );
106 
108  m_selectionTool->AddItemToSel( component );
109  }
110 
111  std::string tool = aEvent.GetCommandStr().get();
112  m_frame->PushTool( tool );
113  Activate();
114 
115  // Prime the pump
116  if( component )
117  {
118  getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
120  }
121  else if( aEvent.HasPosition() )
122  {
124  }
125 
126  auto setCursor =
127  [&]()
128  {
131  };
132 
133  // Set initial cursor
134  setCursor();
135 
136  // Main loop: keep receiving events
137  while( TOOL_EVENT* evt = Wait() )
138  {
139  setCursor();
140  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
141 
142  auto cleanup =
143  [&] ()
144  {
146  m_view->ClearPreview();
147  delete component;
148  component = nullptr;
149  };
150 
151  if( evt->IsCancelInteractive() )
152  {
153  if( component )
154  {
155  cleanup();
156  }
157  else
158  {
159  m_frame->PopTool( tool );
160  break;
161  }
162  }
163  else if( evt->IsActivate() )
164  {
165  if( component )
166  cleanup();
167 
168  if( evt->IsMoveTool() )
169  {
170  // leave ourselves on the stack so we come back after the move
171  break;
172  }
173  else
174  {
175  m_frame->PopTool( tool );
176  break;
177  }
178  }
179  else if( evt->IsClick( BUT_LEFT ) )
180  {
181  if( !component )
182  {
184 
185  // Pick the footprint to be placed
186  bool footprintPreviews = m_frame->eeconfig()->m_Appearance.footprint_preview;
187  PICKED_SYMBOL sel = m_frame->PickSymbolFromLibTree( &filter, *historyList, true,
188  1, 1, footprintPreviews );
189 
190  // Restore cursor after dialog
191  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
192 
193  LIB_PART* part = sel.LibId.IsValid() ? m_frame->GetLibPart( sel.LibId ) : nullptr;
194 
195  if( !part )
196  continue;
197 
198  component = new SCH_COMPONENT( *part, &m_frame->GetCurrentSheet(), sel,
199  (wxPoint) cursorPos );
200  component->SetParent( m_frame->GetCurrentSheet().LastScreen() );
201  component->SetFlags( IS_NEW | IS_MOVED );
202 
204  component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
205 
206  m_frame->SaveCopyForRepeatItem( component );
207 
208  m_view->ClearPreview();
209  m_view->AddToPreview( component->Clone() );
210  m_selectionTool->AddItemToSel( component );
211 
212  // Update cursor now that we have a component
213  setCursor();
214  }
215  else
216  {
217  SCH_COMPONENT* next_comp = nullptr;
218 
219  m_view->ClearPreview();
220  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), component, false );
221 
222  EE_SELECTION new_sel;
223  new_sel.Add( component );
224 
226  m_frame->OnModify();
227 
230  {
231  int new_unit = component->GetUnit();
232 
234  && component->GetUnit() < component->GetUnitCount() )
235  {
236  new_unit++;
237  }
238  else
239  {
240  new_unit = 1;
241  }
242 
243  // We are either stepping to the next unit or next component
244  if( m_frame->eeconfig()->m_SymChooserPanel.keep_symbol || new_unit > 1 )
245  {
246  // Deselect the last placed symbol: obviously we do not want to
247  // apply some changes (like rotation, mirror...) to previously placed
248  // symbols.
250 
251  next_comp = static_cast<SCH_COMPONENT*>( component->Duplicate() );
252  next_comp->SetFlags( IS_NEW | IS_MOVED );
253  next_comp->SetUnit( new_unit );
254  next_comp->SetUnitSelection( &m_frame->GetCurrentSheet(), new_unit );
255 
257  component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
258 
259  m_frame->SaveCopyForRepeatItem( next_comp );
260  m_view->AddToPreview( next_comp->Clone() );
261  m_selectionTool->AddItemToSel( next_comp );
262  }
263  }
264 
265  component = next_comp;
266  }
267  }
268  else if( evt->IsClick( BUT_RIGHT ) )
269  {
270  // Warp after context menu only if dragging...
271  if( !component )
273 
275  }
276  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
277  {
278  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
279  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
280  {
281  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
282 
283  if( component )
284  {
285  m_frame->SelectUnit( component, unit );
287  }
288  }
289  }
290  else if( component && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
291  {
292  component->SetPosition( (wxPoint)cursorPos );
293  m_view->ClearPreview();
294  m_view->AddToPreview( component->Clone() );
295  }
296  else
297  {
298  evt->SetPassEvent();
299  }
300 
301  // Enable autopanning and cursor capture only when there is a footprint to be placed
302  getViewControls()->SetAutoPan( component != nullptr );
303  getViewControls()->CaptureCursor( component != nullptr );
304  }
305 
307  return 0;
308 }
309 
310 
312 {
313  SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
314  bool immediateMode = image;
315  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
316 
318  getViewControls()->ShowCursor( true );
319 
320  // Add all the drawable parts to preview
321  if( image )
322  {
323  image->SetPosition( (wxPoint)cursorPos );
324  m_view->ClearPreview();
325  m_view->AddToPreview( image->Clone() );
326  }
327 
328  std::string tool = aEvent.GetCommandStr().get();
329  m_frame->PushTool( tool );
330  Activate();
331 
332  // Prime the pump
333  if( image )
335  else if( aEvent.HasPosition() )
337 
338  auto setCursor =
339  [&]()
340  {
341  if( image )
343  else
345  };
346 
347  // Set initial cursor
348  setCursor();
349 
350  // Main loop: keep receiving events
351  while( TOOL_EVENT* evt = Wait() )
352  {
353  setCursor();
354  cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
355 
356  auto cleanup =
357  [&] ()
358  {
360  m_view->ClearPreview();
361  delete image;
362  image = nullptr;
363  };
364 
365  if( evt->IsCancelInteractive() )
366  {
367  if( image )
368  {
369  cleanup();
370  }
371  else
372  {
373  m_frame->PopTool( tool );
374  break;
375  }
376 
377  if( immediateMode )
378  {
379  m_frame->PopTool( tool );
380  break;
381  }
382  }
383  else if( evt->IsActivate() )
384  {
385  if( image )
386  cleanup();
387 
388  if( evt->IsMoveTool() )
389  {
390  // leave ourselves on the stack so we come back after the move
391  break;
392  }
393  else
394  {
395  m_frame->PopTool( tool );
396  break;
397  }
398  }
399  else if( evt->IsClick( BUT_LEFT ) )
400  {
401  if( !image )
402  {
404  wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
405  _( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
406  wxFD_OPEN );
407 
408  if( dlg.ShowModal() != wxID_OK )
409  continue;
410 
411  // Restore cursor after dialog
412  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
413 
414  wxString fullFilename = dlg.GetPath();
415 
416  if( wxFileExists( fullFilename ) )
417  image = new SCH_BITMAP( (wxPoint)cursorPos );
418 
419  if( !image || !image->ReadImageFile( fullFilename ) )
420  {
421  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
422  delete image;
423  image = nullptr;
424  continue;
425  }
426 
427  image->SetFlags( IS_NEW | IS_MOVED );
428 
429  m_frame->SaveCopyForRepeatItem( image );
430 
431  m_view->ClearPreview();
432  m_view->AddToPreview( image->Clone() );
433  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
434 
435  m_selectionTool->AddItemToSel( image );
436 
437  getViewControls()->SetCursorPosition( cursorPos, false );
438  setCursor();
439  }
440  else
441  {
443  image = nullptr;
445 
446  m_view->ClearPreview();
447 
448  if( immediateMode )
449  {
450  m_frame->PopTool( tool );
451  break;
452  }
453  }
454  }
455  else if( evt->IsClick( BUT_RIGHT ) )
456  {
457  // Warp after context menu only if dragging...
458  if( !image )
460 
462  }
463  else if( image && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
464  {
465  image->SetPosition( (wxPoint)cursorPos );
466  m_view->ClearPreview();
467  m_view->AddToPreview( image->Clone() );
468  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
469  }
470  else
471  {
472  evt->SetPassEvent();
473  }
474 
475  // Enable autopanning and cursor capture only when there is a footprint to be placed
476  getViewControls()->SetAutoPan( image != nullptr );
477  getViewControls()->CaptureCursor( image != nullptr );
478  }
479 
481  return 0;
482 }
483 
484 
486 {
487  wxPoint cursorPos;
488  KICAD_T type = aEvent.Parameter<KICAD_T>();
489 
490  if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
491  {
492  EE_SELECTION& selection = m_selectionTool->GetSelection();
493  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
494 
495  if( wire )
496  {
497  SEG seg( wire->GetStartPoint(), wire->GetEndPoint() );
498  VECTOR2I nearest = seg.NearestPoint( getViewControls()->GetCursorPosition() );
499  getViewControls()->SetCrossHairCursorPosition( nearest, false );
500  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
501  }
502  }
503 
505  getViewControls()->ShowCursor( true );
506 
507  SCH_ITEM* previewItem;
508  switch( type )
509  {
510  case SCH_NO_CONNECT_T:
511  previewItem = new SCH_NO_CONNECT( cursorPos );
512  break;
513  case SCH_JUNCTION_T:
514  previewItem = new SCH_JUNCTION( cursorPos );
515  break;
517  previewItem = new SCH_BUS_WIRE_ENTRY( cursorPos );
518  break;
519  default:
520  wxASSERT_MSG( false, "Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
521  return 0;
522  }
523 
524  previewItem->SetParent( m_frame->GetScreen() );
525 
526  m_view->ClearPreview();
527  m_view->AddToPreview( previewItem->Clone() );
528 
529  std::string tool = aEvent.GetCommandStr().get();
530  m_frame->PushTool( tool );
531  Activate();
532 
533  // Prime the pump
534  if( aEvent.HasPosition() )
536  else
538 
539  auto setCursor =
540  [&]()
541  {
543  };
544 
545  // Set initial cursor
546  setCursor();
547 
548  // Main loop: keep receiving events
549  while( TOOL_EVENT* evt = Wait() )
550  {
551  setCursor();
552  cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
553 
554  if( evt->IsCancelInteractive() )
555  {
556  m_frame->PopTool( tool );
557  break;
558  }
559  else if( evt->IsActivate() )
560  {
561  if( evt->IsMoveTool() )
562  {
563  // leave ourselves on the stack so we come back after the move
564  break;
565  }
566  else
567  {
568  m_frame->PopTool( tool );
569  break;
570  }
571  }
572  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
573  {
574  if( !m_frame->GetScreen()->GetItem( cursorPos, 0, type ) )
575  {
576  SCH_ITEM* newItem = static_cast<SCH_ITEM*>( previewItem->Clone() );
577  newItem->SetPosition( cursorPos );
578  newItem->SetFlags( IS_NEW );
579 
580  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), newItem, false );
581  m_frame->SaveCopyForRepeatItem( newItem );
582 
583  if( type == SCH_JUNCTION_T )
585  else
587 
588  m_frame->OnModify();
589  }
590 
591  if( evt->IsDblClick( BUT_LEFT ) ) // Finish tool.
592  {
593  m_frame->PopTool( tool );
594  break;
595  }
596  }
597  else if( evt->IsClick( BUT_RIGHT ) )
598  {
600  }
601  else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
602  {
603  previewItem->SetPosition( (wxPoint)cursorPos );
604  m_view->ClearPreview();
605  m_view->AddToPreview( previewItem->Clone() );
606  }
607  else if( evt->Category() == TC_COMMAND )
608  {
609  if( ( type == SCH_BUS_WIRE_ENTRY_T )
610  && ( evt->IsAction( &EE_ACTIONS::rotateCW )
611  || evt->IsAction( &EE_ACTIONS::rotateCCW )
612  || evt->IsAction( &EE_ACTIONS::mirrorX )
613  || evt->IsAction( &EE_ACTIONS::mirrorY ) ) )
614  {
615  SCH_BUS_ENTRY_BASE* busItem = static_cast<SCH_BUS_ENTRY_BASE*>( previewItem );
616 
617  // The bus entries only rotate in one direction
618  if( evt->IsAction( &EE_ACTIONS::rotateCW )
619  || evt->IsAction( &EE_ACTIONS::rotateCCW ) )
620  {
621  busItem->Rotate( busItem->GetPosition() );
622  }
623  else if( evt->IsAction( &EE_ACTIONS::mirrorX ) )
624  {
625  busItem->MirrorX( busItem->GetPosition().x );
626  }
627  else if( evt->IsAction( &EE_ACTIONS::mirrorY ) )
628  {
629  busItem->MirrorY( busItem->GetPosition().y );
630  }
631 
632  m_view->ClearPreview();
633  m_view->AddToPreview( previewItem->Clone() );
634  }
635  else if( evt->IsAction( &EE_ACTIONS::properties ) )
636  {
637  switch( type )
638  {
640  {
641  std::deque<SCH_ITEM*> strokeItems;
642  strokeItems.push_back( previewItem );
643 
644  DIALOG_EDIT_LINE_STYLE dlg( m_frame, strokeItems );
645 
646  if( dlg.ShowModal() == wxID_OK )
647  {
649  m_frame->OnModify();
650  }
651  }
652  break;
653 
654  case SCH_JUNCTION_T:
655  {
656  std::deque<SCH_JUNCTION*> junctions;
657  junctions.push_back( static_cast<SCH_JUNCTION*>( previewItem ) );
658 
659  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
660 
661  if( dlg.ShowModal() == wxID_OK )
662  {
664  m_frame->OnModify();
665  }
666  }
667  break;
668  default:
669  // Do nothing
670  break;
671  }
672 
673  m_view->ClearPreview();
674  m_view->AddToPreview( previewItem->Clone() );
675  }
676  else
677  {
678  evt->SetPassEvent();
679  }
680  }
681  else
682  {
683  evt->SetPassEvent();
684  }
685  }
686 
687  delete previewItem;
688  m_view->ClearPreview();
689 
691  return 0;
692 }
693 
694 
695 SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType )
696 {
697  SCHEMATIC* schematic = getModel<SCHEMATIC>();
698  SCHEMATIC_SETTINGS& settings = schematic->Settings();
699  SCH_TEXT* textItem = nullptr;
700 
701  switch( aType )
702  {
703  case LAYER_NOTES:
704  textItem = new SCH_TEXT( (wxPoint) aPosition );
705  break;
706 
707  case LAYER_LOCLABEL:
708  textItem = new SCH_LABEL( (wxPoint) aPosition );
709  break;
710 
711  case LAYER_HIERLABEL:
712  textItem = new SCH_HIERLABEL( (wxPoint) aPosition );
713  textItem->SetShape( m_lastGlobalLabelShape );
714  break;
715 
716  case LAYER_GLOBLABEL:
717  textItem = new SCH_GLOBALLABEL( (wxPoint) aPosition );
718  textItem->SetShape( m_lastGlobalLabelShape );
719  break;
720 
721  default:
722  wxFAIL_MSG( "SCH_EDIT_FRAME::CreateNewText() unknown layer type" );
723  return nullptr;
724  }
725 
726  textItem->SetParent( schematic );
727  textItem->SetBold( m_lastTextBold );
728  textItem->SetItalic( m_lastTextItalic );
730  textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
731  textItem->SetFlags( IS_NEW | IS_MOVED );
732 
733  DIALOG_LABEL_EDITOR dlg( m_frame, textItem );
734 
735  // Must be quasi modal for syntax help
736  if( dlg.ShowQuasiModal() != wxID_OK || textItem->GetText().IsEmpty() )
737  {
738  delete textItem;
739  return nullptr;
740  }
741 
742  m_lastTextBold = textItem->IsBold();
743  m_lastTextItalic = textItem->IsItalic();
745 
746  if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIER_LABEL_T )
747  m_lastGlobalLabelShape = textItem->GetShape();
748 
749  return textItem;
750 }
751 
752 
754 {
755  if( !aSheet->GetScreen() )
756  return nullptr;
757 
758  for( EDA_ITEM* item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
759  {
760  SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
761 
762  /* A global label has been found: check if there a corresponding sheet label. */
763  if( !aSheet->HasPin( label->GetText() ) )
764  return label;
765  }
766 
767  return nullptr;
768 }
769 
770 
772 {
773  SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
774  wxString text;
775  SCH_SHEET_PIN* sheetPin;
776 
777  if( aLabel )
778  {
779  text = aLabel->GetText();
780  m_lastSheetPinType = aLabel->GetShape();
781  }
782 
783  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
784  sheetPin->SetFlags( IS_NEW );
785  sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
786  sheetPin->SetShape( m_lastSheetPinType );
787 
788  if( !aLabel )
789  {
790  DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
791 
792  if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
793  {
794  delete sheetPin;
795  return nullptr;
796  }
797  }
798 
799  m_lastSheetPinType = sheetPin->GetShape();
800 
801  sheetPin->SetPosition( (wxPoint) getViewControls()->GetCursorPosition() );
802 
803  return sheetPin;
804 }
805 
806 
808 {
809  SCH_ITEM* item = nullptr;
810  bool isImportMode = aEvent.IsAction( &EE_ACTIONS::importSheetPin );
811  bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText );
812  bool isGlobalLabel = aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel );
813  bool isHierLabel = aEvent.IsAction( &EE_ACTIONS::placeHierLabel );
814  bool isNetLabel = aEvent.IsAction( &EE_ACTIONS::placeLabel );
815  KICAD_T type = aEvent.Parameter<KICAD_T>();
816 
818  getViewControls()->ShowCursor( true );
819 
820  std::string tool = aEvent.GetCommandStr().get();
821  m_frame->PushTool( tool );
822  Activate();
823 
824  // Prime the pump
825  if( aEvent.HasPosition() )
827 
828  auto setCursor =
829  [&]()
830  {
831  if( item )
833  else if( isText )
835  else if( isGlobalLabel )
837  else if( isNetLabel )
839  else if( isHierLabel )
841  else
843  };
844 
845  // Set initial cursor
846  setCursor();
847 
848  // Main loop: keep receiving events
849  while( TOOL_EVENT* evt = Wait() )
850  {
851  setCursor();
852 
853  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
854 
855  auto cleanup =
856  [&] ()
857  {
859  m_view->ClearPreview();
860  delete item;
861  item = nullptr;
862  };
863 
864  if( evt->IsCancelInteractive() )
865  {
866  if( item )
867  {
868  cleanup();
869  }
870  else
871  {
872  m_frame->PopTool( tool );
873  break;
874  }
875  }
876  else if( evt->IsActivate() )
877  {
878  if( item )
879  cleanup();
880 
881  if( evt->IsPointEditor() )
882  {
883  // don't exit (the point editor runs in the background)
884  }
885  else if( evt->IsMoveTool() )
886  {
887  // leave ourselves on the stack so we come back after the move
888  break;
889  }
890  else
891  {
892  m_frame->PopTool( tool );
893  break;
894  }
895  }
896  else if( evt->IsClick( BUT_LEFT ) )
897  {
898  // First click creates...
899  if( !item )
900  {
902 
903  switch( type )
904  {
905  case SCH_LABEL_T:
906  item = createNewText( cursorPos, LAYER_LOCLABEL );
907  break;
908  case SCH_HIER_LABEL_T:
909  item = createNewText( cursorPos, LAYER_HIERLABEL );
910  break;
911  case SCH_GLOBAL_LABEL_T:
912  item = createNewText( cursorPos, LAYER_GLOBLABEL );
913  break;
914  case SCH_TEXT_T:
915  item = createNewText( cursorPos, LAYER_NOTES );
916  break;
917  case SCH_SHEET_PIN_T:
918  {
919  EDA_ITEM* i;
920  SCH_HIERLABEL* label = nullptr;
921  SCH_SHEET* sheet = nullptr;
922 
923  if( m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsOnly, &i ) )
924  sheet = dynamic_cast<SCH_SHEET*>( i );
925 
926  item = nullptr;
927 
928  if( !sheet )
929  {
930  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
931  m_statusPopup->SetText( _( "Click over a sheet." ) );
932  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
933  m_statusPopup->PopupFor( 2000 );
934  break;
935  }
936 
937  if( isImportMode )
938  {
939  label = importHierLabel( sheet );
940 
941  if( !label )
942  {
943  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
944  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
945  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
946  m_statusPopup->PopupFor( 2000 );
947  break;
948  }
949  }
950 
951  item = createSheetPin( sheet, label );
952  break;
953  }
954  default:
955  break;
956  }
957 
958  // Restore cursor after dialog
959  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
960 
961  if( item )
962  {
963  item->SetFlags( IS_NEW | IS_MOVED );
964  m_view->ClearPreview();
965  m_view->AddToPreview( item->Clone() );
966  m_selectionTool->AddItemToSel( item );
967 
968  // update the cursor so it looks correct before another event
969  setCursor();
970  }
971 
972  getViewControls()->SetCursorPosition( cursorPos, false );
973  }
974 
975  // ... and second click places:
976  else
977  {
978  item->ClearFlags( IS_MOVED );
979  item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
980 
982  item = nullptr;
983 
984  m_view->ClearPreview();
985  }
986  }
987  else if( evt->IsClick( BUT_RIGHT ) )
988  {
989  // Warp after context menu only if dragging...
990  if( !item )
992 
994  }
995  else if( item && evt->IsSelectionEvent() )
996  {
997  // This happens if our text was replaced out from under us by ConvertTextType()
998  EE_SELECTION& selection = m_selectionTool->GetSelection();
999 
1000  if( selection.GetSize() == 1 )
1001  {
1002  item = (SCH_ITEM*) selection.Front();
1003  m_view->ClearPreview();
1004  m_view->AddToPreview( item->Clone() );
1005  }
1006  else
1007  {
1008  item = nullptr;
1009  }
1010  }
1011  else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1012  {
1013  static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint) cursorPos );
1014  m_view->ClearPreview();
1015  m_view->AddToPreview( item->Clone() );
1016  }
1017  else
1018  {
1019  evt->SetPassEvent();
1020  }
1021 
1022  // Enable autopanning and cursor capture only when there is a footprint to be placed
1023  getViewControls()->SetAutoPan( item != nullptr );
1024  getViewControls()->CaptureCursor( item != nullptr );
1025  }
1026 
1028  return 0;
1029 }
1030 
1031 
1033 {
1034  SCH_SHEET* sheet = nullptr;
1035 
1037  getViewControls()->ShowCursor( true );
1038 
1039  std::string tool = aEvent.GetCommandStr().get();
1040  m_frame->PushTool( tool );
1041  Activate();
1042 
1043  // Prime the pump
1044  if( aEvent.HasPosition() )
1046 
1047  auto setCursor =
1048  [&]()
1049  {
1051  };
1052 
1053  // Set initial cursor
1054  setCursor();
1055 
1056  // Main loop: keep receiving events
1057  while( TOOL_EVENT* evt = Wait() )
1058  {
1059  setCursor();
1060 
1061  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
1062 
1063  auto cleanup =
1064  [&] ()
1065  {
1067  m_view->ClearPreview();
1068  delete sheet;
1069  sheet = nullptr;
1070  };
1071 
1072  if( evt->IsCancelInteractive() )
1073  {
1074  if( sheet )
1075  {
1076  cleanup();
1077  }
1078  else
1079  {
1080  m_frame->PopTool( tool );
1081  break;
1082  }
1083  }
1084  else if( evt->IsActivate() )
1085  {
1086  if( sheet )
1087  cleanup();
1088 
1089  if( evt->IsPointEditor() )
1090  {
1091  // don't exit (the point editor runs in the background)
1092  }
1093  else if( evt->IsMoveTool() )
1094  {
1095  // leave ourselves on the stack so we come back after the move
1096  break;
1097  }
1098  else
1099  {
1100  m_frame->PopTool( tool );
1101  break;
1102  }
1103  }
1104  else if( evt->IsClick( BUT_LEFT ) && !sheet )
1105  {
1107 
1109 
1110  sheet = new SCH_SHEET( m_frame->GetCurrentSheet().Last(),
1111  static_cast<wxPoint>( cursorPos ) );
1112  sheet->SetFlags( IS_NEW | IS_RESIZED );
1113  sheet->SetScreen( NULL );
1117  sheet->GetFields()[ SHEETNAME ].SetText( "Untitled Sheet" );
1118  sheet->GetFields()[ SHEETFILENAME ].SetText( "untitled.kicad_sch" );
1119  sizeSheet( sheet, cursorPos );
1120 
1121  m_view->ClearPreview();
1122  m_view->AddToPreview( sheet->Clone() );
1123  }
1124  else if( sheet && ( evt->IsClick( BUT_LEFT )
1125  || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
1126  {
1127  m_view->ClearPreview();
1128  getViewControls()->SetAutoPan( false );
1129  getViewControls()->CaptureCursor( false );
1130 
1131  if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
1132  &m_frame->GetCurrentSheet(), nullptr ) )
1133  {
1134  sheet->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
1135 
1136  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), sheet, false );
1138  m_selectionTool->AddItemToSel( sheet );
1139  }
1140  else
1141  {
1142  delete sheet;
1143  }
1144 
1145  sheet = nullptr;
1146  }
1147  else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1148  {
1149  sizeSheet( sheet, cursorPos );
1150  m_view->ClearPreview();
1151  m_view->AddToPreview( sheet->Clone() );
1152  }
1153  else if( evt->IsClick( BUT_RIGHT ) )
1154  {
1155  // Warp after context menu only if dragging...
1156  if( !sheet )
1158 
1160  }
1161  else
1162  {
1163  evt->SetPassEvent();
1164  }
1165 
1166  // Enable autopanning and cursor capture only when there is a sheet to be placed
1167  getViewControls()->SetAutoPan( sheet != nullptr );
1168  getViewControls()->CaptureCursor( sheet != nullptr );
1169  }
1170 
1172  return 0;
1173 }
1174 
1175 
1177 {
1178  wxPoint pos = aSheet->GetPosition();
1179  wxPoint size = (wxPoint) aPos - pos;
1180 
1181  size.x = std::max( size.x, MIN_SHEET_WIDTH );
1182  size.y = std::max( size.y, MIN_SHEET_HEIGHT );
1183 
1184  wxPoint grid = m_frame->GetNearestGridPosition( pos + size );
1185  aSheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
1186 }
1187 
1188 
1190 {
1203 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
bool IsBold() const
Definition: eda_text.h:189
static TOOL_ACTION properties
Definition: ee_actions.h:121
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:237
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape
int TwoClickPlace(const TOOL_EVENT &aEvent)
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
static TOOL_ACTION finishSheet
Definition: ee_actions.h:98
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
int PlaceComponent(const TOOL_EVENT &aEvent)
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
static TOOL_ACTION activatePointEditor
Definition: actions.h:168
SCH_SHEET_PIN * createSheetPin(SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
wxPoint GetStartPoint() const
Definition: sch_line.h:94
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:44
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
This file is part of the common library.
virtual void SetPosition(const wxPoint &aPos)
Definition: eda_item.h:326
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1554
VIEW_CONTROLS class definition.
STATUS_TEXT_POPUP.
Definition: status_popup.h:82
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION mirrorY
Definition: ee_actions.h:120
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:125
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:87
void SetItalic(bool isItalic)
Definition: eda_text.h:185
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION placeJunction
Definition: ee_actions.h:83
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1377
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:151
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
int GetUnitCount() const
Return the number of units per package of the symbol.
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
#define IS_RESIZED
Item being resized.
Definition: eda_item.h:107
void SetPosition(const wxPoint &aPosition) override
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
Schematic editor (Eeschema) main window.
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
Load symbol from symbol library table.
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:84
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:244
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:48
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
bool IsValid() const
Definition: lib_id.h:171
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:284
int PlaceImage(const TOOL_EVENT &aEvent)
PANEL_SYM_CHOOSER m_SymChooserPanel
std::vector< PICKED_SYMBOL > m_symbolHistoryList
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:213
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:43
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:184
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
static TOOL_ACTION rotateCW
Definition: ee_actions.h:117
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:75
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:185
void SetBorderWidth(int aWidth)
Definition: sch_sheet.h:290
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:42
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
bool IsItalic() const
Definition: eda_text.h:186
EE_SELECTION & GetSelection()
Function GetSelection()
EESCHEMA_SETTINGS * eeconfig() const
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:270
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static TOOL_ACTION drawSheet
Definition: ee_actions.h:88
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:118
int GetUnit() const
AUTOPLACE_FIELDS m_AutoplaceFields
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:296
static TOOL_ACTION placePower
Definition: ee_actions.h:78
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:220
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:78
#define NULL
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
PICKED_SYMBOL PickSymbolFromLibTree(const SCHLIB_FILTER *aFilter, std::vector< PICKED_SYMBOL > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Function PickSymbolFromLibTree Calls the library viewer to select component to import into schematic.
Definition: getpart.cpp:89
int ShowQuasiModal()
int SingleClickPlace(const TOOL_EVENT &aEvent)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:473
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:91
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
TOOL_EVENT.
Definition: tool_event.h:171
static TOOL_ACTION placeImage
Definition: ee_actions.h:93
void ClearPreview()
Definition: view.cpp:1535
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
Define a library symbol object.
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:293
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
static TOOL_ACTION mirrorX
Definition: ee_actions.h:119
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:181
LABEL_SPIN_STYLE GetLabelSpinStyle() const
Definition: sch_text.h:233
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:85
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:90
void SetUnit(int aUnit)
Change the unit number to aUnit.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:77
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
wxPoint GetPosition() const override
Definition: sch_sheet.h:571
#define IS_MOVED
Item being moved.
Definition: eda_item.h:105
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
void SelectUnit(SCH_COMPONENT *aComponent, int aUnit)
Definition: getpart.cpp:198
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:99
Definition: seg.h:39
std::vector< PICKED_SYMBOL > m_powerHistoryList
static TOOL_ACTION placeLabel
Definition: ee_actions.h:85
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
void SetPosition(const wxPoint &aPosition) override
Definition: sch_sheet.h:206
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
PINSHEETLABEL_SHAPE
Definition: sch_text.h:151
SCH_SHEET & Root() const
Definition: schematic.h:102
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:145
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.
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
bool SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
Function SelectPoint() This overload of SelectPoint will create an EE_COLLECTOR and collect hits at l...
SCH_HIERLABEL * importHierLabel(SCH_SHEET *aSheet)
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
#define _(s)
Definition: 3d_actions.cpp:33
void MirrorX(int aXaxis_position) override
Mirror item relative to the X axis about aXaxis_position.
EE_RTREE & Items()
Definition: sch_screen.h:159
void VetoContextMenuMouseWarp()
Disables mouse warping after the current context menu is closed.
Definition: tool_manager.h:417
SCH_TEXT * createNewText(const VECTOR2I &aPosition, int aType)
Gets the next queued text item.
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:82
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the component.
Schematic symbol object.
Definition: sch_component.h:79
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:89
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:44
These settings were stored in SCH_BASE_FRAME previously.
Class for a wire to bus entry.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:221
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:465
void Activate()
Function Activate() Runs the tool.
bool HasPin(const wxString &aName)
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:308
SCH_SHEET_PATH & GetCurrentSheet() const
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores an image file.
Definition: sch_bitmap.cpp:83
PINSHEETLABEL_SHAPE m_lastSheetPinType
EE_TOOL_BASE.
Definition: ee_tool_base.h:50
LABEL_SPIN_STYLE m_lastTextOrientation
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T)
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:310
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:499
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:232
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:86
LIB_ID LibId
Definition: sch_screen.h:82
void PostEvent(const TOOL_EVENT &aEvent)
Puts an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:274
void SetBold(bool aBold)
Definition: eda_text.h:188
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Adds a menu entry to run a TOOL_ACTION on selected items.
void MirrorY(int aYaxis_position) override
Mirror item relative to the Y axis about aYaxis_position.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
void SetPosition(const wxPoint &aPosition) override
Definition: sch_bitmap.h:141
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION refreshPreview
Definition: actions.h:104
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:201
int DrawSheet(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorClick
Definition: actions.h:121
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:235
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:793
void sizeSheet(SCH_SHEET *aSheet, VECTOR2I aPos)
wxPoint GetPosition() const override
wxPoint GetEndPoint() const
Definition: sch_line.h:97
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup