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-2021 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_grid_helper.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 <widgets/infobar.h>
35 #include <view/view_controls.h>
36 #include <view/view.h>
37 #include <sch_symbol.h>
38 #include <sch_no_connect.h>
39 #include <sch_line.h>
40 #include <sch_junction.h>
41 #include <sch_bus_entry.h>
42 #include <sch_text.h>
43 #include <sch_sheet.h>
44 #include <sch_bitmap.h>
45 #include <schematic.h>
46 #include <class_library.h>
47 #include <eeschema_settings.h>
52 #include <kicad_string.h>
54 
56  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" ),
57  m_lastSheetPinType( PINSHEETLABEL_SHAPE::PS_INPUT ),
58  m_lastGlobalLabelShape( PINSHEETLABEL_SHAPE::PS_INPUT ),
59  m_lastTextOrientation( LABEL_SPIN_STYLE::LEFT ),
60  m_lastTextBold( false ),
61  m_lastTextItalic( false ),
62  m_inPlaceComponent( false ),
63  m_inPlaceImage( false ),
64  m_inSingleClickPlace( false ),
65  m_inTwoClickPlace( false ),
66  m_inDrawSheet( false )
67 {
68 }
69 
70 
72 {
74 
75  auto belowRootSheetCondition =
76  [&]( const SELECTION& aSel )
77  {
78  return m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root();
79  };
80 
81  CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu();
82  ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
83 
84  return true;
85 }
86 
87 
89 {
90  SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
91  SCHLIB_FILTER filter;
92  std::vector<PICKED_SYMBOL>* historyList = nullptr;
93 
94  if( m_inPlaceComponent )
95  return 0;
96  else
97  m_inPlaceComponent = true;
98 
99  if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
100  {
101  historyList = &m_symbolHistoryList;
102  }
103  else if (aEvent.IsAction( &EE_ACTIONS::placePower ) )
104  {
105  historyList = &m_powerHistoryList;
106  filter.FilterPowerParts( true );
107  }
108  else
109  {
110  wxFAIL_MSG( "PlaceCompontent(): unexpected request" );
111  }
112 
113  getViewControls()->ShowCursor( true );
114 
115  // If a component was passed in get it ready for placement.
116  if( component )
117  {
118  component->SetFlags( IS_NEW | IS_MOVED );
119 
121  m_selectionTool->AddItemToSel( component );
122  }
123 
124  std::string tool = aEvent.GetCommandStr().get();
125  m_frame->PushTool( tool );
126  Activate();
127 
128  // Prime the pump
129  if( component )
130  {
131  getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
133  }
134  else if( !aEvent.IsReactivate() )
135  {
137  }
138 
139  auto setCursor =
140  [&]()
141  {
144  };
145 
146  // Set initial cursor
147  setCursor();
148 
149  // Main loop: keep receiving events
150  while( TOOL_EVENT* evt = Wait() )
151  {
152  setCursor();
153  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
154 
155  auto cleanup =
156  [&] ()
157  {
159  m_view->ClearPreview();
160  delete component;
161  component = nullptr;
162  };
163 
164  if( evt->IsCancelInteractive() )
165  {
166  if( component )
167  {
168  cleanup();
169  }
170  else
171  {
172  m_frame->PopTool( tool );
173  break;
174  }
175  }
176  else if( evt->IsActivate() )
177  {
178  if( component && evt->IsMoveTool() )
179  {
180  // we're already moving our own item; ignore the move tool
181  evt->SetPassEvent( false );
182  continue;
183  }
184 
185  if( component )
186  cleanup();
187 
188  if( evt->IsMoveTool() )
189  {
190  // leave ourselves on the stack so we come back after the move
191  break;
192  }
193  else
194  {
195  m_frame->PopTool( tool );
196  break;
197  }
198  }
199  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
200  {
201  if( !component )
202  {
204 
205  // Pick the footprint to be placed
206  bool footprintPreviews = m_frame->eeconfig()->m_Appearance.footprint_preview;
207  PICKED_SYMBOL sel = m_frame->PickSymbolFromLibTree( &filter, *historyList, true,
208  1, 1, footprintPreviews );
209 
210  // Restore cursor after dialog
211  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
212 
213  LIB_PART* part = sel.LibId.IsValid() ? m_frame->GetLibPart( sel.LibId ) : nullptr;
214 
215  if( !part )
216  continue;
217 
218  component = new SCH_COMPONENT( *part, &m_frame->GetCurrentSheet(), sel,
219  (wxPoint) cursorPos );
220  component->SetParent( m_frame->GetCurrentSheet().LastScreen() );
221  component->SetFlags( IS_NEW | IS_MOVED );
222 
224  component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
225 
226  m_frame->SaveCopyForRepeatItem( component );
227 
228  m_view->ClearPreview();
229  m_view->AddToPreview( component->Clone() );
230  m_selectionTool->AddItemToSel( component );
231 
232  // Update cursor now that we have a component
233  setCursor();
234  }
235  else
236  {
237  SCH_COMPONENT* next_comp = nullptr;
238 
239  m_view->ClearPreview();
240  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), component, false );
241 
242  EE_SELECTION new_sel;
243  new_sel.Add( component );
244 
246  m_frame->OnModify();
247 
250  {
251  int new_unit = component->GetUnit();
252 
254  && component->GetUnit() < component->GetUnitCount() )
255  {
256  new_unit++;
257  }
258  else
259  {
260  new_unit = 1;
261  }
262 
263  // We are either stepping to the next unit or next component
264  if( m_frame->eeconfig()->m_SymChooserPanel.keep_symbol || new_unit > 1 )
265  {
266  // Deselect the last placed symbol: obviously we do not want to
267  // apply some changes (like rotation, mirror...) to previously placed
268  // symbols.
270 
271  next_comp = static_cast<SCH_COMPONENT*>( component->Duplicate() );
272  next_comp->SetFlags( IS_NEW | IS_MOVED );
273  next_comp->SetUnit( new_unit );
274  next_comp->SetUnitSelection( new_unit );
275 
277  component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
278 
279  m_frame->SaveCopyForRepeatItem( next_comp );
280  m_view->AddToPreview( next_comp->Clone() );
281  m_selectionTool->AddItemToSel( next_comp );
282  }
283  }
284 
285  component = next_comp;
286  }
287  }
288  else if( evt->IsClick( BUT_RIGHT ) )
289  {
290  // Warp after context menu only if dragging...
291  if( !component )
293 
295  }
296  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
297  {
298  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
299  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
300  {
301  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
302 
303  if( component )
304  {
305  m_frame->SelectUnit( component, unit );
307  }
308  }
309  }
310  else if( component && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
311  {
312  component->SetPosition( (wxPoint)cursorPos );
313  m_view->ClearPreview();
314  m_view->AddToPreview( component->Clone() );
315  }
316  else
317  {
318  evt->SetPassEvent();
319  }
320 
321  // Enable autopanning and cursor capture only when there is a footprint to be placed
322  getViewControls()->SetAutoPan( component != nullptr );
323  getViewControls()->CaptureCursor( component != nullptr );
324  }
325 
327  m_inPlaceComponent = false;
328  return 0;
329 }
330 
331 
333 {
334  SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
335  bool immediateMode = image;
336  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
337 
338  if( m_inPlaceImage )
339  return 0;
340  else
341  m_inPlaceImage = true;
342 
344  getViewControls()->ShowCursor( true );
345 
346  // Add all the drawable parts to preview
347  if( image )
348  {
349  image->SetPosition( (wxPoint)cursorPos );
350  m_view->ClearPreview();
351  m_view->AddToPreview( image->Clone() );
352  }
353 
354  std::string tool = aEvent.GetCommandStr().get();
355  m_frame->PushTool( tool );
356  Activate();
357 
358  // Prime the pump
359  if( image )
361  else if( !aEvent.IsReactivate() )
363 
364  auto setCursor =
365  [&]()
366  {
367  if( image )
369  else
371  };
372 
373  // Set initial cursor
374  setCursor();
375 
376  // Main loop: keep receiving events
377  while( TOOL_EVENT* evt = Wait() )
378  {
379  setCursor();
380  cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
381 
382  auto cleanup =
383  [&] ()
384  {
386  m_view->ClearPreview();
387  delete image;
388  image = nullptr;
389  };
390 
391  if( evt->IsCancelInteractive() )
392  {
393  if( image )
394  {
395  cleanup();
396  }
397  else
398  {
399  m_frame->PopTool( tool );
400  break;
401  }
402 
403  if( immediateMode )
404  {
405  m_frame->PopTool( tool );
406  break;
407  }
408  }
409  else if( evt->IsActivate() )
410  {
411  if( image && evt->IsMoveTool() )
412  {
413  // we're already moving our own item; ignore the move tool
414  evt->SetPassEvent( false );
415  continue;
416  }
417 
418  if( image )
419  cleanup();
420 
421  if( evt->IsMoveTool() )
422  {
423  // leave ourselves on the stack so we come back after the move
424  break;
425  }
426  else
427  {
428  m_frame->PopTool( tool );
429  break;
430  }
431  }
432  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
433  {
434  if( !image )
435  {
437  wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
438  _( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
439  wxFD_OPEN );
440 
441  if( dlg.ShowModal() != wxID_OK )
442  continue;
443 
444  // Restore cursor after dialog
445  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
446 
447  wxString fullFilename = dlg.GetPath();
448 
449  if( wxFileExists( fullFilename ) )
450  image = new SCH_BITMAP( (wxPoint)cursorPos );
451 
452  if( !image || !image->ReadImageFile( fullFilename ) )
453  {
454  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
455  delete image;
456  image = nullptr;
457  continue;
458  }
459 
460  image->SetFlags( IS_NEW | IS_MOVED );
461 
462  m_frame->SaveCopyForRepeatItem( image );
463 
464  m_view->ClearPreview();
465  m_view->AddToPreview( image->Clone() );
466  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
467 
468  m_selectionTool->AddItemToSel( image );
469 
470  getViewControls()->SetCursorPosition( cursorPos, false );
471  setCursor();
472  }
473  else
474  {
476  image = nullptr;
478 
479  m_view->ClearPreview();
480 
481  if( immediateMode )
482  {
483  m_frame->PopTool( tool );
484  break;
485  }
486  }
487  }
488  else if( evt->IsClick( BUT_RIGHT ) )
489  {
490  // Warp after context menu only if dragging...
491  if( !image )
493 
495  }
496  else if( image && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
497  {
498  image->SetPosition( (wxPoint)cursorPos );
499  m_view->ClearPreview();
500  m_view->AddToPreview( image->Clone() );
501  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
502  }
503  else
504  {
505  evt->SetPassEvent();
506  }
507 
508  // Enable autopanning and cursor capture only when there is a footprint to be placed
509  getViewControls()->SetAutoPan( image != nullptr );
510  getViewControls()->CaptureCursor( image != nullptr );
511  }
512 
514  m_inPlaceImage = false;
515  return 0;
516 }
517 
518 
520 {
521  wxPoint cursorPos;
522  KICAD_T type = aEvent.Parameter<KICAD_T>();
523  EE_GRID_HELPER grid( m_toolMgr );
525  SCH_ITEM* previewItem;
526  bool loggedInfoBarError = false;
527 
529  return 0;
530 
531  if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
532  {
533  EE_SELECTION& selection = m_selectionTool->GetSelection();
534  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
535 
536  if( wire )
537  {
538  SEG seg( wire->GetStartPoint(), wire->GetEndPoint() );
539  VECTOR2I nearest = seg.NearestPoint( getViewControls()->GetCursorPosition() );
540  getViewControls()->SetCrossHairCursorPosition( nearest, false );
541  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
542  }
543  }
544 
545  switch( type )
546  {
547  case SCH_NO_CONNECT_T:
548  previewItem = new SCH_NO_CONNECT( cursorPos );
549  previewItem->SetParent( m_frame->GetScreen() );
550  break;
551 
552  case SCH_JUNCTION_T:
553  previewItem = new SCH_JUNCTION( cursorPos );
554  previewItem->SetParent( m_frame->GetScreen() );
555  break;
556 
558  previewItem = new SCH_BUS_WIRE_ENTRY( cursorPos );
559  previewItem->SetParent( m_frame->GetScreen() );
560  break;
561 
562  case SCH_SHEET_PIN_T:
563  {
564  EE_SELECTION& selection = m_selectionTool->GetSelection();
565  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() );
566 
567  if( !sheet )
568  return 0;
569 
570  SCH_HIERLABEL* label = importHierLabel( sheet );
571 
572  if( !label )
573  {
574  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
575  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
576  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
577  m_statusPopup->PopupFor( 2000 );
578  return 0;
579  }
580 
581  previewItem = createSheetPin( sheet, label );
582  }
583  break;
584 
585  default:
586  wxASSERT_MSG( false, "Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
587  return 0;
588  }
589 
590  m_inSingleClickPlace = true;
591 
593  getViewControls()->ShowCursor( true );
594 
595  cursorPos = static_cast<wxPoint>( aEvent.HasPosition() ?
596  aEvent.Position() :
597  controls->GetMousePosition() );
598 
599  std::string tool = aEvent.GetCommandStr().get();
600  m_frame->PushTool( tool );
601  Activate();
602 
603  m_view->ClearPreview();
604  m_view->AddToPreview( previewItem->Clone() );
605 
606  // Prime the pump
607  if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T )
609  else
611 
612  auto setCursor =
613  [&]()
614  {
616  };
617 
618  // Set initial cursor
619  setCursor();
620 
621  // Main loop: keep receiving events
622  while( TOOL_EVENT* evt = Wait() )
623  {
624  setCursor();
625  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
626  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->Modifier( MD_ALT ) );
627 
628  cursorPos = evt->IsPrime() ? (wxPoint) evt->Position()
629  : (wxPoint) controls->GetMousePosition();
630 
631  cursorPos = wxPoint( grid.BestSnapAnchor( cursorPos, LAYER_CONNECTABLE, nullptr ) );
632  controls->ForceCursorPosition( true, cursorPos );
633 
634  if( evt->IsCancelInteractive() )
635  {
636  m_frame->PopTool( tool );
637  break;
638  }
639  else if( evt->IsActivate() )
640  {
641  if( evt->IsMoveTool() )
642  {
643  // leave ourselves on the stack so we come back after the move
644  break;
645  }
646  else
647  {
648  m_frame->PopTool( tool );
649  break;
650  }
651  }
652  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
653  {
654  if( !m_frame->GetScreen()->GetItem( cursorPos, 0, type ) )
655  {
656  if( type == SCH_JUNCTION_T )
657  {
658  if( !m_frame->GetScreen()->IsJunctionNeeded( cursorPos ) )
659  {
660  m_frame->ShowInfoBarError( _( "Junction location contains no joinable "
661  "wires and/or pins." ) );
662  loggedInfoBarError = true;
663  continue;
664  }
665  else if( loggedInfoBarError )
666  {
667  m_frame->GetInfoBar()->Dismiss();
668  }
669  }
670 
671  SCH_ITEM* newItem = static_cast<SCH_ITEM*>( previewItem->Clone() );
672  newItem->SetPosition( cursorPos );
673  newItem->SetFlags( IS_NEW );
674 
675  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), newItem, false );
676 
677  if( type == SCH_JUNCTION_T )
679  else
681 
682  m_frame->OnModify();
683  }
684 
685  if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
686  {
687  m_frame->PopTool( tool );
688  break;
689  }
690  }
691  else if( evt->IsClick( BUT_RIGHT ) )
692  {
694  }
695  else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
696  {
697  previewItem->SetPosition( (wxPoint)cursorPos );
698  m_view->ClearPreview();
699  m_view->AddToPreview( previewItem->Clone() );
700  }
701  else if( evt->Category() == TC_COMMAND )
702  {
703  if( ( type == SCH_BUS_WIRE_ENTRY_T )
704  && ( evt->IsAction( &EE_ACTIONS::rotateCW )
705  || evt->IsAction( &EE_ACTIONS::rotateCCW )
706  || evt->IsAction( &EE_ACTIONS::mirrorV )
707  || evt->IsAction( &EE_ACTIONS::mirrorH ) ) )
708  {
709  SCH_BUS_ENTRY_BASE* busItem = static_cast<SCH_BUS_ENTRY_BASE*>( previewItem );
710 
711  // The bus entries only rotate in one direction
712  if( evt->IsAction( &EE_ACTIONS::rotateCW )
713  || evt->IsAction( &EE_ACTIONS::rotateCCW ) )
714  {
715  busItem->Rotate( busItem->GetPosition() );
716  }
717  else if( evt->IsAction( &EE_ACTIONS::mirrorV ) )
718  {
719  busItem->MirrorVertically( busItem->GetPosition().x );
720  }
721  else if( evt->IsAction( &EE_ACTIONS::mirrorH ) )
722  {
723  busItem->MirrorHorizontally( busItem->GetPosition().y );
724  }
725 
726  m_view->ClearPreview();
727  m_view->AddToPreview( previewItem->Clone() );
728  }
729  else if( evt->IsAction( &EE_ACTIONS::properties ) )
730  {
731  switch( type )
732  {
734  {
735  std::deque<SCH_ITEM*> strokeItems;
736  strokeItems.push_back( previewItem );
737 
738  DIALOG_EDIT_LINE_STYLE dlg( m_frame, strokeItems );
739 
740  if( dlg.ShowModal() == wxID_OK )
741  {
743  m_frame->OnModify();
744  }
745  }
746  break;
747 
748  case SCH_JUNCTION_T:
749  {
750  std::deque<SCH_JUNCTION*> junctions;
751  junctions.push_back( static_cast<SCH_JUNCTION*>( previewItem ) );
752 
753  DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
754 
755  if( dlg.ShowModal() == wxID_OK )
756  {
758  m_frame->OnModify();
759  }
760  }
761  break;
762  default:
763  // Do nothing
764  break;
765  }
766 
767  m_view->ClearPreview();
768  m_view->AddToPreview( previewItem->Clone() );
769  }
770  else
771  {
772  evt->SetPassEvent();
773  }
774  }
775  else
776  {
777  evt->SetPassEvent();
778  }
779  }
780 
781  delete previewItem;
782  m_view->ClearPreview();
783 
785  controls->ForceCursorPosition( false );
786  m_inSingleClickPlace = false;
787  return 0;
788 }
789 
790 
791 SCH_TEXT* SCH_DRAWING_TOOLS::createNewText( const VECTOR2I& aPosition, int aType )
792 {
793  SCHEMATIC* schematic = getModel<SCHEMATIC>();
794  SCHEMATIC_SETTINGS& settings = schematic->Settings();
795  SCH_TEXT* textItem = nullptr;
796 
797  switch( aType )
798  {
799  case LAYER_NOTES:
800  textItem = new SCH_TEXT( (wxPoint) aPosition );
801  break;
802 
803  case LAYER_LOCLABEL:
804  textItem = new SCH_LABEL( (wxPoint) aPosition );
805  break;
806 
807  case LAYER_HIERLABEL:
808  textItem = new SCH_HIERLABEL( (wxPoint) aPosition );
809  textItem->SetShape( m_lastGlobalLabelShape );
810  break;
811 
812  case LAYER_GLOBLABEL:
813  textItem = new SCH_GLOBALLABEL( (wxPoint) aPosition );
814  textItem->SetShape( m_lastGlobalLabelShape );
815  break;
816 
817  default:
818  wxFAIL_MSG( "SCH_EDIT_FRAME::CreateNewText() unknown layer type" );
819  return nullptr;
820  }
821 
822  textItem->SetParent( schematic );
823  textItem->SetBold( m_lastTextBold );
824  textItem->SetItalic( m_lastTextItalic );
826  textItem->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
827  textItem->SetFlags( IS_NEW | IS_MOVED );
828 
829  DIALOG_LABEL_EDITOR dlg( m_frame, textItem );
830 
831  // Must be quasi modal for syntax help
832  if( dlg.ShowQuasiModal() != wxID_OK || NoPrintableChars( textItem->GetText() ) )
833  {
834  delete textItem;
835  return nullptr;
836  }
837 
838  m_lastTextBold = textItem->IsBold();
839  m_lastTextItalic = textItem->IsItalic();
841 
842  if( textItem->Type() == SCH_GLOBAL_LABEL_T || textItem->Type() == SCH_HIER_LABEL_T )
843  m_lastGlobalLabelShape = textItem->GetShape();
844 
845  return textItem;
846 }
847 
848 
850 {
851  if( !aSheet->GetScreen() )
852  return nullptr;
853 
854  for( EDA_ITEM* item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
855  {
856  SCH_HIERLABEL* label = static_cast<SCH_HIERLABEL*>( item );
857 
858  /* A global label has been found: check if there a corresponding sheet label. */
859  if( !aSheet->HasPin( label->GetText() ) )
860  return label;
861  }
862 
863  return nullptr;
864 }
865 
866 
868 {
869  SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
870  wxString text;
871  SCH_SHEET_PIN* sheetPin;
872 
873  if( aLabel )
874  {
875  text = aLabel->GetText();
876  m_lastSheetPinType = aLabel->GetShape();
877  }
878 
879  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
880  sheetPin->SetFlags( IS_NEW );
881  sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
882  sheetPin->SetShape( m_lastSheetPinType );
883 
884  if( !aLabel )
885  {
886  DIALOG_SHEET_PIN_PROPERTIES dlg( m_frame, sheetPin );
887 
888  if( dlg.ShowModal() != wxID_OK || NoPrintableChars( sheetPin->GetText() ) )
889  {
890  delete sheetPin;
891  return nullptr;
892  }
893  }
894 
895  m_lastSheetPinType = sheetPin->GetShape();
896 
897  sheetPin->SetPosition( (wxPoint) getViewControls()->GetCursorPosition() );
898 
899  return sheetPin;
900 }
901 
902 
904 {
905  SCH_ITEM* item = nullptr;
907  EE_GRID_HELPER grid( m_toolMgr );
908  if( m_inTwoClickPlace )
909  return 0;
910  else
911  m_inTwoClickPlace = true;
912 
913  bool isText = aEvent.IsAction( &EE_ACTIONS::placeSchematicText );
914  bool isGlobalLabel = aEvent.IsAction( &EE_ACTIONS::placeGlobalLabel );
915  bool isHierLabel = aEvent.IsAction( &EE_ACTIONS::placeHierLabel );
916  bool isNetLabel = aEvent.IsAction( &EE_ACTIONS::placeLabel );
917  bool isSheetPin = aEvent.IsAction( &EE_ACTIONS::importSheetPin );
918  int snapLayer = isText ? LAYER_GRAPHICS : LAYER_CONNECTABLE;
919 
921  controls->ShowCursor( true );
922 
923  std::string tool = aEvent.GetCommandStr().get();
924  m_frame->PushTool( tool );
925  Activate();
926 
927  // Prime the pump
928  // If the tool isn't being re-activated
929  if( aEvent.HasPosition() || ( !aEvent.IsReactivate()
930  && ( isText || isGlobalLabel || isHierLabel || isNetLabel ) ) )
931  {
933  }
934 
935  auto setCursor =
936  [&]()
937  {
938  if( item )
940  else if( isText )
942  else if( isGlobalLabel )
944  else if( isNetLabel )
946  else if( isHierLabel )
948  else
950  };
951 
952  // Set initial cursor
953  setCursor();
954 
955  // Main loop: keep receiving events
956  while( TOOL_EVENT* evt = Wait() )
957  {
958  setCursor();
959  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
960  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->Modifier( MD_ALT ) );
961 
962  VECTOR2I cursorPos = evt->IsPrime() ? evt->Position() : controls->GetMousePosition();
963  cursorPos = grid.BestSnapAnchor( cursorPos, snapLayer, item );
964  controls->ForceCursorPosition( true, cursorPos );
965 
966  auto cleanup =
967  [&] ()
968  {
970  m_view->ClearPreview();
971  delete item;
972  item = nullptr;
973  };
974 
975  if( evt->IsCancelInteractive() )
976  {
977  if( item )
978  {
979  cleanup();
980  }
981  else
982  {
983  m_frame->PopTool( tool );
984  break;
985  }
986  }
987  else if( evt->IsActivate() )
988  {
989  if( item && evt->IsMoveTool() )
990  {
991  // we're already moving our own item; ignore the move tool
992  evt->SetPassEvent( false );
993  continue;
994  }
995 
996  if( item )
997  cleanup();
998 
999  if( evt->IsPointEditor() )
1000  {
1001  // don't exit (the point editor runs in the background)
1002  }
1003  else if( evt->IsMoveTool() )
1004  {
1005  break;
1006  }
1007  else
1008  {
1009  m_frame->PopTool( tool );
1010  break;
1011  }
1012  }
1013  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1014  {
1015  // First click creates...
1016  if( !item )
1017  {
1019 
1020  if( isText )
1021  {
1022  item = createNewText( cursorPos, LAYER_NOTES );
1023  }
1024  else if( isGlobalLabel )
1025  {
1026  item = createNewText( cursorPos, LAYER_GLOBLABEL );
1027  }
1028  else if( isHierLabel )
1029  {
1030  item = createNewText( cursorPos, LAYER_HIERLABEL );
1031  }
1032  else if( isNetLabel )
1033  {
1034  item = createNewText( cursorPos, LAYER_LOCLABEL );
1035  }
1036  else if( isSheetPin )
1037  {
1038  EDA_ITEM* i;
1039  SCH_HIERLABEL* label = nullptr;
1040  SCH_SHEET* sheet = nullptr;
1041 
1042  if( m_selectionTool->SelectPoint( cursorPos, EE_COLLECTOR::SheetsOnly, &i ) )
1043  sheet = dynamic_cast<SCH_SHEET*>( i );
1044 
1045  if( !sheet )
1046  {
1047  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1048  m_statusPopup->SetText( _( "Click over a sheet." ) );
1049  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1050  m_statusPopup->PopupFor( 2000 );
1051  item = nullptr;
1052  }
1053  else
1054  {
1055  label = importHierLabel( sheet );
1056 
1057  if( !label )
1058  {
1059  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
1060  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
1061  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
1062  m_statusPopup->PopupFor( 2000 );
1063  item = nullptr;
1064  }
1065  else
1066  {
1067  item = createSheetPin( sheet, label );
1068  }
1069  }
1070  }
1071 
1072  // Restore cursor after dialog
1073  controls->WarpCursor( controls->GetCursorPosition(), true );
1074 
1075  if( item )
1076  {
1077  item->SetFlags( IS_NEW | IS_MOVED );
1078  m_view->ClearPreview();
1079  m_view->AddToPreview( item->Clone() );
1080  m_selectionTool->AddItemToSel( item );
1081 
1082  // update the cursor so it looks correct before another event
1083  setCursor();
1084  }
1085 
1086  controls->SetCursorPosition( cursorPos, false );
1087  }
1088 
1089  // ... and second click places:
1090  else
1091  {
1092  item->ClearFlags( IS_MOVED );
1093  item->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1094 
1096  item = nullptr;
1097 
1098  m_view->ClearPreview();
1099  }
1100  }
1101  else if( evt->IsClick( BUT_RIGHT ) )
1102  {
1103  // Warp after context menu only if dragging...
1104  if( !item )
1106 
1108  }
1109  else if( item && evt->IsSelectionEvent() )
1110  {
1111  // This happens if our text was replaced out from under us by ConvertTextType()
1112  EE_SELECTION& selection = m_selectionTool->GetSelection();
1113 
1114  if( selection.GetSize() == 1 )
1115  {
1116  item = (SCH_ITEM*) selection.Front();
1117  m_view->ClearPreview();
1118  m_view->AddToPreview( item->Clone() );
1119  }
1120  else
1121  {
1122  item = nullptr;
1123  }
1124  }
1125  else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1126  {
1127  static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint) cursorPos );
1128  m_view->ClearPreview();
1129  m_view->AddToPreview( item->Clone() );
1130  }
1131  else
1132  {
1133  evt->SetPassEvent();
1134  }
1135 
1136  // Enable autopanning and cursor capture only when there is a footprint to be placed
1137  controls->SetAutoPan( item != nullptr );
1138  controls->CaptureCursor( item != nullptr );
1139  }
1140 
1142  controls->ForceCursorPosition( false );
1143  m_inTwoClickPlace = false;
1144  return 0;
1145 }
1146 
1147 
1149 {
1150  SCH_SHEET* sheet = nullptr;
1151 
1152  if( m_inDrawSheet )
1153  return 0;
1154  else
1155  m_inDrawSheet = true;
1156 
1158  getViewControls()->ShowCursor( true );
1159 
1160  std::string tool = aEvent.GetCommandStr().get();
1161  m_frame->PushTool( tool );
1162  Activate();
1163 
1164  // Prime the pump
1165  if( aEvent.HasPosition() )
1167 
1168  auto setCursor =
1169  [&]()
1170  {
1172  };
1173 
1174  // Set initial cursor
1175  setCursor();
1176 
1177  // Main loop: keep receiving events
1178  while( TOOL_EVENT* evt = Wait() )
1179  {
1180  setCursor();
1181 
1182  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
1183 
1184  auto cleanup =
1185  [&] ()
1186  {
1188  m_view->ClearPreview();
1189  delete sheet;
1190  sheet = nullptr;
1191  };
1192 
1193  if( evt->IsCancelInteractive() )
1194  {
1195  if( sheet )
1196  {
1197  cleanup();
1198  }
1199  else
1200  {
1201  m_frame->PopTool( tool );
1202  break;
1203  }
1204  }
1205  else if( evt->IsActivate() )
1206  {
1207  if( sheet && evt->IsMoveTool() )
1208  {
1209  // we're already drawing our own item; ignore the move tool
1210  evt->SetPassEvent( false );
1211  continue;
1212  }
1213 
1214  if( sheet )
1215  cleanup();
1216 
1217  if( evt->IsPointEditor() )
1218  {
1219  // don't exit (the point editor runs in the background)
1220  }
1221  else if( evt->IsMoveTool() )
1222  {
1223  // leave ourselves on the stack so we come back after the move
1224  break;
1225  }
1226  else
1227  {
1228  m_frame->PopTool( tool );
1229  break;
1230  }
1231  }
1232  else if( !sheet && ( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) ) )
1233  {
1235 
1237 
1238  sheet = new SCH_SHEET( m_frame->GetCurrentSheet().Last(),
1239  static_cast<wxPoint>( cursorPos ) );
1240  sheet->SetFlags( IS_NEW | IS_RESIZED );
1241  sheet->SetScreen( NULL );
1245  sheet->GetFields()[ SHEETNAME ].SetText( "Untitled Sheet" );
1246  sheet->GetFields()[ SHEETFILENAME ].SetText( "untitled." + KiCadSchematicFileExtension );
1247  sizeSheet( sheet, cursorPos );
1248 
1249  m_view->ClearPreview();
1250  m_view->AddToPreview( sheet->Clone() );
1251  }
1252  else if( sheet && ( evt->IsClick( BUT_LEFT )
1253  || evt->IsDblClick( BUT_LEFT )
1254  || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
1255  {
1256  m_view->ClearPreview();
1257  getViewControls()->SetAutoPan( false );
1258  getViewControls()->CaptureCursor( false );
1259 
1260  if( m_frame->EditSheetProperties( static_cast<SCH_SHEET*>( sheet ),
1261  &m_frame->GetCurrentSheet(), nullptr ) )
1262  {
1263  sheet->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
1264 
1265  m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), sheet, false );
1267  m_selectionTool->AddItemToSel( sheet );
1268  }
1269  else
1270  {
1271  delete sheet;
1272  }
1273 
1274  sheet = nullptr;
1275  }
1276  else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
1277  {
1278  sizeSheet( sheet, cursorPos );
1279  m_view->ClearPreview();
1280  m_view->AddToPreview( sheet->Clone() );
1281  }
1282  else if( evt->IsClick( BUT_RIGHT ) )
1283  {
1284  // Warp after context menu only if dragging...
1285  if( !sheet )
1287 
1289  }
1290  else
1291  {
1292  evt->SetPassEvent();
1293  }
1294 
1295  // Enable autopanning and cursor capture only when there is a sheet to be placed
1296  getViewControls()->SetAutoPan( sheet != nullptr );
1297  getViewControls()->CaptureCursor( sheet != nullptr );
1298  }
1299 
1301  m_inDrawSheet = false;
1302  return 0;
1303 }
1304 
1305 
1307 {
1308  wxPoint pos = aSheet->GetPosition();
1309  wxPoint size = (wxPoint) aPos - pos;
1310 
1311  size.x = std::max( size.x, MIN_SHEET_WIDTH );
1312  size.y = std::max( size.y, MIN_SHEET_HEIGHT );
1313 
1314  wxPoint grid = m_frame->GetNearestGridPosition( pos + size );
1315  aSheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
1316 }
1317 
1318 
1320 {
1334 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:219
bool IsBold() const
Definition: eda_text.h:190
static TOOL_ACTION properties
Definition: ee_actions.h:118
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
The functions below are not yet implemented - their interface may change.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
static TOOL_ACTION finishSheet
Definition: ee_actions.h:95
bool Init() override
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))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
static TOOL_ACTION activatePointEditor
Definition: actions.h:171
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:58
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:302
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:369
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1552
Extension of STATUS_POPUP for displaying a single line text.
Definition: status_popup.h:79
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:125
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:85
void SetItalic(bool isItalic)
Definition: eda_text.h:186
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION placeJunction
Definition: ee_actions.h:81
void RecacheAllItems()
Rebuild GAL display lists.
Definition: view.cpp:1372
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:154
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.
Definition: sch_symbol.cpp:355
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)
Run the specified action.
Definition: tool_manager.h:141
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, int aLayer, SCH_ITEM *aDraggedItem)
bool m_lastTextItalic
Re-entrancy guards.
#define IS_RESIZED
Item being resized.
Definition: eda_item.h:107
void SetPosition(const wxPoint &aPosition) override
Definition: sch_symbol.h:682
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.
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:82
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:244
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:49
static TOOL_ACTION mirrorH
Definition: ee_actions.h:117
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
static TOOL_ACTION importSingleSheetPin
Definition: ee_actions.h:185
bool IsValid() const
Check if this LID_ID is valid.
Definition: lib_id.h:168
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:285
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))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:43
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:165
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
static TOOL_ACTION mirrorV
Definition: ee_actions.h:116
static TOOL_ACTION rotateCW
Definition: ee_actions.h:114
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:77
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:70
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:182
void SetBorderWidth(int aWidth)
Definition: sch_sheet.h:291
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:42
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:65
bool IsItalic() const
Definition: eda_text.h:187
EE_SELECTION & GetSelection()
Return the set of currently selected items.
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:86
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:115
int GetUnit() const
Definition: sch_symbol.h:237
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:166
AUTOPLACE_FIELDS m_AutoplaceFields
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:297
static TOOL_ACTION placePower
Definition: ee_actions.h:76
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:78
#define NULL
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force 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
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:466
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:88
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_symbol.cpp:208
Generic, UI-independent tool event.
Definition: tool_event.h:173
static TOOL_ACTION placeImage
Definition: ee_actions.h:90
void ClearPreview()
Definition: view.cpp:1530
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
Define a library symbol object.
Definition: lib_symbol.h:93
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:294
Definition of file extensions used in Kicad.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
An interface for classes handling user events controlling the view behavior such as zooming,...
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:176
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
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:87
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:316
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:54
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:75
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:73
wxPoint GetPosition() const override
Definition: sch_sheet.h:572
#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
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn 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
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
Definition: seg.h:41
std::vector< PICKED_SYMBOL > m_powerHistoryList
static TOOL_ACTION placeLabel
Definition: ee_actions.h:83
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
void SetPosition(const wxPoint &aPosition) override
Definition: sch_sheet.h:206
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Definition: sch_symbol.cpp:561
PINSHEETLABEL_SHAPE
Definition: sch_text.h:151
SCH_SHEET & Root() const
Definition: schematic.h:116
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:148
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)
This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before c...
SCH_HIERLABEL * importHierLabel(SCH_SHEET *aSheet)
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
#define _(s)
Definition: 3d_actions.cpp:33
EE_RTREE & Items()
Definition: sch_screen.h:162
void VetoContextMenuMouseWarp()
Disable mouse warping after the current context menu is closed.
Definition: tool_manager.h:428
SCH_TEXT * createNewText(const VECTOR2I &aPosition, int aType)
Get the next queued text item.
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:80
const std::string KiCadSchematicFileExtension
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the component.
Schematic symbol object.
Definition: sch_symbol.h:79
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:89
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:44
These settings were stored in SCH_BASE_FRAME previously.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool IsReactivate() const
Definition: tool_event.h:273
Class for a wire to bus entry.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:203
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()
Run the tool.
WX_INFOBAR * GetInfoBar()
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
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
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:308
bool HasPosition() const
Definition: tool_event.h:261
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:516
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
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:248
bool NoPrintableChars(wxString aString)
Return true if the string is empty or contains only whitespace.
Definition: string.cpp:370
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:325
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:84
LIB_ID LibId
Definition: sch_screen.h:82
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
Definition: tool_manager.h:267
void SetBold(bool aBold)
Definition: eda_text.h:189
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.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
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
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:284
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
static TOOL_ACTION refreshPreview
Definition: actions.h:109
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:203
int DrawSheet(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorClick
Definition: actions.h:126
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:235
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:792
void sizeSheet(SCH_SHEET *aSheet, VECTOR2I aPos)
Set up handlers for various events.
wxPoint GetPosition() const override
wxPoint GetEndPoint() const
Definition: sch_line.h:97
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup