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