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) 2019 CERN
5  * Copyright (C) 1992-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 <fctsys.h>
26 #include <kiway.h>
27 #include <sch_view.h>
28 #include <sch_edit_frame.h>
29 #include <sch_sheet.h>
30 #include <sch_line.h>
31 #include <connection_graph.h>
32 #include <erc.h>
33 #include <eeschema_id.h>
34 #include <netlist_object.h>
35 #include <tool/tool_manager.h>
36 #include <tool/picker_tool.h>
37 #include <tools/ee_actions.h>
39 #include <tools/ee_selection.h>
41 #include <advanced_config.h>
42 #include <simulation_cursors.h>
43 #include <sim/sim_plot_frame.h>
44 #include <sch_legacy_plugin.h>
45 #include <class_library.h>
46 #include <confirm.h>
47 #include <sch_painter.h>
48 #include <status_popup.h>
49 #include <ws_proxy_undo_item.h>
52 #include <invoke_sch_dialog.h>
53 
54 
55 int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
56 {
58  return 0;
59 }
60 
61 
63 {
65  return 0;
66 }
67 
68 
70 {
71  m_frame->Save_File();
72  return 0;
73 }
74 
75 
77 {
78  m_frame->Save_File( true );
79  return 0;
80 }
81 
82 
84 {
86  return 0;
87 }
88 
89 
91 {
92  PICKED_ITEMS_LIST undoCmd;
94  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
95 
96  undoCmd.PushItem( wrapper );
98 
101 
102  if( dlg.ShowModal() != wxID_OK )
104 
105  return 0;
106 }
107 
108 
110 {
111  m_frame->Print();
112  return 0;
113 }
114 
115 
117 {
119  return 0;
120 }
121 
122 
124 {
125  m_frame->Close( false );
126  return 0;
127 }
128 
129 
130 // A dummy wxFindReplaceData signalling any marker should be found
131 static wxFindReplaceData g_markersOnly;
132 
133 
135 {
137  return UpdateFind( aEvent );
138 }
139 
140 
142 {
143  wxFindReplaceData* data = m_frame->GetFindReplaceData();
144 
145  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
146  || aEvent.IsAction( &ACTIONS::updateFind ) )
147  {
149 
150  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* )
151  {
152  if( data && item->Matches( *data, nullptr ) )
153  m_selectionTool->BrightenItem( item );
154  else if( item->IsBrightened() )
156 
157  return SEARCH_CONTINUE;
158  };
159 
160  EDA_ITEM* start = m_frame->GetScreen()->GetDrawItems();
161  EDA_ITEM::IterateForward( start, inspector, nullptr, EE_COLLECTOR::AllItems );
162  }
163  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
164  {
165  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
166  {
167  if( data && item->Matches( *data, nullptr ) )
168  m_selectionTool->BrightenItem( item );
169  else if( item->IsBrightened() )
171  }
172  }
173 
174  getView()->UpdateItems();
175  m_frame->GetCanvas()->Refresh();
176 
177  return 0;
178 }
179 
180 
181 EDA_ITEM* nextMatch( SCH_SCREEN* aScreen, EDA_ITEM* after, wxFindReplaceData* data )
182 {
183  EDA_ITEM* found = nullptr;
184 
185  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
186  {
187  if( after )
188  {
189  if( after == item )
190  after = nullptr;
191 
192  return SEARCH_CONTINUE;
193  }
194 
195  if( ( data == &g_markersOnly && item->Type() == SCH_MARKER_T )
196  || item->Matches( *data, nullptr ) )
197  {
198  found = item;
199  return SEARCH_QUIT;
200  }
201 
202  return SEARCH_CONTINUE;
203  };
204 
205  EDA_ITEM::IterateForward( aScreen->GetDrawItems(), inspector, nullptr, EE_COLLECTOR::AllItems );
206 
207  return found;
208 }
209 
210 
212 {
213  // A timer during which a subsequent FindNext will result in a wrap-around
214  static wxTimer wrapAroundTimer;
215 
216  wxFindReplaceData* data = m_frame->GetFindReplaceData();
217 
218  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
219  {
220  if( data )
221  g_markersOnly.SetFlags( data->GetFlags() );
222 
223  data = &g_markersOnly;
224  }
225  else if( !data )
226  {
227  return FindAndReplace( ACTIONS::find.MakeEvent() );
228  }
229 
230  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
231  EE_SELECTION& selection = m_selectionTool->GetSelection();
232  SCH_SCREEN* afterScreen = m_frame->GetScreen();
233  EDA_ITEM* afterItem = selection.Front();
234  EDA_ITEM* item = nullptr;
235 
236  if( wrapAroundTimer.IsRunning() )
237  {
238  afterScreen = nullptr;
239  afterItem = nullptr;
240  wrapAroundTimer.Stop();
242  }
243 
245 
246  if( afterScreen || !searchAllSheets )
247  item = nextMatch( m_frame->GetScreen(), afterItem, data );
248 
249  if( !item && searchAllSheets )
250  {
251  SCH_SHEET_LIST schematic( g_RootSheet );
252  SCH_SCREENS screens;
253 
254  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
255  {
256  if( afterScreen )
257  {
258  if( afterScreen == screen )
259  afterScreen = nullptr;
260 
261  continue;
262  }
263 
264  item = nextMatch( screen, nullptr, data );
265 
266  if( item )
267  {
268  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
269  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
270 
271  *g_CurrentSheet = *sheet;
273 
274  screen->SetZoom( m_frame->GetScreen()->GetZoom() );
275  screen->TestDanglingEnds();
276 
277  m_frame->SetScreen( screen );
278  UpdateFind( ACTIONS::updateFind.MakeEvent() );
279 
280  break;
281  }
282  }
283  }
284 
285  if( item )
286  {
287  m_selectionTool->AddItemToSel( item );
288  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter(), true );
289  m_frame->GetCanvas()->Refresh();
290  }
291  else
292  {
293  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
294  : _( "Reached end of sheet." );
295 
296  m_frame->ShowFindReplaceStatus( msg + _( "\nFind again to wrap around to the start." ) );
297  wrapAroundTimer.StartOnce( 4000 );
298  }
299 
300  return 0;
301 }
302 
303 
305 {
306  wxFindReplaceData* data = m_frame->GetFindReplaceData();
308 
309  return data && item && item->Matches( *data, nullptr );
310 }
311 
312 
314 {
315  wxFindReplaceData* data = m_frame->GetFindReplaceData();
317 
318  if( !data )
319  return FindAndReplace( ACTIONS::find.MakeEvent() );
320 
321  if( item && item->Matches( *data, nullptr ) )
322  {
323  item->Replace( *data, g_CurrentSheet );
324  FindNext( ACTIONS::findNext.MakeEvent() );
325  }
326 
327  return 0;
328 }
329 
330 
332 {
333  wxFindReplaceData* data = m_frame->GetFindReplaceData();
334 
335  if( !data )
336  return FindAndReplace( ACTIONS::find.MakeEvent() );
337 
338  SCH_SHEET_LIST schematic( g_RootSheet );
339  SCH_SCREENS screens;
340 
341  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
342  {
343  for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item;
344  item = nextMatch( screen, item, data ) )
345  {
346  item->Replace( *data, schematic.FindSheetForScreen( screen ) );
347  }
348  }
349 
350  return 0;
351 }
352 
353 
355 {
356  doCrossProbeSchToPcb( aEvent, false );
357  return 0;
358 }
359 
360 
362 {
363  doCrossProbeSchToPcb( aEvent, true );
364  return 0;
365 }
366 
367 
368 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
369 {
370  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
371  if( m_probingPcbToSch )
372  return;
373 
375  SCH_ITEM* item = nullptr;
376  SCH_COMPONENT* component = nullptr;
377 
378  if( aForce )
379  {
380  EE_SELECTION& selection = selTool->RequestSelection();
381 
382  if( selection.GetSize() >= 1 )
383  item = (SCH_ITEM*) selection.Front();
384  }
385  else
386  {
387  EE_SELECTION& selection = selTool->GetSelection();
388 
389  if( selection.GetSize() >= 1 )
390  item = (SCH_ITEM*) selection.Front();
391  }
392 
393  if( !item )
394  {
395  if( aForce )
396  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
397 
398  return;
399  }
400 
401 
402  switch( item->Type() )
403  {
404  case SCH_FIELD_T:
405  case LIB_FIELD_T:
406  component = (SCH_COMPONENT*) item->GetParent();
407  m_frame->SendMessageToPCBNEW( item, component );
408  break;
409 
410  case SCH_COMPONENT_T:
411  component = (SCH_COMPONENT*) item;
412  m_frame->SendMessageToPCBNEW( item, component );
413  break;
414 
415  case SCH_PIN_T:
416  component = (SCH_COMPONENT*) item->GetParent();
417  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
418  break;
419 
420  case SCH_SHEET_T:
421  if( aForce )
422  m_frame->SendMessageToPCBNEW( item, nullptr );
423  break;
424 
425  default:
426  break;
427  }
428 }
429 
430 
431 #ifdef KICAD_SPICE
432 
433 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
434 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
435 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
436 
437 #define HITTEST_THRESHOLD_PIXELS 5
438 
439 
440 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
441 {
442  auto picker = m_toolMgr->GetTool<PICKER_TOOL>();
443  auto simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
444 
445  if( !simFrame ) // Defensive coding; shouldn't happen.
446  return 0;
447 
448  // Deactivate other tools; particularly important if another PICKER is currently running
449  Activate();
450 
451  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
452 
453  picker->SetClickHandler(
454  [this, simFrame] ( const VECTOR2D& aPosition )
455  {
457  EDA_ITEM* item = selTool->SelectPoint( aPosition, wiresAndPins );
458 
459  if( !item )
460  return false;
461 
462  if( item->IsType( wires ) )
463  {
464  std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
465 
466  for( NETLIST_OBJECT* obj : *netlist )
467  {
468  if( obj->m_Comp == item )
469  {
470  simFrame->AddVoltagePlot( UnescapeString( obj->GetNetName() ) );
471  break;
472  }
473  }
474  }
475  else if( item->Type() == SCH_PIN_T )
476  {
477  SCH_PIN* pin = (SCH_PIN*) item;
478  SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
479  wxString param = wxString::Format( _T( "I%s" ), pin->GetName().Lower() );
480 
481  simFrame->AddCurrentPlot( comp->GetRef( g_CurrentSheet ), param );
482  }
483 
484  return true;
485  } );
486 
487  picker->SetMotionHandler(
488  [this, picker] ( const VECTOR2D& aPos )
489  {
490  EE_COLLECTOR collector;
491  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
492  collector.Collect( m_frame->GetScreen()->GetDrawItems(), wiresAndPins, (wxPoint) aPos );
493 
495  selectionTool->GuessSelectionCandidates( collector, aPos );
496 
497  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
498  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
499  wxString netName;
500 
501  if( wire )
502  {
503  item = nullptr;
504 
505  if( wire->Connection( *g_CurrentSheet ) )
506  netName = wire->Connection( *g_CurrentSheet )->Name();
507  }
508 
509  if( item && item->Type() == SCH_PIN_T )
510  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURRENT_PROBE ) );
511  else
512  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::VOLTAGE_PROBE ) );
513 
514  if( m_pickerItem != item )
515  {
516 
517  if( m_pickerItem )
518  selectionTool->UnbrightenItem( m_pickerItem );
519 
520  m_pickerItem = item;
521 
522  if( m_pickerItem )
523  selectionTool->BrightenItem( m_pickerItem );
524  }
525 
526  if( m_frame->GetSelectedNetName() != netName )
527  {
528  m_frame->SetSelectedNetName( netName );
529 
530  TOOL_EVENT dummyEvent;
531  UpdateNetHighlighting( dummyEvent );
532  }
533  } );
534 
535  picker->SetFinalizeHandler(
536  [this] ( const int& aFinalState )
537  {
538  if( m_pickerItem )
540 
541  if( !m_frame->GetSelectedNetName().IsEmpty() )
542  {
543  m_frame->SetSelectedNetName( wxEmptyString );
544 
545  TOOL_EVENT dummyEvent;
546  UpdateNetHighlighting( dummyEvent );
547  }
548  } );
549 
550  std::string tool = aEvent.GetCommandStr().get();
551  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
552 
553  return 0;
554 }
555 
556 
557 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
558 {
560 
561  // Deactivate other tools; particularly important if another PICKER is currently running
562  Activate();
563 
564  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) );
565 
566  picker->SetClickHandler(
567  [this] ( const VECTOR2D& aPosition )
568  {
570  EDA_ITEM* item = selTool->SelectPoint( aPosition, fieldsAndComponents );
571 
572  if( !item )
573  return false;
574 
575  if( item->Type() != SCH_COMPONENT_T )
576  {
577  item = item->GetParent();
578 
579  if( item->Type() != SCH_COMPONENT_T )
580  return false;
581  }
582 
583  SIM_PLOT_FRAME* simFrame =
585 
586  if( simFrame )
587  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
588 
589  return true;
590  } );
591 
592  picker->SetMotionHandler(
593  [this] ( const VECTOR2D& aPos )
594  {
595  EE_COLLECTOR collector;
596  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
597  collector.Collect( m_frame->GetScreen()->GetDrawItems(), fieldsAndComponents, (wxPoint) aPos );
598 
600  selectionTool->GuessSelectionCandidates( collector, aPos );
601 
602  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
603 
604  if( m_pickerItem != item )
605  {
606  if( m_pickerItem )
607  selectionTool->UnbrightenItem( m_pickerItem );
608 
609  m_pickerItem = item;
610 
611  if( m_pickerItem )
612  selectionTool->BrightenItem( m_pickerItem );
613  }
614  } );
615 
616  picker->SetFinalizeHandler(
617  [this] ( const int& aFinalState )
618  {
619  if( m_pickerItem )
621  } );
622 
623  std::string tool = aEvent.GetCommandStr().get();
624  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
625 
626  return 0;
627 }
628 #endif /* KICAD_SPICE */
629 
630 
631 // A singleton reference for clearing the highlight
633 
634 
635 // TODO(JE) Probably use netcode rather than connection name here eventually
636 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
637 {
638  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
639  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
640  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
641  wxString netName;
642  bool retVal = true;
643 
644  if( aPosition != CLEAR )
645  {
646  if( TestDuplicateSheetNames( false ) > 0 )
647  {
648  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
649  retVal = false;
650  }
651  else
652  {
653  SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
654 
655  if( item && item->Connection( *g_CurrentSheet ) )
656  netName = item->Connection( *g_CurrentSheet )->Name();
657  }
658  }
659 
660  if( netName.empty() )
661  {
662  editFrame->SetStatusText( wxT( "" ) );
663  editFrame->SendCrossProbeClearHighlight();
664  }
665  else
666  {
667  editFrame->SendCrossProbeNetName( netName );
668  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
669  UnescapeString( netName ) ) );
670  }
671 
672  editFrame->SetSelectedNetName( netName );
674  editorControl->UpdateNetHighlighting( dummy );
675 
676  return retVal;
677 }
678 
679 
681 {
683  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
684 
685  highlightNet( m_toolMgr, cursorPos );
686 
687  return 0;
688 }
689 
690 
692 {
694 
695  return 0;
696 }
697 
698 
700 {
701  SCH_SCREEN* screen = g_CurrentSheet->LastScreen();
702  std::vector<EDA_ITEM*> itemsToRedraw;
703  wxString selectedNetName = m_frame->GetSelectedNetName();
704 
705  if( !screen )
706  return 0;
707 
708  for( SCH_ITEM* item = screen->GetDrawItems(); item; item = item->Next() )
709  {
710  SCH_CONNECTION* conn = item->Connection( *g_CurrentSheet );
711  bool redraw = item->IsBrightened();
712 
713  if( conn && conn->Name() == selectedNetName )
714  item->SetBrightened();
715  else
716  item->ClearBrightened();
717 
718  redraw |= item->IsBrightened();
719 
720  if( item->Type() == SCH_COMPONENT_T )
721  {
722  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
723 
724  redraw |= comp->HasBrightenedPins();
725 
726  comp->ClearBrightenedPins();
727  std::vector<LIB_PIN*> pins;
728  comp->GetPins( pins );
729 
730  for( LIB_PIN* pin : pins )
731  {
732  auto pin_conn = comp->GetConnectionForPin( pin, *g_CurrentSheet );
733 
734  if( pin_conn && pin_conn->Name( false ) == selectedNetName )
735  {
736  comp->BrightenPin( pin );
737  redraw = true;
738  }
739  }
740  }
741  else if( item->Type() == SCH_SHEET_T )
742  {
743  for( SCH_SHEET_PIN& pin : static_cast<SCH_SHEET*>( item )->GetPins() )
744  {
745  auto pin_conn = pin.Connection( *g_CurrentSheet );
746  bool redrawPin = pin.IsBrightened();
747 
748  if( pin_conn && pin_conn->Name() == selectedNetName )
749  pin.SetBrightened();
750  else
751  pin.ClearBrightened();
752 
753  redrawPin |= pin.IsBrightened();
754 
755  if( redrawPin )
756  itemsToRedraw.push_back( &pin );
757  }
758  }
759 
760  if( redraw )
761  itemsToRedraw.push_back( item );
762  }
763 
764  // Be sure hightlight change will be redrawn
765  KIGFX::VIEW* view = getView();
766 
767  for( auto redrawItem : itemsToRedraw )
769 
770  m_frame->GetCanvas()->Refresh();
771 
772  return 0;
773 }
774 
775 
777 {
778  // TODO(JE) remove once real-time connectivity is a given
779  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
781 
782  std::string tool = aEvent.GetCommandStr().get();
784 
785  // Deactivate other tools; particularly important if another PICKER is currently running
786  Activate();
787 
788  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
789 
790  picker->SetClickHandler(
791  [this] ( const VECTOR2D& aPos )
792  {
793  return highlightNet( m_toolMgr, aPos );
794  } );
795 
796  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
797 
798  return 0;
799 }
800 
801 
803 {
804  if( m_frame->GetScreen()->GetUndoCommandCount() <= 0 )
805  return 0;
806 
807  // Inform tools that undo command was issued
809 
810  /* Get the old list */
812 
813  /* Undo the command */
814  m_frame->PutDataInPreviousState( List, false );
815 
816  /* Put the old list in RedoList */
817  List->ReversePickersListOrder();
819 
821  selTool->RebuildSelection();
822 
825 
826  m_frame->SyncView();
827  m_frame->GetCanvas()->Refresh();
828  m_frame->OnModify();
829 
830  return 0;
831 }
832 
833 
835 {
836  if( m_frame->GetScreen()->GetRedoCommandCount() == 0 )
837  return 0;
838 
839  // Inform tools that undo command was issued
841 
842  /* Get the old list */
844 
845  /* Redo the command: */
846  m_frame->PutDataInPreviousState( List, true );
847 
848  /* Put the old list in UndoList */
849  List->ReversePickersListOrder();
851 
853  selTool->RebuildSelection();
854 
857 
858  m_frame->SyncView();
859  m_frame->GetCanvas()->Refresh();
860  m_frame->OnModify();
861 
862  return 0;
863 }
864 
865 
867 {
869  EE_SELECTION& selection = selTool->RequestSelection();
870 
871  if( !selection.GetSize() )
872  return false;
873 
874  STRING_FORMATTER formatter;
875  SCH_LEGACY_PLUGIN plugin;
876 
877  plugin.Format( &selection, &formatter );
878 
879  return m_toolMgr->SaveClipboard( formatter.GetString() );
880 }
881 
882 
884 {
885  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
886 
887  if( textEntry )
888  {
889  textEntry->Cut();
890  return 0;
891  }
892 
893  if( doCopy() )
895 
896  return 0;
897 }
898 
899 
901 {
902  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
903 
904  if( textEntry )
905  {
906  textEntry->Copy();
907  return 0;
908  }
909 
910  doCopy();
911 
912  return 0;
913 }
914 
915 
917 {
918  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
919 
920  if( textEntry )
921  {
922  textEntry->Paste();
923  return 0;
924  }
925 
927 
929  SCH_ITEM* last = dlist.GetLast();
930 
931  std::string text = m_toolMgr->GetClipboard();
932 
933  if( text.empty() )
934  return 0;
935 
936  STRING_LINE_READER reader( text, "Clipboard" );
937  SCH_LEGACY_PLUGIN plugin;
938 
939  try
940  {
941  plugin.LoadContent( reader, m_frame->GetScreen() );
942  }
943  catch( IO_ERROR& e )
944  {
945  // If it wasn't content, then paste as text
946  dlist.Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
947  }
948 
949  // SCH_LEGACY_PLUGIN added the items to the DLIST, but not to the view or anything
950  // else. Pull them back out to start with.
951  //
952  EDA_ITEMS loadedItems;
953  SCH_ITEM* next = nullptr;
954 
955  // We also make sure any pasted sheets will not cause recursion in the destination.
956  // Moreover new sheets create new sheetpaths, and component alternate references must
957  // be created and cleared
958  //
959  bool sheetsPasted = false;
960  SCH_SHEET_LIST hierarchy( g_RootSheet );
961  wxFileName destFn = g_CurrentSheet->Last()->GetFileName();
962 
963  if( destFn.IsRelative() )
964  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
965 
966  for( SCH_ITEM* item = last ? last->Next() : dlist.GetFirst(); item; item = next )
967  {
968  next = item->Next();
969  dlist.Remove( item );
970 
971  loadedItems.push_back( item );
972 
973  if( item->Type() == SCH_COMPONENT_T )
974  {
975  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
976 
977  component->SetTimeStamp( GetNewTimeStamp() );
978 
979  // clear the annotation, but preserve the selected unit
980  int unit = component->GetUnit();
981  component->ClearAnnotation( nullptr );
982  component->SetUnit( unit );
983  }
984  if( item->Type() == SCH_SHEET_T )
985  {
986  SCH_SHEET* sheet = (SCH_SHEET*) item;
987  wxFileName srcFn = sheet->GetFileName();
988 
989  if( srcFn.IsRelative() )
990  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
991 
992  SCH_SHEET_LIST sheetHierarchy( sheet );
993 
994  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
995  {
996  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
997  "was dropped because the destination already has "
998  "the sheet or one of its subsheets as a parent." ),
999  sheet->GetFileName() );
1000  DisplayError( m_frame, msg );
1001  loadedItems.pop_back();
1002  }
1003  else
1004  {
1005  // Duplicate sheet names and sheet time stamps are not valid. Use a time stamp
1006  // based sheet name and update the time stamp for each sheet in the block.
1007  timestamp_t uid = GetNewTimeStamp();
1008 
1009  sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)uid ) );
1010  sheet->SetTimeStamp( uid );
1011  sheet->SetParent( g_CurrentSheet->Last() );
1012  sheet->SetScreen( nullptr );
1013  sheetsPasted = true;
1014  }
1015  }
1016  }
1017 
1018  // Now we can resolve the components and add everything to the screen, view, etc.
1019  //
1020  SYMBOL_LIB_TABLE* symLibTable = m_frame->Prj().SchSymbolLibTable();
1021  PART_LIB* partLib = m_frame->Prj().SchLibs()->GetCacheLibrary();
1022 
1023  for( unsigned i = 0; i < loadedItems.size(); ++i )
1024  {
1025  EDA_ITEM* item = loadedItems[i];
1026 
1027  if( item->Type() == SCH_COMPONENT_T )
1028  {
1029  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1030  component->Resolve( *symLibTable, partLib );
1031  }
1032  else if( item->Type() == SCH_SHEET_T )
1033  {
1034  SCH_SHEET* sheet = (SCH_SHEET*) item;
1035  wxFileName fn = sheet->GetFileName();
1036  SCH_SCREEN* existingScreen = nullptr;
1037 
1038  if( !fn.IsAbsolute() )
1039  {
1040  wxFileName currentSheetFileName = g_CurrentSheet->LastScreen()->GetFileName();
1041  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1042  }
1043 
1044  if( g_RootSheet->SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
1045  {
1046  sheet->SetScreen( existingScreen );
1047 
1048  SCH_SHEET_PATH sheetpath = *g_CurrentSheet;
1049  sheetpath.push_back( sheet );
1050 
1051  // Clear annotation and create the AR for this path, if not exists,
1052  // when the screen is shared by sheet paths.
1053  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1054  // reference default value and takes the latest displayed value
1055  existingScreen->EnsureAlternateReferencesExist();
1056  existingScreen->ClearAnnotation( &sheetpath );
1057  }
1058  else
1059  {
1060  m_frame->LoadSheetFromFile( sheet, g_CurrentSheet, sheet->GetFileName() );
1061  }
1062  }
1063 
1064  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1065  m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
1066 
1067  // Reset flags for subsequent move operation
1068  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1069  }
1070 
1071  if( sheetsPasted )
1073 
1074  // Now clear the previous selection, select the pasted items, and fire up the "move"
1075  // tool.
1076  //
1078  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1079 
1080  EE_SELECTION& selection = selTool->GetSelection();
1081 
1082  if( !selection.Empty() )
1083  {
1084  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1085 
1086  selection.SetReferencePoint( item->GetPosition() );
1088  }
1089 
1090  return 0;
1091 }
1092 
1093 
1095 {
1098  SCH_COMPONENT* sym = nullptr;
1099  LIB_EDIT_FRAME* libEdit;
1100 
1101  if( selection.GetSize() >= 1 )
1102  sym = (SCH_COMPONENT*) selection.Front();
1103 
1104  if( !sym || sym->GetEditFlags() != 0 )
1105  return 0;
1106 
1108  libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1109 
1110  if( libEdit )
1111  libEdit->LoadComponentAndSelectLib( sym->GetLibId(), sym->GetUnit(), sym->GetConvert() );
1112 
1113  return 0;
1114 }
1115 
1116 
1118 {
1119  wxCommandEvent dummy;
1120  m_frame->OnAnnotate( dummy );
1121  return 0;
1122 }
1123 
1124 
1126 {
1127  wxCommandEvent dummy;
1129  return 0;
1130 }
1131 
1132 
1134 {
1136  dlg.ShowQuasiModal();
1137  return 0;
1138 }
1139 
1140 
1142 {
1144  m_frame->HardRedraw();
1145 
1146  return 0;
1147 }
1148 
1149 
1151 {
1152  wxCommandEvent dummy;
1154  return 0;
1155 }
1156 
1157 
1159 {
1160  wxCommandEvent dummy;
1162  return 0;
1163 }
1164 
1165 
1167 {
1168  int result = NET_PLUGIN_CHANGE;
1169 
1170  // If a plugin is removed or added, rebuild and reopen the new dialog
1171  while( result == NET_PLUGIN_CHANGE )
1172  result = InvokeDialogNetList( m_frame );
1173 
1174  return 0;
1175 }
1176 
1177 
1179 {
1181  return 0;
1182 }
1183 
1184 
1186 {
1188  return 0;
1189 }
1190 
1191 
1193 {
1195  return 0;
1196 }
1197 
1198 
1200 {
1202  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1203 
1204  if( selection.GetSize() == 1 )
1205  {
1206  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1207 
1210 
1211  g_CurrentSheet->push_back( sheet );
1213  }
1214 
1215  return 0;
1216 }
1217 
1218 
1220 {
1221  if( g_CurrentSheet->Last() != g_RootSheet )
1222  {
1225 
1228  }
1229 
1230  return 0;
1231 }
1232 
1233 
1235 {
1237 
1238  auto painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1239  painter->GetSettings()->m_ShowHiddenPins = m_frame->GetShowAllPins();
1240 
1242  m_frame->GetCanvas()->Refresh();
1243 
1244  return 0;
1245 }
1246 
1247 
1249 {
1251 
1252  return 0;
1253 }
1254 
1255 
1257 {
1258  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1259  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1260  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1264  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1265  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1266  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1267 
1276 
1281 
1282 #ifdef KICAD_SPICE
1283  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
1284  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
1285 #endif /* KICAD_SPICE */
1286 
1293 
1294  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1295  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1296  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
1297  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
1298  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1299 
1311 
1313 
1317 
1320 }
int Save(const TOOL_EVENT &aEvent)
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)
void SetTimeStamp(timestamp_t aNewTimeStamp)
Change the time stamp to aNewTimeStamp and updates the reference path.
int FindAndReplace(const TOOL_EVENT &aEvent)
void OnOpenCvpcb(wxCommandEvent &event)
void Save_File(bool doSaveAs=false)
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
const wxString & GetFileName() const
Definition: sch_screen.h:118
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:196
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
static TOOL_ACTION findAndReplace
Definition: actions.h:78
int m_Threshold
Definition: collector.h:68
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:542
SCH_SCREEN * GetNext()
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
const wxString & GetSelectedNetName() const
NETLIST_OBJECT_LIST * BuildNetListBase(bool updateStatusText=true)
Create a flat list which stores all connected objects.
std::function< SEARCH_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Typedef INSPECTOR is used to inspect and possibly collect the (search) results of iterating over a li...
Definition: base_struct.h:83
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:159
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:178
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to highlight nets.
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:152
EDA_BASE_FRAME * GetEditFrame() const
Definition: tool_manager.h:256
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to pcbnew for highlighting.
const wxString & GetName() const
Definition: sch_pin.h:95
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
static TOOL_ACTION pageSettings
Definition: actions.h:59
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:197
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.
static TOOL_ACTION doDelete
Definition: actions.h:73
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
SCH_ITEM * Next() const
Definition: sch_item.h:153
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:72
bool SaveClipboard(const std::string &aText)
Stores an information to the system clipboard.
void SetScreen(BASE_SCREEN *aScreen) override
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:65
static wxFindReplaceData g_markersOnly
double GetZoom() const
Function GetZoom returns the current "zoom factor", which is a measure of "internal units per device ...
Definition: base_screen.h:240
int Redo(const TOOL_EVENT &aEvent)
int NavigateHierarchy(const TOOL_EVENT &aEvent)
Definition: hierarch.cpp:132
int EditSymbolFields(const TOOL_EVENT &aEvent)
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.
int GetUndoCommandCount() const
Definition: base_screen.h:201
void SendCrossProbeClearHighlight()
Tells PcbNew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:104
static TOOL_ACTION replaceAll
Definition: actions.h:82
int ReplaceAndFindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1444
void SetWksFileName(const wxString &aFilename)
static const wxCursor & GetCursor(CURSOR aCursorType)
void SetBrightened()
Definition: base_struct.h:241
#define HITTEST_THRESHOLD_PIXELS
void ClearBrightenedPins()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
int New(const TOOL_EVENT &aEvent)
void Format(SCH_SCREEN *aScreen)
Class EE_COLLECTOR.
Definition: ee_collectors.h:39
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:840
bool IsBrightened() const
Definition: base_struct.h:236
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
Schematic editor (Eeschema) main window.
int FindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:152
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:216
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 EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:750
static TOOL_ACTION print
Definition: actions.h:60
int Annotate(const TOOL_EVENT &aEvent)
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:261
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
int GenerateBOM(const TOOL_EVENT &aEvent)
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
static TOOL_ACTION find
Definition: actions.h:77
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:204
SCH_SHEET_PATH * FindSheetForScreen(SCH_SCREEN *aScreen)
Function FindSheetForScreen.
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 SaveAll(const TOOL_EVENT &aEvent)
int DrawSheetOnClipboard(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:200
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
int SaveAs(const TOOL_EVENT &aEvent)
int ToggleForceHV(const TOOL_EVENT &aEvent)
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
void pop_back()
Forwarded method from std::vector.
EDA_ITEM * Next() const
Definition: base_struct.h:218
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:177
void ClearBrightened()
Definition: base_struct.h:245
static TOOL_ACTION pickerTool
Definition: actions.h:144
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:102
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:109
static TOOL_ACTION updateFind
Definition: actions.h:83
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
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.
static TOOL_ACTION annotate
Definition: ee_actions.h:146
Class SCH_EDITOR_CONTROL.
Class TOOL_MANAGER.
Definition: tool_manager.h:50
int EnterSheet(const TOOL_EVENT &aEvent)
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:113
int ShowPcbNew(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 showPcbNew
Definition: ee_actions.h:157
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:243
timestamp_t GetNewTimeStamp()
Definition: common.cpp:217
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int GetUnit() const
void BrightenPin(LIB_PIN *aPin)
void BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:205
virtual wxPoint GetPosition() const =0
Function GetPosition.
static TOOL_ACTION showBusManager
Definition: ee_actions.h:153
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:147
Item is being added to the view.
Definition: view_item.h:60
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:102
int TestDuplicateSheetNames(bool aCreateMarker)
Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names...
Definition: erc.cpp:174
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
wxString Name(bool aIgnoreSheet=false) const
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...
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
int LeaveSheet(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:199
int Print(const TOOL_EVENT &aEvent)
void SetName(const wxString &aName)
Definition: sch_sheet.h:263
void HardRedraw() override
Rebuild the GAL and redraw the screen.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:225
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:269
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.
int ReplaceAll(const TOOL_EVENT &aEvent)
int ShowQuasiModal()
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:622
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static TOOL_ACTION open
Definition: actions.h:53
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:186
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int UpdateFind(const TOOL_EVENT &aEvent)
Class TOOL_EVENT.
Definition: tool_event.h:168
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
PopCommandFromRedoList return the last command to undo and remove it from list nothing is deleted.
int EditWithLibEdit(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void Collect(EDA_ITEM *aItem, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Function Collect scans a EDA_ITEM using this class's Inspector method, which does the collection.
static TOOL_ACTION cut
Definition: actions.h:69
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Definition: backanno.cpp:207
EDA_ITEM * GetParent() const
Definition: base_struct.h:220
static SEARCH_RESULT IterateForward(EDA_ITEM *listStart, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function IterateForward walks through the object tree calling the inspector() on each object type req...
Definition: base_struct.h:417
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
static TOOL_ACTION quit
Definition: actions.h:62
EDA_ITEM * nextMatch(SCH_SCREEN *aScreen, EDA_ITEM *after, wxFindReplaceData *data)
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.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:140
bool InvokeDialogEditComponentsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of components for instance when a symbol has moved from a symbol li...
static const TOOL_EVENT ClearedEvent
Definition: actions.h:198
static TOOL_ACTION replaceAndFindNext
Definition: actions.h:81
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
static TOOL_ACTION plot
Definition: actions.h:61
void UpdateItems()
Function UpdateItems() Iterates through the list of items that asked for updating and updates them.
Definition: view.cpp:1421
const std::string & GetString()
Definition: richio.h:475
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:356
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
void SetUnit(int aUnit)
Change the unit number to aUnit.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:58
Class SCH_SHEET_PATH.
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:144
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:1540
void OnUpdatePCB(wxCommandEvent &event)
const wxString GetRef(const SCH_SHEET_PATH *aSheet)
Return the reference for the given sheet path.
bool LoadComponentAndSelectLib(const LIB_ID &aLibId, int aUnit, int aConvert)
Selects the currently active library and loads the symbol from aLibId.
Definition: libedit.cpp:141
static VECTOR2D CLEAR
#define _(s)
void UnbrightenItem(EDA_ITEM *aItem)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
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:128
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.
Implementing SIM_PLOT_FRAME_BASE.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:204
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:629
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:334
static bool m_allowRealTime
void OnAnnotate(wxCommandEvent &event)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:455
int Open(const TOOL_EVENT &aEvent)
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
static TOOL_ACTION findNextMarker
Definition: actions.h:80
static TOOL_ACTION redo
Definition: actions.h:68
int PageSetup(const TOOL_EVENT &aEvent)
void ClearFindReplaceStatus()
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
The symbol library editor main window.
int Quit(const TOOL_EVENT &aEvent)
void FocusOnLocation(const wxPoint &aPos, bool aCenterView=false)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
int AddItemToSel(const TOOL_EVENT &aEvent)
static TOOL_ACTION showSymbolEditor
Definition: actions.h:149
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
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 saveAs
Definition: actions.h:55
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:183
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
int ShowBusManager(const TOOL_EVENT &aEvent)
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
int Cut(const TOOL_EVENT &aEvent)
Clipboard support.
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:158
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
bool HasBrightenedPins()
size_t i
Definition: json11.cpp:597
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
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...
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
static const KICAD_T AllItems[]
Definition: ee_collectors.h:42
void OnOpenPcbnew(wxCommandEvent &event)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
#define NET_PLUGIN_CHANGE
Create and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::ShowModal() returns.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:193
int Undo(const TOOL_EVENT &aEvent)
bool doCopy()
copy selection to clipboard
static TOOL_ACTION enterSheet
Definition: ee_actions.h:176
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:203
void Activate()
Function Activate() Runs the tool.
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:731
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:156
static TOOL_ACTION move
Definition: ee_actions.h:115
static TOOL_ACTION simProbe
Definition: ee_actions.h:198
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
int GetConvert() const
static TOOL_ACTION undo
Definition: actions.h:67
SCH_SCREEN * GetFirst()
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:50
static TOOL_ACTION generateBOM
Definition: ee_actions.h:160
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 saveAll
Definition: actions.h:57
void Print()
Show the print dialog.
static TOOL_ACTION highlightNet
Definition: ee_actions.h:202
#define MAX_PAGE_SIZE_MILS
Definition: page_info.h:41
void InvokeDialogBusManager(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BUS_MANAGER.
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
Class VIEW.
Definition: view.h:61
void AddTuner(SCH_COMPONENT *aComponent)
Adds a tuner for a component.
const wxPoint GetCenter() const
Definition: eda_rect.h:115
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.
Definition of the NETLIST_OBJECT class.
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:148
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:192
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:106
Object used to load, save, search, and otherwise manipulate symbol library files.
void ShowFindReplaceStatus(const wxString &aMsg)
int GetRedoCommandCount() const
Definition: base_screen.h:206
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:243
void SetSelectedNetName(const wxString &aNetName)
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
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:492
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
static TOOL_ACTION findNext
Definition: actions.h:79
static TOOL_ACTION paste
Definition: actions.h:71
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:486
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:133
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
SCH_SCREEN * LastScreen() const
Function LastScreen.
EDA_ITEM * Front() const
Definition: selection.h:182
void SetShowAllPins(bool aEnable)
int ExportNetlist(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:215
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
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:147