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 <invoke_sch_dialog.h>
37 #include <kicad_string.h>
38 #include <kiway.h>
40 #include <project/project_file.h>
41 #include <project/net_settings.h>
42 #include <sch_edit_frame.h>
44 #include <sch_line.h>
45 #include <sch_painter.h>
46 #include <sch_sheet.h>
47 #include <sch_view.h>
48 #include <schematic.h>
49 #include <advanced_config.h>
50 #include <sim/sim_plot_frame.h>
51 #include <lib_view_frame.h>
52 #include <status_popup.h>
53 #include <tool/picker_tool.h>
54 #include <tool/tool_manager.h>
55 #include <tools/ee_actions.h>
56 #include <tools/ee_selection.h>
60 #include <dialog_update_from_pcb.h>
61 #include <dialog_helpers.h>
62 
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( m_frame->GetScreen(), undoItem, UNDO_REDO::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 signaling any marker should be found
227 static wxFindReplaceData g_markersOnly;
228 
229 
231 {
233  return UpdateFind( aEvent );
234 }
235 
236 
238 {
240  return 0;
241 }
242 
243 
245 {
246  wxFindReplaceData* data = m_frame->GetFindReplaceData();
247 
248  auto visit =
249  [&]( 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  item->RunOnChildren(
273  [&]( SCH_ITEM* aChild )
274  {
275  visit( aChild, &m_frame->GetCurrentSheet() );
276  } );
277  }
278  }
279  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
280  {
281  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
282  visit( item, &m_frame->GetCurrentSheet() );
283  }
284 
285  getView()->UpdateItems();
286  m_frame->GetCanvas()->Refresh();
287  m_frame->UpdateTitle();
288 
289  return 0;
290 }
291 
292 
294  SCH_ITEM* aAfter, wxFindReplaceData* aData )
295 {
296  bool past_item = true;
297 
298  if( aAfter != nullptr )
299  {
300  past_item = false;
301 
302  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
303  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
304  }
305 
306 
307  for( SCH_ITEM* item : aScreen->Items() )
308  {
309  if( item == aAfter )
310  {
311  past_item = true;
312  }
313  else if( past_item )
314  {
315  if( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
316  return item;
317 
318  if( item->Matches( *aData, aSheet ) )
319  return item;
320 
321  if( item->Type() == SCH_COMPONENT_T )
322  {
323  SCH_COMPONENT* cmp = static_cast<SCH_COMPONENT*>( item );
324 
325  for( SCH_FIELD& field : cmp->GetFields() )
326  {
327  if( field.Matches( *aData, aSheet ) )
328  return &field;
329  }
330 
331  for( SCH_PIN* pin : cmp->GetPins() )
332  {
333  if( pin->Matches( *aData, aSheet ) )
334  return pin;
335  }
336  }
337 
338  if( item->Type() == SCH_SHEET_T )
339  {
340  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
341 
342  for( SCH_FIELD& field : sheet->GetFields() )
343  {
344  if( field.Matches( *aData, aSheet ) )
345  return &field;
346  }
347 
348  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
349  {
350  if( pin->Matches( *aData, aSheet ) )
351  return pin;
352  }
353  }
354  }
355  }
356 
357  return nullptr;
358 }
359 
360 
362 {
363  // A timer during which a subsequent FindNext will result in a wrap-around
364  static wxTimer wrapAroundTimer;
365 
366  wxFindReplaceData* data = m_frame->GetFindReplaceData();
367 
368  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
369  {
370  if( data )
371  g_markersOnly.SetFlags( data->GetFlags() );
372 
373  data = &g_markersOnly;
374  }
375  else if( !data )
376  {
377  return FindAndReplace( ACTIONS::find.MakeEvent() );
378  }
379 
380  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
381  EE_SELECTION& selection = m_selectionTool->GetSelection();
382  SCH_SCREEN* afterScreen = m_frame->GetScreen();
383  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
384  SCH_ITEM* item = nullptr;
385 
386  if( wrapAroundTimer.IsRunning() )
387  {
388  afterScreen = nullptr;
389  afterItem = nullptr;
390  wrapAroundTimer.Stop();
392  }
393 
395 
396  if( afterScreen || !searchAllSheets )
397  item = nextMatch( m_frame->GetScreen(), &m_frame->GetCurrentSheet(), afterItem, data );
398 
399  if( !item && searchAllSheets )
400  {
401  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
402  SCH_SCREENS screens( m_frame->Schematic().Root() );
403 
404  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
405  {
406  if( afterScreen )
407  {
408  if( afterScreen == screen )
409  afterScreen = nullptr;
410 
411  continue;
412  }
413 
414  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
415 
416  item = nextMatch( screen, sheet, nullptr, data );
417 
418  if( item )
419  {
420  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
421 
422  m_frame->Schematic().SetCurrentSheet( *sheet );
424 
425  screen->TestDanglingEnds();
426 
427  m_frame->SetScreen( screen );
428  UpdateFind( ACTIONS::updateFind.MakeEvent() );
429 
430  break;
431  }
432  }
433  }
434 
435  if( item )
436  {
437  m_selectionTool->AddItemToSel( item );
438  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
439  m_frame->GetCanvas()->Refresh();
440  }
441  else
442  {
443  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
444  : _( "Reached end of sheet." );
445 
446  // Show the popup during the time period the user can wrap the search
447  m_frame->ShowFindReplaceStatus( msg + wxS( " " ) + _( "Find again to wrap around to the start." ),
448  4000 );
449  wrapAroundTimer.StartOnce( 4000 );
450  }
451 
452  return 0;
453 }
454 
455 
457 {
458  wxFindReplaceData* data = m_frame->GetFindReplaceData();
460 
461  return data && item && item->Matches( *data, &m_frame->GetCurrentSheet() );
462 }
463 
464 
466 {
467  wxFindReplaceData* data = m_frame->GetFindReplaceData();
470 
471  if( !data )
472  return FindAndReplace( ACTIONS::find.MakeEvent() );
473 
474  if( item && item->Matches( *data, sheet ) )
475  {
476  if( item->Replace( *data, sheet ) )
477  {
478  m_frame->UpdateItem( item );
479  m_frame->OnModify();
480  }
481 
482  FindNext( ACTIONS::findNext.MakeEvent() );
483  }
484 
485  return 0;
486 }
487 
488 
490 {
491  wxFindReplaceData* data = m_frame->GetFindReplaceData();
492 
493  if( !data )
494  return FindAndReplace( ACTIONS::find.MakeEvent() );
495 
496  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
497  SCH_SCREENS screens( m_frame->Schematic().Root() );
498 
499  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
500  {
501  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
502 
503  for( EDA_ITEM* item = nextMatch( screen, sheet, nullptr, data ); item; )
504  {
505  if( item->Replace( *data, sheet ) )
506  {
507  m_frame->UpdateItem( item );
508  m_frame->OnModify();
509  }
510 
511  item = nextMatch( screen, sheet, dynamic_cast<SCH_ITEM*>( item ), data );
512  }
513  }
514 
515  return 0;
516 }
517 
518 
520 {
521  doCrossProbeSchToPcb( aEvent, false );
522  return 0;
523 }
524 
525 
527 {
528  doCrossProbeSchToPcb( aEvent, true );
529  return 0;
530 }
531 
532 
533 void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce )
534 {
535  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
536  if( m_probingPcbToSch )
537  return;
538 
540  SCH_ITEM* item = nullptr;
541  SCH_COMPONENT* component = nullptr;
542 
543  if( aForce )
544  {
545  EE_SELECTION& selection = selTool->RequestSelection();
546 
547  if( selection.GetSize() >= 1 )
548  item = (SCH_ITEM*) selection.Front();
549  }
550  else
551  {
552  EE_SELECTION& selection = selTool->GetSelection();
553 
554  if( selection.GetSize() >= 1 )
555  item = (SCH_ITEM*) selection.Front();
556  }
557 
558  if( !item )
559  {
560  if( aForce )
561  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
562 
563  return;
564  }
565 
566 
567  switch( item->Type() )
568  {
569  case SCH_FIELD_T:
570  case LIB_FIELD_T:
571  if( item->GetParent() && item->GetParent()->Type() == SCH_COMPONENT_T )
572  {
573  component = (SCH_COMPONENT*) item->GetParent();
574  m_frame->SendMessageToPCBNEW( item, component );
575  }
576  break;
577 
578  case SCH_COMPONENT_T:
579  component = (SCH_COMPONENT*) item;
580  m_frame->SendMessageToPCBNEW( item, component );
581  break;
582 
583  case SCH_PIN_T:
584  component = (SCH_COMPONENT*) item->GetParent();
585  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), component );
586  break;
587 
588  case SCH_SHEET_T:
589  if( aForce )
590  m_frame->SendMessageToPCBNEW( item, nullptr );
591  break;
592 
593  default:
594  break;
595  }
596 }
597 
598 
599 #ifdef KICAD_SPICE
600 
601 static KICAD_T wires[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
602 static KICAD_T wiresAndPins[] = { SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, EOT };
603 static KICAD_T fieldsAndComponents[] = { SCH_COMPONENT_T, SCH_FIELD_T, EOT };
604 
605 #define HITTEST_THRESHOLD_PIXELS 5
606 
607 
608 int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
609 {
611  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, false );
612 
613  if( !simFrame ) // Defensive coding; shouldn't happen.
614  return 0;
615 
616  // Deactivate other tools; particularly important if another PICKER is currently running
617  Activate();
618 
620 
621  picker->SetClickHandler(
622  [this, simFrame]( const VECTOR2D& aPosition )
623  {
625  EDA_ITEM* item = nullptr;
626  selTool->SelectPoint( aPosition, wiresAndPins, &item );
627 
628  if( !item )
629  return false;
630 
631  if( item->IsType( wires ) )
632  {
633  if( SCH_CONNECTION* conn = static_cast<SCH_ITEM*>( item )->Connection() )
634  simFrame->AddVoltagePlot( UnescapeString( conn->Name() ) );
635  }
636  else if( item->Type() == SCH_PIN_T )
637  {
638  SCH_PIN* pin = (SCH_PIN*) item;
639  SCH_COMPONENT* comp = (SCH_COMPONENT*) item->GetParent();
640  wxString param;
641  wxString primitive;
642 
644  primitive.LowerCase();
645 
646  if( primitive == "c" || primitive == "l" || primitive == "r" )
647  param = wxT( "I" );
648  else if( primitive == "d" )
649  param = wxT( "Id" );
650  else
651  param = wxString::Format( wxT( "I%s" ), pin->GetName().Lower() );
652 
653  simFrame->AddCurrentPlot( comp->GetRef( &m_frame->GetCurrentSheet() ), param );
654  }
655 
656  return true;
657  } );
658 
659  picker->SetMotionHandler(
660  [this, picker]( const VECTOR2D& aPos )
661  {
662  EE_COLLECTOR collector;
663  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
664  collector.Collect( m_frame->GetScreen(), wiresAndPins, (wxPoint) aPos );
665 
667  selectionTool->GuessSelectionCandidates( collector, aPos );
668 
669  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
670  SCH_LINE* wire = dynamic_cast<SCH_LINE*>( item );
671 
672  const SCH_CONNECTION* conn = nullptr;
673 
674  if( wire )
675  {
676  item = nullptr;
677  conn = wire->Connection();
678  }
679 
680  if( item && item->Type() == SCH_PIN_T )
682  else
684 
685  if( m_pickerItem != item )
686  {
687 
688  if( m_pickerItem )
689  selectionTool->UnbrightenItem( m_pickerItem );
690 
691  m_pickerItem = item;
692 
693  if( m_pickerItem )
694  selectionTool->BrightenItem( m_pickerItem );
695  }
696 
697  if( m_frame->GetHighlightedConnection() != conn )
698  {
700 
701  TOOL_EVENT dummyEvent;
702  UpdateNetHighlighting( dummyEvent );
703  }
704  } );
705 
706  picker->SetFinalizeHandler(
707  [this]( const int& aFinalState )
708  {
709  if( m_pickerItem )
711 
713  {
714  m_frame->SetHighlightedConnection( nullptr );
715 
716  TOOL_EVENT dummyEvent;
717  UpdateNetHighlighting( dummyEvent );
718  }
719 
720  // Wake the selection tool after exiting to ensure the cursor gets updated
722  } );
723 
724  std::string tool = aEvent.GetCommandStr().get();
725  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
726 
727  return 0;
728 }
729 
730 
731 int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent )
732 {
734 
735  // Deactivate other tools; particularly important if another PICKER is currently running
736  Activate();
737 
738  picker->SetCursor( KICURSOR::TUNE );
739 
740  picker->SetClickHandler(
741  [this]( const VECTOR2D& aPosition )
742  {
744  EDA_ITEM* item;
745  selTool->SelectPoint( aPosition, fieldsAndComponents, &item );
746 
747  if( !item )
748  return false;
749 
750  if( item->Type() != SCH_COMPONENT_T )
751  {
752  item = item->GetParent();
753 
754  if( item->Type() != SCH_COMPONENT_T )
755  return false;
756  }
757 
758  SIM_PLOT_FRAME* simFrame =
760 
761  if( simFrame )
762  simFrame->AddTuner( static_cast<SCH_COMPONENT*>( item ) );
763 
764  return true;
765  } );
766 
767  picker->SetMotionHandler(
768  [this]( const VECTOR2D& aPos )
769  {
770  EE_COLLECTOR collector;
771  collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
772  collector.Collect( m_frame->GetScreen(), fieldsAndComponents, (wxPoint) aPos );
773 
775  selectionTool->GuessSelectionCandidates( collector, aPos );
776 
777  EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
778 
779  if( m_pickerItem != item )
780  {
781  if( m_pickerItem )
782  selectionTool->UnbrightenItem( m_pickerItem );
783 
784  m_pickerItem = item;
785 
786  if( m_pickerItem )
787  selectionTool->BrightenItem( m_pickerItem );
788  }
789  } );
790 
791  picker->SetFinalizeHandler(
792  [this]( const int& aFinalState )
793  {
794  if( m_pickerItem )
796 
797  // Wake the selection tool after exiting to ensure the cursor gets updated
799  } );
800 
801  std::string tool = aEvent.GetCommandStr().get();
802  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
803 
804  return 0;
805 }
806 #endif /* KICAD_SPICE */
807 
808 
809 // A singleton reference for clearing the highlight
811 
812 
813 static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
814 {
815  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetToolHolder() );
816  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
817  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
818  SCH_CONNECTION* conn = nullptr;
819  bool retVal = true;
820 
821  if( aPosition != CLEAR )
822  {
823  ERC_TESTER erc( &editFrame->Schematic() );
824 
825  if( erc.TestDuplicateSheetNames( false ) > 0 )
826  {
827  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
828  retVal = false;
829  }
830  else
831  {
832  SCH_ITEM* item = static_cast<SCH_ITEM*>( selTool->GetNode( aPosition ) );
833  SCH_COMPONENT* comp = nullptr;
834 
835  if( item )
836  {
837  if( item->Type() == SCH_FIELD_T )
838  comp = dynamic_cast<SCH_COMPONENT*>( item->GetParent() );
839 
840  if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
841  {
842  std::vector<SCH_PIN*> pins = comp->GetPins();
843 
844  if( pins.size() == 1 )
845  conn = pins[0]->Connection();
846  }
847  else
848  {
849  conn = item->Connection();
850  }
851  }
852  }
853  }
854 
855  if( !conn )
856  {
857  editFrame->SetStatusText( wxT( "" ) );
858  editFrame->SendCrossProbeClearHighlight();
859  }
860  else
861  {
862  editFrame->SetCrossProbeConnection( conn );
863  }
864 
865  editFrame->SetHighlightedConnection( conn );
866  editFrame->UpdateNetHighlightStatus();
867 
869  editorControl->UpdateNetHighlighting( dummy );
870 
871  return retVal;
872 }
873 
874 
876 {
878  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
879 
880  highlightNet( m_toolMgr, cursorPos );
881 
882  return 0;
883 }
884 
885 
887 {
889 
890  return 0;
891 }
892 
893 
895 {
898  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
899 
900  // TODO remove once real-time connectivity is a given
902  // Ensure the netlist data is up to date:
904 
905  // Remove selection in favor of highlighting so the whole net is highlighted
906  selectionTool->ClearSelection();
907  highlightNet( m_toolMgr, cursorPos );
908 
910 
911  if( conn )
912  {
913  if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
915  {
916  m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
918  return 0;
919  }
920 
921  wxString netName = conn->Name();
923  wxString netclassName = netSettings.GetNetclassName( netName );
924 
925  wxArrayString headers;
926  std::vector<wxArrayString> items;
927 
928  headers.Add( _( "Netclasses" ) );
929 
930  wxArrayString defaultItem;
931  defaultItem.Add( _( "Default" ) );
932  items.emplace_back( defaultItem );
933 
934  for( const auto& ii : netSettings.m_NetClasses )
935  {
936  wxArrayString item;
937  item.Add( ii.first );
938  items.emplace_back( item );
939  }
940 
941  EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName );
942  dlg.SetListLabel( _( "Select netclass:" ) );
943 
944  if( dlg.ShowModal() == wxID_OK )
945  {
946  netclassName = dlg.GetTextSelection();
947 
948  // Remove from old netclass membership list
949  if( netSettings.m_NetClassAssignments.count( netName ) )
950  {
951  const wxString oldNetclassName = netSettings.m_NetClassAssignments[ netName ];
952  NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName );
953 
954  if( oldNetclass )
955  oldNetclass->Remove( netName );
956  }
957 
958  // Add to new netclass membership list
959  NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
960 
961  if( newNetclass )
962  newNetclass->Add( netName );
963 
964  netSettings.m_NetClassAssignments[ netName ] = netclassName;
965  netSettings.ResolveNetClassAssignments();
966  }
967  }
968 
970  return 0;
971 }
972 
973 
975 {
977  CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
978  std::vector<EDA_ITEM*> itemsToRedraw;
979  const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
980 
981  if( !screen )
982  return 0;
983 
984  bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
985  wxString selectedName = selectedConn ? selectedConn->Name() : "";
986 
987  bool selectedIsNoNet = false;
988  CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
989 
990  if( selectedConn && selectedConn->Driver() == nullptr )
991  {
992  selectedIsNoNet = true;
993  selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
994  }
995 
996  for( SCH_ITEM* item : screen->Items() )
997  {
998  SCH_CONNECTION* itemConn = nullptr;
999  SCH_COMPONENT* comp = nullptr;
1000  bool redraw = item->IsBrightened();
1001  bool highlight = false;
1002 
1003  if( item->Type() == SCH_COMPONENT_T )
1004  comp = static_cast<SCH_COMPONENT*>( item );
1005 
1006  if( comp && comp->GetPartRef() && comp->GetPartRef()->IsPower() )
1007  itemConn = comp->Connection();
1008  else
1009  itemConn = item->Connection();
1010 
1011  if( selectedIsNoNet && selectedSubgraph )
1012  {
1013  for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
1014  {
1015  if( item == subgraphItem )
1016  {
1017  highlight = true;
1018  break;
1019  }
1020  }
1021  }
1022  else if( selectedIsBus && itemConn && itemConn->IsNet() )
1023  {
1024  for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
1025  {
1026  if( member->Name() == itemConn->Name() )
1027  {
1028  highlight = true;
1029  break;
1030  }
1031  else if( member->IsBus() )
1032  {
1033  for( const std::shared_ptr<SCH_CONNECTION>& child_member : member->Members() )
1034  {
1035  if( child_member->Name() == itemConn->Name() )
1036  {
1037  highlight = true;
1038  break;
1039  }
1040  }
1041  }
1042  }
1043  }
1044  else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1045  {
1046  highlight = true;
1047  }
1048 
1049  if( highlight )
1050  item->SetBrightened();
1051  else
1052  item->ClearBrightened();
1053 
1054  redraw |= item->IsBrightened();
1055 
1056  // comp is only non-null if the item is a SCH_COMPONENT_T
1057  if( comp )
1058  {
1059  redraw |= comp->HasBrightenedPins();
1060 
1061  comp->ClearBrightenedPins();
1062 
1063  for( SCH_PIN* pin : comp->GetPins() )
1064  {
1065  SCH_CONNECTION* pin_conn = pin->Connection();
1066 
1067  if( pin_conn && pin_conn->Name() == selectedName )
1068  {
1069  pin->SetBrightened();
1070  redraw = true;
1071  }
1072  }
1073 
1074  if( comp->GetPartRef() && comp->GetPartRef()->IsPower() )
1075  {
1076  std::vector<SCH_FIELD>& fields = comp->GetFields();
1077 
1078  for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1079  {
1080  if( item->IsBrightened() && fields[id].IsVisible() )
1081  fields[id].SetBrightened();
1082  else
1083  fields[id].ClearBrightened();
1084  }
1085  }
1086  }
1087  else if( item->Type() == SCH_SHEET_T )
1088  {
1089  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1090  {
1091  SCH_CONNECTION* pin_conn = pin->Connection();
1092  bool redrawPin = pin->IsBrightened();
1093 
1094  if( pin_conn && pin_conn->Name() == selectedName )
1095  pin->SetBrightened();
1096  else
1097  pin->ClearBrightened();
1098 
1099  redrawPin ^= pin->IsBrightened();
1100  redraw |= redrawPin;
1101  }
1102  }
1103 
1104  if( redraw )
1105  itemsToRedraw.push_back( item );
1106  }
1107 
1108  // Be sure highlight change will be redrawn
1109  KIGFX::VIEW* view = getView();
1110 
1111  for( EDA_ITEM* redrawItem : itemsToRedraw )
1113 
1114  m_frame->GetCanvas()->Refresh();
1115 
1116  return 0;
1117 }
1118 
1119 
1121 {
1122  // TODO(JE) remove once real-time connectivity is a given
1123  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1125 
1126  std::string tool = aEvent.GetCommandStr().get();
1127  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1128 
1129  // Deactivate other tools; particularly important if another PICKER is currently running
1130  Activate();
1131 
1132  picker->SetCursor( KICURSOR::BULLSEYE );
1133 
1134  picker->SetClickHandler(
1135  [this] ( const VECTOR2D& aPos )
1136  {
1137  return highlightNet( m_toolMgr, aPos );
1138  } );
1139 
1140  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1141 
1142  return 0;
1143 }
1144 
1145 
1147 {
1148  if( m_frame->GetUndoCommandCount() <= 0 )
1149  return 0;
1150 
1151  // Inform tools that undo command was issued
1153 
1154  /* Get the old list */
1156 
1157  /* Undo the command */
1158  m_frame->PutDataInPreviousState( List, false );
1159 
1160  /* Put the old list in RedoList */
1161  List->ReversePickersListOrder();
1162  m_frame->PushCommandToRedoList( List );
1163 
1165  selTool->RebuildSelection();
1166 
1169 
1171  m_frame->SyncView();
1172  m_frame->GetCanvas()->Refresh();
1173  m_frame->OnModify();
1174 
1175  return 0;
1176 }
1177 
1178 
1180 {
1181  if( m_frame->GetRedoCommandCount() == 0 )
1182  return 0;
1183 
1184  // Inform tools that undo command was issued
1186 
1187  /* Get the old list */
1189 
1190  /* Redo the command: */
1191  m_frame->PutDataInPreviousState( List, true );
1192 
1193  /* Put the old list in UndoList */
1194  List->ReversePickersListOrder();
1195  m_frame->PushCommandToUndoList( List );
1196 
1198  selTool->RebuildSelection();
1199 
1202 
1204  m_frame->SyncView();
1205  m_frame->GetCanvas()->Refresh();
1206  m_frame->OnModify();
1207 
1208  return 0;
1209 }
1210 
1211 
1213 {
1215  EE_SELECTION& selection = selTool->RequestSelection();
1216  SCHEMATIC& schematic = m_frame->Schematic();
1217 
1218  if( !selection.GetSize() )
1219  return false;
1220 
1221  selection.SetScreen( m_frame->GetScreen() );
1222  m_supplementaryClipboard.clear();
1223 
1224  for( EDA_ITEM* item : selection )
1225  {
1226  if( item->Type() == SCH_SHEET_T )
1227  {
1228  SCH_SHEET* sheet = (SCH_SHEET*) item;
1229  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1230  }
1231  }
1232 
1234  schematic.GetSheets().GetSymbols( m_supplementaryClipboardInstances, true, true );
1236 
1237  STRING_FORMATTER formatter;
1238  SCH_SEXPR_PLUGIN plugin;
1239 
1240  plugin.Format( &selection, &formatter );
1241 
1242  return m_toolMgr->SaveClipboard( formatter.GetString() );
1243 }
1244 
1245 
1246 bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard( const wxString& aSheetFilename,
1247  SCH_SCREEN** aScreen )
1248 {
1249  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1250  {
1251  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1252  return true;
1253  }
1254 
1255  return false;
1256 }
1257 
1258 
1260 {
1261  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1262 
1263  if( textEntry )
1264  {
1265  textEntry->Cut();
1266  return 0;
1267  }
1268 
1269  if( doCopy() )
1271 
1272  return 0;
1273 }
1274 
1275 
1277 {
1278  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1279 
1280  if( textEntry )
1281  {
1282  textEntry->Copy();
1283  return 0;
1284  }
1285 
1286  doCopy();
1287 
1288  return 0;
1289 }
1290 
1291 
1293  const KIID_PATH& aClipPath, SCH_SHEET* aSheet,
1294  bool aForceKeepAnnotations )
1295 {
1296  for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1297  {
1298  if( item->Type() == SCH_COMPONENT_T )
1299  {
1300  SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
1301 
1302  if( aForceKeepAnnotations )
1303  {
1304  KIID_PATH clipItemPath = aClipPath;
1305  clipItemPath.push_back( comp->m_Uuid );
1306 
1307  // SCH_REFERENCE_LIST doesn't include the root sheet in the path
1308  clipItemPath.erase( clipItemPath.begin() );
1309 
1310  int ii = m_supplementaryClipboardInstances.FindRefByPath( clipItemPath.AsString() );
1311 
1312  if( ii >= 0 )
1313  {
1315 
1316  comp->SetUnit( instance.GetUnit() );
1317  comp->SetRef( &aPastePath, instance.GetRef() );
1318  comp->SetValue( &aPastePath, instance.GetValue() );
1319  comp->SetFootprint( &aPastePath, instance.GetFootprint() );
1320  }
1321  else
1322  {
1323  comp->ClearAnnotation( &aPastePath );
1324  }
1325  }
1326  else
1327  {
1328  comp->ClearAnnotation( &aPastePath );
1329  }
1330  }
1331  else if( item->Type() == SCH_SHEET_T )
1332  {
1333  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1334  SCH_SHEET_PATH pastePath = aPastePath;
1335  pastePath.push_back( sheet );
1336 
1337  KIID_PATH clipPath = aClipPath;
1338  clipPath.push_back( sheet->m_Uuid );
1339 
1340  updatePastedInstances( pastePath, clipPath, sheet, aForceKeepAnnotations );
1341  }
1342  }
1343 }
1344 
1345 
1347 {
1348  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1349 
1350  if( textEntry )
1351  {
1352  textEntry->Paste();
1353  return 0;
1354  }
1355 
1357  std::string text = m_toolMgr->GetClipboardUTF8();
1358 
1359  if( text.empty() )
1360  return 0;
1361 
1362  STRING_LINE_READER reader( text, "Clipboard" );
1363  SCH_SEXPR_PLUGIN plugin;
1364 
1365  SCH_SHEET paste_sheet;
1366  SCH_SCREEN* paste_screen = new SCH_SCREEN( &m_frame->Schematic() );
1367 
1368  // Screen object on heap is owned by the sheet.
1369  paste_sheet.SetScreen( paste_screen );
1370 
1371  try
1372  {
1373  plugin.LoadContent( reader, &paste_sheet );
1374  }
1375  catch( IO_ERROR& ioe )
1376  {
1377  // If it wasn't content, then paste as text
1378  paste_screen->Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
1379  }
1380 
1381  bool forceKeepAnnotations = false;
1382 
1383  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1384  {
1385  DIALOG_PASTE_SPECIAL dlg( m_frame, &forceKeepAnnotations );
1386 
1387  if( dlg.ShowModal() == wxID_CANCEL )
1388  return 0;
1389  }
1390 
1391  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1392  // else. Pull them back out to start with.
1393  //
1394  EDA_ITEMS loadedItems;
1395  bool sheetsPasted = false;
1396  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1397  SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1398  wxFileName destFn = pasteRoot.Last()->GetFileName();
1399 
1400  if( destFn.IsRelative() )
1401  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1402 
1403  for( SCH_ITEM* item : paste_screen->Items() )
1404  {
1405  loadedItems.push_back( item );
1406 
1407  if( item->Type() == SCH_SHEET_T )
1408  {
1409  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1410  wxFileName srcFn = sheet->GetFileName();
1411 
1412  if( srcFn.IsRelative() )
1413  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1414 
1415  SCH_SHEET_LIST sheetHierarchy( sheet );
1416 
1417  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1418  {
1419  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1420  "was dropped because the destination already has "
1421  "the sheet or one of its subsheets as a parent." ),
1422  sheet->GetFileName() );
1423  DisplayError( m_frame, msg );
1424  loadedItems.pop_back();
1425  }
1426  }
1427  }
1428 
1429  // Remove the references from our temporary screen to prevent freeing on the DTOR
1430  paste_screen->Clear( false );
1431 
1432  for( unsigned i = 0; i < loadedItems.size(); ++i )
1433  {
1434  EDA_ITEM* item = loadedItems[i];
1436 
1437  if( item->Type() == SCH_COMPONENT_T )
1438  {
1439  SCH_COMPONENT* component = (SCH_COMPONENT*) item;
1440 
1441  // The library symbol gets set from the cached library symbols in the current
1442  // schematic not the symbol libraries. The cached library symbol may have
1443  // changed from the original library symbol which would cause the copy to
1444  // be incorrect.
1445  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1446 
1447  wxCHECK2( currentScreen, continue );
1448 
1449  auto it = currentScreen->GetLibSymbols().find( component->GetSchSymbolLibraryName() );
1450 
1451  if( it != currentScreen->GetLibSymbols().end() )
1452  component->SetLibSymbol( new LIB_PART( *it->second ) );
1453 
1454  if( !forceKeepAnnotations )
1455  {
1456  // clear the annotation, but preserve the selected unit
1457  int unit = component->GetUnit();
1458  component->ClearAnnotation( nullptr );
1459  component->SetUnit( unit );
1460  }
1461  }
1462 
1463  if( item->Type() == SCH_SHEET_T )
1464  {
1465  SCH_SHEET* sheet = (SCH_SHEET*) item;
1466  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1467  wxFileName fn = sheet->GetFileName();
1468  SCH_SCREEN* existingScreen = nullptr;
1469  wxString baseName = nameField.GetText();
1470  wxString candidateName = baseName;
1471  wxString number;
1472 
1473  while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1474  {
1475  number = baseName.Last() + number;
1476  baseName.RemoveLast();
1477  }
1478 
1479  int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1480 
1481  while( hierarchy.NameExists( candidateName ) )
1482  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1483 
1484  nameField.SetText( candidateName );
1485 
1486  sheet->SetParent( pasteRoot.Last() );
1487  sheet->SetScreen( nullptr );
1488  sheetsPasted = true;
1489 
1490  if( !fn.IsAbsolute() )
1491  {
1492  wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1493  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1494  }
1495 
1496  if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1497  &existingScreen ) )
1498  {
1499  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1500  }
1501 
1502  if( existingScreen )
1503  {
1504  sheet->SetScreen( existingScreen );
1505  }
1506  else
1507  {
1508  if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1509  m_frame->InitSheet( sheet, sheet->GetFileName() );
1510  }
1511 
1512  // Push it to the clipboard path while it still has its old KIID
1513  clipPath.push_back( sheet->m_Uuid );
1514  }
1515 
1516  // Everything gets a new KIID
1517  const_cast<KIID&>( item->m_Uuid ) = KIID();
1518 
1519  // Once we have our new KIID we can update all pasted instances. This will either
1520  // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1521  if( item->Type() == SCH_SHEET_T )
1522  {
1523  SCH_SHEET* sheet = (SCH_SHEET*) item;
1524  SCH_SHEET_PATH pastePath = pasteRoot;
1525  pastePath.push_back( sheet );
1526 
1527  updatePastedInstances( pastePath, clipPath, sheet, forceKeepAnnotations );
1528  }
1529 
1530  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1532 
1533  // Reset flags for subsequent move operation
1534  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVED );
1535  // Start out hidden so the pasted items aren't "ghosted" in their original location
1536  // before being moved to the current location.
1537  getView()->Hide( item, true );
1538  }
1539 
1540  if( sheetsPasted )
1541  {
1544  }
1545 
1546  // Now clear the previous selection, select the pasted items, and fire up the "move"
1547  // tool.
1548  //
1550  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1551 
1552  EE_SELECTION& selection = selTool->GetSelection();
1553 
1554  if( !selection.Empty() )
1555  {
1556  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1557 
1558  selection.SetReferencePoint( item->GetPosition() );
1560  }
1561 
1562  return 0;
1563 }
1564 
1565 
1567 {
1570  SCH_SHEET_PATH& currentSheet = m_frame->GetCurrentSheet();
1571  SCH_COMPONENT* sym = nullptr;
1572  SYMBOL_EDIT_FRAME* symbolEditor;
1573 
1574  if( selection.GetSize() >= 1 )
1575  sym = (SCH_COMPONENT*) selection.Front();
1576 
1577  if( !sym || sym->GetEditFlags() != 0 )
1578  return 0;
1579 
1581  symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1582 
1583  if( symbolEditor )
1584  {
1585  symbolEditor->LoadSymbolFromSchematic( sym->GetPartRef(), sym->GetRef( &currentSheet ),
1586  sym->GetUnit(), sym->GetConvert() );
1587  }
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:240
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:1480
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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:51
void OnOpenCvpcb(wxCommandEvent &event)
void Save_File(bool doSaveAs=false)
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:43
const wxString & GetFileName() const
Definition: sch_screen.h:186
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:61
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:158
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:208
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:66
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:151
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:97
void SetMotionHandler(MOTION_HANDLER aHandler)
Function SetMotionHandler() Sets a handler for mouse motion.
Definition: picker_tool.h:83
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanComponents=false) const
Add a SCH_REFERENCE object to aReferences for each component in the list of sheets.
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:44
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:209
const wxString & GetNetclassName(const wxString &aNetName) const
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:137
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
This file is part of the common library.
void ReversePickersListOrder()
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...
Definition: eda_item.cpp:159
int FindRefByPath(const wxString &aPath) const
searches the list for a symbol with the given KIID path
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:73
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 SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:66
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:151
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:1417
void SetWksFileName(const wxString &aFilename)
void SetBrightened()
Definition: eda_item.h:197
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:159
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:141
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:93
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:481
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
EDA_LIST_DIALOG.
virtual int GetRedoCommandCount() const
bool IsBrightened() const
Definition: eda_item.h:193
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:161
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:217
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.
void OnPageSettingsChange() override
Called when modifying the page settings.
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: eda_item.h:325
int Annotate(const TOOL_EVENT &aEvent)
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:234
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()
Update all the symbol references for this sheet path.
static TOOL_ACTION find
Definition: actions.h:79
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:284
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:217
A subgraph is a set of items that are electrically connected on a single sheet.
SCH_SHEET_PATH * FindSheetForScreen(SCH_SCREEN *aScreen)
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) using a particular...
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:462
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
static const TOOL_EVENT SelectedItemsModified
Definition: actions.h:213
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:184
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:196
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
int ToggleForceHV(const TOOL_EVENT &aEvent)
Field Value of part, i.e. "3.3K".
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: eda_item.h:200
static TOOL_ACTION pickerTool
Definition: actions.h:153
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
void SetFinalizeHandler(FINALIZE_HANDLER aHandler)
Function SetFinalizeHandler() Sets a handler for the finalize event.
Definition: picker_tool.h:103
EE_SELECTION & GetSelection()
Function GetSelection()
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:84
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:270
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:104
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: kiid.h:44
static TOOL_ACTION copy
Definition: actions.h:70
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:262
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int GetUnit() const
void BrightenItem(EDA_ITEM *aItem)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:218
static TOOL_ACTION showBusManager
Definition: ee_actions.h:153
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:162
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:101
NETCLASSES m_NetClasses
Definition: net_settings.h:39
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:220
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:345
int LeaveSheet(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:212
int Print(const TOOL_EVENT &aEvent)
void HardRedraw() override
Rebuild the GAL and redraw the screen.
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:225
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)
std::string GetClipboardUTF8() const
Returns the information currently stored in the system clipboard.
int ShowQuasiModal()
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:143
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:198
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: eda_item.h:272
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)
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: eda_item.h:183
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:181
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:210
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:1394
const std::string & GetString()
Definition: richio.h:476
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
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:85
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:576
void SetUnit(int aUnit)
Change the unit number to aUnit.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
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:498
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)
#define IS_MOVED
Item being moved.
Definition: eda_item.h:105
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)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
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:219
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: eda_item.h:151
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:99
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:364
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
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
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: eda_item.h:119
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
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:301
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.
static TOOL_ACTION redo
Definition: actions.h:68
int PageSetup(const TOOL_EVENT &aEvent)
void ClearFindReplaceStatus()
bool SaveClipboard(const std::string &aTextUTF8)
Stores an information to the system clipboard.
bool IsNet() const
void SetHighlightedConnection(const SCH_CONNECTION *aConnection)
SCH_SHEET & Root() const
Definition: schematic.h:102
int Quit(const TOOL_EVENT &aEvent)
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
int AddItemToSel(const TOOL_EVENT &aEvent)
SCH_SCREEN * LastScreen()
static TOOL_ACTION showSymbolEditor
Definition: actions.h:158
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
static TOOL_ACTION saveAs
Definition: actions.h:55
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:129
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() This overload of SelectPoint will create an EE_COLLECTOR and collect hits at l...
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:194
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:152
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: kiid.cpp:206
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41
EE_RTREE & Items()
Definition: sch_screen.h:159
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 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:79
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:85
#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: eda_item.h:148
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:205
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:216
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:211
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
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:215
#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:154
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:113
VIEW.
Definition: view.h:63
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:132
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath)
Clear exiting component annotation.
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:204
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:255
Field Reference of part, i.e. "IC21".
int UpdateFromPCB(const TOOL_EVENT &aEvent)
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:446
bool m_RealTimeConnectivity
Do real-time connectivity.
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: eda_item.h:446
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...
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
static TOOL_ACTION paste
Definition: actions.h:71
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
SCH_REFERENCE is used as a helper to define a symbol's reference designator in a schematic.
PRIORITY GetDriverPriority()
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:521
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
wxString GetName() const
Definition: sch_pin.cpp:79
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:201
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1513
int ExportNetlist(const TOOL_EVENT &aEvent)
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
void SetListLabel(const wxString &aLabel)
The symbol library editor main window.
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:195