KiCad PCB EDA Suite
sch_editor_control.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) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <fctsys.h>
25 #include <kiway.h>
26 #include <sch_view.h>
27 #include <sch_draw_panel.h>
28 #include <sch_edit_frame.h>
29 #include <sch_component.h>
30 #include <sch_sheet.h>
31 #include <sch_bitmap.h>
32 #include <connection_graph.h>
33 #include <erc.h>
34 #include <eeschema_id.h>
35 #include <netlist_object.h>
36 #include <tool/tool_manager.h>
37 #include <tools/ee_actions.h>
38 #include <tools/ee_picker_tool.h>
42 #include <project.h>
43 #include <ee_hotkeys.h>
44 #include <advanced_config.h>
45 #include <simulation_cursors.h>
46 #include <sim/sim_plot_frame.h>
47 #include <sch_legacy_plugin.h>
48 #include <class_library.h>
49 #include <confirm.h>
50 #include <lib_edit_frame.h>
51 #include <sch_painter.h>
52 #include "sch_wire_bus_tool.h"
53 
54 TOOL_ACTION EE_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
55  AS_GLOBAL, 0, "", "" );
56 
57 TOOL_ACTION EE_ACTIONS::simProbe( "eeschema.Simulation.probe",
58  AS_GLOBAL, 0,
59  _( "Add a simulator probe" ), "" );
60 
61 TOOL_ACTION EE_ACTIONS::simTune( "eeschema.Simulation.tune",
62  AS_GLOBAL, 0,
63  _( "Select a value to be tuned" ), "" );
64 
65 TOOL_ACTION EE_ACTIONS::highlightNet( "eeschema.EditorControl.highlightNet",
66  AS_GLOBAL, 0, "", "" );
67 
68 TOOL_ACTION EE_ACTIONS::clearHighlight( "eeschema.EditorControl.clearHighlight",
69  AS_GLOBAL, 0, "", "" );
70 
71 TOOL_ACTION EE_ACTIONS::updateNetHighlighting( "eeschema.EditorControl.updateNetHighlighting",
72  AS_GLOBAL, 0, "", "" );
73 
74 TOOL_ACTION EE_ACTIONS::highlightNetCursor( "eeschema.EditorControl.highlightNetCursor",
75  AS_GLOBAL, 0,
76  _( "Highlight Nets" ), _( "Highlight wires and pins of a net" ),
77  net_highlight_schematic_xpm, AF_ACTIVATE );
78 
79 TOOL_ACTION EE_ACTIONS::showSymbolEditor( "eeschema.EditorControl.showSymbolEditor",
80  AS_GLOBAL, 0,
81  _( "Show Symbol Editor" ), _( "Create, delete and edit symbols" ),
82  libedit_xpm );
83 
84 TOOL_ACTION EE_ACTIONS::editWithSymbolEditor( "eeschema.EditorControl.editWithSymbolEditor",
86  _( "Edit with Symbol Editor" ), _( "Open the symbol editor to edit the symbol" ),
87  libedit_xpm );
88 
89 TOOL_ACTION EE_ACTIONS::showLibraryBrowser( "eeschema.EditorControl.showLibraryBrowser",
90  AS_GLOBAL, 0,
91  _( "Symbol Library Browser" ), "",
92  library_browse_xpm );
93 
94 TOOL_ACTION EE_ACTIONS::enterSheet( "eeschema.EditorControl.enterSheet",
95  AS_GLOBAL, 0,
96  _( "Enter Sheet" ), _( "Display the selected sheet's contents in the Eeschema window" ),
97  enter_sheet_xpm );
98 
99 TOOL_ACTION EE_ACTIONS::leaveSheet( "eeschema.EditorControl.leaveSheet",
101  _( "Leave Sheet" ), _( "Display the parent sheet in the Eeschema window" ),
102  leave_sheet_xpm );
103 
104 TOOL_ACTION EE_ACTIONS::navigateHierarchy( "eeschema.EditorControl.navigateHierarchy",
105  AS_GLOBAL, 0,
106  _( "Show Hierarchy Navigator" ), "",
107  hierarchy_nav_xpm );
108 
109 TOOL_ACTION EE_ACTIONS::explicitCrossProbe( "eeschema.EditorControl.explicitCrossProbe",
111  _( "Highlight on PCB" ), _( "Highlight corresponding items in PCBNew" ),
112  select_same_sheet_xpm );
113 
114 TOOL_ACTION EE_ACTIONS::toggleHiddenPins( "eeschema.EditorControl.showHiddenPins",
115  AS_GLOBAL, 0,
116  _( "Show Hidden Pins" ), "",
117  hidden_pin_xpm );
118 
119 TOOL_ACTION EE_ACTIONS::toggleForceHV( "eeschema.EditorControl.forceHVLines",
120  AS_GLOBAL, 0,
121  _( "Force H/V Wires and Busses" ), "",
122  lines90_xpm );
123 
124 
126 {
127  doCrossProbeSchToPcb( aEvent, false );
128  return 0;
129 }
130 
131 
133 {
134  doCrossProbeSchToPcb( aEvent, true );
135  return 0;
136 }
137 
138 
139 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
140 {
141  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
142  if( m_probingSchToPcb )
143  {
144  m_probingSchToPcb = false;
145  return;
146  }
147 
149  SCH_ITEM* item = nullptr;
150  SCH_COMPONENT* component = nullptr;
151 
152  if( aForce )
153  {
154  SELECTION& selection = selTool->RequestSelection();
155 
156  if( selection.GetSize() >= 1 )
157  item = (SCH_ITEM*) selection.Front();
158  }
159  else
160  {
161  SELECTION& selection = selTool->GetSelection();
162 
163  if( selection.GetSize() >= 1 )
164  item = (SCH_ITEM*) selection.Front();
165  }
166 
167  if( !item )
168  {
169  if( aForce )
170  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
171 
172  return;
173  }
174 
175 
176  switch( item->Type() )
177  {
178  case SCH_FIELD_T:
179  case LIB_FIELD_T:
180  component = (SCH_COMPONENT*) item->GetParent();
181  m_frame->SendMessageToPCBNEW( item, component );
182  break;
183 
184  case SCH_COMPONENT_T:
185  component = (SCH_COMPONENT*) item;
186  m_frame->SendMessageToPCBNEW( item, component );
187  break;
188 
189  case SCH_PIN_T:
190  component = (SCH_COMPONENT*) item->GetParent();
191  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
192  break;
193 
194  case SCH_SHEET_T:
195  if( aForce )
196  m_frame->SendMessageToPCBNEW( item, nullptr );
197  break;
198 
199  default:
200  break;
201  }
202 }
203 
204 
205 #ifdef KICAD_SPICE
206 static bool probeSimulation( SCH_EDIT_FRAME* aFrame, const VECTOR2D& aPosition )
207 {
208  constexpr KICAD_T wiresAndComponents[] = { SCH_LINE_T, SCH_COMPONENT_T, SCH_SHEET_PIN_T, EOT };
210 
211  EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndComponents );
212 
213  if( !item )
214  return false;
215 
216  std::unique_ptr<NETLIST_OBJECT_LIST> netlist( aFrame->BuildNetListBase() );
217 
218  for( NETLIST_OBJECT* obj : *netlist )
219  {
220  if( obj->m_Comp == item )
221  {
222  auto simFrame = (SIM_PLOT_FRAME*) aFrame->Kiway().Player( FRAME_SIMULATOR, false );
223 
224  if( simFrame )
225  simFrame->AddVoltagePlot( obj->GetNetName() );
226 
227  break;
228  }
229  }
230 
231  return true;
232 }
233 
234 
235 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
236 {
237  Activate();
238 
240  assert( picker );
241 
242  m_frame->SetToolID( ID_SIM_PROBE, wxCURSOR_DEFAULT, _( "Add a simulator probe" ) );
244 
245  picker->SetClickHandler( std::bind( probeSimulation, m_frame, std::placeholders::_1 ) );
246  picker->Activate();
247  Wait();
248 
249  return 0;
250 }
251 
252 
253 static bool tuneSimulation( SCH_EDIT_FRAME* aFrame, const VECTOR2D& aPosition )
254 {
255  constexpr KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
257  EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
258 
259  if( !item )
260  return false;
261 
262  if( item->Type() != SCH_COMPONENT_T )
263  {
264  item = item->GetParent();
265 
266  if( item->Type() != SCH_COMPONENT_T )
267  return false;
268  }
269 
270  auto simFrame = (SIM_PLOT_FRAME*) aFrame->Kiway().Player( FRAME_SIMULATOR, false );
271 
272  if( simFrame )
273  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
274 
275  return true;
276 }
277 
278 
279 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
280 {
281  Activate();
282 
284  assert( picker );
285 
286  m_frame->SetToolID( ID_SIM_TUNE, wxCURSOR_DEFAULT, _( "Select a value to be tuned" ) );
288 
289  picker->SetClickHandler( std::bind( tuneSimulation, m_frame, std::placeholders::_1 ) );
290  picker->Activate();
291  Wait();
292 
293  return 0;
294 }
295 #endif /* KICAD_SPICE */
296 
297 
298 // A singleton reference for clearing the highlight
300 
301 
302 // TODO(JE) Probably use netcode rather than connection name here eventually
303 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
304 {
305  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
306  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
307  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
308  wxString netName;
309  bool retVal = true;
310 
311  if( aPosition != CLEAR )
312  {
313  if( TestDuplicateSheetNames( false ) > 0 )
314  {
315  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
316  retVal = false;
317  }
318  else
319  {
320  SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
321 
322  if( item && item->Connection( *g_CurrentSheet ) )
323  netName = item->Connection( *g_CurrentSheet )->Name();
324  }
325  }
326 
327  if( netName.empty() )
328  {
329  editFrame->SetStatusText( wxT( "" ) );
330  editFrame->SendCrossProbeClearHighlight();
331  }
332  else
333  {
334  editFrame->SendCrossProbeNetName( netName );
335  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
336  UnescapeString( netName ) ) );
337  }
338 
339  editFrame->SetSelectedNetName( netName );
341  editorControl->UpdateNetHighlighting( dummy );
342 
343  return retVal;
344 }
345 
346 
348 {
350  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
351 
352  highlightNet( m_toolMgr, cursorPos );
353 
354  return 0;
355 }
356 
357 
359 {
361 
362  return 0;
363 }
364 
365 
367 {
368  SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
369  std::vector<EDA_ITEM*> itemsToRedraw;
370  wxString selectedNetName = m_frame->GetSelectedNetName();
371 
372  if( !screen )
373  return 0;
374 
375  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
376  {
377  SCH_CONNECTION* conn = item->Connection( *g_CurrentSheet );
378  bool redraw = item->IsBrightened();
379 
380  if( conn && conn->Name() == selectedNetName )
381  item->SetBrightened();
382  else
383  item->ClearBrightened();
384 
385  redraw |= item->IsBrightened();
386 
387  if( item->Type() == SCH_COMPONENT_T )
388  {
389  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
390 
391  redraw |= comp->HasBrightenedPins();
392 
393  comp->ClearBrightenedPins();
394  std::vector<LIB_PIN*> pins;
395  comp->GetPins( pins );
396 
397  for( LIB_PIN* pin : pins )
398  {
399  auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
400 
401  if( pin_conn && pin_conn->Name( false ) == selectedNetName )
402  {
403  comp->BrightenPin( pin );
404  redraw = true;
405  }
406  }
407  }
408  else if( item->Type() == SCH_SHEET_T )
409  {
410  for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( item )->GetPins() )
411  {
412  auto pin_conn = pin.Connection( *g_CurrentSheet );
413  bool redrawPin = pin.IsBrightened();
414 
415  if( pin_conn && pin_conn->Name() == selectedNetName )
416  pin.SetBrightened();
417  else
418  pin.ClearBrightened();
419 
420  redrawPin |= pin.IsBrightened();
421 
422  if( redrawPin )
423  itemsToRedraw.push_back( &pin );
424  }
425  }
426 
427  if( redraw )
428  itemsToRedraw.push_back( item );
429  }
430 
431  // Be sure hightlight change will be redrawn
432  KIGFX::VIEW* view = getView();
433 
434  for( auto redrawItem : itemsToRedraw )
436 
438 
439  return 0;
440 }
441 
442 
444 {
445  // TODO(JE) remove once real-time connectivity is a given
446  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
448 
449  Activate();
450 
452  assert( picker );
453 
454  m_frame->SetToolID( ID_HIGHLIGHT_TOOL, wxCURSOR_HAND, _( "Highlight specific net" ) );
455  picker->SetClickHandler( std::bind( highlightNet, m_toolMgr, std::placeholders::_1 ) );
456  picker->Activate();
457  Wait();
458 
459  return 0;
460 }
461 
462 
464 {
465  if( m_frame->GetScreen()->GetUndoCommandCount() <= 0 )
466  return 0;
467 
468  // Inform tools that undo command was issued
470 
471  /* Get the old list */
473 
474  /* Undo the command */
475  m_frame->PutDataInPreviousState( List, false );
476 
477  /* Put the old list in RedoList */
478  List->ReversePickersListOrder();
480 
483 
484  m_frame->SyncView();
485  m_frame->GetCanvas()->Refresh();
486  m_frame->OnModify();
487 
488  return 0;
489 }
490 
491 
493 {
494  if( m_frame->GetScreen()->GetRedoCommandCount() == 0 )
495  return 0;
496 
497  // Inform tools that undo command was issued
499 
500  /* Get the old list */
502 
503  /* Redo the command: */
504  m_frame->PutDataInPreviousState( List, true );
505 
506  /* Put the old list in UndoList */
507  List->ReversePickersListOrder();
509 
511 
513 
514  m_frame->SyncView();
515  m_frame->GetCanvas()->Refresh();
516  m_frame->OnModify();
517 
518  return 0;
519 }
520 
521 
523 {
525  SELECTION& selection = selTool->GetSelection();
526 
527  if( !selection.GetSize() )
528  return false;
529 
530  STRING_FORMATTER formatter;
531  SCH_LEGACY_PLUGIN plugin;
532 
533  plugin.Format( &selection, &formatter );
534 
535  return m_toolMgr->SaveClipboard( formatter.GetString() );
536 }
537 
538 
540 {
541  if( doCopy() )
543 
544  return 0;
545 }
546 
547 
549 {
550  doCopy();
551 
552  return 0;
553 }
554 
555 
557 {
559 
561  SCH_ITEM* last = dlist.GetLast();
562 
563  std::string text = m_toolMgr->GetClipboard();
564  STRING_LINE_READER reader( text, "Clipboard" );
565  SCH_LEGACY_PLUGIN plugin;
566 
567  try
568  {
569  plugin.LoadContent( reader, m_frame->GetScreen() );
570  }
571  catch( IO_ERROR& e )
572  {
573  wxLogError( wxString::Format( "Malformed clipboard: %s" ), GetChars( e.What() ) );
574  return 0;
575  }
576 
577  // SCH_LEGACY_PLUGIN added the items to the DLIST, but not to the view or anything
578  // else. Pull them back out to start with.
579  //
580  EDA_ITEMS loadedItems;
581  SCH_ITEM* next = nullptr;
582 
583  // We also make sure any pasted sheets will not cause recursion in the destination.
584  // Moreover new sheets create new sheetpaths, and component alternate references must
585  // be created and cleared
586  //
587  bool sheetsPasted = false;
588  SCH_SHEET_LIST hierarchy( g_RootSheet );
589  SCH_SHEET_LIST initialHierarchy( g_RootSheet );
590 
591  wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
592 
593  if( destFn.IsRelative() )
594  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
595 
596  for( SCH_ITEM* item = last ? last->Next() : dlist.GetFirst(); item; item = next )
597  {
598  next = item->Next();
599  dlist.Remove( item );
600 
601  loadedItems.push_back( item );
602 
603  if( item->Type() == SCH_COMPONENT_T )
604  {
605  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
606 
607  component->SetTimeStamp( GetNewTimeStamp() );
608 
609  // clear the annotation, but preserve the selected unit
610  int unit = component->GetUnit();
611  component->ClearAnnotation( nullptr );
612  component->SetUnit( unit );
613  }
614  if( item->Type() == SCH_SHEET_T )
615  {
616  SCH_SHEET* sheet = (SCH_SHEET*) item;
617  wxFileName srcFn = sheet->GetFileName();
618 
619  if( srcFn.IsRelative() )
620  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
621 
622  SCH_SHEET_LIST sheetHierarchy( sheet );
623 
624  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
625  {
626  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
627  "was dropped because the destination already has "
628  "the sheet or one of its subsheets as a parent." ),
629  sheet->GetFileName() );
630  DisplayError( m_frame, msg );
631  loadedItems.pop_back();
632  }
633  else
634  {
635  // Duplicate sheet names and sheet time stamps are not valid. Use a time stamp
636  // based sheet name and update the time stamp for each sheet in the block.
638 
639  sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)uid ) );
640  sheet->SetTimeStamp( uid );
641  sheetsPasted = true;
642  }
643  }
644  }
645 
646  // Now we can resolve the components and add everything to the screen, view, etc.
647  //
648  SYMBOL_LIB_TABLE* symLibTable = m_frame->Prj().SchSymbolLibTable();
649  PART_LIB* partLib = m_frame->Prj().SchLibs()->GetCacheLibrary();
650 
651  for( unsigned i = 0; i < loadedItems.size(); ++i )
652  {
653  EDA_ITEM* item = loadedItems[i];
654 
655  if( item->Type() == SCH_COMPONENT_T )
656  {
657  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
658  component->Resolve( *symLibTable, partLib );
659  }
660  else if( item->Type() == SCH_SHEET_T )
661  {
662  SCH_SHEET* sheet = (SCH_SHEET*) item;
663  m_frame->InitSheet( sheet, sheet->GetFileName() );
664  }
665 
666  item->SetFlags( IS_NEW | IS_MOVED );
667  m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
668 
669  // Reset flags for subsequent move operation
670  item->SetFlags( IS_NEW | IS_MOVED );
671  }
672 
673  if( sheetsPasted )
674  {
675  // We clear annotation of new sheet paths.
676  SCH_SCREENS screensList( g_RootSheet );
677  screensList.ClearAnnotationOfNewSheetPaths( initialHierarchy );
679  }
680 
681  // Now clear the previous selection, select the pasted items, and fire up the "move"
682  // tool.
683  //
685  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
686 
687  SELECTION& selection = selTool->GetSelection();
688 
689  if( !selection.Empty() )
690  {
691  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
692 
693  selection.SetReferencePoint( item->GetPosition() );
695  }
696 
697  return 0;
698 }
699 
700 
702 {
705  SCH_COMPONENT* comp = nullptr;
706 
707  if( selection.GetSize() >= 1 )
708  comp = (SCH_COMPONENT*) selection.Front();
709 
710  if( !comp || comp->GetEditFlags() != 0 )
711  return 0;
712 
713  wxCommandEvent dummy;
715 
716  auto libeditFrame = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
717 
718  if( libeditFrame )
719  {
720  const LIB_ID& id = comp->GetLibId();
721  libeditFrame->LoadComponentAndSelectLib( id, comp->GetUnit(), comp->GetConvert() );
722  }
723 
724  return 0;
725 }
726 
727 
729 {
730  wxCommandEvent dummy;
732  return 0;
733 }
734 
735 
737 {
738  wxCommandEvent dummy;
740  return 0;
741 }
742 
743 
745 {
747  const SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
748 
749  if( selection.GetSize() == 1 )
750  {
751  g_CurrentSheet->push_back( (SCH_SHEET*) selection.Front() );
753  }
754 
755  return 0;
756 }
757 
758 
760 {
761  if( g_CurrentSheet->Last() != g_RootSheet )
762  {
765  }
766 
767  return 0;
768 }
769 
770 
772 {
774 
775  auto painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
776  painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
777 
779  m_frame->GetCanvas()->Refresh();
780 
781  return 0;
782 }
783 
784 
786 {
788 
789  return 0;
790 }
791 
792 
793 
795 {
796  /*
797  Go( &SCH_EDITOR_CONTROL::ToggleLockSelected, EE_ACTIONS::toggleLock.MakeEvent() );
798  Go( &SCH_EDITOR_CONTROL::LockSelected, EE_ACTIONS::lock.MakeEvent() );
799  Go( &SCH_EDITOR_CONTROL::UnlockSelected, EE_ACTIONS::unlock.MakeEvent() );
800  */
801 
806 
807 #ifdef KICAD_SPICE
808  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
809  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
810 #endif /* KICAD_SPICE */
811 
817 
818  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
819  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
820  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
821  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
823 
827 
831 
834 }
SELECTION & GetSelection()
Function GetSelection()
CITER next(CITER it)
Definition: ptree.cpp:130
Class SCH_SHEET_LIST.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToUndoList add a command to undo in undo list delete the very old commands when t...
void LoadContent(LINE_READER &aReader, SCH_SCREEN *aScreen, int version=EESCHEMA_VERSION)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
void SetTimeStamp(timestamp_t aNewTimeStamp)
Change the time stamp to aNewTimeStamp and updates the reference path.
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
Definition: actions.h:132
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:61
const wxString & GetSelectedNetName() const
NETLIST_OBJECT_LIST * BuildNetListBase(bool updateStatusText=true)
Create a flat list which stores all connected objects.
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:162
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to highlight nets.
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to pcbnew for highlighting.
void OnOpenLibraryViewer(wxCommandEvent &event)
Open the library viewer only to browse library contents.
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
Definition: actions.h:133
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...
This file is part of the common library.
void SetForceHVLines(bool aForceHVdirection)
void ReversePickersListOrder()
Function ReversePickersListOrder reverses the order of pickers stored in this list.
SCH_ITEM * Next() const
Definition: sch_item.h:153
bool SaveClipboard(const std::string &aText)
Stores an information to the system clipboard.
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:64
int Redo(const TOOL_EVENT &aEvent)
int NavigateHierarchy(const TOOL_EVENT &aEvent)
Definition: hierarch.cpp:132
bool Resolve(PART_LIBS *aLibs)
Assigns the current LIB_PART from aLibs which this symbol is based on.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
int GetUndoCommandCount() const
Definition: base_screen.h:301
void SendCrossProbeClearHighlight()
Tells PcbNew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1443
EDA_DRAW_FRAME * GetEditFrame() const
Definition: tool_manager.h:267
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void ClearBrightenedPins()
static TOOL_ACTION refreshPreview
Definition: ee_actions.h:168
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static int LegacyHotKey(int aHotKey)
Creates a hot key code that refers to a legacy hot key setting, instead of a particular key.
Definition: tool_action.h:165
void Format(SCH_SCREEN *aScreen)
Schematic editor (Eeschema) main window.
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:44
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:258
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:45
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:184
void setTransitions() override
Sets up handlers for various events.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int ShowLibraryBrowser(const TOOL_EVENT &aEvent)
search types array terminator (End Of Types)
Definition: typeinfo.h:82
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:136
int ToggleForceHV(const TOOL_EVENT &aEvent)
void pop_back()
Forwarded method from std::vector.
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:161
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
PopCommandFromUndoList return the last command to undo and remove it from list nothing is deleted.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Class SCH_EDITOR_CONTROL.
Class TOOL_MANAGER.
Definition: tool_manager.h:49
int EnterSheet(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_COMPONENT *aPart)
Send a message to Pcbnew via a socket connection.
static TOOL_ACTION copy
Definition: actions.h:53
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:208
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
int GetUnit() const
void BrightenPin(LIB_PIN *aPin)
virtual wxPoint GetPosition() const =0
Function GetPosition.
Item is being added to the view.
Definition: view_item.h:60
int TestDuplicateSheetNames(bool aCreateMarker)
Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names...
Definition: erc.cpp:177
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
wxString Name(bool aIgnoreSheet=false) const
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:56
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:321
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
int LeaveSheet(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:179
void SetName(const wxString &aName)
Definition: sch_sheet.h:260
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:263
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
bool GetForceHVLines() const
void SyncView()
Mark all items for refresh.
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:588
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:169
TOOL_MANAGER * GetToolManager() const override
Return the tool manager instance, if any.
Definition: draw_frame.h:937
SCH_DRAW_PANEL * GetCanvas() const override
Class TOOL_EVENT.
Definition: tool_event.h:167
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
PopCommandFromRedoList return the last command to undo and remove it from list nothing is deleted.
static TOOL_ACTION cut
Definition: actions.h:52
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const
EDA_ITEM * GetParent() const
Definition: base_struct.h:214
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
SCH_CONNECTION * GetConnectionForPin(LIB_PIN *aPin, const SCH_SHEET_PATH &aSheet)
Retrieves the connection for a given pin of the component.
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
static TOOL_ACTION doDelete
Definition: ee_actions.h:131
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
Definition: actions.h:134
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
const std::string & GetString()
Definition: richio.h:475
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:56
void SetUnit(int aUnit)
Change the unit number to aUnit.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:57
void InitSheet(SCH_SHEET *aSheet, const wxString &aFilename)
Definition: sheet.cpp:40
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg)
Set the tool command ID to aId and sets the cursor to aCursor.
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Updates net highlighting after an edit
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
All active tools
Definition: tool_event.h:143
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1539
static VECTOR2D CLEAR
static TOOL_ACTION highlightNetCursor
Definition: ee_actions.h:185
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:127
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
A SCH_PLUGIN derivation for loading schematic files created before the new s-expression file format.
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Implementing SIM_PLOT_FRAME_BASE.
void OnOpenLibraryEditor(wxCommandEvent &event)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList, bool aRedoCommand)
Restore an undo or redo command to put data pointed by aList in the previous state.
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:98
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:627
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:316
static bool m_allowRealTime
static TOOL_ACTION redo
Definition: actions.h:51
static TOOL_ACTION showLibraryBrowser
Definition: ee_actions.h:152
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
The symbol library editor main window.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:100
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static TOOL_ACTION showSymbolEditor
Definition: ee_actions.h:150
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:164
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
int Cut(const TOOL_EVENT &aEvent)
Clipboard support.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123
bool HasBrightenedPins()
Class TOOL_ACTION.
Definition: tool_action.h:46
size_t i
Definition: json11.cpp:597
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
int ClearHighlight(const TOOL_EVENT &aEvent)
Removes any net highlighting
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToRedoList add a command to redo in redo list delete the very old commands when t...
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
int Undo(const TOOL_EVENT &aEvent)
bool doCopy()
copy selection to clipboard
static TOOL_ACTION enterSheet
Definition: ee_actions.h:160
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:183
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION move
Definition: ee_actions.h:116
static TOOL_ACTION simProbe
Definition: ee_actions.h:178
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
static const wxCursor & GetCursor(CURSOR aCursorType)
int GetConvert() const
static TOOL_ACTION undo
Definition: actions.h:50
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:53
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
static TOOL_ACTION highlightNet
Definition: ee_actions.h:182
EDA_ITEM * SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, bool *aSelectionCancelledFlag=NULL, bool aCheckLocked=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
Class VIEW.
Definition: view.h:61
void ClearAnnotationOfNewSheetPaths(SCH_SHEET_LIST &aInitialSheetPathList)
Clear the annotation for the components inside new sheetpaths when a complex hierarchy is modified an...
Definition of the NETLIST_OBJECT class.
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:175
const LIB_ID & GetLibId() const
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName) const
Function TestForRecursion.
Class STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
Class STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
DLIST< SCH_ITEM > & GetDrawList()
Definition: sch_screen.h:112
Object used to load, save, search, and otherwise manipulate symbol library files.
int GetRedoCommandCount() const
Definition: base_screen.h:306
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:244
void SetSelectedNetName(const wxString &aNetName)
SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
int ShowSymbolEditor(const TOOL_EVENT &aEvent)
static TOOL_ACTION editWithSymbolEditor
Definition: ee_actions.h:151
static TOOL_ACTION paste
Definition: actions.h:54
void RecalculateConnections(bool aDoCleanup=true)
Generates the connection data for the entire schematic hierarchy.
bool GetShowAllPins() const override
Allow some frames to show/hide hidden pins.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:493
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
SCH_SCREEN * LastScreen() const
Function LastScreen.
EDA_ITEM * Front() const
Definition: selection.h:155
void SetShowAllPins(bool aEnable)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:209
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:113
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:153