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 <widgets/infobar.h>
28 #include <connection_graph.h>
34 #include <project_rescue.h>
35 #include <erc.h>
36 #include <fctsys.h>
37 #include <invoke_sch_dialog.h>
38 #include <kiway.h>
40 #include <project/project_file.h>
41 #include <project/net_settings.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 
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  WS_PROXY_UNDO_ITEM* undoItem = new WS_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<LIB_VIEW_FRAME*>( viewer )->ReCreateListLib();
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 signalling 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 = [&]( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheet )
250  {
251  if( data && aItem->Matches( *data, aSheet ) )
252  {
253  aItem->SetForceVisible( true );
254  m_selectionTool->BrightenItem( aItem );
255  }
256  else if( aItem->IsBrightened() )
257  {
258  aItem->SetForceVisible( false );
260  }
261  };
262 
263  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
264  || aEvent.IsAction( &ACTIONS::updateFind ) )
265  {
267 
268  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
269  {
270  visit( item, &m_frame->GetCurrentSheet() );
271 
272  if( item->Type() == SCH_COMPONENT_T )
273  {
274  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
275 
276  for( SCH_FIELD& field : cmp->GetFields() )
277  visit( &field, &m_frame->GetCurrentSheet() );
278 
279  for( SCH_PIN* pin : cmp->GetPins() )
280  visit( pin, &m_frame->GetCurrentSheet() );
281  }
282  else if( item->Type() == SCH_SHEET_T )
283  {
284  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
285 
286  for( SCH_FIELD& field : sheet->GetFields() )
287  visit( &field, &m_frame->GetCurrentSheet() );
288 
289  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
290  visit( pin, &m_frame->GetCurrentSheet() );
291  }
292 
293  }
294  }
295  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
296  {
297  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
298  visit( item, &m_frame->GetCurrentSheet() );
299  }
300 
301  getView()->UpdateItems();
302  m_frame->GetCanvas()->Refresh();
303  m_frame->UpdateTitle();
304 
305  return 0;
306 }
307 
308 
310  SCH_ITEM* aAfter, wxFindReplaceData* aData )
311 {
312  bool past_item = true;
313 
314  if( aAfter != nullptr )
315  {
316  past_item = false;
317 
318  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
319  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
320  }
321 
322 
323  for( SCH_ITEM* item : aScreen->Items() )
324  {
325  if( item == aAfter )
326  {
327  past_item = true;
328  }
329  else if( past_item )
330  {
331  if( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
332  return item;
333 
334  if( item->Matches( *aData, aSheet ) )
335  return item;
336 
337  if( item->Type() == SCH_COMPONENT_T )
338  {
339  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
340 
341  for( SCH_FIELD& field : cmp->GetFields() )
342  {
343  if( field.Matches( *aData, aSheet ) )
344  return &field;
345  }
346 
347  for( SCH_PIN* pin : cmp->GetPins() )
348  {
349  if( pin->Matches( *aData, aSheet ) )
350  return pin;
351  }
352  }
353 
354  if( item->Type() == SCH_SHEET_T )
355  {
356  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
357 
358  for( SCH_FIELD& field : sheet->GetFields() )
359  {
360  if( field.Matches( *aData, aSheet ) )
361  return &field;
362  }
363 
364  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
365  {
366  if( pin->Matches( *aData, aSheet ) )
367  return pin;
368  }
369  }
370  }
371  }
372 
373  return nullptr;
374 }
375 
376 
378 {
379  // A timer during which a subsequent FindNext will result in a wrap-around
380  static wxTimer wrapAroundTimer;
381 
382  wxFindReplaceData* data = m_frame->GetFindReplaceData();
383 
384  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
385  {
386  if( data )
387  g_markersOnly.SetFlags( data->GetFlags() );
388 
389  data = &g_markersOnly;
390  }
391  else if( !data )
392  {
393  return FindAndReplace( ACTIONS::find.MakeEvent() );
394  }
395 
396  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
397  EE_SELECTION& selection = m_selectionTool->GetSelection();
398  SCH_SCREEN* afterScreen = m_frame->GetScreen();
399  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
400  SCH_ITEM* item = nullptr;
401 
402  if( wrapAroundTimer.IsRunning() )
403  {
404  afterScreen = nullptr;
405  afterItem = nullptr;
406  wrapAroundTimer.Stop();
408  }
409 
411 
412  if( afterScreen || !searchAllSheets )
413  item = nextMatch( m_frame->GetScreen(), &m_frame->GetCurrentSheet(), afterItem, data );
414 
415  if( !item && searchAllSheets )
416  {
417  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
418  SCH_SCREENS screens( m_frame->Schematic().Root() );
419 
420  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
421  {
422  if( afterScreen )
423  {
424  if( afterScreen == screen )
425  afterScreen = nullptr;
426 
427  continue;
428  }
429 
430  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
431 
432  item = nextMatch( screen, sheet, nullptr, data );
433 
434  if( item )
435  {
436  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
437 
438  m_frame->Schematic().SetCurrentSheet( *sheet );
440 
441  screen->TestDanglingEnds();
442 
443  m_frame->SetScreen( screen );
444  UpdateFind( ACTIONS::updateFind.MakeEvent() );
445 
446  break;
447  }
448  }
449  }
450 
451  if( item )
452  {
453  m_selectionTool->AddItemToSel( item );
454  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
455  m_frame->GetCanvas()->Refresh();
456  }
457  else
458  {
459  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
460  : _( "Reached end of sheet." );
461 
462  // Show the popup during the timeperiod the user can wrap the search
463  m_frame->ShowFindReplaceStatus( msg + _( " Find again to wrap around to the start." ),
464  4000 );
465  wrapAroundTimer.StartOnce( 4000 );
466  }
467 
468  return 0;
469 }
470 
471 
473 {
474  wxFindReplaceData* data = m_frame->GetFindReplaceData();
476 
477  return data && item && item->Matches( *data, &m_frame->GetCurrentSheet() );
478 }
479 
480 
482 {
483  wxFindReplaceData* data = m_frame->GetFindReplaceData();
486 
487  if( !data )
488  return FindAndReplace( ACTIONS::find.MakeEvent() );
489 
490  if( item && item->Matches( *data, sheet ) )
491  {
492  if( item->Replace( *data, sheet ) )
493  {
494  m_frame->UpdateItem( item );
495  m_frame->OnModify();
496  }
497 
498  FindNext( ACTIONS::findNext.MakeEvent() );
499  }
500 
501  return 0;
502 }
503 
504 
506 {
507  wxFindReplaceData* data = m_frame->GetFindReplaceData();
508 
509  if( !data )
510  return FindAndReplace( ACTIONS::find.MakeEvent() );
511 
512  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
513  SCH_SCREENS screens( m_frame->Schematic().Root() );
514 
515  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
516  {
517  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
518 
519  for( EDA_ITEM* item = nextMatch( screen, sheet, nullptr, data ); item; )
520  {
521  if( item->Replace( *data, sheet ) )
522  {
523  m_frame->UpdateItem( item );
524  m_frame->OnModify();
525  }
526 
527  item = nextMatch( screen, sheet, dynamic_cast<SCH_ITEM*>( item ), data );
528  }
529  }
530 
531  return 0;
532 }
533 
534 
536 {
537  doCrossProbeSchToPcb( aEvent, false );
538  return 0;
539 }
540 
541 
543 {
544  doCrossProbeSchToPcb( aEvent, true );
545  return 0;
546 }
547 
548 
549 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
550 {
551  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
552  if( m_probingPcbToSch )
553  return;
554 
556  SCH_ITEM* item = nullptr;
557  SCH_COMPONENT* component = nullptr;
558 
559  if( aForce )
560  {
561  EE_SELECTION& selection = selTool->RequestSelection();
562 
563  if( selection.GetSize() >= 1 )
564  item = (SCH_ITEM*) selection.Front();
565  }
566  else
567  {
568  EE_SELECTION& selection = selTool->GetSelection();
569 
570  if( selection.GetSize() >= 1 )
571  item = (SCH_ITEM*) selection.Front();
572  }
573 
574  if( !item )
575  {
576  if( aForce )
577  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
578 
579  return;
580  }
581 
582 
583  switch( item->Type() )
584  {
585  case SCH_FIELD_T:
586  case LIB_FIELD_T:
587  if( item->GetParent() && item->GetParent()->Type() == SCH_COMPONENT_T )
588  {
589  component = (SCH_COMPONENT*) item->GetParent();
590  m_frame->SendMessageToPCBNEW( item, component );
591  }
592  break;
593 
594  case SCH_COMPONENT_T:
595  component = (SCH_COMPONENT*) item;
596  m_frame->SendMessageToPCBNEW( item, component );
597  break;
598 
599  case SCH_PIN_T:
600  component = (SCH_COMPONENT*) item->GetParent();
601  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
602  break;
603 
604  case SCH_SHEET_T:
605  if( aForce )
606  m_frame->SendMessageToPCBNEW( item, nullptr );
607  break;
608 
609  default:
610  break;
611  }
612 }
613 
614 
615 #ifdef KICAD_SPICE
616 
617 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
618 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
619 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
620 
621 #define HITTEST_THRESHOLD_PIXELS 5
622 
623 
624 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
625 {
627  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
628 
629  if( !simFrame ) // Defensive coding; shouldn't happen.
630  return 0;
631 
632  // Deactivate other tools; particularly important if another PICKER is currently running
633  Activate();
634 
636 
637  picker->SetClickHandler(
638  [this, simFrame] ( const VECTOR2D& aPosition )
639  {
641  EDA_ITEM* item = nullptr;
642  selTool->SelectPoint( aPosition, wiresAndPins, &item );
643 
644  if( !item )
645  return false;
646 
648 
649  if( item->IsType( wires ) )
650  {
651  if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection( sheet ) )
652  simFrame->AddVoltagePlot( UnescapeString( conn->Name() ) );
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( &sheet ), 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  std::vector<SCH_PIN*> pins = comp->GetPins();
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  }
874 
875  editFrame->SetHighlightedConnection( conn );
876  editFrame->UpdateNetHighlightStatus();
877 
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  m_frame->ShowInfoBarError( _( "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 
1075  for( SCH_PIN* pin : comp->GetPins() )
1076  {
1077  SCH_CONNECTION* pin_conn = pin->Connection( m_frame->GetCurrentSheet() );
1078 
1079  if( pin_conn && pin_conn->Name() == selectedName )
1080  {
1081  pin->SetBrightened();
1082  redraw = true;
1083  }
1084  }
1085 
1086  if( comp->GetPartRef() && comp->GetPartRef()->IsPower() )
1087  {
1088  std::vector<SCH_FIELD>& fields = comp->GetFields();
1089 
1090  for( int id : { REFERENCE, VALUE } )
1091  {
1092  if( item->IsBrightened() && fields[id].IsVisible() )
1093  fields[id].SetBrightened();
1094  else
1095  fields[id].ClearBrightened();
1096  }
1097  }
1098  }
1099  else if( item->Type() == SCH_SHEET_T )
1100  {
1101  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1102  {
1103  SCH_CONNECTION* pin_conn = pin->Connection( m_frame->GetCurrentSheet() );
1104  bool redrawPin = pin->IsBrightened();
1105 
1106  if( pin_conn && pin_conn->Name() == selectedName )
1107  pin->SetBrightened();
1108  else
1109  pin->ClearBrightened();
1110 
1111  redrawPin ^= pin->IsBrightened();
1112  redraw |= redrawPin;
1113  }
1114  }
1115 
1116  if( redraw )
1117  itemsToRedraw.push_back( item );
1118  }
1119 
1120  // Be sure highlight change will be redrawn
1121  KIGFX::VIEW* view = getView();
1122 
1123  for( EDA_ITEM* redrawItem : itemsToRedraw )
1125 
1126  m_frame->GetCanvas()->Refresh();
1127 
1128  return 0;
1129 }
1130 
1131 
1133 {
1134  // TODO(JE) remove once real-time connectivity is a given
1135  if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1137 
1138  std::string tool = aEvent.GetCommandStr().get();
1139  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1140 
1141  // Deactivate other tools; particularly important if another PICKER is currently running
1142  Activate();
1143 
1144  picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
1145 
1146  picker->SetClickHandler(
1147  [this] ( const VECTOR2D& aPos )
1148  {
1149  return highlightNet( m_toolMgr, aPos );
1150  } );
1151 
1152  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1153 
1154  return 0;
1155 }
1156 
1157 
1159 {
1160  if( m_frame->GetUndoCommandCount() <= 0 )
1161  return 0;
1162 
1163  // Inform tools that undo command was issued
1165 
1166  /* Get the old list */
1168 
1169  /* Undo the command */
1170  m_frame->PutDataInPreviousState( List, false );
1171 
1172  /* Put the old list in RedoList */
1173  List->ReversePickersListOrder();
1174  m_frame->PushCommandToRedoList( List );
1175 
1177  selTool->RebuildSelection();
1178 
1181 
1182  m_frame->SyncView();
1183  m_frame->GetCanvas()->Refresh();
1184  m_frame->OnModify();
1185 
1186  return 0;
1187 }
1188 
1189 
1191 {
1192  if( m_frame->GetRedoCommandCount() == 0 )
1193  return 0;
1194 
1195  // Inform tools that undo command was issued
1197 
1198  /* Get the old list */
1200 
1201  /* Redo the command: */
1202  m_frame->PutDataInPreviousState( List, true );
1203 
1204  /* Put the old list in UndoList */
1205  List->ReversePickersListOrder();
1206  m_frame->PushCommandToUndoList( List );
1207 
1209  selTool->RebuildSelection();
1210 
1213 
1214  m_frame->SyncView();
1215  m_frame->GetCanvas()->Refresh();
1216  m_frame->OnModify();
1217 
1218  return 0;
1219 }
1220 
1221 
1223 {
1225  EE_SELECTION& selection = selTool->RequestSelection();
1226  SCHEMATIC& schematic = m_frame->Schematic();
1227 
1228  if( !selection.GetSize() )
1229  return false;
1230 
1231  selection.SetScreen( m_frame->GetScreen() );
1232  m_supplementaryClipboard.clear();
1233 
1234  for( EDA_ITEM* item : selection )
1235  {
1236  if( item->Type() == SCH_SHEET_T )
1237  {
1238  SCH_SHEET* sheet = (SCH_SHEET*) item;
1239  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1240  }
1241  }
1242 
1244  schematic.GetSheets().GetComponents( m_supplementaryClipboardInstances, true, true );
1246 
1247  STRING_FORMATTER formatter;
1248  SCH_SEXPR_PLUGIN plugin;
1249 
1250  plugin.Format( &selection, &formatter );
1251 
1252  return m_toolMgr->SaveClipboard( formatter.GetString() );
1253 }
1254 
1255 
1256 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1257  SCH_SCREEN** aScreen )
1258 {
1259  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1260  {
1261  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1262  return true;
1263  }
1264 
1265  return false;
1266 }
1267 
1268 
1270 {
1271  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1272 
1273  if( textEntry )
1274  {
1275  textEntry->Cut();
1276  return 0;
1277  }
1278 
1279  if( doCopy() )
1281 
1282  return 0;
1283 }
1284 
1285 
1287 {
1288  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1289 
1290  if( textEntry )
1291  {
1292  textEntry->Copy();
1293  return 0;
1294  }
1295 
1296  doCopy();
1297 
1298  return 0;
1299 }
1300 
1301 
1303  const KIID_PATH& aClipPath, SCH_SHEET* aSheet,
1304  bool aForceKeepAnnotations )
1305 {
1306  for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1307  {
1308  if( item->Type() == SCH_COMPONENT_T )
1309  {
1310  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
1311 
1312  if( aForceKeepAnnotations )
1313  {
1314  KIID_PATH clipItemPath = aClipPath;
1315  clipItemPath.push_back( comp->m_Uuid );
1316 
1317  // SCH_REFERENCE_LIST doesn't include the root sheet in the path
1318  clipItemPath.erase( clipItemPath.begin() );
1319 
1320  int ii = m_supplementaryClipboardInstances.FindRefByPath( clipItemPath.AsString() );
1321 
1322  if( ii >= 0 )
1323  {
1325 
1326  comp->SetUnit( instance.GetUnit() );
1327  comp->SetRef( &aPastePath, instance.GetRef() );
1328  comp->SetValue( &aPastePath, instance.GetValue() );
1329  comp->SetFootprint( &aPastePath, instance.GetFootprint() );
1330  }
1331  else
1332  {
1333  comp->ClearAnnotation( &aPastePath );
1334  }
1335  }
1336  else
1337  {
1338  comp->ClearAnnotation( &aPastePath );
1339  }
1340  }
1341  else if( item->Type() == SCH_SHEET_T )
1342  {
1343  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1344  SCH_SHEET_PATH pastePath = aPastePath;
1345  pastePath.push_back( sheet );
1346 
1347  KIID_PATH clipPath = aClipPath;
1348  clipPath.push_back( sheet->m_Uuid );
1349 
1350  updatePastedInstances( pastePath, clipPath, sheet, aForceKeepAnnotations );
1351  }
1352  }
1353 }
1354 
1355 
1357 {
1358  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1359 
1360  if( textEntry )
1361  {
1362  textEntry->Paste();
1363  return 0;
1364  }
1365 
1367  std::string text = m_toolMgr->GetClipboard();
1368 
1369  if( text.empty() )
1370  return 0;
1371 
1372  STRING_LINE_READER reader( text, "Clipboard" );
1373  SCH_SEXPR_PLUGIN plugin;
1374 
1375  SCH_SHEET paste_sheet;
1376  SCH_SCREEN* paste_screen = new SCH_SCREEN( &m_frame->Schematic() );
1377 
1378  // Screen object on heap is owned by the sheet.
1379  paste_sheet.SetScreen( paste_screen );
1380 
1381  try
1382  {
1383  plugin.LoadContent( reader, &paste_sheet );
1384  }
1385  catch( IO_ERROR& ioe )
1386  {
1387  // If it wasn't content, then paste as text
1388  paste_screen->Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
1389  }
1390 
1391  bool forceKeepAnnotations = false;
1392 
1393  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1394  {
1395  DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations );
1396 
1397  if( dlg.ShowModal() == wxID_CANCEL )
1398  return 0;
1399  }
1400 
1401  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1402  // else. Pull them back out to start with.
1403  //
1404  EDA_ITEMS loadedItems;
1405  bool sheetsPasted = false;
1406  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1407  SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1408  wxFileName destFn = pasteRoot.Last()->GetFileName();
1409 
1410  if( destFn.IsRelative() )
1411  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1412 
1413  for( SCH_ITEM* item : paste_screen->Items() )
1414  {
1415  loadedItems.push_back( item );
1416 
1417  if( item->Type() == SCH_SHEET_T )
1418  {
1419  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1420  wxFileName srcFn = sheet->GetFileName();
1421 
1422  if( srcFn.IsRelative() )
1423  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1424 
1425  SCH_SHEET_LIST sheetHierarchy( sheet );
1426 
1427  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1428  {
1429  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1430  "was dropped because the destination already has "
1431  "the sheet or one of its subsheets as a parent." ),
1432  sheet->GetFileName() );
1433  DisplayError( m_frame, msg );
1434  loadedItems.pop_back();
1435  }
1436  }
1437  }
1438 
1439  // Remove the references from our temporary screen to prevent freeing on the DTOR
1440  paste_screen->Clear( false );
1441 
1442  for( unsigned i = 0; i < loadedItems.size(); ++i )
1443  {
1444  EDA_ITEM* item = loadedItems[i];
1446 
1447  if( item->Type() == SCH_COMPONENT_T )
1448  {
1449  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1450 
1451  // The library symbol gets set from the cached library symbols in the current
1452  // schematic not the symbol libraries. The cached library symbol may have
1453  // changed from the original library symbol which would cause the copy to
1454  // be incorrect.
1455  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1456 
1457  wxCHECK2( currentScreen, continue );
1458 
1459  auto it = currentScreen->GetLibSymbols().find( component->GetSchSymbolLibraryName() );
1460 
1461  if( it != currentScreen->GetLibSymbols().end() )
1462  component->SetLibSymbol( new LIB_PART( *it->second ) );
1463 
1464  if( !forceKeepAnnotations )
1465  {
1466  // clear the annotation, but preserve the selected unit
1467  int unit = component->GetUnit();
1468  component->ClearAnnotation( nullptr );
1469  component->SetUnit( unit );
1470  }
1471  }
1472 
1473  if( item->Type() == SCH_SHEET_T )
1474  {
1475  SCH_SHEET* sheet = (SCH_SHEET*) item;
1476  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1477  wxFileName fn = sheet->GetFileName();
1478  SCH_SCREEN* existingScreen = nullptr;
1479  wxString baseName = nameField.GetText();
1480  wxString candidateName = baseName;
1481  int uniquifier = 1;
1482 
1483  while( hierarchy.NameExists( candidateName ) )
1484  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1485 
1486  nameField.SetText( candidateName );
1487 
1488  sheet->SetParent( pasteRoot.Last() );
1489  sheet->SetScreen( nullptr );
1490  sheetsPasted = true;
1491 
1492  if( !fn.IsAbsolute() )
1493  {
1494  wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1495  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1496  }
1497 
1498  if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1499  &existingScreen ) )
1500  {
1501  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1502  }
1503 
1504  if( existingScreen )
1505  {
1506  sheet->SetScreen( existingScreen );
1507  }
1508  else
1509  {
1510  if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1511  m_frame->InitSheet( sheet, sheet->GetFileName() );
1512  }
1513 
1514  // Push it to the clipboard path while it still has its old KIID
1515  clipPath.push_back( sheet->m_Uuid );
1516  }
1517 
1518  // Everything gets a new KIID
1519  const_cast<KIID&>( item->m_Uuid ) = KIID();
1520 
1521  // Once we have our new KIID we can update all pasted instances. This will either
1522  // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1523  if( item->Type() == SCH_SHEET_T )
1524  {
1525  SCH_SHEET* sheet = (SCH_SHEET*) item;
1526  SCH_SHEET_PATH pastePath = pasteRoot;
1527  pastePath.push_back( sheet );
1528 
1529  updatePastedInstances( pastePath, clipPath, sheet, forceKeepAnnotations );
1530  }
1531 
1532  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1534 
1535  // Reset flags for subsequent move operation
1536  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1537  // Start out hidden so the pasted items aren't "ghosted" in their original location
1538  // before being moved to the current location.
1539  getView()->Hide( item, true );
1540  }
1541 
1542  if( sheetsPasted )
1543  {
1546  }
1547 
1548  // Now clear the previous selection, select the pasted items, and fire up the "move"
1549  // tool.
1550  //
1552  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1553 
1554  EE_SELECTION& selection = selTool->GetSelection();
1555 
1556  if( !selection.Empty() )
1557  {
1558  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1559 
1560  selection.SetReferencePoint( item->GetPosition() );
1562  }
1563 
1564  return 0;
1565 }
1566 
1567 
1569 {
1572  SCH_SHEET_PATH& currentSheet = m_frame->GetCurrentSheet();
1573  SCH_COMPONENT* sym = nullptr;
1574  LIB_EDIT_FRAME* libEdit;
1575 
1576  if( selection.GetSize() >= 1 )
1577  sym = (SCH_COMPONENT*) selection.Front();
1578 
1579  if( !sym || sym->GetEditFlags() != 0 )
1580  return 0;
1581 
1583  libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
1584 
1585  if( libEdit )
1586  libEdit->LoadSymbolFromSchematic( sym->GetPartRef(), sym->GetRef( &currentSheet ),
1587  sym->GetUnit(), sym->GetConvert() );
1588 
1589  return 0;
1590 }
1591 
1592 
1594 {
1595  wxCommandEvent dummy;
1596  m_frame->OnAnnotate( dummy );
1597  return 0;
1598 }
1599 
1600 
1602 {
1603  wxCommandEvent dummy;
1605  return 0;
1606 }
1607 
1608 
1610 {
1612  dlg.ShowQuasiModal();
1613  return 0;
1614 }
1615 
1616 
1618 {
1620  m_frame->HardRedraw();
1621 
1622  return 0;
1623 }
1624 
1625 
1627 {
1628  wxCommandEvent dummy;
1630  return 0;
1631 }
1632 
1633 
1635 {
1636  wxCommandEvent dummy;
1638  return 0;
1639 }
1640 
1641 
1643 {
1645  dlg.ShowModal();
1646  return 0;
1647 }
1648 
1649 
1651 {
1652  int result = NET_PLUGIN_CHANGE;
1653 
1654  // If a plugin is removed or added, rebuild and reopen the new dialog
1655  while( result == NET_PLUGIN_CHANGE )
1656  result = InvokeDialogNetList( m_frame );
1657 
1658  return 0;
1659 }
1660 
1661 
1663 {
1665  return 0;
1666 }
1667 
1668 
1670 {
1672  return 0;
1673 }
1674 
1675 
1677 {
1679  return 0;
1680 }
1681 
1682 
1684 {
1686  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1687 
1688  if( selection.GetSize() == 1 )
1689  {
1690  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1691 
1694 
1695  m_frame->GetCurrentSheet().push_back( sheet );
1698  }
1699 
1700  return 0;
1701 }
1702 
1703 
1705 {
1706  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
1707  {
1710 
1714  }
1715 
1716  return 0;
1717 }
1718 
1719 
1721 {
1724 
1725  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1727 
1729  m_frame->GetCanvas()->Refresh();
1730 
1731  return 0;
1732 }
1733 
1734 
1736 {
1739 
1740  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1742 
1744  m_frame->GetCanvas()->Refresh();
1745 
1746  return 0;
1747 }
1748 
1749 
1751 {
1753 
1754  return 0;
1755 }
1756 
1757 
1759 {
1760  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1761  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1762  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1766  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1767  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1768  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1769 
1772 
1781 
1786 
1787 #ifdef KICAD_SPICE
1788  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
1789  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
1790 #endif /* KICAD_SPICE */
1791 
1798 
1800 
1801  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
1802  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
1803  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
1804  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
1805  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
1807 
1820 
1822 
1826 
1830 }
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:1498
SCH_SHEET_LIST.
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
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:157
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:206
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: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:631
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
void UpdateNetHighlightStatus()
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:165
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:186
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:152
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:89
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:82
static TOOL_ACTION pageSettings
Definition: actions.h:59
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.
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:129
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:75
static bool Replace(wxFindReplaceData &aSearchData, wxString &aText)
Helper function used in search and replace dialog Function Replace performs a text replace on aText u...
int FindRefByPath(const wxString &aPath) const
searches the list for a component with the given KIID path
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.
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: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.
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Function PushCommandToRedoList add a command to redo in redo list delete the very old commands when t...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
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:150
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)
Updates all items in the view according to the given flags.
Definition: view.cpp:1435
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:158
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)
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: 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:537
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
EDA_LIST_DIALOG.
virtual int GetRedoCommandCount() const
bool IsBrightened() const
Definition: base_struct.h:205
void LoadSymbolFromSchematic(const std::unique_ptr< LIB_PART > &aSymbol, const wxString &aReference, int aUnit, int aConvert)
Load a symbol from the schematic to edit in place.
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:159
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.
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
PopCommandFromRedoList return the last command to undo and remove it from list nothing is deleted.
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
int GetUnit() const
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:236
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:79
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:216
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:124
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:461
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:211
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:272
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:198
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.
KIID_PATH m_supplementaryClipboardPath
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:185
void ClearBrightened()
Definition: base_struct.h:212
static TOOL_ACTION pickerTool
Definition: actions.h:151
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:57
static TOOL_ACTION updateFind
Definition: actions.h:85
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
SCH_ITEM * nextMatch(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aSheet, SCH_ITEM *aAfter, wxFindReplaceData *aData)
Advances 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:142
wxString GetRef() const
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
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:163
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 BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:217
static TOOL_ACTION showBusManager
Definition: ee_actions.h:154
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:160
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:143
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:103
NETCLASSES m_NetClasses
Definition: net_settings.h:39
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
wxString Name(bool aIgnoreSheet=false) const
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
virtual int GetUndoCommandCount() const
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:343
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 GetComponents(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false) const
Function GetComponents adds a SCH_REFERENCE() object to aReferences for each component in the list of...
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).
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:588
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:141
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:197
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)
Function SetForceVisible is used to set and cleag force visible flag used to force the item to be dra...
Definition: base_struct.h:284
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:133
int EditWithLibEdit(const TOOL_EVENT &aEvent)
size_t GetCandidateCount()
Returen the number of rescue candidates found.
int Plot(const TOOL_EVENT &aEvent)
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.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
SCH_ITEM * Driver() const
Helper dialog and control classes.
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Definition: backanno.cpp:204
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
PopCommandFromUndoList return the last command to undo and remove it from list nothing is deleted.
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
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:160
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:208
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()
Function UpdateItems() Iterates through the list of items that asked for updating and updates them.
Definition: view.cpp:1412
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)
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
All active tools
Definition: tool_event.h:147
void ShowInfoBarError(const wxString &aErrorMsg)
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:1531
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
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)
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
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:148
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: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.
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)
SCH_SHEET & Root() const
Definition: schematic.h:94
The symbol library editor main window.
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()
Function LastScreen.
static TOOL_ACTION showSymbolEditor
Definition: actions.h:156
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:201
static TOOL_ACTION saveAs
Definition: actions.h:55
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:131
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:193
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:164
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:153
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
bool HasBrightenedPins()
wxString AsString() const
Definition: common.h:137
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.
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
Schematic symbol object.
Definition: sch_component.h:80
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:204
SCH_ITEM * Parent() const
int Undo(const TOOL_EVENT &aEvent)
bool doCopy()
copy selection to clipboard
static TOOL_ACTION enterSheet
Definition: ee_actions.h:184
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:215
void Activate()
Function Activate() Runs the tool.
const wxString GetValue() const
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:162
static TOOL_ACTION move
Definition: ee_actions.h:114
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 of advanced config.
int GetConvert() const
static TOOL_ACTION undo
Definition: actions.h:67
static TOOL_ACTION generateBOM
Definition: ee_actions.h:166
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: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:155
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:112
VIEW.
Definition: view.h:61
#define NAMELESS_PROJECT
default name for nameless projects
Definition: common.h:181
void AddTuner(SCH_COMPONENT *aComponent)
Adds a tuner for a component.
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
bool IsBus() const
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:144
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:124
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath)
Clear exiting component 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 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
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:458
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
static TOOL_ACTION findNext
Definition: actions.h:81
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
static TOOL_ACTION paste
Definition: actions.h:71
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
SCH_REFERENCE is used as a helper to define a component's reference designator in a schematic.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:515
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
wxString GetName() const
Definition: sch_pin.cpp:65
#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
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:116
void SetListLabel(const wxString &aLabel)
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:194