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-2020 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 <connection_graph.h>
33 #include <project_rescue.h>
34 #include <erc.h>
35 #include <fctsys.h>
36 #include <invoke_sch_dialog.h>
37 #include <kiway.h>
39 #include <project/project_file.h>
40 #include <project/net_settings.h>
41 #include <netlist_object.h>
42 #include <sch_edit_frame.h>
43 #include <sch_sexpr_plugin.h>
44 #include <sch_line.h>
45 #include <sch_painter.h>
46 #include <sch_sheet.h>
47 #include <sch_view.h>
48 #include <schematic.h>
49 #include <advanced_config.h>
50 #include <sim/sim_plot_frame.h>
51 #include <simulation_cursors.h>
52 #include <lib_view_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>
60 #include <ws_proxy_undo_item.h>
61 #include <dialog_update_from_pcb.h>
62 #include <dialog_helpers.h>
63 
64 int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
65 {
67  return 0;
68 }
69 
70 
72 {
74  return 0;
75 }
76 
77 
79 {
81  return 0;
82 }
83 
84 
86 {
87  m_frame->Save_File( true );
88  return 0;
89 }
90 
91 
93 {
95  return 0;
96 }
97 
98 
100 {
101  PICKED_ITEMS_LIST undoCmd;
102  WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
103  ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
104 
105  undoCmd.PushItem( wrapper );
107 
110 
111  if( dlg.ShowModal() != wxID_OK )
113 
114  return 0;
115 }
116 
117 
119 {
120  SCH_SCREENS schematic( m_frame->Schematic().Root() );
121 
122  if( schematic.HasNoFullyDefinedLibIds() )
123  RescueLegacyProject( true );
124  else
126 
127  return 0;
128 }
129 
130 
131 bool SCH_EDITOR_CONTROL::RescueLegacyProject( bool aRunningOnDemand )
132 {
134  m_frame->GetCanvas()->GetBackend() );
135 
136  return rescueProject( rescuer, aRunningOnDemand );
137 }
138 
139 
141 {
144  m_frame->GetCanvas()->GetBackend() );
145 
146  return rescueProject( rescuer, aRunningOnDemand );
147 }
148 
149 
150 bool SCH_EDITOR_CONTROL::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
151 {
152  if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
153  return false;
154 
155  if( aRescuer.GetCandidateCount() )
156  {
157  KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
158 
159  if( viewer )
160  static_cast<LIB_VIEW_FRAME*>( viewer )->ReCreateListLib();
161 
162  if( aRunningOnDemand )
163  {
164  SCH_SCREENS schematic( m_frame->Schematic().Root() );
165 
166  schematic.UpdateSymbolLinks();
168  }
169 
171  m_frame->SyncView();
172  m_frame->GetCanvas()->Refresh();
173  m_frame->OnModify();
174  }
175 
176  return true;
177 }
178 
179 
181 {
182  DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
183 
184  dlgRemap.ShowQuasiModal();
185 
186  m_frame->GetCanvas()->Refresh( true );
187 
188  return 0;
189 }
190 
191 
193 {
195 
196  wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->Schematic().RootScreen()->GetFileName() );
197 
198  if( fn.GetName() != NAMELESS_PROJECT )
200 
201  return 0;
202 }
203 
204 
206 {
208 
209  dlg.ShowModal();
210 
211  // save project config if the prj config has changed:
212  if( dlg.PrjConfigChanged() )
214 
215  return 0;
216 }
217 
218 
220 {
221  m_frame->Close( false );
222  return 0;
223 }
224 
225 
226 // A dummy wxFindReplaceData signalling any marker should be found
227 static wxFindReplaceData g_markersOnly;
228 
229 
231 {
233  return UpdateFind( aEvent );
234 }
235 
237 {
239  return 0;
240 }
241 
243 {
244  wxFindReplaceData* data = m_frame->GetFindReplaceData();
245 
246  auto visit = [&] ( EDA_ITEM* aItem )
247  {
248  if( data && aItem->Matches( *data, nullptr ) )
249  {
250  aItem->SetForceVisible( true );
251  m_selectionTool->BrightenItem( aItem );
252  }
253  else if( aItem->IsBrightened() )
254  {
255  aItem->SetForceVisible( false );
257  }
258  };
259 
260  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
261  || aEvent.IsAction( &ACTIONS::updateFind ) )
262  {
264 
265  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
266  {
267  visit( item );
268 
269  if( item->Type() == SCH_COMPONENT_T )
270  {
271  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
272 
273  for( SCH_FIELD& field : cmp->GetFields() )
274  visit( &field );
275 
276  for( SCH_PIN* pin : cmp->GetSchPins() )
277  visit( pin );
278  }
279  else if( item->Type() == SCH_SHEET_T )
280  {
281  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
282 
283  for( SCH_FIELD& field : sheet->GetFields() )
284  visit( &field );
285 
286  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
287  visit( pin );
288  }
289 
290  }
291  }
292  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
293  {
294  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
295  visit( item );
296  }
297 
298  getView()->UpdateItems();
299  m_frame->GetCanvas()->Refresh();
300  m_frame->UpdateTitle();
301 
302  return 0;
303 }
304 
305 
307  wxFindReplaceData* aData )
308 {
309  bool past_item = true;
310 
311  if( aAfter != nullptr )
312  {
313  past_item = false;
314 
315  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
316  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
317  }
318 
319 
320  for( SCH_ITEM* item : aScreen->Items() )
321  {
322  if( item == aAfter )
323  {
324  past_item = true;
325  }
326  else if( past_item )
327  {
328  if( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
329  return item;
330 
331  if( item->Matches( *aData, nullptr ) )
332  return item;
333 
334  if( item->Type() == SCH_COMPONENT_T )
335  {
336  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
337 
338  for( SCH_FIELD& field : cmp->GetFields() )
339  {
340  if( field.Matches( *aData, nullptr ) )
341  return &field;
342  }
343 
344  for( SCH_PIN* pin : cmp->GetSchPins() )
345  {
346  if( pin->Matches( *aData, nullptr ) )
347  return pin;
348  }
349  }
350 
351  if( item->Type() == SCH_SHEET_T )
352  {
353  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
354 
355  for( SCH_FIELD& field : sheet->GetFields() )
356  {
357  if( field.Matches( *aData, nullptr ) )
358  return &field;
359  }
360 
361  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
362  {
363  if( pin->Matches( *aData, nullptr ) )
364  return pin;
365  }
366  }
367  }
368  }
369 
370  return nullptr;
371 }
372 
373 
375 {
376  // A timer during which a subsequent FindNext will result in a wrap-around
377  static wxTimer wrapAroundTimer;
378 
379  wxFindReplaceData* data = m_frame->GetFindReplaceData();
380 
381  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
382  {
383  if( data )
384  g_markersOnly.SetFlags( data->GetFlags() );
385 
386  data = &g_markersOnly;
387  }
388  else if( !data )
389  {
390  return FindAndReplace( ACTIONS::find.MakeEvent() );
391  }
392 
393  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
394  EE_SELECTION& selection = m_selectionTool->GetSelection();
395  SCH_SCREEN* afterScreen = m_frame->GetScreen();
396  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
397  SCH_ITEM* item = nullptr;
398 
399  if( wrapAroundTimer.IsRunning() )
400  {
401  afterScreen = nullptr;
402  afterItem = nullptr;
403  wrapAroundTimer.Stop();
405  }
406 
408 
409  if( afterScreen || !searchAllSheets )
410  item = nextMatch( m_frame->GetScreen(), afterItem, data );
411 
412  if( !item && searchAllSheets )
413  {
414  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
415  SCH_SCREENS screens( m_frame->Schematic().Root() );
416 
417  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
418  {
419  if( afterScreen )
420  {
421  if( afterScreen == screen )
422  afterScreen = nullptr;
423 
424  continue;
425  }
426 
427  item = nextMatch( screen, nullptr, data );
428 
429  if( item )
430  {
431  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
432  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
433 
434  m_frame->Schematic().SetCurrentSheet( *sheet );
436 
437  screen->TestDanglingEnds();
438 
439  m_frame->SetScreen( screen );
440  UpdateFind( ACTIONS::updateFind.MakeEvent() );
441 
442  break;
443  }
444  }
445  }
446 
447  if( item )
448  {
449  m_selectionTool->AddItemToSel( item );
450  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
451  m_frame->GetCanvas()->Refresh();
452  }
453  else
454  {
455  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
456  : _( "Reached end of sheet." );
457 
458  // Show the popup during the timeperiod the user can wrap the search
459  m_frame->ShowFindReplaceStatus( msg + _( " Find again to wrap around to the start." ),
460  4000 );
461  wrapAroundTimer.StartOnce( 4000 );
462  }
463 
464  return 0;
465 }
466 
467 
469 {
470  wxFindReplaceData* data = m_frame->GetFindReplaceData();
472 
473  return data && item && item->Matches( *data, nullptr );
474 }
475 
476 
478 {
479  wxFindReplaceData* data = m_frame->GetFindReplaceData();
481 
482  if( !data )
483  return FindAndReplace( ACTIONS::find.MakeEvent() );
484 
485  if( item && item->Matches( *data, nullptr ) )
486  {
487  if( item->Replace( *data, &m_frame->GetCurrentSheet() ) )
488  {
489  m_frame->RefreshItem( item );
490  m_frame->OnModify();
491  }
492 
493  FindNext( ACTIONS::findNext.MakeEvent() );
494  }
495 
496  return 0;
497 }
498 
499 
501 {
502  wxFindReplaceData* data = m_frame->GetFindReplaceData();
503 
504  if( !data )
505  return FindAndReplace( ACTIONS::find.MakeEvent() );
506 
507  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
508  SCH_SCREENS screens( m_frame->Schematic().Root() );
509 
510  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
511  {
512  for( EDA_ITEM* item = nextMatch( screen, nullptr, data ); item; )
513  {
514  if( item->Replace( *data, schematic.FindSheetForScreen( screen ) ) )
515  {
516  m_frame->RefreshItem( item );
517  m_frame->OnModify();
518  }
519 
520  item = nextMatch( screen, dynamic_cast<SCH_ITEM*>( item ), data );
521  }
522  }
523 
524  return 0;
525 }
526 
527 
529 {
530  doCrossProbeSchToPcb( aEvent, false );
531  return 0;
532 }
533 
534 
536 {
537  doCrossProbeSchToPcb( aEvent, true );
538  return 0;
539 }
540 
541 
542 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
543 {
544  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
545  if( m_probingPcbToSch )
546  return;
547 
549  SCH_ITEM* item = nullptr;
550  SCH_COMPONENT* component = nullptr;
551 
552  if( aForce )
553  {
554  EE_SELECTION& selection = selTool->RequestSelection();
555 
556  if( selection.GetSize() >= 1 )
557  item = (SCH_ITEM*) selection.Front();
558  }
559  else
560  {
561  EE_SELECTION& selection = selTool->GetSelection();
562 
563  if( selection.GetSize() >= 1 )
564  item = (SCH_ITEM*) selection.Front();
565  }
566 
567  if( !item )
568  {
569  if( aForce )
570  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
571 
572  return;
573  }
574 
575 
576  switch( item->Type() )
577  {
578  case SCH_FIELD_T:
579  case LIB_FIELD_T:
580  if( item->GetParent() && item->GetParent()->Type() == SCH_COMPONENT_T )
581  {
582  component = (SCH_COMPONENT*) item->GetParent();
583  m_frame->SendMessageToPCBNEW( item, component );
584  }
585  break;
586 
587  case SCH_COMPONENT_T:
588  component = (SCH_COMPONENT*) item;
589  m_frame->SendMessageToPCBNEW( item, component );
590  break;
591 
592  case SCH_PIN_T:
593  component = (SCH_COMPONENT*) item->GetParent();
594  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
595  break;
596 
597  case SCH_SHEET_T:
598  if( aForce )
599  m_frame->SendMessageToPCBNEW( item, nullptr );
600  break;
601 
602  default:
603  break;
604  }
605 }
606 
607 
608 #ifdef KICAD_SPICE
609 
610 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
611 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
612 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
613 
614 #define HITTEST_THRESHOLD_PIXELS 5
615 
616 
617 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
618 {
620  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
621 
622  if( !simFrame ) // Defensive coding; shouldn't happen.
623  return 0;
624 
625  // Deactivate other tools; particularly important if another PICKER is currently running
626  Activate();
627 
629 
630  picker->SetClickHandler(
631  [this, simFrame] ( const VECTOR2D& aPosition )
632  {
634  EDA_ITEM* item;
635  selTool->SelectPoint( aPosition, wiresAndPins, &item );
636 
637  if( !item )
638  return false;
639 
640  if( item->IsType( wires ) )
641  {
642  // TODO(JE) Port to connection graph
643  std::unique_ptr<NETLIST_OBJECT_LIST> netlist( m_frame->BuildNetListBase() );
644 
645  for( NETLIST_OBJECT* obj : *netlist )
646  {
647  if( obj->m_Comp == item )
648  {
649  simFrame->AddVoltagePlot( UnescapeString( obj->GetNetName() ) );
650  break;
651  }
652  }
653  }
654  else if( item->Type() == SCH_PIN_T )
655  {
656  SCH_PIN* pin = (SCH_PIN*) item;
657  SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
658  wxString param;
659  wxString primitive;
660 
662  primitive.LowerCase();
663 
664  if( primitive == "c" || primitive == "l" || primitive == "r" )
665  param = wxT( "I" );
666  else if( primitive == "d" )
667  param = wxT( "Id" );
668  else
669  param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
670 
671  simFrame->AddCurrentPlot( comp->GetRef( &m_frame->GetCurrentSheet() ), param );
672  }
673 
674  return true;
675  } );
676 
677  picker->SetMotionHandler(
678  [this, picker] ( const VECTOR2D& aPos )
679  {
680  EE_COLLECTOR collector;
681  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
682  collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
683 
685  selectionTool->GuessSelectionCandidates( collector, aPos );
686 
687  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
688  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
689 
690  const SCH_CONNECTION* conn = nullptr;
691 
692  if( wire )
693  {
694  item = nullptr;
695  conn = wire->Connection( m_frame->GetCurrentSheet() );
696  }
697 
698  if( item && item->Type() == SCH_PIN_T )
700  else
702 
703  if( m_pickerItem != item )
704  {
705 
706  if( m_pickerItem )
707  selectionTool->UnbrightenItem( m_pickerItem );
708 
709  m_pickerItem = item;
710 
711  if( m_pickerItem )
712  selectionTool->BrightenItem( m_pickerItem );
713  }
714 
715  if( m_frame->GetHighlightedConnection() != conn )
716  {
718 
719  TOOL_EVENT dummyEvent;
720  UpdateNetHighlighting( dummyEvent );
721  }
722  } );
723 
724  picker->SetFinalizeHandler(
725  [this] ( const int& aFinalState )
726  {
727  if( m_pickerItem )
729 
731  {
732  m_frame->SetHighlightedConnection( nullptr );
733 
734  TOOL_EVENT dummyEvent;
735  UpdateNetHighlighting( dummyEvent );
736  }
737  } );
738 
739  std::string tool = aEvent.GetCommandStr().get();
740  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
741 
742  return 0;
743 }
744 
745 
746 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
747 {
749 
750  // Deactivate other tools; particularly important if another PICKER is currently running
751  Activate();
752 
753  picker->SetCursor( SIM_CURSORS::GetCursor( SIM_CURSORS::CURSOR::TUNE ) );
754 
755  picker->SetClickHandler(
756  [this] ( const VECTOR2D& aPosition )
757  {
759  EDA_ITEM* item;
760  selTool->SelectPoint( aPosition, fieldsAndComponents, &item );
761 
762  if( !item )
763  return false;
764 
765  if( item->Type() != SCH_COMPONENT_T )
766  {
767  item = item->GetParent();
768 
769  if( item->Type() != SCH_COMPONENT_T )
770  return false;
771  }
772 
773  SIM_PLOT_FRAME* simFrame =
775 
776  if( simFrame )
777  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
778 
779  return true;
780  } );
781 
782  picker->SetMotionHandler(
783  [this] ( const VECTOR2D& aPos )
784  {
785  EE_COLLECTOR collector;
786  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
787  collector.Collect( m_frame->GetScreen(), fieldsAndComponents, (wxPoint) aPos );
788 
790  selectionTool->GuessSelectionCandidates( collector, aPos );
791 
792  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
793 
794  if( m_pickerItem != item )
795  {
796  if( m_pickerItem )
797  selectionTool->UnbrightenItem( m_pickerItem );
798 
799  m_pickerItem = item;
800 
801  if( m_pickerItem )
802  selectionTool->BrightenItem( m_pickerItem );
803  }
804  } );
805 
806  picker->SetFinalizeHandler(
807  [this] ( const int& aFinalState )
808  {
809  if( m_pickerItem )
811  } );
812 
813  std::string tool = aEvent.GetCommandStr().get();
814  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
815 
816  return 0;
817 }
818 #endif /* KICAD_SPICE */
819 
820 
821 // A singleton reference for clearing the highlight
823 
824 
825 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
826 {
827  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetToolHolder() );
828  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
829  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
830  SCH_CONNECTION* conn = nullptr;
831  bool retVal = true;
832 
833  if( aPosition != CLEAR )
834  {
835  ERC_TESTER erc( &editFrame->Schematic() );
836 
837  if( erc.TestDuplicateSheetNames( false ) > 0 )
838  {
839  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
840  retVal = false;
841  }
842  else
843  {
844  SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
845  SCH_COMPONENT* comp = nullptr;
846 
847  if( item )
848  {
849  if( item->Type() == SCH_FIELD_T )
850  comp = dynamic_cast<SCH_COMPONENT*>( item->GetParent() );
851 
852  if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
853  {
854  SCH_PIN_PTRS pins = comp->GetSchPins( &editFrame->GetCurrentSheet() );
855 
856  if( pins.size() == 1 )
857  conn = pins[0]->Connection( editFrame->GetCurrentSheet() );
858  }
859  else
860  conn = item->Connection( editFrame->GetCurrentSheet() );
861  }
862  }
863  }
864 
865  if( !conn )
866  {
867  editFrame->SetStatusText( wxT( "" ) );
868  editFrame->SendCrossProbeClearHighlight();
869  }
870  else
871  {
872  editFrame->SetCrossProbeConnection( conn );
873  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
874  UnescapeString( conn->Name() ) ) );
875  }
876 
877  editFrame->SetHighlightedConnection( conn );
879  editorControl->UpdateNetHighlighting( dummy );
880 
881  return retVal;
882 }
883 
884 
886 {
888  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
889 
890  highlightNet( m_toolMgr, cursorPos );
891 
892  return 0;
893 }
894 
895 
897 {
899 
900  return 0;
901 }
902 
903 
905 {
908  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
909 
910  // TODO remove once real-time connectivity is a given
912  // Ensure the netlist data is up to date:
914 
915  // Remove selection in favour of highlighting so the whole net is highlighted
916  selectionTool->ClearSelection();
917  highlightNet( m_toolMgr, cursorPos );
918 
920 
921  if( conn )
922  {
923  wxString netName = conn->Name( true );
924 
925  if( conn->Name( true ).IsEmpty() )
926  {
927  DisplayError( m_frame, _( "Net must be labelled to assign a netclass." ) );
929  return 0;
930  }
931 
933  wxString netclassName = netSettings.m_NetClassAssignments[ netName ];
934 
935  wxArrayString headers;
936  std::vector<wxArrayString> items;
937 
938  headers.Add( _( "Netclasses" ) );
939 
940  wxArrayString defaultItem;
941  defaultItem.Add( _( "Default" ) );
942  items.emplace_back( defaultItem );
943 
944  for( const auto& ii : netSettings.m_NetClasses )
945  {
946  wxArrayString item;
947  item.Add( ii.first );
948  items.emplace_back( item );
949  }
950 
951  EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName );
952  dlg.SetListLabel( _( "Select netclass:" ) );
953 
954  if( dlg.ShowModal() == wxID_OK )
955  {
956  netclassName = dlg.GetTextSelection();
957 
958  // Remove from old netclass membership list
959  if( netSettings.m_NetClassAssignments.count( netName ) )
960  {
961  const wxString oldNetclassName = netSettings.m_NetClassAssignments[ netName ];
962  NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName );
963 
964  if( oldNetclass )
965  oldNetclass->Remove( netName );
966  }
967 
968  // Add to new netclass membership list
969  NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
970 
971  if( newNetclass )
972  {
973  newNetclass->Add( netName );
974  }
975 
976  netSettings.m_NetClassAssignments[ netName ] = netclassName;
977  netSettings.ResolveNetClassAssignments();
978  }
979  }
980 
982  return 0;
983 }
984 
985 
987 {
989  CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
990  std::vector<EDA_ITEM*> itemsToRedraw;
991  const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
992 
993  if( !screen )
994  return 0;
995 
996  bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
997  wxString selectedName = selectedConn ? selectedConn->Name() : "";
998 
999  bool selectedIsNoNet = false;
1000  CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
1001 
1002  if( selectedConn && selectedConn->Driver() == nullptr )
1003  {
1004  selectedIsNoNet = true;
1005  selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
1006  }
1007 
1008  for( SCH_ITEM* item : screen->Items() )
1009  {
1010  SCH_CONNECTION* itemConn = nullptr;
1011  SCH_COMPONENT* comp = nullptr;
1012  bool redraw = item->IsBrightened();
1013  bool highlight = false;
1014 
1015  if( item->Type() == SCH_COMPONENT_T )
1016  comp = static_cast<SCH_COMPONENT*>( item );
1017 
1018  if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
1019  itemConn = comp->Connection( m_frame->GetCurrentSheet() );
1020  else
1021  itemConn = item->Connection( m_frame->GetCurrentSheet() );
1022 
1023  if( selectedIsNoNet && selectedSubgraph )
1024  {
1025  for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
1026  {
1027  if( item == subgraphItem )
1028  {
1029  highlight = true;
1030  break;
1031  }
1032  }
1033  }
1034  else if( selectedIsBus && itemConn && itemConn->IsNet() )
1035  {
1036  for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
1037  {
1038  if( member->Name() == itemConn->Name() )
1039  {
1040  highlight = true;
1041  break;
1042  }
1043  else if( member->IsBus() )
1044  {
1045  for( const std::shared_ptr<SCH_CONNECTION>& child_member : member->Members() )
1046  {
1047  if( child_member->Name() == itemConn->Name() )
1048  {
1049  highlight = true;
1050  break;
1051  }
1052  }
1053  }
1054  }
1055  }
1056  else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1057  {
1058  highlight = true;
1059  }
1060 
1061  if( highlight )
1062  item->SetBrightened();
1063  else
1064  item->ClearBrightened();
1065 
1066  redraw |= item->IsBrightened();
1067 
1068  // comp is only non-null if the item is a SCH_COMPONENT_T
1069  if( comp )
1070  {
1071  redraw |= comp->HasBrightenedPins();
1072 
1073  comp->ClearBrightenedPins();
1074  std::vector<LIB_PIN*> pins;
1075  comp->GetPins( pins );
1076 
1077  for( LIB_PIN* pin : pins )
1078  {
1079  SCH_CONNECTION* pin_conn =
1080  comp->GetConnectionForPin( pin, m_frame->GetCurrentSheet() );
1081 
1082  if( pin_conn && pin_conn->Name() == selectedName )
1083  {
1084  comp->BrightenPin( pin );
1085  redraw = true;
1086  }
1087  }
1088 
1089  if( comp->GetPartRef() && comp->GetPartRef()->IsPower() )
1090  {
1091  std::vector<SCH_FIELD>& fields = comp->GetFields();
1092 
1093  for( int id : { REFERENCE, VALUE } )
1094  {
1095  if( item->IsBrightened() && fields[id].IsVisible() )
1096  fields[id].SetBrightened();
1097  else
1098  fields[id].ClearBrightened();
1099  }
1100  }
1101  }
1102  else if( item->Type() == SCH_SHEET_T )
1103  {
1104  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1105  {
1106  SCH_CONNECTION* pin_conn = pin->Connection( m_frame->GetCurrentSheet() );
1107  bool redrawPin = pin->IsBrightened();
1108 
1109  if( pin_conn && pin_conn->Name() == selectedName )
1110  pin->SetBrightened();
1111  else
1112  pin->ClearBrightened();
1113 
1114  redrawPin ^= pin->IsBrightened();
1115  redraw |= redrawPin;
1116  }
1117  }
1118 
1119  if( redraw )
1120  itemsToRedraw.push_back( item );
1121  }
1122 
1123  // Be sure highlight change will be redrawn
1124  KIGFX::VIEW* view = getView();
1125 
1126  for( EDA_ITEM* redrawItem : itemsToRedraw )
1128 
1129  m_frame->GetCanvas()->Refresh();
1130 
1131  return 0;
1132 }
1133 
1134 
1136 {
1137  // TODO(JE) remove once real-time connectivity is a given
1138  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1140 
1141  std::string tool = aEvent.GetCommandStr().get();
1142  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1143 
1144  // Deactivate other tools; particularly important if another PICKER is currently running
1145  Activate();
1146 
1147  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
1148 
1149  picker->SetClickHandler(
1150  [this] ( const VECTOR2D& aPos )
1151  {
1152  return highlightNet( m_toolMgr, aPos );
1153  } );
1154 
1155  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1156 
1157  return 0;
1158 }
1159 
1160 
1162 {
1163  if( m_frame->GetScreen()->GetUndoCommandCount() <= 0 )
1164  return 0;
1165 
1166  // Inform tools that undo command was issued
1168 
1169  /* Get the old list */
1171 
1172  /* Undo the command */
1173  m_frame->PutDataInPreviousState( List, false );
1174 
1175  /* Put the old list in RedoList */
1176  List->ReversePickersListOrder();
1178 
1180  selTool->RebuildSelection();
1181 
1184 
1185  m_frame->SyncView();
1186  m_frame->GetCanvas()->Refresh();
1187  m_frame->OnModify();
1188 
1189  return 0;
1190 }
1191 
1192 
1194 {
1195  if( m_frame->GetScreen()->GetRedoCommandCount() == 0 )
1196  return 0;
1197 
1198  // Inform tools that undo command was issued
1200 
1201  /* Get the old list */
1203 
1204  /* Redo the command: */
1205  m_frame->PutDataInPreviousState( List, true );
1206 
1207  /* Put the old list in UndoList */
1208  List->ReversePickersListOrder();
1210 
1212  selTool->RebuildSelection();
1213 
1216 
1217  m_frame->SyncView();
1218  m_frame->GetCanvas()->Refresh();
1219  m_frame->OnModify();
1220 
1221  return 0;
1222 }
1223 
1224 
1226 {
1228  EE_SELECTION& selection = selTool->RequestSelection();
1229 
1230  if( !selection.GetSize() )
1231  return false;
1232 
1233  selection.SetScreen( m_frame->GetScreen() );
1234  m_supplementaryClipboard.clear();
1235 
1236  for( EDA_ITEM* item : selection )
1237  {
1238  if( item->Type() == SCH_SHEET_T )
1239  {
1240  SCH_SHEET* sheet = (SCH_SHEET*) item;
1241  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1242  }
1243  }
1244 
1245  STRING_FORMATTER formatter;
1246  SCH_SEXPR_PLUGIN plugin;
1247 
1248  plugin.Format( &selection, &formatter );
1249 
1250  return m_toolMgr->SaveClipboard( formatter.GetString() );
1251 }
1252 
1253 
1254 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1255  SCH_SCREEN** aScreen )
1256 {
1257  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1258  {
1259  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1260  return true;
1261  }
1262 
1263  return false;
1264 }
1265 
1266 
1268 {
1269  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1270 
1271  if( textEntry )
1272  {
1273  textEntry->Cut();
1274  return 0;
1275  }
1276 
1277  if( doCopy() )
1279 
1280  return 0;
1281 }
1282 
1283 
1285 {
1286  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1287 
1288  if( textEntry )
1289  {
1290  textEntry->Copy();
1291  return 0;
1292  }
1293 
1294  doCopy();
1295 
1296  return 0;
1297 }
1298 
1299 
1301 {
1302  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1303 
1304  if( textEntry )
1305  {
1306  textEntry->Paste();
1307  return 0;
1308  }
1309 
1311  std::string text = m_toolMgr->GetClipboard();
1312 
1313  if( text.empty() )
1314  return 0;
1315 
1316  STRING_LINE_READER reader( text, "Clipboard" );
1317  SCH_SEXPR_PLUGIN plugin;
1318 
1319  SCH_SHEET paste_sheet;
1320  SCH_SCREEN* paste_screen = new SCH_SCREEN( &m_frame->Schematic() );
1321 
1322  // Screen object on heap is owned by the sheet.
1323  paste_sheet.SetScreen( paste_screen );
1324 
1325  try
1326  {
1327  plugin.LoadContent( reader, &paste_sheet );
1328  }
1329  catch( IO_ERROR& ioe )
1330  {
1331  // If it wasn't content, then paste as text
1332  paste_screen->Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
1333  }
1334 
1335  bool forceKeepAnnotations = false;
1336  bool forceDropAnnotations = false;
1337  bool dropAnnotations = false;
1338 
1339  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1340  {
1341  DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations, &forceDropAnnotations );
1342 
1343  if( dlg.ShowModal() == wxID_CANCEL )
1344  return 0;
1345  }
1346 
1347  if( forceDropAnnotations )
1348  dropAnnotations = true;
1349 
1350  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1351  // else. Pull them back out to start with.
1352  //
1353  EDA_ITEMS loadedItems;
1354  bool sheetsPasted = false;
1355  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1356  SCH_SHEET_PATH& currentSheet = m_frame->GetCurrentSheet();
1357  wxFileName destFn = currentSheet.Last()->GetFileName();
1358 
1359  if( destFn.IsRelative() )
1360  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1361 
1362  for( SCH_ITEM* item : paste_screen->Items() )
1363  {
1364  loadedItems.push_back( item );
1365 
1366  if( item->Type() == SCH_COMPONENT_T )
1367  {
1368  if( !dropAnnotations && !forceKeepAnnotations )
1369  {
1370  for( SCH_ITEM* existingItem : m_frame->GetScreen()->Items() )
1371  {
1372  if( item->m_Uuid == existingItem->m_Uuid )
1373  {
1374  dropAnnotations = true;
1375  break;
1376  }
1377  }
1378  }
1379  }
1380  else if( item->Type() == SCH_SHEET_T )
1381  {
1382  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1383  wxFileName srcFn = sheet->GetFileName();
1384 
1385  if( srcFn.IsRelative() )
1386  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1387 
1388  SCH_SHEET_LIST sheetHierarchy( sheet );
1389 
1390  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1391  {
1392  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1393  "was dropped because the destination already has "
1394  "the sheet or one of its subsheets as a parent." ),
1395  sheet->GetFileName() );
1396  DisplayError( m_frame, msg );
1397  loadedItems.pop_back();
1398  }
1399  }
1400  }
1401 
1402  // Remove the references from our temporary screen to prevent freeing on the DTOR
1403  paste_screen->Clear( false );
1404 
1405  for( unsigned i = 0; i < loadedItems.size(); ++i )
1406  {
1407  EDA_ITEM* item = loadedItems[i];
1408 
1409  if( item->Type() == SCH_COMPONENT_T )
1410  {
1411  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1412 
1413  // The library symbol gets set from the cached library symbols in the current
1414  // schematic not the symbol libraries. The cached library symbol may have
1415  // changed from the original library symbol which would cause the copy to
1416  // be incorrect.
1417  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1418 
1419  wxCHECK2( currentScreen, continue );
1420 
1421  auto it = currentScreen->GetLibSymbols().find( component->GetSchSymbolLibraryName() );
1422 
1423  if( it != currentScreen->GetLibSymbols().end() )
1424  component->SetLibSymbol( new LIB_PART( *it->second ) );
1425 
1426  if( dropAnnotations )
1427  {
1428  const_cast<KIID&>( component->m_Uuid ) = KIID();
1429 
1430  // clear the annotation, but preserve the selected unit
1431  int unit = component->GetUnit();
1432  component->ClearAnnotation( nullptr );
1433  component->SetUnit( unit );
1434  }
1435  }
1436  else
1437  {
1438  // Everything else gets a new UUID
1439  const_cast<KIID&>( item->m_Uuid ) = KIID();
1440  }
1441 
1442  if( item->Type() == SCH_SHEET_T )
1443  {
1444  SCH_SHEET* sheet = (SCH_SHEET*) item;
1445  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1446  wxFileName fn = sheet->GetFileName();
1447  SCH_SCREEN* existingScreen = nullptr;
1448  bool dropSheetAnnotations = false;
1449  wxString baseName = nameField.GetText();
1450  wxString candidateName = baseName;
1451  int uniquifier = 1;
1452 
1453  while( hierarchy.NameExists( candidateName ) )
1454  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1455 
1456  nameField.SetText( candidateName );
1457 
1458  sheet->SetParent( currentSheet.Last() );
1459  sheet->SetScreen( nullptr );
1460  sheetsPasted = true;
1461 
1462  if( !fn.IsAbsolute() )
1463  {
1464  wxFileName currentSheetFileName = currentSheet.LastScreen()->GetFileName();
1465  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1466  }
1467 
1469  fn.GetFullPath( wxPATH_UNIX ), &existingScreen ) )
1470  dropSheetAnnotations = !forceKeepAnnotations;
1471  else
1472  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1473 
1474  if( existingScreen )
1475  {
1476  sheet->SetScreen( existingScreen );
1477 
1478  SCH_SHEET_PATH sheetpath = currentSheet;
1479  sheetpath.push_back( sheet );
1480 
1481  // Clear annotation and create the AR for this path, if not exists,
1482  // when the screen is shared by sheet paths.
1483  // Otherwise ClearAnnotation do nothing, because the F1 field is used as
1484  // reference default value and takes the latest displayed value
1485  existingScreen->EnsureAlternateReferencesExist();
1486 
1487  if( forceDropAnnotations || dropSheetAnnotations )
1488  existingScreen->ClearAnnotation( &sheetpath );
1489  }
1490  else
1491  {
1492  if( !m_frame->LoadSheetFromFile( sheet, &currentSheet, fn.GetFullPath() ) )
1493  m_frame->InitSheet( sheet, sheet->GetFileName() );
1494  }
1495  }
1496 
1497  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1498  m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 );
1499 
1500  // Reset flags for subsequent move operation
1501  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1502  // Start out hidden so the pasted items aren't "ghosted" in their original location
1503  // before being moved to the current location.
1504  getView()->Hide( item, true );
1505  }
1506 
1507  if( sheetsPasted )
1508  {
1511  }
1512 
1513  // Now clear the previous selection, select the pasted items, and fire up the "move"
1514  // tool.
1515  //
1517  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1518 
1519  EE_SELECTION& selection = selTool->GetSelection();
1520 
1521  if( !selection.Empty() )
1522  {
1523  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1524 
1525  selection.SetReferencePoint( item->GetPosition() );
1527  }
1528 
1529  return 0;
1530 }
1531 
1532 
1534 {
1537  SCH_COMPONENT* sym = nullptr;
1538  LIB_EDIT_FRAME* libEdit;
1539 
1540  if( selection.GetSize() >= 1 )
1541  sym = (SCH_COMPONENT*) selection.Front();
1542 
1543  if( !sym || sym->GetEditFlags() != 0 )
1544  return 0;
1545 
1547  libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1548 
1549  if( libEdit )
1550  libEdit->LoadComponentAndSelectLib( sym->GetLibId(), sym->GetUnit(), sym->GetConvert() );
1551 
1552  return 0;
1553 }
1554 
1555 
1557 {
1558  wxCommandEvent dummy;
1559  m_frame->OnAnnotate( dummy );
1560  return 0;
1561 }
1562 
1563 
1565 {
1566  wxCommandEvent dummy;
1568  return 0;
1569 }
1570 
1571 
1573 {
1575  dlg.ShowQuasiModal();
1576  return 0;
1577 }
1578 
1579 
1581 {
1583  m_frame->HardRedraw();
1584 
1585  return 0;
1586 }
1587 
1588 
1590 {
1591  wxCommandEvent dummy;
1593  return 0;
1594 }
1595 
1596 
1598 {
1599  wxCommandEvent dummy;
1601  return 0;
1602 }
1603 
1604 
1606 {
1608  dlg.ShowModal();
1609  return 0;
1610 }
1611 
1612 
1614 {
1615  int result = NET_PLUGIN_CHANGE;
1616 
1617  // If a plugin is removed or added, rebuild and reopen the new dialog
1618  while( result == NET_PLUGIN_CHANGE )
1619  result = InvokeDialogNetList( m_frame );
1620 
1621  return 0;
1622 }
1623 
1624 
1626 {
1628  return 0;
1629 }
1630 
1631 
1633 {
1635  return 0;
1636 }
1637 
1638 
1640 {
1642  return 0;
1643 }
1644 
1645 
1647 {
1649  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1650 
1651  if( selection.GetSize() == 1 )
1652  {
1653  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1654 
1657 
1658  m_frame->GetCurrentSheet().push_back( sheet );
1661  }
1662 
1663  return 0;
1664 }
1665 
1666 
1668 {
1669  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
1670  {
1673 
1677  }
1678 
1679  return 0;
1680 }
1681 
1682 
1684 {
1687 
1688  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1690 
1692  m_frame->GetCanvas()->Refresh();
1693 
1694  return 0;
1695 }
1696 
1697 
1699 {
1702 
1703  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1705 
1707  m_frame->GetCanvas()->Refresh();
1708 
1709  return 0;
1710 }
1711 
1712 
1714 {
1716 
1717  return 0;
1718 }
1719 
1720 
1722 {
1723  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1724  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1725  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1729  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1730  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1731  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1732 
1735 
1744 
1749 
1750 #ifdef KICAD_SPICE
1751  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
1752  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
1753 #endif /* KICAD_SPICE */
1754 
1761 
1763 
1764  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1765  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1766  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
1767  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
1768  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1770 
1783 
1785 
1789 
1793 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
int Save(const TOOL_EVENT &aEvent)
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
SCH_SHEET_LIST.
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToUndoList add a command to undo in undo list delete the very old commands when t...
Definition: base_screen.cpp:80
SCH_ITEM * nextMatch(SCH_SCREEN *aScreen, SCH_ITEM *aAfter, wxFindReplaceData *aData)
Advances the search and returns the next matching item after aAfter.
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
int FindAndReplace(const TOOL_EVENT &aEvent)
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
std::vector< SCH_PIN * > SCH_PIN_PTRS
Definition: sch_component.h:71
void OnOpenCvpcb(wxCommandEvent &event)
void Save_File(bool doSaveAs=false)
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:43
void SetCursor(const wxCursor &aCursor)
Definition: picker_tool.h:65
const wxString & GetFileName() const
Definition: sch_screen.h:185
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:152
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:203
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
bool RescueLegacyProject(bool aRunningOnDemand)
static TOOL_ACTION findAndReplace
Definition: actions.h:79
int m_Threshold
Definition: collector.h:67
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:632
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
NETLIST_OBJECT_LIST * BuildNetListBase(bool updateStatusText=true)
Create a flat list which stores all connected objects.
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:160
wxString GetTextSelection(int aColumn=0)
Function GetTextSelection 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:178
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Launches a tool to highlight nets.
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:147
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:92
const wxString & GetName() const
Definition: sch_pin.h:102
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
void SetScreen(SCH_SCREEN *aScreen)
Definition: ee_selection.h:46
static TOOL_ACTION pageSettings
Definition: actions.h:59
void ResolveNetClassAssignments()
Explodes the list of netclass assignments to include atomic members of composite labels (buses).
void Format(SCH_SHEET *aSheet)
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:204
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:132
SCH_SHEET * Last() const
Function Last returns a pointer to the last sheet of the list One can see the others sheet as the "pa...
This file is part of the common library.
void ReversePickersListOrder()
Function ReversePickersListOrder reverses the order of pickers stored in this list.
static TOOL_ACTION doDelete
Definition: actions.h:74
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:72
bool SaveClipboard(const std::string &aText)
Stores an information to the system clipboard.
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.
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
static wxFindReplaceData g_markersOnly
int Redo(const TOOL_EVENT &aEvent)
int NavigateHierarchy(const TOOL_EVENT &aEvent)
int EditSymbolFields(const TOOL_EVENT &aEvent)
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
int GetUndoCommandCount() const
Definition: base_screen.h:160
void SendCrossProbeClearHighlight()
Tells PcbNew to clear the existing highlighted net, if one exists.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
wxString GetSchSymbolLibraryName() const
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:151
static TOOL_ACTION replaceAll
Definition: actions.h:83
int ReplaceAndFindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1444
void SetWksFileName(const wxString &aFilename)
static const wxCursor & GetCursor(CURSOR aCursorType)
void SetBrightened()
Definition: base_struct.h:209
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:153
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)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
int New(const TOOL_EVENT &aEvent)
Definition: erc.h:51
EE_COLLECTOR.
Definition: ee_collectors.h:42
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:95
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:555
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
EDA_LIST_DIALOG.
bool IsBrightened() const
Definition: base_struct.h:205
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
Schematic editor (Eeschema) main window.
int FindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:157
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:215
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
void EnsureAlternateReferencesExist()
For screens shared by many sheetpaths (complex hierarchies): to be able to clear or modify any refere...
Definition: sch_screen.cpp:926
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
static TOOL_ACTION print
Definition: actions.h:60
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
int Annotate(const TOOL_EVENT &aEvent)
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:229
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:48
VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:85
int GenerateBOM(const TOOL_EVENT &aEvent)
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
static TOOL_ACTION find
Definition: actions.h:78
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:208
A subgraph is a set of items that are electrically connected on a single sheet.
SCH_SHEET_PATH * FindSheetForScreen(SCH_SCREEN *aScreen)
Function FindSheetForScreen.
void setTransitions() override
Sets up handlers for various events.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:122
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
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:492
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
Field Reference of part, i.e. "IC21".
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:207
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
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)
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:270
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:200
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int ToggleForceHV(const TOOL_EVENT &aEvent)
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
void pop_back()
Forwarded method from std::vector.
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:177
void ClearBrightened()
Definition: base_struct.h:212
static TOOL_ACTION pickerTool
Definition: actions.h:149
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:102
EE_SELECTION & GetSelection()
Function GetSelection()
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:59
static TOOL_ACTION updateFind
Definition: actions.h:84
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Function RequestSelection()
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
PopCommandFromUndoList return the last command to undo and remove it from list nothing is deleted.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
static TOOL_ACTION annotate
Definition: ee_actions.h:141
SCH_EDITOR_CONTROL.
TOOL_MANAGER.
Definition: tool_manager.h:51
int EnterSheet(const TOOL_EVENT &aEvent)
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
#define NAMELESS_PROJECT
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:158
Definition: common.h:68
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Function TestForRecursion.
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int GetUnit() const
void BrightenPin(LIB_PIN *aPin)
void BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:209
static TOOL_ACTION showBusManager
Definition: ee_actions.h:149
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:158
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:142
Item is being added to the view.
Definition: view_item.h:62
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:104
NETCLASSES m_NetClasses
Definition: net_settings.h:39
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:342
int LeaveSheet(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:203
int Print(const TOOL_EVENT &aEvent)
void HardRedraw() override
Rebuild the GAL and redraw the screen.
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:237
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
UNDO_REDO_CONTAINER m_UndoList
Objects list for the undo command (old data)
Definition: base_screen.h:82
void SyncView()
Mark all items for refresh.
int ReplaceAll(const TOOL_EVENT &aEvent)
int ShowQuasiModal()
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: base_struct.h:587
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:129
PROJECT & Prj() const
Function Prj returns 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:189
static TOOL_ACTION save
Definition: actions.h:54
static TOOL_ACTION doNew
Definition: actions.h:47
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int UpdateFind(const TOOL_EVENT &aEvent)
TOOL_EVENT.
Definition: tool_event.h:171
SCH_PAINTER Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:128
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
PopCommandFromRedoList return the last command to undo and remove it from list nothing is deleted.
int EditWithLibEdit(const TOOL_EVENT &aEvent)
size_t GetCandidateCount()
Returen the number of rescue candidates found.
int Plot(const TOOL_EVENT &aEvent)
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
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.
SCH_ITEM * Driver() const
Helper dialog and control classes.
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Definition: backanno.cpp:208
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
static TOOL_ACTION quit
Definition: actions.h:62
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:31
SCH_CONNECTION * GetConnectionForPin(LIB_PIN *aPin, const SCH_SHEET_PATH &aSheet)
Retrieves the connection for a given pin of the component.
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:153
bool InvokeDialogEditComponentsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of components for instance when a symbol has moved from a symbol li...
static const TOOL_EVENT ClearedEvent
Definition: actions.h:205
static TOOL_ACTION replaceAndFindNext
Definition: actions.h:82
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
static TOOL_ACTION plot
Definition: actions.h:61
const wxString & Name(bool aIgnoreSheet=false) const
void UpdateItems()
Function UpdateItems() Iterates through the list of items that asked for updating and updates them.
Definition: view.cpp:1421
const std::string & GetString()
Definition: richio.h:475
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:364
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
void SetUnit(int aUnit)
Change the unit number to aUnit.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
SCH_SHEET_PATH.
std::unique_ptr< LIB_PART > & GetPartRef()
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:496
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Updates net highlighting after an edit
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
All active tools
Definition: tool_event.h:147
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
void OnUpdatePCB(wxCommandEvent &event)
bool LoadComponentAndSelectLib(const LIB_ID &aLibId, int aUnit, int aConvert)
Selects the currently active library and loads the symbol from aLibId.
static VECTOR2D CLEAR
void UnbrightenItem(EDA_ITEM *aItem)
int RemapSymbols(const TOOL_EVENT &aEvent)
KIGFX::VIEW * getView() const
Function getView()
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 NameExists(const wxString &aSheetName)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:150
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
Implementing SIM_PLOT_FRAME_BASE.
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:216
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList, bool aRedoCommand)
Restore an undo or redo command to put data pointed by aList in the previous state.
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
const KIID m_Uuid
Definition: base_struct.h:162
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:100
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:362
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
static bool m_allowRealTime
void OnAnnotate(wxCommandEvent &event)
virtual SCH_RENDER_SETTINGS * GetSettings() override
Definition: sch_painter.h:143
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
Field Value of part, i.e. "3.3K".
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:295
int Open(const TOOL_EVENT &aEvent)
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
static TOOL_ACTION findNextMarker
Definition: actions.h:81
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
bool m_realTimeConnectivity
Do real-time connectivity.
static TOOL_ACTION redo
Definition: actions.h:68
int PageSetup(const TOOL_EVENT &aEvent)
void ClearFindReplaceStatus()
bool IsNet() const
void SetHighlightedConnection(const SCH_CONNECTION *aConnection)
void GetPins(std::vector< LIB_PIN * > &aPinsList)
Populate a vector with all the pins from the library object.
SCH_SHEET & Root() const
Definition: schematic.h:97
The symbol library editor main window.
int Quit(const TOOL_EVENT &aEvent)
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
Function LastScreen.
static TOOL_ACTION showSymbolEditor
Definition: actions.h:154
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static TOOL_ACTION saveAs
Definition: actions.h:55
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:133
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
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)
Function SelectPoint() Selects one or all items pointed by the parameter aWhere.
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:185
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
int ShowBusManager(const TOOL_EVENT &aEvent)
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
int Cut(const TOOL_EVENT &aEvent)
Clipboard support.
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:159
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:148
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
bool HasBrightenedPins()
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
std::string GetClipboard() const
Returns the information currently stored in the system clipboard.
EE_RTREE & Items()
Definition: sch_screen.h:158
void RebuildSelection()
Rebuilds the selection from the EDA_ITEMs' selection flags.
int ClearHighlight(const TOOL_EVENT &aEvent)
Removes any net highlighting
static wxString GetSpiceField(SPICE_FIELD aField, SCH_COMPONENT *aComponent, unsigned aCtl)
Retrieves either the requested field value or the default value.
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToRedoList add a command to redo in redo list delete the very old commands when t...
Definition: base_screen.cpp:95
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
Schematic symbol object.
Definition: sch_component.h:88
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:77
#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)
Sends a connection (net or bus) to pcbnew for highlighting.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:196
SCH_ITEM * Parent() const
int Undo(const TOOL_EVENT &aEvent)
bool doCopy()
copy selection to clipboard
static TOOL_ACTION enterSheet
Definition: ee_actions.h:176
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:207
void Activate()
Function Activate() Runs the tool.
SCH_SHEET_PATH & GetCurrentSheet() const
void ClearAnnotation(SCH_SHEET_PATH *aSheetPath)
Clear the annotation for the components in aSheetPath on the screen.
Definition: sch_screen.cpp:909
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:157
static TOOL_ACTION move
Definition: ee_actions.h:113
static TOOL_ACTION simProbe
Definition: ee_actions.h:202
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
int GetConvert() const
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION generateBOM
Definition: ee_actions.h:161
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
GAL_TYPE GetBackend() const
Function GetBackend Returns 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:206
#define MAX_PAGE_SIZE_MILS
Definition: page_info.h:41
virtual void ClearUndoORRedoList(UNDO_REDO_CONTAINER &aList, int aItemCount=-1) override
Free the undo or redo list from aList element.
Definition: sch_screen.cpp:804
void InvokeDialogBusManager(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BUS_MANAGER.
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:150
Definition for part library class.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
SCH_SCREEN * RootScreen() const
Helper to retreive the screen of the root sheet.
Definition: schematic.cpp:126
VIEW.
Definition: view.h:61
void AddTuner(SCH_COMPONENT *aComponent)
Adds a tuner for a component.
bool IsBus() const
Definition of the NETLIST_OBJECT class.
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:143
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:127
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:195
const LIB_ID & GetLibId() const
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
STRING_LINE_READER is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:254
int UpdateFromPCB(const TOOL_EVENT &aEvent)
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
int GetRedoCommandCount() const
Definition: base_screen.h:165
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:457
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:187
static TOOL_ACTION findNext
Definition: actions.h:80
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
static TOOL_ACTION paste
Definition: actions.h:71
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
SCH_PIN_PTRS GetSchPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:546
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:130
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184
int ExportNetlist(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:116
void SetListLabel(const wxString &aLabel)
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:186