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 <class_library.h>
26 #include <confirm.h>
27 #include <widgets/infobar.h>
28 #include <connection_graph.h>
34 #include <project_rescue.h>
35 #include <erc.h>
36 #include <invoke_sch_dialog.h>
37 #include <kicad_string.h>
38 #include <kiway.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 <dialog_helpers.h>
63 
64 
65 int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
66 {
68  return 0;
69 }
70 
71 
73 {
75  return 0;
76 }
77 
78 
80 {
82  return 0;
83 }
84 
85 
87 {
88  m_frame->Save_File( true );
89  return 0;
90 }
91 
92 
94 {
96  return 0;
97 }
98 
99 
101 {
102  PICKED_ITEMS_LIST undoCmd;
103  DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
104  ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
105 
106  undoCmd.PushItem( wrapper );
108 
111 
112  if( dlg.ShowModal() != wxID_OK )
114 
115  return 0;
116 }
117 
118 
120 {
121  SCH_SCREENS schematic( m_frame->Schematic().Root() );
122 
123  if( schematic.HasNoFullyDefinedLibIds() )
124  RescueLegacyProject( true );
125  else
127 
128  return 0;
129 }
130 
131 
132 bool SCH_EDITOR_CONTROL::RescueLegacyProject( bool aRunningOnDemand )
133 {
135  m_frame->GetCanvas()->GetBackend() );
136 
137  return rescueProject( rescuer, aRunningOnDemand );
138 }
139 
140 
142 {
145  m_frame->GetCanvas()->GetBackend() );
146 
147  return rescueProject( rescuer, aRunningOnDemand );
148 }
149 
150 
151 bool SCH_EDITOR_CONTROL::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
152 {
153  if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
154  return false;
155 
156  if( aRescuer.GetCandidateCount() )
157  {
158  KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
159 
160  if( viewer )
161  static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
162 
163  if( aRunningOnDemand )
164  {
165  SCH_SCREENS schematic( m_frame->Schematic().Root() );
166 
167  schematic.UpdateSymbolLinks();
169  }
170 
172  m_frame->SyncView();
173  m_frame->GetCanvas()->Refresh();
174  m_frame->OnModify();
175  }
176 
177  return true;
178 }
179 
180 
182 {
183  DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
184 
185  dlgRemap.ShowQuasiModal();
186 
187  m_frame->GetCanvas()->Refresh( true );
188 
189  return 0;
190 }
191 
192 
194 {
196 
197  wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->Schematic().RootScreen()->GetFileName() );
198 
199  if( fn.GetName() != NAMELESS_PROJECT )
201 
202  return 0;
203 }
204 
205 
207 {
209 
210  dlg.ShowModal();
211 
212  // save project config if the prj config has changed:
213  if( dlg.PrjConfigChanged() )
215 
216  return 0;
217 }
218 
219 
221 {
222  m_frame->Close( false );
223  return 0;
224 }
225 
226 
227 // A dummy wxFindReplaceData signaling any marker should be found
228 static wxFindReplaceData g_markersOnly;
229 
230 
232 {
234  return UpdateFind( aEvent );
235 }
236 
237 
239 {
241  return 0;
242 }
243 
244 
246 {
247  wxFindReplaceData* data = m_frame->GetFindReplaceData();
248 
249  auto visit =
250  [&]( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheet )
251  {
252  if( data && aItem->Matches( *data, aSheet ) )
253  {
254  aItem->SetForceVisible( true );
255  m_selectionTool->BrightenItem( aItem );
256  }
257  else if( aItem->IsBrightened() )
258  {
259  aItem->SetForceVisible( false );
261  }
262  };
263 
264  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
265  || aEvent.IsAction( &ACTIONS::updateFind ) )
266  {
268 
269  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
270  {
271  visit( item, &m_frame->GetCurrentSheet() );
272 
273  item->RunOnChildren(
274  [&]( SCH_ITEM* aChild )
275  {
276  visit( aChild, &m_frame->GetCurrentSheet() );
277  } );
278  }
279  }
280  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
281  {
282  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
283  visit( item, &m_frame->GetCurrentSheet() );
284  }
285 
286  getView()->UpdateItems();
287  m_frame->GetCanvas()->Refresh();
288  m_frame->UpdateTitle();
289 
290  return 0;
291 }
292 
293 
295  SCH_ITEM* aAfter, wxFindReplaceData* aData )
296 {
297  bool past_item = true;
298 
299  if( aAfter != nullptr )
300  {
301  past_item = false;
302 
303  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
304  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
305  }
306 
307 
308  for( SCH_ITEM* item : aScreen->Items() )
309  {
310  if( item == aAfter )
311  {
312  past_item = true;
313  }
314  else if( past_item )
315  {
316  if( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
317  return item;
318 
319  if( item->Matches( *aData, aSheet ) )
320  return item;
321 
322  if( item->Type() == SCH_COMPONENT_T )
323  {
324  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
325 
326  for( SCH_FIELD& field : cmp->GetFields() )
327  {
328  if( field.Matches( *aData, aSheet ) )
329  return &field;
330  }
331 
332  for( SCH_PIN* pin : cmp->GetPins() )
333  {
334  if( pin->Matches( *aData, aSheet ) )
335  return pin;
336  }
337  }
338 
339  if( item->Type() == SCH_SHEET_T )
340  {
341  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
342 
343  for( SCH_FIELD& field : sheet->GetFields() )
344  {
345  if( field.Matches( *aData, aSheet ) )
346  return &field;
347  }
348 
349  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
350  {
351  if( pin->Matches( *aData, aSheet ) )
352  return pin;
353  }
354  }
355  }
356  }
357 
358  return nullptr;
359 }
360 
361 
363 {
364  // A timer during which a subsequent FindNext will result in a wrap-around
365  static wxTimer wrapAroundTimer;
366 
367  wxFindReplaceData* data = m_frame->GetFindReplaceData();
368 
369  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
370  {
371  if( data )
372  g_markersOnly.SetFlags( data->GetFlags() );
373 
374  data = &g_markersOnly;
375  }
376  else if( !data )
377  {
378  return FindAndReplace( ACTIONS::find.MakeEvent() );
379  }
380 
381  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
382  EE_SELECTION& selection = m_selectionTool->GetSelection();
383  SCH_SCREEN* afterScreen = m_frame->GetScreen();
384  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
385  SCH_ITEM* item = nullptr;
386 
387  if( wrapAroundTimer.IsRunning() )
388  {
389  afterScreen = nullptr;
390  afterItem = nullptr;
391  wrapAroundTimer.Stop();
393  }
394 
396 
397  if( afterScreen || !searchAllSheets )
398  item = nextMatch( m_frame->GetScreen(), &m_frame->GetCurrentSheet(), afterItem, data );
399 
400  if( !item && searchAllSheets )
401  {
402  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
403  SCH_SCREENS screens( m_frame->Schematic().Root() );
404 
405  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
406  {
407  if( afterScreen )
408  {
409  if( afterScreen == screen )
410  afterScreen = nullptr;
411 
412  continue;
413  }
414 
415  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
416 
417  item = nextMatch( screen, sheet, nullptr, data );
418 
419  if( item )
420  {
421  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
422 
423  m_frame->Schematic().SetCurrentSheet( *sheet );
425 
426  screen->TestDanglingEnds();
427 
428  m_frame->SetScreen( screen );
429  UpdateFind( ACTIONS::updateFind.MakeEvent() );
430 
431  break;
432  }
433  }
434  }
435 
436  if( item )
437  {
438  m_selectionTool->AddItemToSel( item );
439  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
440  m_frame->GetCanvas()->Refresh();
441  }
442  else
443  {
444  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
445  : _( "Reached end of sheet." );
446 
447  // Show the popup during the time period the user can wrap the search
448  m_frame->ShowFindReplaceStatus( msg + wxS( " " ) + _( "Find again to wrap around to the start." ),
449  4000 );
450  wrapAroundTimer.StartOnce( 4000 );
451  }
452 
453  return 0;
454 }
455 
456 
458 {
459  wxFindReplaceData* data = m_frame->GetFindReplaceData();
461 
462  return data && item && item->Matches( *data, &m_frame->GetCurrentSheet() );
463 }
464 
465 
467 {
468  wxFindReplaceData* data = m_frame->GetFindReplaceData();
471 
472  if( !data )
473  return FindAndReplace( ACTIONS::find.MakeEvent() );
474 
475  if( item && item->Matches( *data, sheet ) )
476  {
477  if( item->Replace( *data, sheet ) )
478  {
479  m_frame->UpdateItem( item );
480  m_frame->OnModify();
481  }
482 
483  FindNext( ACTIONS::findNext.MakeEvent() );
484  }
485 
486  return 0;
487 }
488 
489 
491 {
492  wxFindReplaceData* data = m_frame->GetFindReplaceData();
493 
494  if( !data )
495  return FindAndReplace( ACTIONS::find.MakeEvent() );
496 
497  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
498  SCH_SCREENS screens( m_frame->Schematic().Root() );
499 
500  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
501  {
502  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
503 
504  for( EDA_ITEM* item = nextMatch( screen, sheet, nullptr, data ); item; )
505  {
506  if( item->Replace( *data, sheet ) )
507  {
508  m_frame->UpdateItem( item );
509  m_frame->OnModify();
510  }
511 
512  item = nextMatch( screen, sheet, dynamic_cast<SCH_ITEM*>( item ), data );
513  }
514  }
515 
516  return 0;
517 }
518 
519 
521 {
522  doCrossProbeSchToPcb( aEvent, false );
523  return 0;
524 }
525 
526 
528 {
529  doCrossProbeSchToPcb( aEvent, true );
530  return 0;
531 }
532 
533 
534 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
535 {
536  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
537  if( m_probingPcbToSch )
538  return;
539 
541  SCH_ITEM* item = nullptr;
542  SCH_COMPONENT* symbol = nullptr;
543 
544  if( aForce )
545  {
546  EE_SELECTION& selection = selTool->RequestSelection();
547 
548  if( selection.GetSize() >= 1 )
549  item = (SCH_ITEM*) selection.Front();
550  }
551  else
552  {
553  EE_SELECTION& selection = selTool->GetSelection();
554 
555  if( selection.GetSize() >= 1 )
556  item = (SCH_ITEM*) selection.Front();
557  }
558 
559  if( !item )
560  {
561  if( aForce )
562  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
563 
564  return;
565  }
566 
567 
568  switch( item->Type() )
569  {
570  case SCH_FIELD_T:
571  case LIB_FIELD_T:
572  if( item->GetParent() && item->GetParent()->Type() == SCH_COMPONENT_T )
573  {
574  symbol = (SCH_COMPONENT*) item->GetParent();
575  m_frame->SendMessageToPCBNEW( item, symbol );
576  }
577  break;
578 
579  case SCH_COMPONENT_T:
580  symbol = (SCH_COMPONENT*) item;
581  m_frame->SendMessageToPCBNEW( item, symbol );
582  break;
583 
584  case SCH_PIN_T:
585  symbol = (SCH_COMPONENT*) item->GetParent();
586  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), symbol );
587  break;
588 
589  case SCH_SHEET_T:
590  if( aForce )
591  m_frame->SendMessageToPCBNEW( item, nullptr );
592  break;
593 
594  default:
595  break;
596  }
597 }
598 
599 
600 #ifdef KICAD_SPICE
601 
602 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
603 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
604 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
605 
606 #define HITTEST_THRESHOLD_PIXELS 5
607 
608 
609 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
610 {
612  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
613 
614  if( !simFrame ) // Defensive coding; shouldn't happen.
615  return 0;
616 
617  // Deactivate other tools; particularly important if another PICKER is currently running
618  Activate();
619 
621  picker->SetSnapping( false );
622 
623  picker->SetClickHandler(
624  [this, simFrame]( const VECTOR2D& aPosition )
625  {
627  EDA_ITEM* item = nullptr;
628  selTool->SelectPoint( aPosition, wiresAndPins, &item );
629 
630  if( !item )
631  return false;
632 
633  if( item->IsType( wires ) )
634  {
635  if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
636  simFrame->AddVoltagePlot( UnescapeString( conn->Name() ) );
637  }
638  else if( item->Type() == SCH_PIN_T )
639  {
640  SCH_PIN* pin = (SCH_PIN*) item;
641  SCH_COMPONENT* symbol = (SCH_COMPONENT*) item->GetParent();
642  wxString param;
643  wxString primitive;
644 
645  primitive = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, symbol, 0 );
646  primitive.LowerCase();
647 
648  if( primitive == "c" || primitive == "l" || primitive == "r" )
649  param = wxT( "I" );
650  else if( primitive == "d" )
651  param = wxT( "Id" );
652  else
653  param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
654 
655  simFrame->AddCurrentPlot( symbol->GetRef( &m_frame->GetCurrentSheet() ),
656  param );
657  }
658 
659  return true;
660  } );
661 
662  picker->SetMotionHandler(
663  [this, picker]( const VECTOR2D& aPos )
664  {
665  EE_COLLECTOR collector;
666  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
667  collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
668 
670  selectionTool->GuessSelectionCandidates( collector, aPos );
671 
672  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
673  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
674 
675  const SCH_CONNECTION* conn = nullptr;
676 
677  if( wire )
678  {
679  item = nullptr;
680  conn = wire->Connection();
681  }
682 
683  if( item && item->Type() == SCH_PIN_T )
685  else
687 
688  if( m_pickerItem != item )
689  {
690 
691  if( m_pickerItem )
692  selectionTool->UnbrightenItem( m_pickerItem );
693 
694  m_pickerItem = item;
695 
696  if( m_pickerItem )
697  selectionTool->BrightenItem( m_pickerItem );
698  }
699 
700  if( m_frame->GetHighlightedConnection() != conn )
701  {
703 
704  TOOL_EVENT dummyEvent;
705  UpdateNetHighlighting( dummyEvent );
706  }
707  } );
708 
709  picker->SetFinalizeHandler(
710  [this]( const int& aFinalState )
711  {
712  if( m_pickerItem )
714 
716  {
717  m_frame->SetHighlightedConnection( nullptr );
718 
719  TOOL_EVENT dummyEvent;
720  UpdateNetHighlighting( dummyEvent );
721  }
722 
723  // Wake the selection tool after exiting to ensure the cursor gets updated
725  } );
726 
727  std::string tool = aEvent.GetCommandStr().get();
728  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
729 
730  return 0;
731 }
732 
733 
734 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
735 {
737 
738  // Deactivate other tools; particularly important if another PICKER is currently running
739  Activate();
740 
741  picker->SetCursor( KICURSOR::TUNE );
742  picker->SetSnapping( false );
743 
744  picker->SetClickHandler(
745  [this]( const VECTOR2D& aPosition )
746  {
748  EDA_ITEM* item = nullptr;
749  selTool->SelectPoint( aPosition, fieldsAndComponents, &item );
750 
751  if( !item )
752  return false;
753 
754  if( item->Type() != SCH_COMPONENT_T )
755  {
756  item = item->GetParent();
757 
758  if( item->Type() != SCH_COMPONENT_T )
759  return false;
760  }
761 
762  SIM_PLOT_FRAME* simFrame =
764 
765  if( simFrame )
766  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
767 
768  return true;
769  } );
770 
771  picker->SetMotionHandler(
772  [this]( const VECTOR2D& aPos )
773  {
774  EE_COLLECTOR collector;
775  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
776  collector.Collect( m_frame->GetScreen(), fieldsAndComponents, (wxPoint) aPos );
777 
779  selectionTool->GuessSelectionCandidates( collector, aPos );
780 
781  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
782 
783  if( m_pickerItem != item )
784  {
785  if( m_pickerItem )
786  selectionTool->UnbrightenItem( m_pickerItem );
787 
788  m_pickerItem = item;
789 
790  if( m_pickerItem )
791  selectionTool->BrightenItem( m_pickerItem );
792  }
793  } );
794 
795  picker->SetFinalizeHandler(
796  [this]( const int& aFinalState )
797  {
798  if( m_pickerItem )
800 
801  // Wake the selection tool after exiting to ensure the cursor gets updated
803  } );
804 
805  std::string tool = aEvent.GetCommandStr().get();
806  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
807 
808  return 0;
809 }
810 #endif /* KICAD_SPICE */
811 
812 
813 // A singleton reference for clearing the highlight
815 
816 
817 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
818 {
819  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetToolHolder() );
820  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
821  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
822  SCH_CONNECTION* conn = nullptr;
823  bool retVal = true;
824 
825  if( aPosition != CLEAR )
826  {
827  ERC_TESTER erc( &editFrame->Schematic() );
828 
829  if( erc.TestDuplicateSheetNames( false ) > 0 )
830  {
831  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
832  retVal = false;
833  }
834  else
835  {
836  SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
837  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( item );
838 
839  if( item )
840  {
841  if( item->Type() == SCH_FIELD_T )
842  symbol = dynamic_cast<SCH_COMPONENT*>( item->GetParent() );
843 
844  if( symbol && symbol->GetPartRef() && symbol->GetPartRef()->IsPower() )
845  {
846  std::vector<SCH_PIN*> pins = symbol->GetPins();
847 
848  if( pins.size() == 1 )
849  conn = pins[0]->Connection();
850  }
851  else
852  {
853  conn = item->Connection();
854  }
855  }
856  }
857  }
858 
859  if( !conn )
860  {
861  editFrame->SetStatusText( wxT( "" ) );
862  editFrame->SendCrossProbeClearHighlight();
863  }
864  else
865  {
866  editFrame->SetCrossProbeConnection( conn );
867  }
868 
869  editFrame->SetHighlightedConnection( conn );
870  editFrame->UpdateNetHighlightStatus();
871 
873  editorControl->UpdateNetHighlighting( dummy );
874 
875  return retVal;
876 }
877 
878 
880 {
882  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
883 
884  highlightNet( m_toolMgr, cursorPos );
885 
886  return 0;
887 }
888 
889 
891 {
893 
894  return 0;
895 }
896 
897 
899 {
902  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
903 
904  // TODO remove once real-time connectivity is a given
906  // Ensure the netlist data is up to date:
908 
909  // Remove selection in favor of highlighting so the whole net is highlighted
910  selectionTool->ClearSelection();
911  highlightNet( m_toolMgr, cursorPos );
912 
914 
915  if( conn )
916  {
917  if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
919  {
920  m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
922  return 0;
923  }
924 
925  wxString netName = conn->Name();
927  wxString netclassName = netSettings.GetNetclassName( netName );
928 
929  wxArrayString headers;
930  std::vector<wxArrayString> items;
931 
932  headers.Add( _( "Netclasses" ) );
933 
934  wxArrayString defaultItem;
935  defaultItem.Add( _( "Default" ) );
936  items.emplace_back( defaultItem );
937 
938  for( const auto& ii : netSettings.m_NetClasses )
939  {
940  wxArrayString item;
941  item.Add( ii.first );
942  items.emplace_back( item );
943  }
944 
945  EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName );
946  dlg.SetListLabel( _( "Select netclass:" ) );
947 
948  if( dlg.ShowModal() == wxID_OK )
949  {
950  netclassName = dlg.GetTextSelection();
951 
952  // Remove from old netclass membership list
953  if( netSettings.m_NetClassAssignments.count( netName ) )
954  {
955  const wxString oldNetclassName = netSettings.m_NetClassAssignments[ netName ];
956  NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName );
957 
958  if( oldNetclass )
959  oldNetclass->Remove( netName );
960  }
961 
962  // Add to new netclass membership list
963  NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
964 
965  if( newNetclass )
966  newNetclass->Add( netName );
967 
968  netSettings.m_NetClassAssignments[ netName ] = netclassName;
969  netSettings.ResolveNetClassAssignments();
970  }
971  }
972 
974  return 0;
975 }
976 
977 
979 {
981  CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
982  std::vector<EDA_ITEM*> itemsToRedraw;
983  const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
984 
985  if( !screen )
986  return 0;
987 
988  bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
989  wxString selectedName = selectedConn ? selectedConn->Name() : "";
990 
991  bool selectedIsNoNet = false;
992  CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
993 
994  if( selectedConn && selectedConn->Driver() == nullptr )
995  {
996  selectedIsNoNet = true;
997  selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
998  }
999 
1000  for( SCH_ITEM* item : screen->Items() )
1001  {
1002  SCH_CONNECTION* itemConn = nullptr;
1003  SCH_COMPONENT* symbol = nullptr;
1004  bool redraw = item->IsBrightened();
1005  bool highlight = false;
1006 
1007  if( item->Type() == SCH_COMPONENT_T )
1008  symbol = static_cast<SCH_COMPONENT*>( item );
1009 
1010  if( symbol && symbol->GetPartRef() && symbol->GetPartRef()->IsPower() )
1011  itemConn = symbol->Connection();
1012  else
1013  itemConn = item->Connection();
1014 
1015  if( selectedIsNoNet && selectedSubgraph )
1016  {
1017  for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
1018  {
1019  if( item == subgraphItem )
1020  {
1021  highlight = true;
1022  break;
1023  }
1024  }
1025  }
1026  else if( selectedIsBus && itemConn && itemConn->IsNet() )
1027  {
1028  for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
1029  {
1030  if( member->Name() == itemConn->Name() )
1031  {
1032  highlight = true;
1033  break;
1034  }
1035  else if( member->IsBus() )
1036  {
1037  for( const std::shared_ptr<SCH_CONNECTION>& child_member : member->Members() )
1038  {
1039  if( child_member->Name() == itemConn->Name() )
1040  {
1041  highlight = true;
1042  break;
1043  }
1044  }
1045  }
1046  }
1047  }
1048  else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1049  {
1050  highlight = true;
1051  }
1052 
1053  if( highlight )
1054  item->SetBrightened();
1055  else
1056  item->ClearBrightened();
1057 
1058  redraw |= item->IsBrightened();
1059 
1060  // symbol is only non-null if the item is a SCH_COMPONENT_T
1061  if( symbol )
1062  {
1063  redraw |= symbol->HasBrightenedPins();
1064 
1065  symbol->ClearBrightenedPins();
1066 
1067  for( SCH_PIN* pin : symbol->GetPins() )
1068  {
1069  SCH_CONNECTION* pin_conn = pin->Connection();
1070 
1071  if( pin_conn && pin_conn->Name() == selectedName )
1072  {
1073  pin->SetBrightened();
1074  redraw = true;
1075  }
1076  }
1077 
1078  if( symbol->GetPartRef() && symbol->GetPartRef()->IsPower() )
1079  {
1080  std::vector<SCH_FIELD>& fields = symbol->GetFields();
1081 
1082  for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1083  {
1084  if( item->IsBrightened() && fields[id].IsVisible() )
1085  fields[id].SetBrightened();
1086  else
1087  fields[id].ClearBrightened();
1088  }
1089  }
1090  }
1091  else if( item->Type() == SCH_SHEET_T )
1092  {
1093  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1094  {
1095  SCH_CONNECTION* pin_conn = pin->Connection();
1096  bool redrawPin = pin->IsBrightened();
1097 
1098  if( pin_conn && pin_conn->Name() == selectedName )
1099  pin->SetBrightened();
1100  else
1101  pin->ClearBrightened();
1102 
1103  redrawPin ^= pin->IsBrightened();
1104  redraw |= redrawPin;
1105  }
1106  }
1107 
1108  if( redraw )
1109  itemsToRedraw.push_back( item );
1110  }
1111 
1112  // Be sure highlight change will be redrawn
1113  KIGFX::VIEW* view = getView();
1114 
1115  for( EDA_ITEM* redrawItem : itemsToRedraw )
1117 
1118  m_frame->GetCanvas()->Refresh();
1119 
1120  return 0;
1121 }
1122 
1123 
1125 {
1126  // TODO(JE) remove once real-time connectivity is a given
1127  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1129 
1130  std::string tool = aEvent.GetCommandStr().get();
1131  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1132 
1133  // Deactivate other tools; particularly important if another PICKER is currently running
1134  Activate();
1135 
1136  picker->SetCursor( KICURSOR::BULLSEYE );
1137  picker->SetSnapping( false );
1138 
1139  picker->SetClickHandler(
1140  [this] ( const VECTOR2D& aPos )
1141  {
1142  return highlightNet( m_toolMgr, aPos );
1143  } );
1144 
1145  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1146 
1147  return 0;
1148 }
1149 
1150 
1152 {
1153  if( m_frame->GetUndoCommandCount() <= 0 )
1154  return 0;
1155 
1156  // Inform tools that undo command was issued
1158 
1159  /* Get the old list */
1161 
1162  /* Undo the command */
1164 
1165  /* Put the old list in RedoList */
1166  List->ReversePickersListOrder();
1167  m_frame->PushCommandToRedoList( List );
1168 
1170  selTool->RebuildSelection();
1171 
1174 
1176  m_frame->SyncView();
1177  m_frame->GetCanvas()->Refresh();
1178  m_frame->OnModify();
1179 
1180  return 0;
1181 }
1182 
1183 
1185 {
1186  if( m_frame->GetRedoCommandCount() == 0 )
1187  return 0;
1188 
1189  // Inform tools that undo command was issued
1191 
1192  /* Get the old list */
1194 
1195  /* Redo the command: */
1197 
1198  /* Put the old list in UndoList */
1199  list->ReversePickersListOrder();
1200  m_frame->PushCommandToUndoList( list );
1201 
1203  selTool->RebuildSelection();
1204 
1207 
1209  m_frame->SyncView();
1210  m_frame->GetCanvas()->Refresh();
1211  m_frame->OnModify();
1212 
1213  return 0;
1214 }
1215 
1216 
1218 {
1220  EE_SELECTION& selection = selTool->RequestSelection();
1221  SCHEMATIC& schematic = m_frame->Schematic();
1222 
1223  if( !selection.GetSize() )
1224  return false;
1225 
1226  selection.SetScreen( m_frame->GetScreen() );
1227  m_supplementaryClipboard.clear();
1228 
1229  for( EDA_ITEM* item : selection )
1230  {
1231  if( item->Type() == SCH_SHEET_T )
1232  {
1233  SCH_SHEET* sheet = (SCH_SHEET*) item;
1234  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1235  }
1236  }
1237 
1239  schematic.GetSheets().GetSymbols( m_supplementaryClipboardInstances, true, true );
1241 
1242  STRING_FORMATTER formatter;
1243  SCH_SEXPR_PLUGIN plugin;
1244 
1245  plugin.Format( &selection, &m_frame->GetCurrentSheet(), &formatter );
1246 
1247  return m_toolMgr->SaveClipboard( formatter.GetString() );
1248 }
1249 
1250 
1251 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1252  SCH_SCREEN** aScreen )
1253 {
1254  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1255  {
1256  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1257  return true;
1258  }
1259 
1260  return false;
1261 }
1262 
1263 
1265 {
1266  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1267 
1268  if( textEntry )
1269  {
1270  textEntry->Cut();
1271  return 0;
1272  }
1273 
1274  if( doCopy() )
1276 
1277  return 0;
1278 }
1279 
1280 
1282 {
1283  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1284 
1285  if( textEntry )
1286  {
1287  textEntry->Copy();
1288  return 0;
1289  }
1290 
1291  doCopy();
1292 
1293  return 0;
1294 }
1295 
1296 
1298  const KIID_PATH& aClipPath, SCH_SHEET* aSheet,
1299  bool aForceKeepAnnotations )
1300 {
1301  for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1302  {
1303  if( item->Type() == SCH_COMPONENT_T )
1304  {
1305  SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
1306 
1307  KIID_PATH clipItemPath = aClipPath;
1308  clipItemPath.push_back( symbol->m_Uuid );
1309 
1310  // SCH_REFERENCE_LIST doesn't include the root sheet in the path
1311  clipItemPath.erase( clipItemPath.begin() );
1312 
1313  int ii = m_supplementaryClipboardInstances.FindRefByPath( clipItemPath.AsString() );
1314 
1315  if( ii >= 0 )
1316  {
1318 
1319  symbol->SetUnitSelection( &aPastePath, instance.GetUnit() );
1320  symbol->SetUnit( instance.GetUnit() );
1321 
1322  if( aForceKeepAnnotations )
1323  {
1324  symbol->SetRef( &aPastePath, instance.GetRef() );
1325  symbol->SetValue( &aPastePath, instance.GetValue() );
1326  symbol->SetFootprint( &aPastePath, instance.GetFootprint() );
1327  }
1328  else
1329  {
1330  symbol->ClearAnnotation( &aPastePath );
1331  }
1332  }
1333  else
1334  {
1335  symbol->ClearAnnotation( &aPastePath );
1336  }
1337  }
1338  else if( item->Type() == SCH_SHEET_T )
1339  {
1340  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1341  SCH_SHEET_PATH pastePath = aPastePath;
1342  pastePath.push_back( sheet );
1343 
1344  KIID_PATH clipPath = aClipPath;
1345  clipPath.push_back( sheet->m_Uuid );
1346 
1347  sheet->AddInstance( pastePath.Path() );
1348  updatePastedInstances( pastePath, clipPath, sheet, aForceKeepAnnotations );
1349  }
1350  }
1351 }
1352 
1353 
1355 {
1356  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1357 
1358  if( textEntry )
1359  {
1360  textEntry->Paste();
1361  return 0;
1362  }
1363 
1365  std::string text = m_toolMgr->GetClipboardUTF8();
1366 
1367  if( text.empty() )
1368  return 0;
1369 
1370  STRING_LINE_READER reader( text, "Clipboard" );
1371  SCH_SEXPR_PLUGIN plugin;
1372 
1373  SCH_SHEET paste_sheet;
1374  SCH_SCREEN* paste_screen = new SCH_SCREEN( &m_frame->Schematic() );
1375 
1376  // Screen object on heap is owned by the sheet.
1377  paste_sheet.SetScreen( paste_screen );
1378 
1379  try
1380  {
1381  plugin.LoadContent( reader, &paste_sheet );
1382  }
1383  catch( IO_ERROR& )
1384  {
1385  // If it wasn't content, then paste as text
1386  paste_screen->Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
1387  }
1388 
1389  bool forceKeepAnnotations = false;
1390 
1391  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1392  {
1393  DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations );
1394 
1395  if( dlg.ShowModal() == wxID_CANCEL )
1396  return 0;
1397  }
1398 
1399  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1400  // else. Pull them back out to start with.
1401  //
1402  EDA_ITEMS loadedItems;
1403  bool sheetsPasted = false;
1404  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1405  SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1406  wxFileName destFn = pasteRoot.Last()->GetFileName();
1407 
1408  if( destFn.IsRelative() )
1409  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1410 
1411  for( SCH_ITEM* item : paste_screen->Items() )
1412  {
1413  loadedItems.push_back( item );
1414 
1415  if( item->Type() == SCH_SHEET_T )
1416  {
1417  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1418  wxFileName srcFn = sheet->GetFileName();
1419 
1420  if( srcFn.IsRelative() )
1421  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1422 
1423  SCH_SHEET_LIST sheetHierarchy( sheet );
1424 
1425  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1426  {
1427  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1428  "was dropped because the destination already has "
1429  "the sheet or one of its subsheets as a parent." ),
1430  sheet->GetFileName() );
1431  DisplayError( m_frame, msg );
1432  loadedItems.pop_back();
1433  }
1434  }
1435  }
1436 
1437  // Remove the references from our temporary screen to prevent freeing on the DTOR
1438  paste_screen->Clear( false );
1439 
1440  for( unsigned i = 0; i < loadedItems.size(); ++i )
1441  {
1442  EDA_ITEM* item = loadedItems[i];
1444 
1445  if( item->Type() == SCH_COMPONENT_T )
1446  {
1447  SCH_COMPONENT* symbol = static_cast<SCH_COMPONENT*>( item );
1448 
1449  // The library symbol gets set from the cached library symbols in the current
1450  // schematic not the symbol libraries. The cached library symbol may have
1451  // changed from the original library symbol which would cause the copy to
1452  // be incorrect.
1453  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1454 
1455  wxCHECK2( currentScreen, continue );
1456 
1457  auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1458 
1459  if( it != currentScreen->GetLibSymbols().end() )
1460  symbol->SetLibSymbol( new LIB_PART( *it->second ) );
1461 
1462  if( !forceKeepAnnotations )
1463  {
1464  // clear the annotation, but preserve the selected unit
1465  int unit = symbol->GetUnit();
1466  symbol->ClearAnnotation( nullptr );
1467  symbol->SetUnit( unit );
1468  }
1469  }
1470 
1471  if( item->Type() == SCH_SHEET_T )
1472  {
1473  SCH_SHEET* sheet = (SCH_SHEET*) item;
1474  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1475  wxFileName fn = sheet->GetFileName();
1476  SCH_SCREEN* existingScreen = nullptr;
1477  wxString baseName = nameField.GetText();
1478  wxString candidateName = baseName;
1479  wxString number;
1480 
1481  while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1482  {
1483  number = baseName.Last() + number;
1484  baseName.RemoveLast();
1485  }
1486 
1487  int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1488 
1489  // Ensure we have latest hierarchy, as we may have added a sheet in the previous
1490  // iteration
1491  hierarchy = m_frame->Schematic().GetSheets();
1492 
1493  while( hierarchy.NameExists( candidateName ) )
1494  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1495 
1496  nameField.SetText( candidateName );
1497 
1498  sheet->SetParent( pasteRoot.Last() );
1499  sheet->SetScreen( nullptr );
1500  sheetsPasted = true;
1501 
1502  if( !fn.IsAbsolute() )
1503  {
1504  wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1505  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1506  }
1507 
1508  if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1509  &existingScreen ) )
1510  {
1511  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1512  }
1513 
1514  if( existingScreen )
1515  {
1516  sheet->SetScreen( existingScreen );
1517  }
1518  else
1519  {
1520  if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1521  m_frame->InitSheet( sheet, sheet->GetFileName() );
1522  }
1523 
1524  // Push it to the clipboard path while it still has its old KIID
1525  clipPath.push_back( sheet->m_Uuid );
1526  }
1527 
1528  // Everything gets a new KIID
1529  const_cast<KIID&>( item->m_Uuid ) = KIID();
1530 
1531  // Once we have our new KIID we can update all pasted instances. This will either
1532  // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1533  if( item->Type() == SCH_SHEET_T )
1534  {
1535  SCH_SHEET* sheet = (SCH_SHEET*) item;
1536  SCH_SHEET_PATH pastePath = pasteRoot;
1537  pastePath.push_back( sheet );
1538 
1539  int page = 1;
1540  wxString pageNum = wxString::Format( "%d", page );
1541 
1542  while( hierarchy.PageNumberExists( pageNum ) )
1543  pageNum = wxString::Format( "%d", ++page );
1544 
1545  sheet->AddInstance( pastePath.Path() );
1546  sheet->SetPageNumber( pastePath, pageNum );
1547  updatePastedInstances( pastePath, clipPath, sheet, forceKeepAnnotations );
1548  }
1549 
1550  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1552 
1553  // Reset flags for subsequent move operation
1554  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1555  // Start out hidden so the pasted items aren't "ghosted" in their original location
1556  // before being moved to the current location.
1557  getView()->Hide( item, true );
1558  }
1559 
1560  if( sheetsPasted )
1561  {
1564  }
1565 
1566  // Now clear the previous selection, select the pasted items, and fire up the "move"
1567  // tool.
1568  //
1570  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1571 
1572  EE_SELECTION& selection = selTool->GetSelection();
1573 
1574  if( !selection.Empty() )
1575  {
1576  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1577 
1578  selection.SetReferencePoint( item->GetPosition() );
1580  }
1581 
1582  return 0;
1583 }
1584 
1585 
1587 {
1590  SCH_COMPONENT* symbol = nullptr;
1591  SYMBOL_EDIT_FRAME* symbolEditor;
1592 
1593  if( selection.GetSize() >= 1 )
1594  symbol = (SCH_COMPONENT*) selection.Front();
1595 
1596  if( !symbol || symbol->GetEditFlags() != 0 )
1597  return 0;
1598 
1600  symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1601 
1602  if( symbolEditor )
1603  symbolEditor->LoadSymbolFromSchematic( symbol );
1604 
1605  return 0;
1606 }
1607 
1608 
1610 {
1611  wxCommandEvent dummy;
1612  m_frame->OnAnnotate( dummy );
1613  return 0;
1614 }
1615 
1616 
1618 {
1619  wxCommandEvent dummy;
1621  return 0;
1622 }
1623 
1624 
1626 {
1628  dlg.ShowQuasiModal();
1629  return 0;
1630 }
1631 
1632 
1634 {
1636  m_frame->HardRedraw();
1637 
1638  return 0;
1639 }
1640 
1641 
1643 {
1644  wxCommandEvent dummy;
1646  return 0;
1647 }
1648 
1649 
1651 {
1652  wxCommandEvent dummy;
1654  return 0;
1655 }
1656 
1657 
1659 {
1661  dlg.ShowModal();
1662  return 0;
1663 }
1664 
1665 
1667 {
1668  int result = NET_PLUGIN_CHANGE;
1669 
1670  // If a plugin is removed or added, rebuild and reopen the new dialog
1671  while( result == NET_PLUGIN_CHANGE )
1672  result = InvokeDialogNetList( m_frame );
1673 
1674  return 0;
1675 }
1676 
1677 
1679 {
1681  return 0;
1682 }
1683 
1684 
1686 {
1688  return 0;
1689 }
1690 
1691 
1693 {
1695  return 0;
1696 }
1697 
1698 
1700 {
1702  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1703 
1704  if( selection.GetSize() == 1 )
1705  {
1706  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1707 
1710 
1711  // Store the current zoom level into the current screen before switching
1713 
1714  m_frame->GetCurrentSheet().push_back( sheet );
1717  }
1718 
1719  return 0;
1720 }
1721 
1722 
1724 {
1725  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
1726  {
1729 
1730  // Store the current zoom level into the current screen before switching
1732 
1736  }
1737 
1738  return 0;
1739 }
1740 
1741 
1743 {
1746 
1747  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1749 
1751  m_frame->GetCanvas()->Refresh();
1752 
1753  return 0;
1754 }
1755 
1756 
1758 {
1761 
1762  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1764 
1766  m_frame->GetCanvas()->Refresh();
1767 
1768  return 0;
1769 }
1770 
1771 
1773 {
1775 
1776  return 0;
1777 }
1778 
1779 
1781 {
1782  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1783  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1784  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1788  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1789  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1790  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1791 
1794 
1803 
1808 
1809 #ifdef KICAD_SPICE
1810  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
1811  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
1812 #endif /* KICAD_SPICE */
1813 
1820 
1822 
1823  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1824  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1825  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
1826  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
1827  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1829 
1842 
1844 
1848 
1852 }
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:252
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:1470
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 component's value,...
Definition: sch_field.h:50
void OnOpenCvpcb(wxCommandEvent &event)
void Save_File(bool doSaveAs=false)
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:43
const wxString & GetFileName() const
Definition: sch_screen.h:133
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:61
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:155
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:201
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:415
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
bool RescueLegacyProject(bool aRunningOnDemand)
static TOOL_ACTION findAndReplace
Definition: actions.h:80
int m_Threshold
Definition: collector.h:248
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:629
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:248
void UpdateNetHighlightStatus()
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:56
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:162
wxString GetTextSelection(int aColumn=0)
Return the selected text from aColumn in the wxListCtrl in the dialog.
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:183
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:148
static TOOL_ACTION pageSettings
Definition: actions.h:59
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...
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
Holds all the data relating to one schematic.
Definition: schematic.h:59
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:202
const wxString & GetNetclassName(const wxString &aNetName) const
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:129
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:75
int FindRefByPath(const wxString &aPath) const
Search the list for a symbol with the given KIID path.
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)
Function Collect scans a EDA_ITEM using this class's Inspector method, which does the collection.
bool PageNumberExists(const wxString &aPageNumber) const
void updatePastedInstances(const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, SCH_SHEET *aSheet, bool aForceKeepAnnotations)
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:61
static wxFindReplaceData g_markersOnly
bool PrjConfigChanged()
Return true if the project configutation 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.
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:215
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:473
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:239
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:84
int ReplaceAndFindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1415
void SetWksFileName(const wxString &aFilename)
void SetBrightened()
Definition: eda_item.h:180
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:156
void ClearBrightenedPins()
#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:141
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
EE_COLLECTOR.
Definition: ee_collectors.h:42
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:93
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:481
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:357
A dialog which shows:
virtual int GetRedoCommandCount() const
bool IsBrightened() const
Definition: eda_item.h:176
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:166
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:106
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:100
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:48
int GetUnit() const
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
static TOOL_ACTION print
Definition: actions.h:60
virtual wxPoint GetPosition() const
Definition: eda_item.h:302
int Annotate(const TOOL_EVENT &aEvent)
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:289
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:49
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
int GenerateBOM(const TOOL_EVENT &aEvent)
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
static TOOL_ACTION find
Definition: actions.h:79
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:216
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:123
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).
std::map< wxString, LIB_PART * > & GetLibSymbols()
Fetch a list of unique LIB_PART object pointers required to properly render each SCH_COMPONENT in thi...
Definition: sch_screen.h:416
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1135
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:206
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:166
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)
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:271
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:199
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:729
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:70
void pop_back()
Forwarded method from std::vector.
KIID_PATH m_supplementaryClipboardPath
int HighlightNet(const TOOL_EVENT &aEvent)
< Highlight net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:182
void ClearBrightened()
Definition: eda_item.h:183
static TOOL_ACTION pickerTool
Definition: actions.h:158
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
EE_SELECTION & GetSelection()
Return the set of currently selected items.
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:89
static TOOL_ACTION updateFind
Definition: actions.h:85
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...
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:88
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.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
static TOOL_ACTION annotate
Definition: ee_actions.h:139
wxString GetRef() const
Handle actions specific to the schematic editor.
Master controller class:
Definition: tool_manager.h:52
int EnterSheet(const TOOL_EVENT &aEvent)
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
int ShowPcbNew(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int Paste(const TOOL_EVENT &aEvent)
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_COMPONENT *aPart)
Send a message to Pcbnew via a socket connection.
static bool RescueProject(wxWindow *aParent, RESCUER &aRescuer, bool aRunningOnDemand)
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:160
Definition: kiid.h:44
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:264
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int GetUnit() const
Definition: sch_symbol.h:195
void BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:217
static TOOL_ACTION showBusManager
Definition: ee_actions.h:150
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:167
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:140
Item needs to be redrawn.
Definition: view_item.h:57
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:101
NETCLASSES m_NetClasses
Definition: net_settings.h:39
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:203
wxString Name(bool aIgnoreSheet=false) const
Field Value of part, i.e. "3.3K".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
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:211
int Print(const TOOL_EVENT &aEvent)
void HardRedraw() override
Rebuild the GAL and redraw the screen.
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:208
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)
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:53
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:196
void ResolveNetClassAssignments(bool aRebuildFromScratch=false)
Explodes the list of netclass assignments to include atomic members of composite labels (buses).
static TOOL_ACTION save
Definition: actions.h:54
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:254
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)
Notifies pcbnew about the selected item.
Generic, UI-independent tool event.
Definition: tool_event.h:173
Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:133
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:80
static TOOL_ACTION cut
Definition: actions.h:69
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
Define a library symbol object.
Definition: lib_symbol.h:93
bool NameExists(const wxString &aSheetName) const
SCH_ITEM * Driver() const
Helper dialog and control classes.
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.
EDA_ITEM * GetParent() const
Definition: eda_item.h:165
An interface for classes handling user events controlling the view behavior such as zooming,...
static TOOL_ACTION quit
Definition: actions.h:62
const wxString GetFootprint() const
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:31
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:176
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
Selected item had a property changed (except movement)
Definition: actions.h:203
static TOOL_ACTION replaceAndFindNext
Definition: actions.h:83
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
static TOOL_ACTION plot
Definition: actions.h:61
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1397
const std::string & GetString()
Definition: richio.h:435
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:44
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:373
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:557
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:322
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:54
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::unique_ptr< LIB_PART > & GetPartRef()
Definition: sch_symbol.h:164
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.
Global action (toolbar/main menu event, global shortcut)
Definition: tool_event.h:151
#define IS_MOVED
Item being moved.
Definition: eda_item.h:106
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:143
void OnUpdatePCB(wxCommandEvent &event)
static VECTOR2D CLEAR
SCH_REFERENCE_LIST m_supplementaryClipboardInstances
void UnbrightenItem(EDA_ITEM *aItem)
int RemapSymbols(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.
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...
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
Implementing SIM_PLOT_FRAME_BASE.
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:60
int AssignNetclass(const TOOL_EVENT &aEvent)
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:884
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:72
const KIID m_Uuid
Definition: eda_item.h:525
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:69
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
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:352
void LoadSymbolFromSchematic(SCH_COMPONENT *aSymbol)
Load a symbol from the schematic to edit in place.
static bool m_allowRealTime
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: eda_item.h:120
void OnAnnotate(wxCommandEvent &event)
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:142
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:300
int Open(const TOOL_EVENT &aEvent)
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
static TOOL_ACTION findNextMarker
Definition: actions.h:82
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
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:482
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:68
int PageSetup(const TOOL_EVENT &aEvent)
void ClearFindReplaceStatus()
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:567
bool IsNet() const
void SetHighlightedConnection(const SCH_CONNECTION *aConnection)
SCH_SHEET & Root() const
Definition: schematic.h:92
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.
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
static TOOL_ACTION showSymbolEditor
Definition: actions.h:163
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:55
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:128
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:192
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)
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:161
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:149
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:151
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
bool HasBrightenedPins()
wxString AsString() const
Definition: kiid.cpp:256
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41
EE_RTREE & Items()
Definition: sch_screen.h:103
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
static wxString GetSpiceField(SPICE_FIELD aField, SCH_COMPONENT *aComponent, unsigned aCtl)
Retrieve either the requested field value or the default value.
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
Schematic symbol object.
Definition: sch_symbol.h:78
#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:68
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:124
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:204
SCH_ITEM * Parent() const
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
int Undo(const TOOL_EVENT &aEvent)
bool doCopy()
< copy selection to clipboard
static TOOL_ACTION enterSheet
Definition: ee_actions.h:181
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:215
void Activate()
Run the tool.
const wxString GetValue() const
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:159
static TOOL_ACTION move
Definition: ee_actions.h:111
static TOOL_ACTION simProbe
Definition: ee_actions.h:210
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:62
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:67
static TOOL_ACTION generateBOM
Definition: ee_actions.h:163
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:214
#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:151
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:115
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
void AddTuner(SCH_COMPONENT *aComponent)
Add a tuner for a component.
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:614
bool IsBus() const
double GetScale() const
Definition: view.h:263
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_PART reference for each SCH_COMPONENT found in the full schematic.
void ShowSchematicSetupDialog(const wxString &aInitialPage=wxEmptyString)
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:141
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath)
Clear exiting symbol annotation.
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:203
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:237
int UpdateFromPCB(const TOOL_EVENT &aEvent)
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:411
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:197
static TOOL_ACTION findNext
Definition: actions.h:81
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
#define IS_NEW
New item, just created.
Definition: eda_item.h:107
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:71
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:664
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
A helper to define a symbol's reference designator in a schematic.
PRIORITY GetDriverPriority()
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:549
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:203
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:1503
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:1093
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:432
void SetListLabel(const wxString &aLabel)
The symbol library editor main window.
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:193