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-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <symbol_library.h>
26 #include <confirm.h>
27 #include <connection_graph.h>
33 #include <project_rescue.h>
34 #include <erc.h>
35 #include <invoke_sch_dialog.h>
36 #include <string_utils.h>
37 #include <kiway.h>
38 #include <kiway_player.h>
40 #include <project/project_file.h>
41 #include <project/net_settings.h>
42 #include <sch_edit_frame.h>
44 #include <sch_line.h>
45 #include <sch_painter.h>
46 #include <sch_sheet.h>
47 #include <sch_sheet_pin.h>
48 #include <sch_view.h>
49 #include <schematic.h>
50 #include <advanced_config.h>
51 #include <sim/sim_plot_frame.h>
52 #include <symbol_viewer_frame.h>
53 #include <status_popup.h>
54 #include <tool/picker_tool.h>
55 #include <tool/tool_manager.h>
56 #include <tools/ee_actions.h>
57 #include <tools/ee_selection.h>
61 #include <dialog_update_from_pcb.h>
62 #include <eda_list_dialog.h>
63 
65 #include <sch_sheet_path.h>
66 #include <wx/filedlg.h>
67 
68 
69 int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
70 {
72  return 0;
73 }
74 
75 
77 {
79  return 0;
80 }
81 
82 
84 {
86  return 0;
87 }
88 
89 
91 {
92  m_frame->SaveProject( true );
93  return 0;
94 }
95 
96 
98 {
99  SCH_SHEET* curr_sheet = m_frame->GetCurrentSheet().Last();
100  wxFileName curr_fn = curr_sheet->GetFileName();
101  wxFileDialog dlg( m_frame, _( "Schematic Files" ), curr_fn.GetPath(),
102  curr_fn.GetFullName(), KiCadSchematicFileWildcard(),
103  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
104 
105  if( dlg.ShowModal() == wxID_CANCEL )
106  return false;
107 
108  wxFileName newFileName = dlg.GetPath();
109  newFileName.SetExt( KiCadSchematicFileExtension );
110 
111  m_frame->saveSchematicFile( curr_sheet, newFileName.GetFullPath() );
112  return 0;
113 }
114 
115 
117 {
119  return 0;
120 }
121 
122 
124 {
125  PICKED_ITEMS_LIST undoCmd;
126  DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
127  ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
128 
129  undoCmd.PushItem( wrapper );
131 
134 
135  if( dlg.ShowModal() != wxID_OK )
137 
138  return 0;
139 }
140 
141 
143 {
144  SCH_SCREENS schematic( m_frame->Schematic().Root() );
145 
146  if( schematic.HasNoFullyDefinedLibIds() )
147  RescueLegacyProject( true );
148  else
150 
151  return 0;
152 }
153 
154 
155 bool SCH_EDITOR_CONTROL::RescueLegacyProject( bool aRunningOnDemand )
156 {
158  m_frame->GetCanvas()->GetBackend() );
159 
160  return rescueProject( rescuer, aRunningOnDemand );
161 }
162 
163 
165 {
168  m_frame->GetCanvas()->GetBackend() );
169 
170  return rescueProject( rescuer, aRunningOnDemand );
171 }
172 
173 
174 bool SCH_EDITOR_CONTROL::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
175 {
176  if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
177  return false;
178 
179  if( aRescuer.GetCandidateCount() )
180  {
181  KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
182 
183  if( viewer )
184  static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
185 
186  if( aRunningOnDemand )
187  {
188  SCH_SCREENS schematic( m_frame->Schematic().Root() );
189 
190  schematic.UpdateSymbolLinks();
192  }
193 
195  m_frame->SyncView();
196  m_frame->GetCanvas()->Refresh();
197  m_frame->OnModify();
198  }
199 
200  return true;
201 }
202 
203 
205 {
206  DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
207 
208  dlgRemap.ShowQuasiModal();
209 
210  m_frame->GetCanvas()->Refresh( true );
211 
212  return 0;
213 }
214 
215 
217 {
219 
220  wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->Schematic().RootScreen()->GetFileName() );
221 
222  if( fn.GetName() != NAMELESS_PROJECT )
224 
225  return 0;
226 }
227 
228 
230 {
232 
233  dlg.ShowModal();
234 
235  // save project config if the prj config has changed:
236  if( dlg.PrjConfigChanged() )
238 
239  return 0;
240 }
241 
242 
244 {
245  m_frame->Close( false );
246  return 0;
247 }
248 
249 
250 // A dummy wxFindReplaceData signaling any marker should be found
251 static wxFindReplaceData g_markersOnly;
252 
253 
255 {
257  return UpdateFind( aEvent );
258 }
259 
260 
262 {
264  return 0;
265 }
266 
267 
269 {
270  wxFindReplaceData& data = m_frame->GetFindReplaceData();
271 
272  auto visit =
273  [&]( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheet )
274  {
275  // We may get triggered when the dialog is not opened due to binding
276  // SelectedItemsModified we also get triggered when the find dialog is
277  // closed....so we need to double check the dialog is open.
278  if( m_frame->m_findReplaceDialog != nullptr
279  && !data.GetFindString().IsEmpty()
280  && aItem->Matches( data, aSheet ) )
281  {
282  aItem->SetForceVisible( true );
283  m_selectionTool->BrightenItem( aItem );
284  }
285  else if( aItem->IsBrightened() )
286  {
287  aItem->SetForceVisible( false );
289  }
290  };
291 
292  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
293  || aEvent.IsAction( &ACTIONS::updateFind ) )
294  {
296 
297  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
298  {
299  visit( item, &m_frame->GetCurrentSheet() );
300 
301  item->RunOnChildren(
302  [&]( SCH_ITEM* aChild )
303  {
304  visit( aChild, &m_frame->GetCurrentSheet() );
305  } );
306  }
307  }
308  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
309  {
310  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
311  visit( item, &m_frame->GetCurrentSheet() );
312  }
313 
314  getView()->UpdateItems();
315  m_frame->GetCanvas()->Refresh();
316  m_frame->UpdateTitle();
317 
318  return 0;
319 }
320 
321 
323  SCH_ITEM* aAfter, wxFindReplaceData& aData )
324 {
325  bool past_item = true;
326 
327  if( aAfter != nullptr )
328  {
329  past_item = false;
330 
331  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
332  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
333  }
334 
335  std::vector<SCH_ITEM*> sorted_items;
336 
337  for( SCH_ITEM* item : aScreen->Items() )
338  sorted_items.push_back( item );
339 
340  std::sort( sorted_items.begin(), sorted_items.end(),
341  [&]( SCH_ITEM* a, SCH_ITEM* b )
342  {
343  if( a->GetPosition().x == b->GetPosition().x )
344  {
345  // Ensure deterministic sort
346  if( a->GetPosition().y == b->GetPosition().y )
347  return a->m_Uuid < b->m_Uuid;
348 
349  return a->GetPosition().y < b->GetPosition().y;
350  }
351  else
352  return a->GetPosition().x < b->GetPosition().x;
353  }
354  );
355 
356  for( SCH_ITEM* item : sorted_items )
357  {
358  if( item == aAfter )
359  {
360  past_item = true;
361  }
362  else if( past_item )
363  {
364  if( &aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
365  return item;
366 
367  if( item->Matches( aData, aSheet ) )
368  return item;
369 
370  if( item->Type() == SCH_SYMBOL_T )
371  {
372  SCH_SYMBOL* cmp = static_cast<SCH_SYMBOL*>( item );
373 
374  for( SCH_FIELD& field : cmp->GetFields() )
375  {
376  if( field.Matches( aData, aSheet ) )
377  return &field;
378  }
379 
380  for( SCH_PIN* pin : cmp->GetPins() )
381  {
382  if( pin->Matches( aData, aSheet ) )
383  return pin;
384  }
385  }
386 
387  if( item->Type() == SCH_SHEET_T )
388  {
389  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
390 
391  for( SCH_FIELD& field : sheet->GetFields() )
392  {
393  if( field.Matches( aData, aSheet ) )
394  return &field;
395  }
396 
397  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
398  {
399  if( pin->Matches( aData, aSheet ) )
400  return pin;
401  }
402  }
403  }
404  }
405 
406  return nullptr;
407 }
408 
409 
411 {
412  // A timer during which a subsequent FindNext will result in a wrap-around
413  static wxTimer wrapAroundTimer;
414 
415  wxFindReplaceData& data = m_frame->GetFindReplaceData();
416 
417  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
418  {
419  g_markersOnly.SetFlags( data.GetFlags() );
420 
421  data = g_markersOnly;
422  }
423  else if( data.GetFindString().IsEmpty() )
424  {
425  return FindAndReplace( ACTIONS::find.MakeEvent() );
426  }
427 
428  bool searchAllSheets = !( data.GetFlags() & FR_CURRENT_SHEET_ONLY );
429  EE_SELECTION& selection = m_selectionTool->GetSelection();
430  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
431  SCH_ITEM* item = nullptr;
432 
433  SCH_SHEET_PATH* afterSheet = &m_frame->GetCurrentSheet();
434 
435  if( wrapAroundTimer.IsRunning() )
436  {
437  afterSheet = nullptr;
438  afterItem = nullptr;
439  wrapAroundTimer.Stop();
441  }
442 
444 
445  if( afterSheet || !searchAllSheets )
446  item = nextMatch( m_frame->GetScreen(), &m_frame->GetCurrentSheet(), afterItem, data );
447 
448  if( !item && searchAllSheets )
449  {
450  SCH_SCREENS screens( m_frame->Schematic().Root() );
451  std::vector<SCH_SHEET_PATH*> paths;
452 
453  screens.BuildClientSheetPathList();
454 
455  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
456  {
457  for( SCH_SHEET_PATH& sheet : screen->GetClientSheetPaths() )
458  paths.push_back( &sheet );
459  }
460 
461  std::sort( paths.begin(), paths.end(), [] ( const SCH_SHEET_PATH* lhs,
462  const SCH_SHEET_PATH* rhs ) -> bool
463  {
464  int retval = lhs->ComparePageNumAndName( *rhs );
465 
466  if( retval < 0 )
467  return true;
468  else if( retval > 0 )
469  return false;
470  else
471  return lhs->GetCurrentHash() < rhs->GetCurrentHash();
472  } );
473 
474  for( SCH_SHEET_PATH* sheet : paths )
475  {
476  if( afterSheet )
477  {
478  if( afterSheet->GetPageNumber() == sheet->GetPageNumber() )
479  afterSheet = nullptr;
480 
481  continue;
482  }
483 
484  SCH_SCREEN* screen = sheet->LastScreen();
485 
486  item = nextMatch( screen, sheet, nullptr, data );
487 
488  if( item )
489  {
490  m_frame->Schematic().SetCurrentSheet( *sheet );
492 
493  screen->TestDanglingEnds();
494 
495  m_frame->SetScreen( screen );
497  UpdateFind( ACTIONS::updateFind.MakeEvent() );
498 
499  break;
500  }
501  }
502  }
503 
504  if( item )
505  {
506  m_selectionTool->AddItemToSel( item );
507  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
508  m_frame->GetCanvas()->Refresh();
509  }
510  else
511  {
512  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
513  : _( "Reached end of sheet." );
514 
515  // Show the popup during the time period the user can wrap the search
516  m_frame->ShowFindReplaceStatus( msg + wxS( " " ) +
517  _( "Find again to wrap around to the start." ), 4000 );
518  wrapAroundTimer.StartOnce( 4000 );
519  }
520 
521  return 0;
522 }
523 
524 
526 {
527  wxFindReplaceData& data = m_frame->GetFindReplaceData();
529 
530  return item && item->Matches( data, &m_frame->GetCurrentSheet() );
531 }
532 
533 
535 {
536  wxFindReplaceData& data = m_frame->GetFindReplaceData();
539 
540  if( data.GetFindString().IsEmpty() )
541  return FindAndReplace( ACTIONS::find.MakeEvent() );
542 
543  if( item && item->Matches( data, sheet ) )
544  {
545  if( item->Replace( data, sheet ) )
546  {
547  m_frame->UpdateItem( item, false, true );
549  m_frame->OnModify();
550  }
551 
552  FindNext( ACTIONS::findNext.MakeEvent() );
553  }
554 
555  return 0;
556 }
557 
558 
560 {
561  wxFindReplaceData& data = m_frame->GetFindReplaceData();
562  bool modified = false;
563 
564  if( data.GetFindString().IsEmpty() )
565  return FindAndReplace( ACTIONS::find.MakeEvent() );
566 
567  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
568  SCH_SCREENS screens( m_frame->Schematic().Root() );
569 
570  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
571  {
572  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
573 
574  for( EDA_ITEM* item = nextMatch( screen, sheet, nullptr, data ); item; )
575  {
576  if( item->Replace( data, sheet ) )
577  {
578  m_frame->UpdateItem( item, false, true );
579  modified = true;
580  }
581 
582  item = nextMatch( screen, sheet, dynamic_cast<SCH_ITEM*>( item ), data );
583  }
584  }
585 
586  if( modified )
587  {
589  m_frame->OnModify();
590  }
591 
592  return 0;
593 }
594 
595 
597 {
598  doCrossProbeSchToPcb( aEvent, false );
599  return 0;
600 }
601 
602 
604 {
605  doCrossProbeSchToPcb( aEvent, true );
606  return 0;
607 }
608 
609 
610 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
611 {
612  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
613  if( m_probingPcbToSch )
614  return;
615 
617  SCH_ITEM* item = nullptr;
618  SCH_SYMBOL* symbol = nullptr;
619 
620  if( aForce )
621  {
622  EE_SELECTION& selection = selTool->RequestSelection();
623 
624  if( selection.GetSize() >= 1 )
625  item = (SCH_ITEM*) selection.Front();
626  }
627  else
628  {
629  EE_SELECTION& selection = selTool->GetSelection();
630 
631  if( selection.GetSize() >= 1 )
632  item = (SCH_ITEM*) selection.Front();
633  }
634 
635  if( !item )
636  {
637  if( aForce )
638  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
639 
640  return;
641  }
642 
643 
644  switch( item->Type() )
645  {
646  case SCH_FIELD_T:
647  case LIB_FIELD_T:
648  if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T )
649  {
650  symbol = (SCH_SYMBOL*) item->GetParent();
651  m_frame->SendMessageToPCBNEW( item, symbol );
652  }
653  break;
654 
655  case SCH_SYMBOL_T:
656  symbol = (SCH_SYMBOL*) item;
657  m_frame->SendMessageToPCBNEW( item, symbol );
658  break;
659 
660  case SCH_PIN_T:
661  symbol = (SCH_SYMBOL*) item->GetParent();
662  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), symbol );
663  break;
664 
665  case SCH_SHEET_T:
666  if( aForce )
667  m_frame->SendMessageToPCBNEW( item, nullptr );
668  break;
669 
670  default:
671  break;
672  }
673 }
674 
675 
676 #ifdef KICAD_SPICE
677 
678 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
679 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
680 static KICAD_T fieldsAndSymbols[] = { SCH_SYMBOL_T, SCH_FIELD_T, EOT };
681 
682 #define HITTEST_THRESHOLD_PIXELS 5
683 
684 
685 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
686 {
688  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
689 
690  if( !simFrame ) // Defensive coding; shouldn't happen.
691  return 0;
692 
693  // Deactivate other tools; particularly important if another PICKER is currently running
694  Activate();
695 
697  picker->SetSnapping( false );
698 
699  picker->SetClickHandler(
700  [this, simFrame]( const VECTOR2D& aPosition )
701  {
703  EDA_ITEM* item = selTool->GetNode( aPosition );
704 
705  if( !item )
706  return false;
707 
708  if( item->IsType( wires ) )
709  {
710  if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
711  simFrame->AddVoltagePlot( UnescapeString( conn->Name() ) );
712  }
713  else if( item->Type() == SCH_PIN_T )
714  {
715  SCH_PIN* pin = (SCH_PIN*) item;
716  SCH_SYMBOL* symbol = (SCH_SYMBOL*) item->GetParent();
717  wxString ref = symbol->GetRef( &m_frame->GetCurrentSheet() );
718  wxString param;
719  wxString primitive;
720 
721  primitive = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, symbol, 0 );
722  primitive.LowerCase();
723 
724  if( primitive == "c" || primitive == "l" || primitive == "r" )
725  param = wxT( "I" );
726  else if( primitive == "d" )
727  param = wxT( "Id" );
728  else
729  param = wxString::Format( wxT( "I%s" ), pin->GetShownName().Lower() );
730 
731  simFrame->AddCurrentPlot( ref, param );
732  }
733 
734  return true;
735  } );
736 
737  picker->SetMotionHandler(
738  [this, picker]( const VECTOR2D& aPos )
739  {
740  EE_COLLECTOR collector;
741  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
742  collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
743 
745  selectionTool->GuessSelectionCandidates( collector, aPos );
746 
747  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
748  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
749 
750  const SCH_CONNECTION* conn = nullptr;
751 
752  if( wire )
753  {
754  item = nullptr;
755  conn = wire->Connection();
756  }
757 
758  if( item && item->Type() == SCH_PIN_T )
760  else
762 
763  if( m_pickerItem != item )
764  {
765  if( m_pickerItem )
766  selectionTool->UnbrightenItem( m_pickerItem );
767 
768  m_pickerItem = item;
769 
770  if( m_pickerItem )
771  selectionTool->BrightenItem( m_pickerItem );
772  }
773 
774  if( m_frame->GetHighlightedConnection() != conn )
775  {
777 
778  TOOL_EVENT dummyEvent;
779  UpdateNetHighlighting( dummyEvent );
780  }
781  } );
782 
783  picker->SetFinalizeHandler(
784  [this]( const int& aFinalState )
785  {
786  if( m_pickerItem )
788 
790  {
791  m_frame->SetHighlightedConnection( nullptr );
792 
793  TOOL_EVENT dummyEvent;
794  UpdateNetHighlighting( dummyEvent );
795  }
796 
797  // Wake the selection tool after exiting to ensure the cursor gets updated
799  } );
800 
801  std::string tool = aEvent.GetCommandStr().get();
802  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
803 
804  return 0;
805 }
806 
807 
808 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
809 {
811 
812  // Deactivate other tools; particularly important if another PICKER is currently running
813  Activate();
814 
815  picker->SetCursor( KICURSOR::TUNE );
816  picker->SetSnapping( false );
817 
818  picker->SetClickHandler(
819  [this]( const VECTOR2D& aPosition )
820  {
822  EDA_ITEM* item = nullptr;
823  selTool->SelectPoint( aPosition, fieldsAndSymbols, &item );
824 
825  if( !item )
826  return false;
827 
828  if( item->Type() != SCH_SYMBOL_T )
829  {
830  item = item->GetParent();
831 
832  if( item->Type() != SCH_SYMBOL_T )
833  return false;
834  }
835 
836  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
837  KIWAY_PLAYER* simFrame = m_frame->Kiway().Player( FRAME_SIMULATOR, false );
838 
839  if( simFrame )
840  static_cast<SIM_PLOT_FRAME*>( simFrame )->AddTuner( symbol );
841 
842  return true;
843  } );
844 
845  picker->SetMotionHandler(
846  [this]( const VECTOR2D& aPos )
847  {
848  EE_COLLECTOR collector;
849  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
850  collector.Collect( m_frame->GetScreen(), fieldsAndSymbols, (wxPoint) aPos );
851 
853  selectionTool->GuessSelectionCandidates( collector, aPos );
854 
855  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
856 
857  if( m_pickerItem != item )
858  {
859  if( m_pickerItem )
860  selectionTool->UnbrightenItem( m_pickerItem );
861 
862  m_pickerItem = item;
863 
864  if( m_pickerItem )
865  selectionTool->BrightenItem( m_pickerItem );
866  }
867  } );
868 
869  picker->SetFinalizeHandler(
870  [this]( const int& aFinalState )
871  {
872  if( m_pickerItem )
874 
875  // Wake the selection tool after exiting to ensure the cursor gets updated
877  } );
878 
879  std::string tool = aEvent.GetCommandStr().get();
880  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
881 
882  return 0;
883 }
884 #endif /* KICAD_SPICE */
885 
886 
887 // A singleton reference for clearing the highlight
889 
890 
891 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
892 {
893  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetToolHolder() );
894  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
895  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
896  SCH_CONNECTION* conn = nullptr;
897  bool retVal = true;
898 
899  if( aPosition != CLEAR )
900  {
901  ERC_TESTER erc( &editFrame->Schematic() );
902 
903  if( erc.TestDuplicateSheetNames( false ) > 0 )
904  {
905  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
906  retVal = false;
907  }
908  else
909  {
910  SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
911  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
912 
913  if( item )
914  {
915  if( item->Type() == SCH_FIELD_T )
916  symbol = dynamic_cast<SCH_SYMBOL*>( item->GetParent() );
917 
918  if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
919  {
920  std::vector<SCH_PIN*> pins = symbol->GetPins();
921 
922  if( pins.size() == 1 )
923  conn = pins[0]->Connection();
924  }
925  else
926  {
927  conn = item->Connection();
928  }
929  }
930  }
931  }
932 
933  if( !conn )
934  {
935  editFrame->SetStatusText( wxT( "" ) );
936  editFrame->SendCrossProbeClearHighlight();
937  }
938  else
939  {
940  editFrame->SetCrossProbeConnection( conn );
941  }
942 
943  editFrame->SetHighlightedConnection( conn );
944  editFrame->UpdateNetHighlightStatus();
945 
947  editorControl->UpdateNetHighlighting( dummy );
948 
949  return retVal;
950 }
951 
952 
954 {
956  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
957 
958  highlightNet( m_toolMgr, cursorPos );
959 
960  return 0;
961 }
962 
963 
965 {
967 
968  return 0;
969 }
970 
971 
973 {
976  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
977 
978  // TODO remove once real-time connectivity is a given
980  // Ensure the netlist data is up to date:
982 
983  // Remove selection in favor of highlighting so the whole net is highlighted
984  selectionTool->ClearSelection();
985  highlightNet( m_toolMgr, cursorPos );
986 
988 
989  if( conn )
990  {
991  if( !conn->IsBus()
992  && ( !conn->Driver()
995  {
996  m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
998  return 0;
999  }
1000  else if( conn->IsBus() && conn->Members().size() == 0 )
1001  {
1002  m_frame->ShowInfoBarError( _( "Bus has no members to assign netclass to." ) );
1004  return 0;
1005  }
1006 
1007  wxArrayString netNames;
1008 
1009  if( conn->IsBus() )
1010  {
1011  for( const std::shared_ptr<SCH_CONNECTION>& member : conn->Members() )
1012  {
1013  if( member->IsBus() )
1014  {
1015  for( const std::shared_ptr<SCH_CONNECTION>& subMember : member->Members() )
1016  netNames.Add( subMember->Name() );
1017  }
1018  else
1019  {
1020  netNames.Add( member->Name() );
1021  }
1022  }
1023  }
1024  else
1025  {
1026  netNames.Add( conn->Name() );
1027  }
1028 
1029  NET_SETTINGS& netSettings = m_frame->Schematic().Prj().GetProjectFile().NetSettings();
1030  wxString netclassName = netSettings.GetNetclassName( netNames.front() );
1031 
1032  wxArrayString headers;
1033  std::vector<wxArrayString> items;
1034 
1035  headers.Add( _( "Netclasses" ) );
1036 
1037  wxArrayString defaultItem;
1038  defaultItem.Add( _( "Default" ) );
1039  items.emplace_back( defaultItem );
1040 
1041  for( const std::pair<const wxString, NETCLASSPTR>& ii : netSettings.m_NetClasses )
1042  {
1043  wxArrayString item;
1044  item.Add( ii.first );
1045  items.emplace_back( item );
1046  }
1047 
1048  EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName );
1049  dlg.SetListLabel( _( "Select netclass:" ) );
1050 
1051  if( dlg.ShowModal() == wxID_OK )
1052  {
1053  netclassName = dlg.GetTextSelection();
1054 
1055  for( const wxString& netName : netNames )
1056  {
1057  // Remove from old netclass membership list
1058  if( netSettings.m_NetClassAssignments.count( netName ) )
1059  {
1060  const wxString oldNetclassName = netSettings.m_NetClassAssignments[netName];
1061  NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName );
1062 
1063  if( oldNetclass )
1064  oldNetclass->Remove( netName );
1065  }
1066 
1067  // Add to new netclass membership list
1068  NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
1069 
1070  if( newNetclass )
1071  newNetclass->Add( netName );
1072 
1073  netSettings.m_NetClassAssignments[netName] = netclassName;
1074  }
1075  }
1076  }
1077 
1079  return 0;
1080 }
1081 
1082 
1084 {
1086  CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
1087  std::vector<EDA_ITEM*> itemsToRedraw;
1088  const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
1089 
1090  if( !screen )
1091  return 0;
1092 
1093  bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
1094  wxString selectedName = selectedConn ? selectedConn->Name() : "";
1095 
1096  bool selectedIsNoNet = false;
1097  CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
1098 
1099  if( selectedConn && selectedConn->Driver() == nullptr )
1100  {
1101  selectedIsNoNet = true;
1102  selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
1103  }
1104 
1105  for( SCH_ITEM* item : screen->Items() )
1106  {
1107  SCH_CONNECTION* itemConn = nullptr;
1108  SCH_SYMBOL* symbol = nullptr;
1109  bool redraw = item->IsBrightened();
1110  bool highlight = false;
1111 
1112  if( item->Type() == SCH_SYMBOL_T )
1113  symbol = static_cast<SCH_SYMBOL*>( item );
1114 
1115  if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1116  itemConn = symbol->Connection();
1117  else
1118  itemConn = item->Connection();
1119 
1120  if( selectedIsNoNet && selectedSubgraph )
1121  {
1122  for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
1123  {
1124  if( item == subgraphItem )
1125  {
1126  highlight = true;
1127  break;
1128  }
1129  }
1130  }
1131  else if( selectedIsBus && itemConn && itemConn->IsNet() )
1132  {
1133  for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
1134  {
1135  if( member->Name() == itemConn->Name() )
1136  {
1137  highlight = true;
1138  break;
1139  }
1140  else if( member->IsBus() )
1141  {
1142  for( const std::shared_ptr<SCH_CONNECTION>& child_member : member->Members() )
1143  {
1144  if( child_member->Name() == itemConn->Name() )
1145  {
1146  highlight = true;
1147  break;
1148  }
1149  }
1150  }
1151  }
1152  }
1153  else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1154  {
1155  highlight = true;
1156  }
1157 
1158  if( highlight )
1159  item->SetBrightened();
1160  else
1161  item->ClearBrightened();
1162 
1163  redraw |= item->IsBrightened();
1164 
1165  // symbol is only non-null if the item is a SCH_SYMBOL_T
1166  if( symbol )
1167  {
1168  redraw |= symbol->HasBrightenedPins();
1169 
1170  symbol->ClearBrightenedPins();
1171 
1172  for( SCH_PIN* pin : symbol->GetPins() )
1173  {
1174  SCH_CONNECTION* pin_conn = pin->Connection();
1175 
1176  if( pin_conn && pin_conn->Name() == selectedName )
1177  {
1178  pin->SetBrightened();
1179  redraw = true;
1180  }
1181  }
1182 
1183  if( symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1184  {
1185  std::vector<SCH_FIELD>& fields = symbol->GetFields();
1186 
1187  for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1188  {
1189  if( item->IsBrightened() && fields[id].IsVisible() )
1190  fields[id].SetBrightened();
1191  else
1192  fields[id].ClearBrightened();
1193  }
1194  }
1195  }
1196  else if( item->Type() == SCH_SHEET_T )
1197  {
1198  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1199  {
1200  SCH_CONNECTION* pin_conn = pin->Connection();
1201  bool redrawPin = pin->IsBrightened();
1202 
1203  if( pin_conn && pin_conn->Name() == selectedName )
1204  pin->SetBrightened();
1205  else
1206  pin->ClearBrightened();
1207 
1208  redrawPin ^= pin->IsBrightened();
1209  redraw |= redrawPin;
1210  }
1211  }
1212 
1213  if( redraw )
1214  itemsToRedraw.push_back( item );
1215  }
1216 
1217  // Be sure highlight change will be redrawn
1218  KIGFX::VIEW* view = getView();
1219 
1220  for( EDA_ITEM* redrawItem : itemsToRedraw )
1222 
1223  m_frame->GetCanvas()->Refresh();
1224 
1225  return 0;
1226 }
1227 
1228 
1230 {
1231  // TODO(JE) remove once real-time connectivity is a given
1232  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1234 
1235  std::string tool = aEvent.GetCommandStr().get();
1236  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1237 
1238  // Deactivate other tools; particularly important if another PICKER is currently running
1239  Activate();
1240 
1241  picker->SetCursor( KICURSOR::BULLSEYE );
1242  picker->SetSnapping( false );
1243 
1244  picker->SetClickHandler(
1245  [this] ( const VECTOR2D& aPos )
1246  {
1247  return highlightNet( m_toolMgr, aPos );
1248  } );
1249 
1250  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1251 
1252  return 0;
1253 }
1254 
1255 
1257 {
1258  if( m_frame->GetUndoCommandCount() <= 0 )
1259  return 0;
1260 
1261  // Inform tools that undo command was issued
1263 
1264  /* Get the old list */
1266  size_t num_undos = m_frame->m_undoList.m_CommandsList.size();
1267 
1268  /* Undo the command */
1270 
1274 
1275  // If we modified anything during cleanup we don't want it going on the undolist
1276  while( m_frame->m_undoList.m_CommandsList.size() > num_undos )
1277  delete m_frame->PopCommandFromUndoList();
1278 
1279  // Now push the old command to the RedoList
1280  List->ReversePickersListOrder();
1281  m_frame->PushCommandToRedoList( List );
1282 
1283  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1284 
1285  m_frame->SyncView();
1286  m_frame->GetCanvas()->Refresh();
1287  m_frame->OnModify();
1288 
1289  return 0;
1290 }
1291 
1292 
1294 {
1295  if( m_frame->GetRedoCommandCount() == 0 )
1296  return 0;
1297 
1298  // Inform tools that undo command was issued
1300 
1301  /* Get the old list */
1303 
1304  /* Redo the command: */
1306 
1307  /* Put the old list in UndoList */
1308  list->ReversePickersListOrder();
1309  m_frame->PushCommandToUndoList( list );
1310 
1314 
1315  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1316 
1317  m_frame->SyncView();
1318  m_frame->GetCanvas()->Refresh();
1319  m_frame->OnModify();
1320 
1321  return 0;
1322 }
1323 
1324 
1325 bool SCH_EDITOR_CONTROL::doCopy( bool aUseLocalClipboard )
1326 {
1328  EE_SELECTION& selection = selTool->RequestSelection();
1329  SCHEMATIC& schematic = m_frame->Schematic();
1330 
1331  if( !selection.GetSize() )
1332  return false;
1333 
1334  selection.SetScreen( m_frame->GetScreen() );
1335  m_supplementaryClipboard.clear();
1336 
1337  for( EDA_ITEM* item : selection )
1338  {
1339  if( item->Type() == SCH_SHEET_T )
1340  {
1341  SCH_SHEET* sheet = (SCH_SHEET*) item;
1342  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1343  }
1344  }
1345 
1346  STRING_FORMATTER formatter;
1347  SCH_SEXPR_PLUGIN plugin;
1348  SCH_SHEET_LIST hierarchy = schematic.GetSheets();
1349  SCH_SHEET_PATH selPath = m_frame->GetCurrentSheet();
1350 
1351  plugin.Format( &selection, &selPath, &hierarchy, &formatter );
1352 
1353  if( aUseLocalClipboard )
1354  {
1355  m_localClipboard = formatter.GetString();
1356  return true;
1357  }
1358 
1359  return m_toolMgr->SaveClipboard( formatter.GetString() );
1360 }
1361 
1362 
1363 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1364  SCH_SCREEN** aScreen )
1365 {
1366  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1367  {
1368  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1369  return true;
1370  }
1371 
1372  return false;
1373 }
1374 
1375 
1377 {
1378  doCopy( true ); // Use the local clipboard
1379  Paste( aEvent );
1380 
1381  return 0;
1382 }
1383 
1384 
1386 {
1387  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1388 
1389  if( textEntry )
1390  {
1391  textEntry->Cut();
1392  return 0;
1393  }
1394 
1395  if( doCopy() )
1397 
1398  return 0;
1399 }
1400 
1401 
1403 {
1404  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1405 
1406  if( textEntry )
1407  {
1408  textEntry->Copy();
1409  return 0;
1410  }
1411 
1412  doCopy();
1413 
1414  return 0;
1415 }
1416 
1417 
1419  const SCH_SHEET_PATH& aPastePath,
1420  const KIID_PATH& aClipPath,
1421  bool aForceKeepAnnotations )
1422 {
1423  KIID_PATH clipItemPath = aClipPath;
1424  clipItemPath.push_back( aSymbol->m_Uuid );
1425 
1426  wxString reference, value, footprint;
1427  int unit;
1428 
1429  if( m_clipboardSymbolInstances.count( clipItemPath ) > 0 )
1430  {
1431  SYMBOL_INSTANCE_REFERENCE instance = m_clipboardSymbolInstances.at( clipItemPath );
1432 
1433  unit = instance.m_Unit;
1434  reference = instance.m_Reference;
1435  value = instance.m_Value;
1436  footprint = instance.m_Footprint;
1437  }
1438  else
1439  {
1440  // Pasted from notepad or an older instance of eeschema.
1441  // Use the values in the fields instead
1442  reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
1443  value = aSymbol->GetField( VALUE_FIELD )->GetText();
1444  footprint = aSymbol->GetField( FOOTPRINT_FIELD )->GetText();
1445  unit = aSymbol->GetUnit();
1446  }
1447 
1448  if( aForceKeepAnnotations && !reference.IsEmpty() )
1449  {
1450  aSymbol->SetRef( &aPastePath, reference );
1451  aSymbol->SetValue( &aPastePath, value );
1452  aSymbol->SetFootprint( &aPastePath, footprint );
1453  }
1454  else
1455  {
1456  aSymbol->ClearAnnotation( &aPastePath );
1457  }
1458 
1459  // We might clear annotations but always leave the original unit number from the paste
1460  aSymbol->SetUnitSelection( &aPastePath, unit );
1461  aSymbol->SetUnit( unit );
1462 }
1463 
1464 
1466  const KIID_PATH& aClipPath, SCH_SHEET* aSheet,
1467  bool aForceKeepAnnotations,
1468  SCH_SHEET_LIST* aPastedSheetsSoFar,
1469  SCH_REFERENCE_LIST* aPastedSymbolsSoFar )
1470 {
1471  SCH_SHEET_PATH sheetPath = aPastePath;
1472  sheetPath.push_back( aSheet );
1473 
1474  aSheet->AddInstance( sheetPath.Path() );
1475 
1476  wxString pageNum;
1477 
1478  if( m_clipboardSheetInstances.count( aClipPath ) > 0 )
1479  pageNum = m_clipboardSheetInstances.at( aClipPath ).m_PageNumber;
1480  else
1481  pageNum = wxString::Format( "%d", static_cast<int>( aPastedSheetsSoFar->size() ) );
1482 
1483  aSheet->SetPageNumber( sheetPath, pageNum );
1484  aPastedSheetsSoFar->push_back( sheetPath );
1485 
1486  if( aSheet->GetScreen() == nullptr )
1487  return sheetPath; // We can only really set the page number but not load any items
1488 
1489  for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1490  {
1491  if( item->Type() == SCH_SYMBOL_T )
1492  {
1493  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1494 
1495  updatePastedSymbol( symbol, aSheet->GetScreen(), sheetPath, aClipPath,
1496  aForceKeepAnnotations );
1497  }
1498  else if( item->Type() == SCH_SHEET_T )
1499  {
1500  SCH_SHEET* subsheet = static_cast<SCH_SHEET*>( item );
1501 
1502  KIID_PATH newClipPath = aClipPath;
1503  newClipPath.push_back( subsheet->m_Uuid );
1504 
1505  updatePastedSheet( sheetPath, newClipPath, subsheet, aForceKeepAnnotations,
1506  aPastedSheetsSoFar, aPastedSymbolsSoFar );
1507 
1508  SCH_SHEET_PATH subSheetPath = sheetPath;
1509  subSheetPath.push_back( subsheet );
1510 
1511  subSheetPath.GetSymbols( *aPastedSymbolsSoFar );
1512  }
1513  }
1514 
1515  return sheetPath;
1516 }
1517 
1518 
1520 {
1521  m_clipboardSheetInstances.clear();
1522 
1523  for( const SCH_SHEET_INSTANCE& sheet : aPastedScreen->GetSheetInstances() )
1524  m_clipboardSheetInstances[sheet.m_Path] = sheet;
1525 
1527 
1528  for( const SYMBOL_INSTANCE_REFERENCE& symbol : aPastedScreen->GetSymbolInstances() )
1529  m_clipboardSymbolInstances[symbol.m_Path] = symbol;
1530 }
1531 
1532 
1534 {
1535  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1536 
1537  if( textEntry )
1538  {
1539  textEntry->Paste();
1540  return 0;
1541  }
1542 
1544  std::string text;
1545 
1546  if( aEvent.IsAction( &ACTIONS::duplicate ) )
1548  else
1550 
1551  if( text.empty() )
1552  return 0;
1553 
1554  STRING_LINE_READER reader( text, "Clipboard" );
1555  SCH_SEXPR_PLUGIN plugin;
1556 
1557  SCH_SHEET paste_sheet;
1558  SCH_SCREEN* paste_screen = new SCH_SCREEN( &m_frame->Schematic() );
1559 
1560  // Screen object on heap is owned by the sheet.
1561  paste_sheet.SetScreen( paste_screen );
1562 
1563  try
1564  {
1565  plugin.LoadContent( reader, &paste_sheet );
1566  }
1567  catch( IO_ERROR& )
1568  {
1569  // If it wasn't content, then paste as text
1570  SCH_TEXT* text_item = new SCH_TEXT( wxPoint( 0, 0 ), text );
1571  text_item->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); // Left alignment
1572  paste_screen->Append( text_item );
1573  }
1574 
1575  // Save loaded screen instances to m_clipboardSheetInstances
1576  setClipboardInstances( paste_screen );
1577 
1579 
1580  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1581  {
1582  DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1583 
1584  if( dlg.ShowModal() == wxID_CANCEL )
1585  return 0;
1586  }
1587 
1588  bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1589 
1590  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1591  // else. Pull them back out to start with.
1592  //
1593  EDA_ITEMS loadedItems;
1594  bool sheetsPasted = false;
1595  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1596  SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1597  wxFileName destFn = pasteRoot.Last()->GetFileName();
1598 
1599  if( destFn.IsRelative() )
1600  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1601 
1602  // List of paths in the hierarchy that refer to the destination sheet of the paste
1603  SCH_SHEET_LIST pasteInstances = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1604  pasteInstances.SortByPageNumbers();
1605 
1606  // Build a list of screens from the current design (to avoid loading sheets that already exist)
1607  std::map<wxString, SCH_SCREEN*> loadedScreens;
1608 
1609  for( const SCH_SHEET_PATH& item : hierarchy )
1610  {
1611  if( item.LastScreen() )
1612  loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1613  }
1614 
1615  // Build symbol list for reannotation of duplicates
1616  SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets();
1617  SCH_REFERENCE_LIST existingRefs;
1618  sheets.GetSymbols( existingRefs );
1619  existingRefs.SortByReferenceOnly();
1620 
1621  // Keep track of pasted sheets and symbols for the different
1622  // paths to the hierarchy
1623  std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1624  std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1625 
1626  for( SCH_ITEM* item : paste_screen->Items() )
1627  {
1628  loadedItems.push_back( item );
1629 
1630  //@todo: we might want to sort the sheets by page number before adding to loadedItems
1631  if( item->Type() == SCH_SHEET_T )
1632  {
1633  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1634  wxFileName srcFn = sheet->GetFileName();
1635 
1636  if( srcFn.IsRelative() )
1637  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1638 
1639  SCH_SHEET_LIST sheetHierarchy( sheet );
1640 
1641  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1642  {
1643  auto msg = wxString::Format( _( "The pasted sheet '%s'\n"
1644  "was dropped because the destination already has "
1645  "the sheet or one of its subsheets as a parent." ),
1646  sheet->GetFileName() );
1647  DisplayError( m_frame, msg );
1648  loadedItems.pop_back();
1649  }
1650  }
1651  }
1652 
1653  // Remove the references from our temporary screen to prevent freeing on the DTOR
1654  paste_screen->Clear( false );
1655 
1656  for( unsigned i = 0; i < loadedItems.size(); ++i )
1657  {
1658  EDA_ITEM* item = loadedItems[i];
1659  KIID_PATH clipPath( wxT("/") ); // clipboard is at root
1660 
1661  if( item->Type() == SCH_SYMBOL_T )
1662  {
1663  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1664 
1665  // The library symbol gets set from the cached library symbols in the current
1666  // schematic not the symbol libraries. The cached library symbol may have
1667  // changed from the original library symbol which would cause the copy to
1668  // be incorrect.
1669  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1670 
1671  wxCHECK2( currentScreen, continue );
1672 
1673  auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1674  auto end = currentScreen->GetLibSymbols().end();
1675 
1676  if( it == end )
1677  {
1678  // If can't find library definition in the design, use the pasted library
1679  it = paste_screen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1680  end = paste_screen->GetLibSymbols().end();
1681  }
1682 
1683  LIB_SYMBOL* libSymbol = nullptr;
1684 
1685  if( it != end )
1686  {
1687  libSymbol = new LIB_SYMBOL( *it->second );
1688  symbol->SetLibSymbol( libSymbol );
1689  }
1690 
1691  for( SCH_SHEET_PATH& instance : pasteInstances )
1692  {
1693  updatePastedSymbol( symbol, paste_screen, instance, clipPath,
1694  forceKeepAnnotations );
1695  }
1696 
1697  // Assign a new KIID
1698  const_cast<KIID&>( item->m_Uuid ) = KIID();
1699 
1700  // Make sure pins get a new UUID
1701  for( SCH_PIN* pin : symbol->GetPins() )
1702  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1703 
1704  for( SCH_SHEET_PATH& instance : pasteInstances )
1705  {
1706  // Ignore pseudo-symbols (e.g. power symbols) and symbols from a non-existant
1707  // library.
1708  if( libSymbol && symbol->GetRef( &instance )[0] != wxT( '#' ) )
1709  {
1710  SCH_REFERENCE schReference( symbol, libSymbol, instance );
1711  schReference.SetSheetNumber( instance.GetVirtualPageNumber() );
1712  pastedSymbols[instance].AddItem( schReference );
1713  }
1714  }
1715  }
1716  else if( item->Type() == SCH_SHEET_T )
1717  {
1718  SCH_SHEET* sheet = (SCH_SHEET*) item;
1719  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1720  wxString baseName = nameField.GetText();
1721  wxString candidateName = baseName;
1722  wxString number;
1723 
1724  while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1725  {
1726  number = baseName.Last() + number;
1727  baseName.RemoveLast();
1728  }
1729  // Update hierarchy to include any other sheets we already added, avoiding
1730  // duplicate sheet names
1731  hierarchy = m_frame->Schematic().GetSheets();
1732 
1733  //@todo: it might be better to just iterate through the sheet names
1734  // in this screen instead of the whole hierarchy.
1735  int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1736 
1737  while( hierarchy.NameExists( candidateName ) )
1738  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1739 
1740  nameField.SetText( candidateName );
1741 
1742  wxFileName fn = sheet->GetFileName();
1743  SCH_SCREEN* existingScreen = nullptr;
1744 
1745  sheet->SetParent( pasteRoot.Last() );
1746  sheet->SetScreen( nullptr );
1747 
1748  if( !fn.IsAbsolute() )
1749  {
1750  wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1751  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1752  }
1753 
1754  // Try to find the screen for the pasted sheet by several means
1755  if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1756  &existingScreen ) )
1757  {
1758  if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1759  existingScreen = loadedScreens.at( sheet->GetFileName() );
1760  else
1761  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1762  }
1763 
1764  if( existingScreen )
1765  {
1766  sheet->SetScreen( existingScreen );
1767  }
1768  else
1769  {
1770  if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1771  m_frame->InitSheet( sheet, sheet->GetFileName() );
1772  }
1773 
1774  sheetsPasted = true;
1775 
1776  // Push it to the clipboard path while it still has its old KIID
1777  clipPath.push_back( sheet->m_Uuid );
1778 
1779  // Assign a new KIID to the pasted sheet
1780  const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1781 
1782  // Make sure pins get a new UUID
1783  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1784  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1785 
1786  // Once we have our new KIID we can update all pasted instances. This will either
1787  // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1788  for( SCH_SHEET_PATH& instance : pasteInstances )
1789  {
1790  SCH_SHEET_PATH sheetPath = updatePastedSheet( instance, clipPath, sheet,
1791  forceKeepAnnotations,
1792  &pastedSheets[instance],
1793  &pastedSymbols[instance] );
1794 
1795  sheetPath.GetSymbols( pastedSymbols[instance] );
1796  }
1797  }
1798  else
1799  {
1800  // Everything gets a new KIID
1801  const_cast<KIID&>( item->m_Uuid ) = KIID();
1802  }
1803 
1804  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1806 
1807  // Reset flags for subsequent move operation
1808  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1809  // Start out hidden so the pasted items aren't "ghosted" in their original location
1810  // before being moved to the current location.
1811  getView()->Hide( item, true );
1812  }
1813 
1814  pasteInstances.SortByPageNumbers();
1815 
1816  if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
1817  {
1818  for( SCH_SHEET_PATH& instance : pasteInstances )
1819  {
1820  pastedSymbols[instance].SortByReferenceOnly();
1821  pastedSymbols[instance].ReannotateDuplicates( existingRefs );
1822  pastedSymbols[instance].UpdateAnnotation();
1823 
1824  // Update existing refs for next iteration
1825  for( size_t i = 0; i < pastedSymbols[instance].GetCount(); i++ )
1826  existingRefs.AddItem( pastedSymbols[instance][i] );
1827  }
1828  }
1829 
1831 
1832  if( sheetsPasted )
1833  {
1834  // Update page numbers: Find next free numeric page number
1835  for( SCH_SHEET_PATH& instance : pasteInstances )
1836  {
1837  pastedSheets[instance].SortByPageNumbers();
1838 
1839  for( SCH_SHEET_PATH& pastedSheet : pastedSheets[instance] )
1840  {
1841  int page = 1;
1842  wxString pageNum = wxString::Format( "%d", page );
1843 
1844  while( hierarchy.PageNumberExists( pageNum ) )
1845  pageNum = wxString::Format( "%d", ++page );
1846 
1847  pastedSheet.SetPageNumber( pageNum );
1848  hierarchy.push_back( pastedSheet );
1849  }
1850  }
1851 
1854  }
1855 
1856  // Now clear the previous selection, select the pasted items, and fire up the "move"
1857  // tool.
1858  //
1860  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1861 
1862  EE_SELECTION& selection = selTool->GetSelection();
1863 
1864  if( !selection.Empty() )
1865  {
1866  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1867 
1868  selection.SetReferencePoint( item->GetPosition() );
1870  }
1871 
1872  return 0;
1873 }
1874 
1875 
1877 {
1879  EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
1880  SCH_SYMBOL* symbol = nullptr;
1881  SYMBOL_EDIT_FRAME* symbolEditor;
1882 
1883  if( selection.GetSize() >= 1 )
1884  symbol = (SCH_SYMBOL*) selection.Front();
1885 
1886  if( !symbol || symbol->GetEditFlags() != 0 )
1887  return 0;
1888 
1890  symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1891 
1892  if( symbolEditor )
1893  symbolEditor->LoadSymbolFromSchematic( symbol );
1894 
1895  return 0;
1896 }
1897 
1898 
1900 {
1901  wxCommandEvent dummy;
1902  m_frame->OnAnnotate( dummy );
1903  return 0;
1904 }
1905 
1906 
1908 {
1909  wxCommandEvent dummy;
1911  return 0;
1912 }
1913 
1914 
1916 {
1918  dlg.ShowQuasiModal();
1919  return 0;
1920 }
1921 
1922 
1924 {
1926  m_frame->HardRedraw();
1927 
1928  return 0;
1929 }
1930 
1931 
1933 {
1934  wxCommandEvent dummy;
1936  return 0;
1937 }
1938 
1939 
1941 {
1942  wxCommandEvent dummy;
1944  return 0;
1945 }
1946 
1947 
1949 {
1951  dlg.ShowModal();
1952  return 0;
1953 }
1954 
1955 
1957 {
1958  int result = NET_PLUGIN_CHANGE;
1959 
1960  // If a plugin is removed or added, rebuild and reopen the new dialog
1961  while( result == NET_PLUGIN_CHANGE )
1962  result = InvokeDialogNetList( m_frame );
1963 
1964  return 0;
1965 }
1966 
1967 
1969 {
1971  return 0;
1972 }
1973 
1974 
1976 {
1978  return 0;
1979 }
1980 
1981 
1983 {
1985  return 0;
1986 }
1987 
1988 
1990 {
1992  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1993 
1994  if( selection.GetSize() == 1 )
1995  {
1996  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1997 
2000 
2001  // Store the current zoom level into the current screen before switching
2003 
2004  m_frame->GetCurrentSheet().push_back( sheet );
2006  }
2007 
2008  return 0;
2009 }
2010 
2011 
2013 {
2014  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
2015  {
2018 
2019  // Store the current zoom level into the current screen before switching
2021 
2024  }
2025 
2026  return 0;
2027 }
2028 
2029 
2031 {
2034 
2035  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
2037 
2039  m_frame->GetCanvas()->Refresh();
2040 
2041  return 0;
2042 }
2043 
2044 
2046 {
2049 
2050  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
2052 
2054  m_frame->GetCanvas()->Refresh();
2055 
2056  return 0;
2057 }
2058 
2059 
2061 {
2063 
2064  return 0;
2065 }
2066 
2067 
2069 {
2070 
2072  return 0;
2073 }
2074 
2075 
2077 {
2078  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
2079  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
2080  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
2082  //Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveCopyAs.MakeEvent() );
2086  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
2087  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
2088  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
2089 
2092 
2101 
2106 
2107 #ifdef KICAD_SPICE
2108  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
2109  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
2110 #endif /* KICAD_SPICE */
2111 
2117 
2119 
2120  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2121  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2122  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2123  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2124  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
2127 
2140 
2142 
2146 
2150 
2152 }
Field Reference of part, i.e. "IC21".
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1479
void SetSheetNumber(int aSheetNumber)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
int FindAndReplace(const TOOL_EVENT &aEvent)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void OnOpenCvpcb(wxCommandEvent &event)
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:44
const wxString & GetFileName() const
Definition: sch_screen.h:145
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:157
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:365
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
bool RescueLegacyProject(bool aRunningOnDemand)
static TOOL_ACTION findAndReplace
Definition: actions.h:77
int m_Threshold
Definition: collector.h:241
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:636
void UpdateNetHighlightStatus()
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:164
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:185
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
int HighlightNetCursor(const TOOL_EVENT &aEvent)
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:150
static TOOL_ACTION pageSettings
Definition: actions.h:56
void Format(SCH_SHEET *aSheet)
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
SCH_SHEET_PATH * FindSheetForScreen(const SCH_SCREEN *aScreen)
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) using a particular...
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:675
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:331
Holds all the data relating to one schematic.
Definition: schematic.h:59
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:200
const wxString & GetNetclassName(const wxString &aNetName) const
#define IS_NEW
New item, just created.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:131
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
This file is part of the common library.
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
static TOOL_ACTION doDelete
Definition: actions.h:72
Calculates the connectivity of a schematic and generates netlists.
void SetScreen(BASE_SCREEN *aScreen) override
const SCH_CONNECTION * GetHighlightedConnection() const
void Collect(SCH_SCREEN *aScreen, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
UNDO_REDO_CONTAINER m_undoList
static wxFindReplaceData g_markersOnly
bool PrjConfigChanged()
Return true if the project configuration was modified.
int Redo(const TOOL_EVENT &aEvent)
Clipboard support.
int NavigateHierarchy(const TOOL_EVENT &aEvent)
int EditSymbolFields(const TOOL_EVENT &aEvent)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetSymbolInstances() const
Definition: sch_screen.h:465
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void SendCrossProbeClearHighlight()
Tell Pcbnew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:487
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath)
Clear exiting symbol annotation.
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:594
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:156
static TOOL_ACTION replaceAll
Definition: actions.h:81
int ReplaceAndFindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1424
void updatePastedSymbol(SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
wxString KiCadSchematicFileWildcard()
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:711
void SetWksFileName(const wxString &aFilename)
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
void SetBrightened()
Definition: eda_item.h:130
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:158
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:980
#define HITTEST_THRESHOLD_PIXELS
void UpdateTitle()
Set the main window title bar text.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
int New(const TOOL_EVENT &aEvent)
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
Definition: erc.h:47
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:97
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:474
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:383
A dialog which shows:
virtual int GetRedoCommandCount() const
bool IsBrightened() const
Definition: eda_item.h:126
void PushItem(const ITEM_PICKER &aItem)
Push 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:163
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:108
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
void OnPageSettingsChange() override
Called when modifying the page settings.
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Set a handler for the finalize event.
Definition: picker_tool.h:102
void AddItem(const SCH_REFERENCE &aItem)
void ScriptingConsoleEnableDisable()
Toggles the scripting console visibility.
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
static TOOL_ACTION print
Definition: actions.h:57
virtual wxPoint GetPosition() const
Definition: eda_item.h:252
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:441
int Annotate(const TOOL_EVENT &aEvent)
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:285
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:46
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:76
int GenerateBOM(const TOOL_EVENT &aEvent)
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
static TOOL_ACTION find
Definition: actions.h:76
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
static TOOL_ACTION saveCurrSheetCopyAs
Definition: ee_actions.h:42
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
Define a library symbol object.
Definition: lib_symbol.h:96
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:645
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:219
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:257
A subgraph is a set of items that are electrically connected on a single sheet.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:547
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1130
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:204
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:116
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)
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:164
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:269
wxFindReplaceData & GetFindReplaceData()
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:228
int ToggleForceHV(const TOOL_EVENT &aEvent)
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
void pop_back()
Forwarded method from std::vector.
int HighlightNet(const TOOL_EVENT &aEvent)
< Highlight net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:184
void ClearBrightened()
Definition: eda_item.h:133
static TOOL_ACTION pickerTool
Definition: actions.h:155
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
EE_SELECTION & GetSelection()
Return the set of currently selected items.
static TOOL_ACTION updateFind
Definition: actions.h:82
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:88
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
static TOOL_ACTION annotate
Definition: ee_actions.h:141
Handle actions specific to the schematic editor.
Master controller class:
Definition: tool_manager.h:54
int EnterSheet(const TOOL_EVENT &aEvent)
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
SCH_ITEM * nextMatch(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aSheet, SCH_ITEM *aAfter, wxFindReplaceData &aData)
Advance the search and returns the next matching item after aAfter.
int ShowPcbNew(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int Paste(const TOOL_EVENT &aEvent)
static bool RescueProject(wxWindow *aParent, RESCUER &aRescuer, bool aRunningOnDemand)
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:162
Definition: kiid.h:44
static TOOL_ACTION copy
Definition: actions.h:67
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:187
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
void BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:220
static TOOL_ACTION showBusManager
Definition: ee_actions.h:152
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:164
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:142
Item needs to be redrawn.
Definition: view_item.h:52
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
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:105
NETCLASSES m_NetClasses
Definition: net_settings.h:40
#define IS_MOVING
Item being moved.
wxString Name(bool aIgnoreSheet=false) const
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:114
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual int GetUndoCommandCount() const
int LeaveSheet(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:214
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
int Print(const TOOL_EVENT &aEvent)
void HardRedraw() override
Rebuild the GAL and redraw the screen.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void SyncView()
Mark all items for refresh.
int ReplaceAll(const TOOL_EVENT &aEvent)
int ComparePageNumAndName(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare sheets by their page number and then by their name.
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:248
std::string GetClipboardUTF8() const
Return the information currently stored in the system clipboard.
int ShowQuasiModal()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
std::vector< SCH_ITEM * > m_items
static TOOL_ACTION open
Definition: actions.h:50
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:198
wxString GetPageNumber() const
static TOOL_ACTION save
Definition: actions.h:51
void SetForceVisible(bool aEnable)
Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is se...
Definition: eda_item.h:204
const std::vector< SCH_SHEET_INSTANCE > & GetSheetInstances() const
Definition: sch_screen.h:470
static TOOL_ACTION doNew
Definition: actions.h:44
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int UpdateFind(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
Generic, UI-independent tool event.
Definition: tool_event.h:152
Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:132
size_t GetCandidateCount()
Return the number of rescue candidates found.
int Plot(const TOOL_EVENT &aEvent)
void SetMotionHandler(MOTION_HANDLER aHandler)
Set a handler for mouse motion.
Definition: picker_tool.h:82
static TOOL_ACTION cut
Definition: actions.h:66
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
Definition of file extensions used in Kicad.
SCH_ITEM * Driver() const
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:209
bool doCopy(bool aUseLocalClipboard=false)
< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true
int ImportFPAssignments(const TOOL_EVENT &aEvent)
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
A simple container for schematic symbol instance information.
Definition for symbol library class.
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
An interface for classes handling user events controlling the view behavior such as zooming,...
static TOOL_ACTION quit
Definition: actions.h:59
#define _(s)
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
DIALOG_SCH_FIND * m_findReplaceDialog
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:177
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:201
static TOOL_ACTION replaceAndFindNext
Definition: actions.h:80
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:430
static TOOL_ACTION plot
Definition: actions.h:58
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1406
const std::string & GetString()
Definition: richio.h:438
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:362
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:507
bool DisableGridSnapping() const
Definition: tool_event.h:341
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:158
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
A holder to handle information on schematic or board items.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:315
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
void setClipboardInstances(const SCH_SCREEN *aPastedScreen)
int SaveCurrSheetCopyAs(const TOOL_EVENT &aEvent)
Saves the currently-open schematic sheet to an other name.
static bool Replace(const wxFindReplaceData &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
Definition: eda_item.cpp:145
void OnUpdatePCB(wxCommandEvent &event)
static VECTOR2D CLEAR
void UnbrightenItem(EDA_ITEM *aItem)
int RemapSymbols(const TOOL_EVENT &aEvent)
std::map< KIID_PATH, SCH_SHEET_INSTANCE > m_clipboardSheetInstances
EDA_ITEM * GetNode(VECTOR2I aPosition)
Select node under cursor.
int Duplicate(const TOOL_EVENT &aEvent)
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.
std::map< KIID_PATH, SYMBOL_INSTANCE_REFERENCE > m_clipboardSymbolInstances
wxString UnescapeString(const wxString &aSource)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
Implementing SIM_PLOT_FRAME_BASE.
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
bool InvokeDialogEditSymbolsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of symbols for instance when a symbol has moved from a symbol libra...
int AssignNetclass(const TOOL_EVENT &aEvent)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
const KIID m_Uuid
Definition: eda_item.h:475
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
static wxString GetSpiceField(SPICE_FIELD aField, SCH_SYMBOL *aSymbol, unsigned aCtl)
Retrieve either the requested field value or the default value.
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static bool m_allowRealTime
void OnAnnotate(wxCommandEvent &event)
bool HasBrightenedPins()
virtual SCH_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: sch_painter.h:141
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:294
int Open(const TOOL_EVENT &aEvent)
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
static TOOL_ACTION findNextMarker
Definition: actions.h:79
void ClearBrightenedPins()
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
static TOOL_ACTION redo
Definition: actions.h:65
int PageSetup(const TOOL_EVENT &aEvent)
void ClearFindReplaceStatus()
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
bool IsNet() const
void SetHighlightedConnection(const SCH_CONNECTION *aConnection)
std::string m_localClipboard
SCH_SHEET & Root() const
Definition: schematic.h:92
A simple container for sheet instance information.
SCH_SHEET_PATH updatePastedSheet(const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, SCH_SHEET *aSheet, bool aForceKeepAnnotations, SCH_SHEET_LIST *aPastedSheetsSoFar, SCH_REFERENCE_LIST *aPastedSymbolsSoFar)
int Quit(const TOOL_EVENT &aEvent)
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
Schematic symbol object.
Definition: sch_symbol.h:78
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
static TOOL_ACTION showSymbolEditor
Definition: actions.h:160
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
static TOOL_ACTION saveAs
Definition: actions.h:52
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
bool SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before c...
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:194
Global action (toolbar/main menu event, global shortcut)
void SortByReferenceOnly()
Sort the list of references by reference.
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)
Select all visible items in sheet.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
int Cut(const TOOL_EVENT &aEvent)
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:163
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition: base_screen.h:85
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:151
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:481
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
size_t GetCurrentHash() const
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
const std::string KiCadSchematicFileExtension
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
#define NET_PLUGIN_CHANGE
Create and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::ShowModal() returns.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
void SetCrossProbeConnection(const SCH_CONNECTION *aConnection)
Send a connection (net or bus) to Pcbnew for highlighting.
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:126
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:206
SCH_ITEM * Parent() const
int Undo(const TOOL_EVENT &aEvent)
static TOOL_ACTION enterSheet
Definition: ee_actions.h:183
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:218
void Activate()
Run the tool.
SCH_SHEET_PATH & GetCurrentSheet() const
static const KICAD_T SymbolsOnly[]
Definition: ee_collectors.h:45
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:161
static TOOL_ACTION move
Definition: ee_actions.h:113
static TOOL_ACTION simProbe
Definition: ee_actions.h:213
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetSnapping(bool aSnap)
Definition: picker_tool.h:64
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Restore an undo or redo command to put data pointed by aList in the previous state.
static TOOL_ACTION undo
Definition: actions.h:64
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_SYMBOL *aPart)
Send a message to Pcbnew via a socket connection.
static TOOL_ACTION generateBOM
Definition: ee_actions.h:165
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
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:217
#define MAX_PAGE_SIZE_MILS
Definition: page_info.h:41
void InvokeDialogBusManager(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BUS_MANAGER.
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:153
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
int GetUnit() const
Definition: sch_symbol.h:195
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:320
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
bool IsBus() const
double GetScale() const
Definition: view.h:264
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
void ShowSchematicSetupDialog(const wxString &aInitialPage=wxEmptyString)
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:143
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:205
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240
int UpdateFromPCB(const TOOL_EVENT &aEvent)
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:414
bool m_RealTimeConnectivity
Do real-time connectivity.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
static TOOL_ACTION findNext
Definition: actions.h:78
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
static TOOL_ACTION paste
Definition: actions.h:68
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
static TOOL_ACTION duplicate
Definition: actions.h:71
A helper to define a symbol's reference designator in a schematic.
PRIORITY GetDriverPriority()
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
Definition: sch_symbol.cpp:866
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:568
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:145
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1512
int ExportNetlist(const TOOL_EVENT &aEvent)
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1088
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
Field Name Module PCB, i.e. "16DIP300".
void SetListLabel(const wxString &aLabel)
The symbol library editor main window.
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:195