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 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 <sch_view.h>
31 #include <class_draw_panel_gal.h>
32 #include <project.h>
33 #include <id.h>
34 #include <eeschema_id.h>
35 #include <confirm.h>
36 #include <view/view_group.h>
37 #include <view/view_controls.h>
38 #include <view/view.h>
39 #include <tool/tool_manager.h>
40 #include <sch_component.h>
41 #include <sch_no_connect.h>
42 #include <sch_line.h>
43 #include <sch_junction.h>
44 #include <sch_bus_entry.h>
45 #include <sch_text.h>
46 #include <sch_sheet.h>
47 #include <sch_bitmap.h>
48 #include <class_library.h>
49 
50 
52  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.InteractiveDrawing" )
53 {
54 }
55 
56 
58 {
60 
61  auto belowRootSheetCondition = [] ( const SELECTION& aSel ) {
62  return g_CurrentSheet->Last() != g_RootSheet;
63  };
64 
65  auto& ctxMenu = m_menu.GetMenu();
66  ctxMenu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
67 
68  return true;
69 }
70 
71 
72 // History lists for PlaceComponent()
75 
76 
78 {
79  SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
80  SCHLIB_FILTER filter;
81  SCH_BASE_FRAME::HISTORY_LIST* historyList = nullptr;
82 
83  if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
84  historyList = &s_SymbolHistoryList;
85  else if (aEvent.IsAction( &EE_ACTIONS::placePower ) )
86  {
87  historyList = &s_PowerHistoryList;
88  filter.FilterPowerParts( true );
89  }
90  else
91  wxFAIL_MSG( "PlaceCompontent(): unexpected request" );
92 
93  getViewControls()->ShowCursor( true );
94 
95  // If a component was passed in get it ready for placement.
96  if( component )
97  {
98  component->SetFlags( IS_NEW | IS_MOVED );
99 
101  m_selectionTool->AddItemToSel( component );
102  }
103 
104  std::string tool = aEvent.GetCommandStr().get();
105  m_frame->PushTool( tool );
106  Activate();
107 
108  // Prime the pump
109  if( component )
110  {
111  getViewControls()->WarpCursor( getViewControls()->GetMousePosition( false ) );
113  }
114  else if( aEvent.HasPosition() )
116 
117  // Main loop: keep receiving events
118  while( TOOL_EVENT* evt = Wait() )
119  {
120  m_frame->GetCanvas()->SetCurrentCursor( component ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
121  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
122 
123  auto cleanup = [&] () {
125  m_view->ClearPreview();
126  delete component;
127  component = nullptr;
128  };
129 
130  if( evt->IsCancelInteractive() )
131  {
132  if( component )
133  cleanup();
134  else
135  {
136  m_frame->PopTool( tool );
137  break;
138  }
139  }
140  else if( evt->IsActivate() )
141  {
142  if( component )
143  cleanup();
144 
145  if( evt->IsMoveTool() )
146  {
147  // leave ourselves on the stack so we come back after the move
148  break;
149  }
150  else
151  {
152  m_frame->PopTool( tool );
153  break;
154  }
155  }
156  else if( evt->IsClick( BUT_LEFT ) )
157  {
158  if( !component )
159  {
161 
162  // Pick the module to be placed
163  auto sel = m_frame->SelectCompFromLibTree( &filter, *historyList, true, 1, 1,
165 
166  // Restore cursor after dialog
167  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
168 
169  LIB_PART* part = sel.LibId.IsValid() ? m_frame->GetLibPart( sel.LibId ) : nullptr;
170 
171  if( !part )
172  continue;
173 
174  component = new SCH_COMPONENT( *part, g_CurrentSheet, sel, (wxPoint) cursorPos );
175  component->SetFlags( IS_NEW | IS_MOVED );
176 
177  // Be sure the link to the corresponding LIB_PART is OK:
178  component->Resolve( *m_frame->Prj().SchSymbolLibTable() );
179 
180  if( m_frame->GetAutoplaceFields() )
181  component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
182 
183  m_frame->SaveCopyForRepeatItem( component );
184 
185  m_view->ClearPreview();
186  m_view->AddToPreview( component->Clone() );
187  m_selectionTool->AddItemToSel( component );
188  }
189  else
190  {
191  m_frame->AddItemToScreenAndUndoList( component );
192  component = nullptr;
193 
194  m_view->ClearPreview();
195  }
196  }
197  else if( evt->IsClick( BUT_RIGHT ) )
198  {
199  // Warp after context menu only if dragging...
200  if( !component )
202 
204  }
205  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
206  {
207  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
208  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
209  {
210  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
211 
212  if( component )
213  {
214  m_frame->SelectUnit( component, unit );
216  }
217  }
218  }
219  else if( component && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
220  {
221  component->SetPosition( (wxPoint)cursorPos );
222  m_view->ClearPreview();
223  m_view->AddToPreview( component->Clone() );
224  }
225  else
226  evt->SetPassEvent();
227 
228  // Enable autopanning and cursor capture only when there is a module to be placed
229  getViewControls()->SetAutoPan( component != nullptr );
230  getViewControls()->CaptureCursor( component != nullptr );
231  }
232 
233  return 0;
234 }
235 
236 
238 {
239  SCH_BITMAP* image = aEvent.Parameter<SCH_BITMAP*>();
240  bool immediateMode = image;
241  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
242 
244  getViewControls()->ShowCursor( true );
245 
246  // Add all the drawable parts to preview
247  if( image )
248  {
249  image->SetPosition( (wxPoint)cursorPos );
250  m_view->ClearPreview();
251  m_view->AddToPreview( image->Clone() );
252  }
253 
254  std::string tool = aEvent.GetCommandStr().get();
255  m_frame->PushTool( tool );
256  Activate();
257 
258  // Prime the pump
259  if( image )
261  else if( aEvent.HasPosition() )
263 
264  // Main loop: keep receiving events
265  while( TOOL_EVENT* evt = Wait() )
266  {
267  m_frame->GetCanvas()->SetCurrentCursor( image ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
268  cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
269 
270  auto cleanup = [&] () {
272  m_view->ClearPreview();
273  delete image;
274  image = nullptr;
275  };
276 
277  if( evt->IsCancelInteractive() )
278  {
279  if( image )
280  cleanup();
281  else
282  {
283  m_frame->PopTool( tool );
284  break;
285  }
286 
287  if( immediateMode )
288  {
289  m_frame->PopTool( tool );
290  break;
291  }
292  }
293  else if( evt->IsActivate() )
294  {
295  if( image )
296  cleanup();
297 
298  if( evt->IsMoveTool() )
299  {
300  // leave ourselves on the stack so we come back after the move
301  break;
302  }
303  else
304  {
305  m_frame->PopTool( tool );
306  break;
307  }
308  }
309  else if( evt->IsClick( BUT_LEFT ) )
310  {
311  if( !image )
312  {
314  wxFileDialog dlg( m_frame, _( "Choose Image" ), wxEmptyString, wxEmptyString,
315  _( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN );
316 
317  if( dlg.ShowModal() != wxID_OK )
318  continue;
319 
320  // Restore cursor after dialog
321  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
322 
323  wxString fullFilename = dlg.GetPath();
324 
325  if( wxFileExists( fullFilename ) )
326  image = new SCH_BITMAP( (wxPoint)cursorPos );
327 
328  if( !image || !image->ReadImageFile( fullFilename ) )
329  {
330  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
331  delete image;
332  image = nullptr;
333  continue;
334  }
335 
336  image->SetFlags( IS_NEW | IS_MOVED );
337 
338  m_frame->SaveCopyForRepeatItem( image );
339 
340  m_view->ClearPreview();
341  m_view->AddToPreview( image->Clone() );
342  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
343 
344  m_selectionTool->AddItemToSel( image );
345 
346  getViewControls()->SetCursorPosition( cursorPos, false );
347  }
348  else
349  {
351  image = nullptr;
353 
354  m_view->ClearPreview();
355 
356  if( immediateMode )
357  {
358  m_frame->PopTool( tool );
359  break;
360  }
361  }
362  }
363  else if( evt->IsClick( BUT_RIGHT ) )
364  {
365  // Warp after context menu only if dragging...
366  if( !image )
368 
370  }
371  else if( image && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
372  {
373  image->SetPosition( (wxPoint)cursorPos );
374  m_view->ClearPreview();
375  m_view->AddToPreview( image->Clone() );
376  m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
377  }
378  else
379  evt->SetPassEvent();
380 
381  // Enable autopanning and cursor capture only when there is a module to be placed
382  getViewControls()->SetAutoPan( image != nullptr );
383  getViewControls()->CaptureCursor( image != nullptr );
384  }
385 
386  return 0;
387 }
388 
389 
391 {
392  wxPoint cursorPos;
393  KICAD_T type = aEvent.Parameter<KICAD_T>();
394 
395  auto itemFactory = [&] () -> SCH_ITEM* {
396  switch( type )
397  {
398  case SCH_NO_CONNECT_T:
399  return new SCH_NO_CONNECT( cursorPos );
400  case SCH_JUNCTION_T:
401  return new SCH_JUNCTION( cursorPos );
403  return new SCH_BUS_WIRE_ENTRY( cursorPos, g_lastBusEntryShape );
404  case SCH_BUS_BUS_ENTRY_T:
405  return new SCH_BUS_BUS_ENTRY( cursorPos, g_lastBusEntryShape );
406  default:
407  return nullptr;
408  }
409  };
410 
411  if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
412  {
413  EE_SELECTION& selection = m_selectionTool->GetSelection();
414  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( selection.Front() );
415 
416  if( wire )
417  {
418  SEG seg( wire->GetStartPoint(), wire->GetEndPoint() );
419  VECTOR2I nearest = seg.NearestPoint( getViewControls()->GetCursorPosition() );
420  getViewControls()->SetCrossHairCursorPosition( nearest, false );
421  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
422  }
423  }
424 
425  if( aEvent.IsAction( &EE_ACTIONS::placeSheetPin ) )
426  type = SCH_SHEET_PIN_T;
427 
429  getViewControls()->ShowCursor( true );
430  getViewControls()->SetSnapping( true );
431 
432  SCH_ITEM* previewItem = itemFactory();
433  m_view->ClearPreview();
434  m_view->AddToPreview( previewItem->Clone() );
435 
436  std::string tool = aEvent.GetCommandStr().get();
437  m_frame->PushTool( tool );
438  Activate();
439 
440  // Prime the pump
441  if( aEvent.HasPosition() )
443 
444  // Main loop: keep receiving events
445  while( TOOL_EVENT* evt = Wait() )
446  {
447  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
448  cursorPos = (wxPoint) getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
449 
450  if( evt->IsCancelInteractive() )
451  {
452  m_frame->PopTool( tool );
453  break;
454  }
455  else if( evt->IsActivate() )
456  {
457  if( evt->IsMoveTool() )
458  {
459  // leave ourselves on the stack so we come back after the move
460  break;
461  }
462  else
463  {
464  m_frame->PopTool( tool );
465  break;
466  }
467  }
468  else if( evt->IsClick( BUT_LEFT ) )
469  {
470  if( !m_frame->GetScreen()->GetItem( cursorPos, 0, type ) )
471  {
472  if( type == SCH_JUNCTION_T )
473  m_frame->AddJunction( cursorPos );
474  else
475  {
476  SCH_ITEM* newItem = itemFactory();
477  newItem->SetFlags( IS_NEW );
478 
480  m_frame->SaveCopyForRepeatItem( newItem );
481 
484  m_frame->OnModify();
485  }
486  }
487  }
488  else if( evt->IsClick( BUT_RIGHT ) )
489  {
491  }
492  else if( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() )
493  {
494  previewItem->SetPosition( (wxPoint)cursorPos );
495  m_view->ClearPreview();
496  m_view->AddToPreview( previewItem->Clone() );
497  }
498  else
499  evt->SetPassEvent();
500  }
501 
502  delete previewItem;
503  m_view->ClearPreview();
504 
505  return 0;
506 }
507 
508 
510 {
511  EDA_ITEM* item = nullptr;
512  bool importMode = aEvent.IsAction( &EE_ACTIONS::importSheetPin );
513  KICAD_T type = aEvent.Parameter<KICAD_T>();
514 
516  getViewControls()->ShowCursor( true );
517 
518  std::string tool = aEvent.GetCommandStr().get();
519  m_frame->PushTool( tool );
520  Activate();
521 
522  // Prime the pump
523  if( aEvent.HasPosition() )
525 
526  // Main loop: keep receiving events
527  while( TOOL_EVENT* evt = Wait() )
528  {
529  m_frame->GetCanvas()->SetCurrentCursor( item ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
530  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
531 
532  auto cleanup = [&] () {
534  m_view->ClearPreview();
535  delete item;
536  item = nullptr;
537  };
538 
539  if( evt->IsCancelInteractive() )
540  {
541  if( item )
542  cleanup();
543  else
544  {
545  m_frame->PopTool( tool );
546  break;
547  }
548  }
549  else if( evt->IsActivate() )
550  {
551  if( item )
552  cleanup();
553 
554  if( evt->IsPointEditor() )
555  {
556  // don't exit (the point editor runs in the background)
557  }
558  else if( evt->IsMoveTool() )
559  {
560  // leave ourselves on the stack so we come back after the move
561  break;
562  }
563  else
564  {
565  m_frame->PopTool( tool );
566  break;
567  }
568  }
569  else if( evt->IsClick( BUT_LEFT ) )
570  {
571  // First click creates...
572  if( !item )
573  {
575 
576  switch( type )
577  {
578  case SCH_LABEL_T:
580  break;
581  case SCH_HIER_LABEL_T:
583  break;
584  case SCH_GLOBAL_LABEL_T:
586  break;
587  case SCH_TEXT_T:
588  item = m_frame->CreateNewText( LAYER_NOTES );
589  break;
590  case SCH_SHEET_PIN_T:
591  {
592  SCH_HIERLABEL* label = nullptr;
593  SCH_SHEET* sheet = (SCH_SHEET*) m_selectionTool->SelectPoint( cursorPos,
595  if( !sheet )
596  {
597  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
598  m_statusPopup->SetText( _( "Click over a sheet." ) );
599  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
600  m_statusPopup->PopupFor( 2000 );
601  break;
602  }
603 
604  if( importMode )
605  {
606  label = m_frame->ImportHierLabel( sheet );
607 
608  if( !label )
609  {
610  m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
611  m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
612  m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
613  m_statusPopup->PopupFor( 2000 );
614  break;
615  }
616  }
617 
618  item = m_frame->CreateSheetPin( sheet, label );
619  break;
620  }
621  default:
622  break;
623  }
624 
625  // Restore cursor after dialog
626  getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
627 
628  if( item )
629  {
630  item->SetFlags( IS_NEW | IS_MOVED );
631  m_view->ClearPreview();
632  m_view->AddToPreview( item->Clone() );
633  m_selectionTool->AddItemToSel( item );
634  }
635 
636  getViewControls()->SetCursorPosition( cursorPos, false );
637  }
638 
639  // ... and second click places:
640  else
641  {
642  item->ClearFlags( IS_MOVED );
644  item = m_frame->GetNextNewText();
645 
646  if( item )
647  {
649  item->SetFlags( IS_NEW | IS_MOVED );
650  m_view->ClearPreview();
651  m_view->AddToPreview( item->Clone() );
652  m_selectionTool->AddItemToSel( item );
653  }
654  else
655  {
656  m_view->ClearPreview();
657  }
658  }
659  }
660  else if( evt->IsClick( BUT_RIGHT ) )
661  {
662  // Warp after context menu only if dragging...
663  if( !item )
665 
667  }
668  else if( item && evt->IsSelectionEvent() )
669  {
670  // This happens if our text was replaced out from under us by ConvertTextType()
671  EE_SELECTION& selection = m_selectionTool->GetSelection();
672 
673  if( selection.GetSize() == 1 )
674  {
675  item = (SCH_ITEM*) selection.Front();
676  m_view->ClearPreview();
677  m_view->AddToPreview( item->Clone() );
678  }
679  else
680  item = nullptr;
681  }
682  else if( item && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
683  {
684  static_cast<SCH_ITEM*>( item )->SetPosition( (wxPoint) cursorPos );
685  m_view->ClearPreview();
686  m_view->AddToPreview( item->Clone() );
687  }
688  else
689  evt->SetPassEvent();
690 
691  // Enable autopanning and cursor capture only when there is a module to be placed
692  getViewControls()->SetAutoPan( item != nullptr );
693  getViewControls()->CaptureCursor( item != nullptr );
694  }
695 
696  return 0;
697 }
698 
699 
701 {
703  SCH_SHEET* sheet = nullptr;
704 
706  getViewControls()->ShowCursor( true );
707 
708  std::string tool = aEvent.GetCommandStr().get();
709  m_frame->PushTool( tool );
710  Activate();
711 
712  // Prime the pump
713  if( aEvent.HasPosition() )
715 
716  // Main loop: keep receiving events
717  while( TOOL_EVENT* evt = Wait() )
718  {
719  if( !pointEditor->HasPoint() )
720  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
721 
722  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !evt->Modifier( MD_ALT ) );
723 
724  auto cleanup = [&] () {
726  m_view->ClearPreview();
727  delete sheet;
728  sheet = nullptr;
729  };
730 
731  if( evt->IsCancelInteractive() )
732  {
733  if( sheet )
734  cleanup();
735  else
736  {
737  m_frame->PopTool( tool );
738  break;
739  }
740  }
741  else if( evt->IsActivate() )
742  {
743  if( sheet )
744  cleanup();
745 
746  if( evt->IsPointEditor() )
747  {
748  // don't exit (the point editor runs in the background)
749  }
750  else if( evt->IsMoveTool() )
751  {
752  // leave ourselves on the stack so we come back after the move
753  break;
754  }
755  else
756  {
757  m_frame->PopTool( tool );
758  break;
759  }
760  }
761 
762  else if( evt->IsClick( BUT_LEFT ) && !sheet )
763  {
765 
766  sheet = new SCH_SHEET( (wxPoint) cursorPos );
767  sheet->SetFlags( IS_NEW | IS_RESIZED );
768  sheet->SetTimeStamp( GetNewTimeStamp() );
769  sheet->SetParent( m_frame->GetScreen() );
770  sheet->SetScreen( NULL );
771  sizeSheet( sheet, cursorPos );
772 
773  m_view->ClearPreview();
774  m_view->AddToPreview( sheet->Clone() );
775  }
776 
777  else if( sheet && ( evt->IsClick( BUT_LEFT )
778  || evt->IsAction( &EE_ACTIONS::finishSheet ) ) )
779  {
780  m_view->ClearPreview();
781 
782  if( m_frame->EditSheet( (SCH_SHEET*)sheet, g_CurrentSheet, nullptr ) )
783  {
785  m_selectionTool->AddItemToSel( sheet );
786  }
787  else
788  {
789  delete sheet;
790  }
791 
792  sheet = nullptr;
793  }
794 
795  else if( sheet && ( evt->IsAction( &ACTIONS::refreshPreview ) || evt->IsMotion() ) )
796  {
797  sizeSheet( sheet, cursorPos );
798  m_view->ClearPreview();
799  m_view->AddToPreview( sheet->Clone() );
800  }
801 
802  else if( evt->IsClick( BUT_RIGHT ) )
803  {
804  // Warp after context menu only if dragging...
805  if( !sheet )
807 
809  }
810  else
811  evt->SetPassEvent();
812 
813  // Enable autopanning and cursor capture only when there is a sheet to be placed
814  getViewControls()->SetAutoPan( sheet != nullptr );
815  getViewControls()->CaptureCursor( sheet != nullptr);
816  }
817 
818  return 0;
819 }
820 
821 
823 {
824  wxPoint pos = aSheet->GetPosition();
825  wxPoint size = (wxPoint) aPos - pos;
826 
827  size.x = std::max( size.x, MIN_SHEET_WIDTH );
828  size.y = std::max( size.y, MIN_SHEET_HEIGHT );
829 
830  wxPoint grid = m_frame->GetNearestGridPosition( pos + size );
831  aSheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
832 }
833 
834 
836 {
851 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
Class for a bus to bus entry.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
int TwoClickPlace(const TOOL_EVENT &aEvent)
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: sch_view.cpp:155
static TOOL_ACTION finishSheet
Definition: ee_actions.h:101
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
int PlaceComponent(const TOOL_EVENT &aEvent)
SCH_TEXT * CreateNewText(int aType)
Definition: edit_label.cpp:62
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
static TOOL_ACTION activatePointEditor
Definition: actions.h:158
wxPoint GetStartPoint() const
Definition: sch_line.h:90
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
char g_lastBusEntryShape
This file is part of the common library.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
VIEW_CONTROLS class definition.
bool HasPoint()
Indicates the cursor is over an edit point.
bool Resolve(PART_LIBS *aLibs)
Assigns the current LIB_PART from aLibs which this symbol is based on.
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
bool GetShowFootprintPreviews() const
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:90
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION placeJunction
Definition: ee_actions.h:85
void RecacheAllItems()
Function RecacheAllItems() Rebuilds GAL display lists.
Definition: view.cpp:1402
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
std::vector< COMPONENT_SELECTION > HISTORY_LIST
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
static SCH_BASE_FRAME::HISTORY_LIST s_PowerHistoryList
Schematic editor (Eeschema) main window.
static TOOL_ACTION placeBusBusEntry
Definition: ee_actions.h:87
LIB_PART * GetLibPart(const LIB_ID &aLibId, bool aUseCacheLib=false, bool aShowErrorMsg=false)
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:86
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:45
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
bool GetAutoplaceFields() const
int PlaceImage(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
bool EditSheet(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:518
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:42
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
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:63
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:177
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:69
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
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:91
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
static TOOL_ACTION placePower
Definition: ee_actions.h:80
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:47
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
COMPONENT_SELECTION SelectCompFromLibTree(const SCHLIB_FILTER *aFilter, std::vector< COMPONENT_SELECTION > &aHistoryList, bool aUseLibBrowser, int aUnit, int aConvert, bool aShowFootprints, const LIB_ID *aHighlight=nullptr, bool aAllowFields=true)
Function SelectComponentFromLib Calls the library viewer to select component to import into schematic...
Definition: getpart.cpp:94
virtual void SetPosition(const wxPoint &aPosition)=0
Function SetPosition set the schematic item position to aPosition.
static TOOL_ACTION placeSheetPin
Definition: ee_actions.h:92
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
int SingleClickPlace(const TOOL_EVENT &aEvent)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:427
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:94
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.
Class TOOL_EVENT.
Definition: tool_event.h:168
static TOOL_ACTION placeImage
Definition: ee_actions.h:96
void ClearPreview()
Definition: sch_view.cpp:143
SCH_ITEM * GetItem(const wxPoint &aPosition, int aAccuracy=0, KICAD_T aType=SCH_LOCATE_ANY_T) const
Check aPosition within a distance of aAccuracy for items of type aFilter.
Definition: sch_screen.cpp:234
Define a library symbol object.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
VIEW_GROUP extends VIEW_ITEM by possibility of grouping items into a single object.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:93
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:79
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves the graphic crosshair cursor to the requested position expressed in world coordinates.
SCH_TEXT * GetNextNewText()
Gets the next queued text item.
Definition: edit_label.cpp:50
wxPoint GetPosition() const override
Function GetPosition.
Definition: sch_sheet.h:533
#define _(s)
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:206
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:204
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
Definition: seg.h:36
static TOOL_ACTION placeLabel
Definition: ee_actions.h:88
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:455
SCH_HIERLABEL * ImportHierLabel(SCH_SHEET *aSheet)
Import a hierarchical label with no attached sheet pin.
Definition: sheet.cpp:815
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Automatically orient all the fields in the component.
int AddItemToSel(const TOOL_EVENT &aEvent)
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
#define max(a, b)
Definition: auxiliary.h:86
Class EE_POINT_EDITOR.
void VetoContextMenuMouseWarp()
Disables mouse warping after the current context menu is closed.
Definition: tool_manager.h:372
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:84
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_bitmap.cpp:87
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:43
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:121
virtual void PopTool(const std::string &actionName)
Class for a wire to bus entry.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
void Activate()
Function Activate() Runs the tool.
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores an image file.
Definition: sch_bitmap.cpp:81
Class EE_TOOL_BASE.
Definition: ee_tool_base.h:50
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:257
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
EDA_ITEM * SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, bool *aSelectionCancelledFlag=NULL, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
Definitions of the SCH_TEXT class and derivatives for Eeschema.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
SCH_SHEET_PIN * CreateSheetPin(SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
Create a new SCH_SHEET_PIN object and add it to aSheet at the current cursor position.
Definition: sheet.cpp:779
void SetPosition(const wxPoint &aPosition) override
Function SetPosition set the schematic item position to aPosition.
Definition: sch_bitmap.h:136
void setTransitions() override
Sets up handlers for various events.
static TOOL_ACTION refreshPreview
Definition: actions.h:100
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false)=0
Moves cursor to the requested position expressed in world coordinates.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:182
int DrawSheet(const TOOL_EVENT &aEvent)
static TOOL_ACTION cursorClick
Definition: actions.h:114
static SCH_BASE_FRAME::HISTORY_LIST s_SymbolHistoryList
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:704
void sizeSheet(SCH_SHEET *aSheet, VECTOR2I aPos)
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:119
wxPoint GetEndPoint() const
Definition: sch_line.h:93
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup