KiCad PCB EDA Suite
sch_edit_frame.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) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
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 <base_units.h>
26 #include <bitmaps.h>
27 #include <symbol_library.h>
28 #include <confirm.h>
29 #include <connection_graph.h>
31 #include <eeschema_id.h>
32 #include <executable_names.h>
33 #include <gestfich.h>
34 #include <hierarch.h>
36 #include <ignore.h>
37 #include <invoke_sch_dialog.h>
38 #include <string_utils.h>
39 #include <kiface_base.h>
40 #include <kiplatform/app.h>
41 #include <kiway.h>
42 #include <symbol_edit_frame.h>
43 #include <symbol_viewer_frame.h>
44 #include <pgm_base.h>
45 #include <profile.h>
46 #include <project.h>
47 #include <project/project_file.h>
48 #include <project/net_settings.h>
49 #include <python_scripting.h>
50 #include <sch_edit_frame.h>
51 #include <sch_painter.h>
52 #include <sch_sheet.h>
53 #include <sch_marker.h>
54 #include <schematic.h>
56 #include <advanced_config.h>
57 #include <sim/sim_plot_frame.h>
58 #include <sim/spice_settings.h>
59 #include <tool/action_manager.h>
60 #include <tool/action_toolbar.h>
61 #include <tool/common_control.h>
62 #include <tool/common_tools.h>
63 #include <tool/editor_conditions.h>
64 #include <tool/picker_tool.h>
65 #include <tool/selection.h>
66 #include <tool/tool_dispatcher.h>
67 #include <tool/tool_manager.h>
68 #include <tool/zoom_tool.h>
69 #include <tools/ee_actions.h>
71 #include <tools/ee_point_editor.h>
74 #include <tools/sch_edit_tool.h>
77 #include <tools/sch_move_tool.h>
79 #include <view/view_controls.h>
80 #include <widgets/infobar.h>
82 #include <wx/cmdline.h>
83 #include <wx/app.h>
84 #include <wx/filedlg.h>
85 #include <wx/socket.h>
86 
89 
90 // non-member so it can be moved easily, and kept REALLY private.
91 // Do NOT Clear() in here.
92 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
93 {
94  for( unsigned i=0; i<aSrc.GetCount(); ++i )
95  aDst->AddPaths( aSrc[i], aIndex );
96 }
97 
98 
99 SEARCH_STACK* PROJECT::SchSearchS()
100 {
102 
103  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
104 
105  if( !ss )
106  {
107  ss = new SEARCH_STACK();
108 
109  // Make PROJECT the new SEARCH_STACK owner.
111 
112  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
113  ss->AddPaths( m_project_name.GetPath() );
114 
115  // next add the paths found in *.pro, variable "LibDir"
116  wxString libDir;
117 
118  try
119  {
120  SYMBOL_LIBS::LibNamesAndPaths( this, false, &libDir );
121  }
122  catch( const IO_ERROR& )
123  {
124  }
125 
126  if( !!libDir )
127  {
128  wxArrayString paths;
129 
130  SEARCH_STACK::Split( &paths, libDir );
131 
132  for( unsigned i =0; i<paths.GetCount(); ++i )
133  {
134  wxString path = AbsolutePath( paths[i] );
135 
136  ss->AddPaths( path ); // at the end
137  }
138  }
139 
140  // append all paths from aSList
141  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
142  }
143 
144  return ss;
145 }
146 
147 
148 SYMBOL_LIBS* PROJECT::SchLibs()
149 {
151 
152  wxASSERT( !libs || libs->Type() == SYMBOL_LIBS_T );
153 
154  if( !libs )
155  {
156  libs = new SYMBOL_LIBS();
157 
158  // Make PROJECT the new SYMBOL_LIBS owner.
160 
161  try
162  {
163  libs->LoadAllLibraries( this );
164  }
165  catch( const PARSE_ERROR& pe )
166  {
167  wxString lib_list = UTF8( pe.inputLine );
168  wxWindow* parent = Pgm().App().GetTopWindow();
169 
170  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
171  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
172 
173  dlg.MessageSet( _( "The following libraries were not found:" ) );
174 
175  dlg.ListSet( lib_list );
176 
177  dlg.Layout();
178 
179  dlg.ShowModal();
180  }
181  catch( const IO_ERROR& ioe )
182  {
183  wxWindow* parent = Pgm().App().GetTopWindow();
184 
185  DisplayError( parent, ioe.What() );
186  }
187  }
188 
189  return libs;
190 }
191 
192 
193 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
196 
197  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
198 
201 
204 
205  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
206  EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
207 
209 END_EVENT_TABLE()
210 
211 
212 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
213  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
215  m_highlightedConn( nullptr ),
216  m_item_to_repeat( nullptr )
217 {
218  m_maximizeByDefault = true;
219  m_schematic = new SCHEMATIC( nullptr );
220 
221  m_showBorderAndTitleBlock = true; // true to show sheet references
222  m_hasAutoSave = true;
223  m_aboutTitle = _( "KiCad Schematic Editor" );
224 
225  m_findReplaceDialog = nullptr;
226 
227  // Give an icon
228  wxIcon icon;
229  wxIconBundle icon_bundle;
230 
231  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema ) );
232  icon_bundle.AddIcon( icon );
233  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
234  icon_bundle.AddIcon( icon );
235  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
236  icon_bundle.AddIcon( icon );
237 
238  SetIcons( icon_bundle );
239 
240  LoadSettings( eeconfig() );
241 
242  // NB: also links the schematic to the loaded project
243  CreateScreens();
244 
245  setupTools();
246  setupUIConditions();
247  ReCreateMenuBar();
248  ReCreateHToolbar();
249  ReCreateVToolbar();
250  ReCreateOptToolbar();
251 
252  // Initialize common print setup dialog settings.
253  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
254  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
255  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
256  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
257 
258  m_auimgr.SetManagedWindow( this );
259 
260  CreateInfoBar();
261  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
262  .Top().Layer( 6 ) );
263  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
264  .Left().Layer( 3 ) );
265  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
266  .Right().Layer( 2 ) );
267  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
268  .Center() );
269  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
270  .Bottom().Layer( 6 ) );
271 
272  FinishAUIInitialization();
273 
274  resolveCanvasType();
275  SwitchCanvas( m_canvasType );
276 
277  LoadProjectSettings();
278 
279  initScreenZoom();
280 
281  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
282  // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
283  Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
284 
285  if( GetCanvas() )
286  {
287  GetCanvas()->GetGAL()->SetAxesEnabled( false );
288 
289  if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
290  p->SetSchematic( m_schematic );
291  }
292 
293  setupUnits( eeconfig() );
294 
295  // Net list generator
296  DefaultExecFlags();
297 
298  UpdateTitle();
299 
300  // Default shutdown reason until a file is loaded
301  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
302 
303  // Ensure the window is on top
304  Raise();
305 }
306 
307 
309 {
310  // Ensure m_canvasType is up to date, to save it in config
312 
313  // Shutdown all running tools
314  if( m_toolManager )
315  {
317  delete m_toolManager;
318  m_toolManager = nullptr;
319  }
320 
321  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
322 
323  SetScreen( nullptr );
324 
325  delete m_schematic;
326  m_schematic = nullptr;
327 
328  // Close the project if we are standalone, so it gets cleaned up properly
329  if( Kiface().IsSingle() )
330  GetSettingsManager()->UnloadProject( &Prj(), false );
331 }
332 
333 
335 {
336  // Create the manager and dispatcher & route draw panel events to the dispatcher
338  m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
339  GetCanvas()->GetViewControls(), config(), this );
340  m_actions = new EE_ACTIONS();
342 
343  // Register tools
358 
359  // Run the selection tool, it is supposed to be always active
361 
363 }
364 
365 
367 {
369 
371  EDITOR_CONDITIONS cond( this );
372 
373  wxASSERT( mgr );
374 
375  auto hasElements =
376  [ this ] ( const SELECTION& aSel )
377  {
378  return GetScreen() &&
379  ( !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel ) );
380  };
381 
382 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
383 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
384 
386  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
387  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
388 
392  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
395 
396  mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
397  mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
400  mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
401  mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
402  mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
403 
404  mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
405  mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
406  mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
407  mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
408 
410  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
413 
414  if( SCRIPTING::IsWxAvailable() )
416  CHECK( cond.ScriptingConsoleVisible() ) );
417 
418  auto showHiddenPinsCond =
419  [this] ( const SELECTION& )
420  {
421  return GetShowAllPins();
422  };
423 
424  auto forceHVCond =
425  [this] ( const SELECTION& )
426  {
427  EESCHEMA_SETTINGS* cfg = eeconfig();
428  return cfg && cfg->m_Drawing.hv_lines_only;
429  };
430 
431  auto remapSymbolsCondition =
432  [&]( const SELECTION& aSel )
433  {
434  SCH_SCREENS schematic( Schematic().Root() );
435 
436  // The remapping can only be performed on legacy projects.
437  return schematic.HasNoFullyDefinedLibIds();
438  };
439 
440  auto belowRootSheetCondition =
441  [this]( const SELECTION& aSel )
442  {
443  return GetCurrentSheet().Last() != &Schematic().Root();
444  };
445 
446  mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) );
447  mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) );
448  mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) );
449  mgr->SetConditions( EE_ACTIONS::toggleForceHV, CHECK( forceHVCond ) );
450 
451 
452 #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
453 
471 
472 #undef CURRENT_TOOL
473 #undef CHECK
474 #undef ENABLE
475 }
476 
477 
479 {
480  // we cannot store a pointer to an item in the display list here since
481  // that item may be deleted, such as part of a line concatenation or other.
482  // So simply always keep a copy of the object which is to be repeated.
483 
484  if( aItem )
485  {
486  delete m_item_to_repeat;
487 
488  m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
489 
490  // Clone() preserves the flags, we want 'em cleared.
492  }
493 }
494 
495 
497 {
498  return Schematic().GetSheets().GetItem( aId );
499 }
500 
501 
503 {
504  SCH_SCREEN* screen;
505  SCH_SCREENS s_list( Schematic().Root() );
506 
507  // Set the sheet count, and the sheet number (1 for root sheet)
508  int sheet_count = Schematic().Root().CountSheets();
509  int sheet_number = 1;
510  const KIID_PATH& current_sheetpath = GetCurrentSheet().Path();
511 
512  // @todo Remove all pseudo page number system is left over from prior to real page number
513  // implementation.
514  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
515  {
516  if( sheet.Path() == current_sheetpath ) // Current sheet path found
517  break;
518 
519  sheet_number++; // Not found, increment before this current path
520  }
521 
522  for( screen = s_list.GetFirst(); screen != nullptr; screen = s_list.GetNext() )
523  screen->SetPageCount( sheet_count );
524 
525  GetCurrentSheet().SetVirtualPageNumber( sheet_number );
526  GetScreen()->SetVirtualPageNumber( sheet_number );
527  GetScreen()->SetPageNumber( GetCurrentSheet().GetPageNumber() );
528 }
529 
530 
532 {
533  return GetCurrentSheet().LastScreen();
534 }
535 
536 
538 {
539  return *m_schematic;
540 }
541 
542 
544 {
545  wxString s = GetCurrentSheet().PathHumanReadable();
546 
547  return s;
548 }
549 
550 
552 {
553  m_schematic->Reset();
554  m_schematic->SetProject( &Prj() );
555 
557 
558  SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
559  m_schematic->Root().SetScreen( rootScreen );
560  SetScreen( Schematic().RootScreen() );
561 
562  m_schematic->RootScreen()->SetFileName( wxEmptyString );
563 
564  // Don't leave root page number empty
565  SCH_SHEET_PATH rootSheetPath;
566  rootSheetPath.push_back( &m_schematic->Root() );
567  m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
568  m_schematic->Root().AddInstance( rootSheetPath.Path() );
569  m_schematic->Root().SetPageNumber( rootSheetPath, wxT( "1" ) );
570 
571  if( GetScreen() == nullptr )
572  {
573  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
574  SetScreen( screen );
575  }
576 }
577 
578 
580 {
581  return m_schematic->CurrentSheet();
582 }
583 
584 
586 {
587  if( aSheet != GetCurrentSheet() )
588  {
589  FocusOnItem( nullptr );
590 
591  Schematic().SetCurrentSheet( aSheet );
592  GetCanvas()->DisplaySheet( aSheet.LastScreen() );
593  }
594 }
595 
596 
598 {
600 
601  FocusOnItem( nullptr );
602 
603  GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
604  GetCanvas()->ForceRefresh();
605 }
606 
607 
608 bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
609 {
610  // Exit interactive editing
611  // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
612  // will cancel any drag currently in progress, but commit all changes from previous drags.
613  if( m_toolManager )
615 
616  // Shutdown blocks must be determined and vetoed as early as possible
617  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
618  && Schematic().GetSheets().IsModified() )
619  {
620  return false;
621  }
622 
623  if( Kiface().IsSingle() )
624  {
625  auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
626 
627  if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
628  return false;
629 
630  auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
631 
632  if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
633  return false;
634 
635  symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
636 
637  if( symbolViewer && !symbolViewer->Close() ) // Can close modal symbol viewer?
638  return false;
639  }
640 
641  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
642 
643  if( simFrame && !simFrame->Close() ) // Can close the simulator?
644  return false;
645 
646  // We may have gotten multiple events; don't clean up twice
647  if( !Schematic().IsValid() )
648  return false;
649 
650  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
651 
652  if( sheetlist.IsModified() )
653  {
654  wxFileName fileName = Schematic().RootScreen()->GetFileName();
655  wxString msg = _( "Save changes to '%s' before closing?" );
656 
657  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
658  [&]() -> bool
659  {
660  return SaveProject();
661  } ) )
662  {
663  return false;
664  }
665  }
666 
667  return true;
668 }
669 
670 
672 {
673  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
674 
675  // Shutdown all running tools
676  if( m_toolManager )
678 
680 
681  // Close the find dialog and preserve its setting if it is displayed.
682  if( m_findReplaceDialog )
683  {
686 
687  m_findReplaceDialog->Destroy();
688  m_findReplaceDialog = nullptr;
689  }
690 
691  if( FindHierarchyNavigator() )
692  FindHierarchyNavigator()->Close( true );
693 
694  if( Kiway().Player( FRAME_SIMULATOR, false ) )
696 
697  SCH_SCREENS screens( Schematic().Root() );
698  wxFileName fn;
699 
700  for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
701  {
702  fn = Prj().AbsolutePath( screen->GetFileName() );
703 
704  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
705  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
706 
707  if( fn.IsFileWritable() )
708  wxRemoveFile( fn.GetFullPath() );
709  }
710 
711  wxFileName tmpFn = Prj().GetProjectFullName();
712  wxFileName autoSaveFileName( tmpFn.GetPath(), getAutoSaveFileName() );
713 
714  if( autoSaveFileName.IsFileWritable() )
715  wxRemoveFile( autoSaveFileName.GetFullPath() );
716 
717  sheetlist.ClearModifyStatus();
718 
719  wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
720 
721  if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
722  UpdateFileHistory( fileName );
723 
724  Schematic().RootScreen()->Clear();
725 
726  // all sub sheets are deleted, only the main sheet is usable
728 
729  // Clear view before destroying schematic as repaints depend on schematic being valid
730  SetScreen( nullptr );
731 
732  Schematic().Reset();
733 
734  Destroy();
735 }
736 
737 
739 {
740  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
741  ERC_SETTINGS& ercSettings = Schematic().ErcSettings();
742 
743  ercSettings.m_ErcExclusions.clear();
744 
745  for( unsigned i = 0; i < sheetList.size(); i++ )
746  {
747  for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
748  {
749  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
750 
751  if( marker->IsExcluded() )
752  ercSettings.m_ErcExclusions.insert( marker->Serialize() );
753  }
754  }
755 }
756 
757 
759 {
760  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
761 
762  for( SCH_MARKER* marker : Schematic().ResolveERCExclusions() )
763  {
764  SCH_SHEET_PATH errorPath;
765  ignore_unused( sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath ) );
766 
767  if( errorPath.LastScreen() )
768  errorPath.LastScreen()->Append( marker );
769  else
770  Schematic().RootScreen()->Append( marker );
771  }
772 }
773 
774 
776 {
777  // Filename is rootSheetName-sheetName-...-sheetName
778  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
779  // name is just a timestamp.
780 
781  wxFileName rootFn( GetCurrentSheet().at( 0 )->GetFileName() );
782  wxString filename = rootFn.GetName();
783 
784  for( unsigned i = 1; i < GetCurrentSheet().size(); i++ )
785  filename += wxT( "-" ) + GetCurrentSheet().at( i )->GetName();
786 
787  return filename;
788 }
789 
790 
792 {
793  wxASSERT( GetScreen() );
794 
795  if( !GetScreen() )
796  return;
797 
799 
800  if( ADVANCED_CFG::GetCfg().m_RealTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
802 
803  GetCanvas()->Refresh();
805 
806  if( !GetTitle().StartsWith( "*" ) )
807  UpdateTitle();
808 }
809 
810 
811 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
812 {
813  if( Kiface().IsSingle() )
814  {
815  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
816  " in stand-alone mode. In order to create/update PCBs from"
817  " schematics, launch the KiCad shell and create a project." ) );
818  return;
819  }
820 
821  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
822 
823  if( !frame )
824  {
825  wxFileName fn = Prj().GetProjectFullName();
826  fn.SetExt( PcbFileExtension );
827 
828  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
829  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
830  }
831 
832  if( !frame->IsVisible() )
833  frame->Show( true );
834 
835  // On Windows, Raise() does not bring the window on screen, when iconized
836  if( frame->IsIconized() )
837  frame->Iconize( false );
838 
839  frame->Raise();
840 
841  std::string payload;
842  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
843 }
844 
845 
847 {
848  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
849 
850  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
851 }
852 
853 
855 {
856  if( aForceUpdate )
857  {
858  if( FindHierarchyNavigator() )
859  FindHierarchyNavigator()->Close();
860 
861  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
862 
863  hierarchyDialog->Show( true );
864  }
865  else
866  {
867  if( FindHierarchyNavigator() )
869  }
870 }
871 
872 
874 {
875  if( m_findReplaceDialog )
876  m_findReplaceDialog->Destroy();
877 
878  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
879  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
880 
883  m_findReplaceDialog->Show( true );
884 }
885 
886 
887 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
888 {
889  // Prepare the infobar, since we don't know its state
892 
893  m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
894 }
895 
896 
898 {
899  m_infoBar->Dismiss();
900 }
901 
902 
904 {
907 
908  m_findReplaceDialog->Destroy();
909  m_findReplaceDialog = nullptr;
910 
912 }
913 
914 
915 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
916 {
917  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
918 
919  if( fn.size() )
920  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
921 }
922 
923 
924 void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
925 {
927 }
928 
929 
931 {
932  wxString pro_dir = m_mruPath;
933 
934  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
935  KiCadSchematicFileWildcard(), wxFD_SAVE );
936 
937  if( dlg.ShowModal() != wxID_CANCEL )
938  {
939  // Enforce the extension, wxFileDialog is inept.
940  wxFileName create_me = dlg.GetPath();
941  create_me.SetExt( KiCadSchematicFileExtension );
942 
943  if( create_me.FileExists() )
944  {
945  wxString msg;
946  msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
947  DisplayError( this, msg );
948  return ;
949  }
950 
951  // OpenProjectFiles() requires absolute
952  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
953 
954  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
955  m_mruPath = create_me.GetPath();
956  }
957 }
958 
959 
961 {
962  wxString pro_dir = m_mruPath;
963  wxString wildcards = KiCadSchematicFileWildcard();
964 
965  wildcards += "|" + LegacySchematicFileWildcard();
966 
967  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
968  wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
969 
970  if( dlg.ShowModal() != wxID_CANCEL )
971  {
972  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
974  }
975 }
976 
977 
978 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
979 {
980  wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
981 
982  if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
983  {
984  kicad_board.SetExt( PcbFileExtension );
985  wxFileName legacy_board( kicad_board );
986  legacy_board.SetExt( LegacyPcbFileExtension );
987  wxFileName& boardfn = legacy_board;
988 
989  if( !legacy_board.FileExists() || kicad_board.FileExists() )
990  boardfn = kicad_board;
991 
992  if( Kiface().IsSingle() )
993  {
994  ExecuteFile( PCBNEW_EXE, boardfn.GetFullPath() );
995  }
996  else
997  {
998  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
999 
1000  if( !frame )
1001  {
1002  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1003  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1004  }
1005 
1006  if( !frame->IsVisible() )
1007  frame->Show( true );
1008 
1009  // On Windows, Raise() does not bring the window on screen, when iconized
1010  if( frame->IsIconized() )
1011  frame->Iconize( false );
1012 
1013  frame->Raise();
1014  }
1015  }
1016  else
1017  {
1018  // If we are running inside a project, it should be impossible for this case to happen
1019  wxASSERT( Kiface().IsSingle() );
1021  }
1022 }
1023 
1024 
1025 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1026 {
1027  wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1028  fn.SetExt( NetlistFileExtension );
1029 
1030  if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1031  return;
1032 
1033  try
1034  {
1035  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1036 
1037  if( !player )
1038  {
1039  player = Kiway().Player( FRAME_CVPCB, true );
1040  player->Show( true );
1041  }
1042 
1044 
1045  player->Raise();
1046  }
1047  catch( const IO_ERROR& )
1048  {
1049  DisplayError( this, _( "Could not open CvPcb" ) );
1050  }
1051 }
1052 
1053 
1054 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1055 {
1056  if( event.GetId() == wxID_EXIT )
1057  Kiway().OnKiCadExit();
1058 
1059  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1060  Close( false );
1061 }
1062 
1063 
1065 {
1066  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1067 
1068  const wxBrush& brush =
1069  wxBrush( GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ).ToColour() );
1070  aSettings->GetPrintDC()->SetBackground( brush );
1071  aSettings->GetPrintDC()->Clear();
1072 
1073  aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
1074  GetScreen()->Print( aSettings );
1075  PrintDrawingSheet( aSettings, GetScreen(), IU_PER_MILS, fileName );
1076 }
1077 
1078 
1080 {
1081  // In case this event happens before g_RootSheet is initialized which does happen
1082  // on mingw64 builds.
1083 
1084  if( Schematic().IsValid() )
1085  {
1086  return IsContentModified();
1087  }
1088 
1089  return false;
1090 }
1091 
1092 
1093 static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem )
1094 {
1095  // Netclasses are assigned to subgraphs by association with their netname. However, when
1096  // a new label is attached to an existing subgraph (with an existing netclass association),
1097  // the association will be lost as the label will drive its name on to the graph.
1098  //
1099  // Here we find the previous driver of the subgraph and if it had a netclass we associate
1100  // the new netname with that netclass as well.
1101  //
1102  SCHEMATIC* schematic = aItem->Schematic();
1103  CONNECTION_SUBGRAPH* subgraph = schematic->ConnectionGraph()->GetSubgraphForItem( aItem );
1104 
1105  std::map<wxString, wxString>& netclassAssignments =
1107 
1108  if( subgraph )
1109  {
1110  SCH_ITEM* previousDriver = nullptr;
1112 
1113  for( SCH_ITEM* item : subgraph->m_drivers )
1114  {
1115  if( item == aItem )
1116  continue;
1117 
1119 
1120  if( p > priority )
1121  {
1122  priority = p;
1123  previousDriver = item;
1124  }
1125  }
1126 
1127  if( previousDriver )
1128  {
1129  wxString path = aSheetPath.PathHumanReadable();
1130  wxString oldDrivenName = path + subgraph->GetNameForDriver( previousDriver );
1131  wxString drivenName = path + subgraph->GetNameForDriver( aItem );
1132 
1133  if( netclassAssignments.count( oldDrivenName ) )
1134  netclassAssignments[ drivenName ] = netclassAssignments[ oldDrivenName ];
1135  }
1136  }
1137 }
1138 
1139 
1141  bool aUndoAppend )
1142 {
1143  wxCHECK_RET( aItem != nullptr, wxT( "Cannot add null item to list." ) );
1144 
1145  SCH_SHEET* parentSheet = nullptr;
1146  SCH_SYMBOL* parentSymbol = nullptr;
1147  SCH_ITEM* undoItem = aItem;
1148 
1149  if( aItem->Type() == SCH_SHEET_PIN_T )
1150  {
1151  parentSheet = (SCH_SHEET*) aItem->GetParent();
1152 
1153  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1154  wxT( "Cannot place sheet pin in invalid schematic sheet." ) );
1155 
1156  undoItem = parentSheet;
1157  }
1158 
1159  else if( aItem->Type() == SCH_FIELD_T )
1160  {
1161  parentSymbol = (SCH_SYMBOL*) aItem->GetParent();
1162 
1163  wxCHECK_RET( parentSymbol && parentSymbol->Type() == SCH_SYMBOL_T,
1164  wxT( "Cannot place field in invalid schematic symbol." ) );
1165 
1166  undoItem = parentSymbol;
1167  }
1168 
1169  if( aItem->IsNew() )
1170  {
1171  if( aItem->Type() == SCH_SHEET_PIN_T )
1172  {
1173  // Sheet pins are owned by their parent sheet.
1174  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1175 
1176  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1177  }
1178  else if( aItem->Type() == SCH_FIELD_T )
1179  {
1180  // Symbol fields are also owned by their parent, but new symbol fields are
1181  // handled elsewhere.
1182  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1183  }
1184  else
1185  {
1186  if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1187  AddToScreen( aItem, aScreen );
1188 
1189  SaveCopyForRepeatItem( aItem );
1190  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1191  }
1192 
1193  // Update connectivity info for new item
1194  if( !aItem->IsMoving() )
1195  {
1197 
1198  if( SCH_TEXT* textItem = dynamic_cast<SCH_TEXT*>( aItem ) )
1199  inheritNetclass( GetCurrentSheet(), textItem );
1200  }
1201  }
1202 
1203  aItem->ClearFlags( IS_NEW );
1204 
1205  aScreen->SetContentModified();
1206  UpdateItem( aItem );
1207 
1208  if( !aItem->IsMoving() && aItem->IsConnectable() )
1209  {
1210  std::vector< wxPoint > pts = aItem->GetConnectionPoints();
1211 
1212  for( auto i = pts.begin(); i != pts.end(); i++ )
1213  {
1214  for( auto j = i + 1; j != pts.end(); j++ )
1215  TrimWire( *i, *j );
1216 
1217  if( aScreen->IsJunctionNeeded( *i, true ) )
1218  AddJunction( aScreen, *i, true, false );
1219  }
1220 
1221  TestDanglingEnds();
1222 
1223  for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1224  UpdateItem( item );
1225  }
1226 
1227  aItem->ClearEditFlags();
1228  GetCanvas()->Refresh();
1229 }
1230 
1231 
1233 {
1234  SCH_SCREEN* screen = GetScreen();
1235 
1236  wxCHECK( screen, /* void */ );
1237 
1238  wxString title;
1239 
1240  if( !screen->GetFileName().IsEmpty() )
1241  {
1242  wxFileName fn( Prj().AbsolutePath( screen->GetFileName() ) );
1243  bool readOnly = false;
1244  bool unsaved = false;
1245 
1246  if( fn.IsOk() && screen->FileExists() )
1247  readOnly = screen->IsReadOnly();
1248  else
1249  unsaved = true;
1250 
1251  if( IsContentModified() )
1252  title = wxT( "*" );
1253 
1254  title += fn.GetName();
1255  title += wxString::Format( wxT( " [%s]" ), GetCurrentSheet().PathHumanReadable( false ) );
1256 
1257  if( readOnly )
1258  title += wxS( " " ) + _( "[Read Only]" );
1259 
1260  if( unsaved )
1261  title += wxS( " " ) + _( "[Unsaved]" );
1262  }
1263  else
1264  {
1265  title = _( "[no schematic loaded]" );
1266  }
1267 
1268  title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1269 
1270  SetTitle( title );
1271 }
1272 
1273 
1275 {
1277  GetScreen()->m_zoomInitialized = true;
1278 }
1279 
1280 
1282 {
1283  const SCH_CONNECTION* highlight = GetHighlightedConnection();
1284  SCH_ITEM* highlightedItem = highlight ? highlight->Parent() : nullptr;
1285  SCH_SHEET_PATH highlightPath;
1286 
1287  if( highlight )
1288  highlightPath = highlight->Sheet();
1289 
1290  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1291  SCH_SHEET_LIST list = Schematic().GetSheets();
1292 #ifdef PROFILE
1293  PROF_COUNTER timer;
1294 #endif
1295 
1296  // Ensure schematic graph is accurate
1297  if( aCleanupFlags == LOCAL_CLEANUP )
1298  {
1300  }
1301  else if( aCleanupFlags == GLOBAL_CLEANUP )
1302  {
1303  for( const SCH_SHEET_PATH& sheet : list )
1304  SchematicCleanUp( sheet.LastScreen() );
1305  }
1306 
1307 #ifdef PROFILE
1308  timer.Stop();
1309  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1310 #endif
1311 
1312  if( settings.m_IntersheetRefsShow )
1314 
1315  std::function<void( SCH_ITEM* )> changeHandler =
1316  [&]( SCH_ITEM* aChangedItem ) -> void
1317  {
1318  GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1319  };
1320 
1321  Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1322 
1324  []( KIGFX::VIEW_ITEM* aItem )
1325  {
1326  SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1327  SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1328 
1329  if( connection && connection->HasDriverChanged() )
1330  {
1331  connection->ClearDriverChanged();
1332  return true;
1333  }
1334 
1335  EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1336 
1337  if( text && text->HasTextVars() )
1338  return true;
1339 
1340  return false;
1341  } );
1342 
1343  if( highlightedItem )
1344  SetHighlightedConnection( highlightedItem->Connection( &highlightPath ) );
1345 }
1346 
1347 
1349 {
1350  std::map<wxString, std::set<wxString>>& pageRefsMap = Schematic().GetPageRefsMap();
1351 
1352  pageRefsMap.clear();
1353 
1354  SCH_SCREENS screens( Schematic().Root() );
1355  std::vector<wxString> pageNumbers;
1356 
1357  /* Iterate over screens */
1358  for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1359  {
1360  pageNumbers.clear();
1361 
1362  /* Find in which sheets this screen is used */
1363  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
1364  {
1365  if( sheet.LastScreen() == screen )
1366  pageNumbers.push_back( sheet.GetPageNumber() );
1367  }
1368 
1369  for( SCH_ITEM* item : screen->Items() )
1370  {
1371  if( item->Type() == SCH_GLOBAL_LABEL_T )
1372  {
1373  SCH_GLOBALLABEL* globalLabel = static_cast<SCH_GLOBALLABEL*>( item );
1374  std::set<wxString>& pageList = pageRefsMap[ globalLabel->GetText() ];
1375 
1376  for( const wxString& pageNo : pageNumbers )
1377  pageList.insert( pageNo );
1378  }
1379  }
1380  }
1381 
1382  bool show = Schematic().Settings().m_IntersheetRefsShow;
1383 
1384  // Refresh all global labels. Note that we have to collect them first as the
1385  // SCH_SCREEN::Update() call is going to invalidate the RTree iterator.
1386 
1387  std::vector<SCH_GLOBALLABEL*> globalLabels;
1388 
1389  for( EDA_ITEM* item : GetScreen()->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1390  globalLabels.push_back( static_cast<SCH_GLOBALLABEL*>( item ) );
1391 
1392  for( SCH_GLOBALLABEL* globalLabel : globalLabels )
1393  {
1394  globalLabel->GetIntersheetRefs()->SetVisible( show );
1395 
1396  if( show )
1397  {
1398  GetScreen()->Update( globalLabel );
1399  GetCanvas()->GetView()->Update( globalLabel );
1400  }
1401  }
1402 }
1403 
1404 
1406 {
1407  if( aShow )
1409 
1410  SCH_SCREENS screens( Schematic().Root() );
1411 
1412  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
1413  {
1414  for( SCH_ITEM* item : screen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1415  {
1416  SCH_GLOBALLABEL* gLabel = (SCH_GLOBALLABEL*)( item );
1417  SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs();
1418 
1419  intersheetRef->SetVisible( aShow );
1420  UpdateItem( intersheetRef, true );
1421  }
1422  }
1423 }
1424 
1425 
1426 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1427 {
1428  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1429  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1430 
1432 
1433  RecreateToolbars();
1434  Layout();
1435  SendSizeEvent();
1436 }
1437 
1438 
1440 {
1441  // Store the current zoom level into the current screen before calling
1442  // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
1444  // Rebuild the sheet view (draw area and any other items):
1446 }
1447 
1448 
1450 {
1451  // call my base class
1453 
1454  // tooltips in toolbars
1455  RecreateToolbars();
1456 
1457  // status bar
1458  UpdateMsgPanel();
1459 
1460  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1461  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1462  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1463  // toolbar to update correctly.
1464 #if defined( __WXMSW__ )
1465  PostSizeEvent();
1466 #endif
1467 }
1468 
1469 
1471 {
1472  if( const SCH_CONNECTION* conn = GetHighlightedConnection() )
1473  {
1474  SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1475  UnescapeString( conn->Name() ) ) );
1476  }
1477  else
1478  {
1479  SetStatusText( wxT( "" ) );
1480  }
1481 }
1482 
1483 
1485 {
1486  if( m_toolManager )
1488 
1489  SCH_BASE_FRAME::SetScreen( aScreen );
1490  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1491 }
1492 
1493 
1494 const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1495 {
1496  BOX2I bBoxDoc;
1497 
1498  if( aIncludeAllVisible )
1499  {
1500  // Get the whole page size and return that
1501  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1502  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1503  bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
1504  }
1505  else
1506  {
1507  // Get current drawing-sheet in a form we can compare to an EDA_ITEM
1509  EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
1510 
1511  // Need an EDA_RECT so the first ".Merge" sees it's uninitialized
1512  EDA_RECT bBoxItems;
1513 
1514  // Calc the bounding box of all items on screen except the page border
1515  for( EDA_ITEM* item : GetScreen()->Items() )
1516  {
1517  if( item != dsAsItem ) // Ignore the drawing-sheet itself
1518  bBoxItems.Merge( item->GetBoundingBox() );
1519 
1520  bBoxDoc = bBoxItems;
1521  }
1522  }
1523  return bBoxDoc;
1524 }
1525 
1526 
1528 {
1529  // Save the current sheet, to retrieve it later
1530  SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1531 
1532  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1533 
1534  for( const SCH_SHEET_PATH& sheet : sheetList )
1535  {
1536  size_t num_undos = m_undoList.m_CommandsList.size();
1537 
1538  // We require a set here to avoid adding multiple junctions to the same spot
1539  std::set<wxPoint> junctions;
1540 
1541  SetCurrentSheet( sheet );
1543 
1544  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
1545 
1546  EE_SELECTION allItems;
1547 
1548  for( auto item : screen->Items() )
1549  allItems.Add( item );
1550 
1552 
1553  // Check if we modified anything during this routine
1554  // Needs to happen for every sheet to set the proper modified flag
1555  if( m_undoList.m_CommandsList.size() > num_undos )
1556  OnModify();
1557  }
1558 
1559  // Reselect the initial sheet:
1560  SetCurrentSheet( oldsheetpath );
1562  SetScreen( GetCurrentSheet().LastScreen() );
1563 }
1564 
1565 
1567 {
1568  return Schematic().GetSheets().IsModified();
1569 }
1570 
1571 
1573 {
1574  EESCHEMA_SETTINGS* cfg = eeconfig();
1575  return cfg && cfg->m_Appearance.show_hidden_pins;
1576 }
1577 
1578 
1580 {
1581  static KIID lastBrightenedItemID( niluuid );
1582 
1583  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1585  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1586 
1587  if( lastItem && lastItem != aItem )
1588  {
1589  lastItem->ClearBrightened();
1590 
1591  UpdateItem( lastItem );
1592  lastBrightenedItemID = niluuid;
1593  }
1594 
1595  if( aItem )
1596  {
1597  aItem->SetBrightened();
1598 
1599  UpdateItem( aItem );
1600  lastBrightenedItemID = aItem->m_Uuid;
1601 
1602  FocusOnLocation( aItem->GetFocusPosition() );
1603  }
1604 }
1605 
1606 
1608 {
1609  return Schematic().GetFileName();
1610 }
1611 
1612 
1614 {
1615  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1616 }
1617 
1618 
1619 void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1620 {
1621  if( IsShown() )
1622  {
1623  // We only need this until the frame is done resizing and the final client size is
1624  // established.
1625  Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
1627  }
1628 
1629  // Skip() is called in the base class.
1630  EDA_DRAW_FRAME::OnSize( aEvent );
1631 }
1632 
1633 
1635 {
1636  wxString msg;
1637  bool appendToUndo = false;
1638 
1639  wxCHECK( m_toolManager, /* void */ );
1640 
1642 
1643  wxCHECK( selectionTool, /* void */ );
1644 
1645  EE_SELECTION& selection = selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
1646 
1647  if( selection.Empty() )
1648  return;
1649 
1650  SCH_SCREEN* currentScreen = GetScreen();
1651 
1652  wxCHECK( currentScreen, /* void */ );
1653 
1654  // This should work for multiple selections of the same symbol even though the editor
1655  // only works for a single symbol selection.
1656  for( EDA_ITEM* item : selection )
1657  {
1658  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
1659 
1660  wxCHECK( symbol, /* void */ );
1661 
1662  // This needs to be done before the LIB_SYMBOL is changed to prevent stale library
1663  // symbols in the schematic file.
1664  currentScreen->Remove( symbol );
1665 
1666  if( !symbol->IsNew() )
1667  {
1668  SaveCopyInUndoList( currentScreen, symbol, UNDO_REDO::CHANGED, appendToUndo );
1669  appendToUndo = true;
1670  }
1671 
1672  symbol->SetLibSymbol( aSymbol.Flatten().release() );
1673  symbol->UpdateFields( &GetCurrentSheet(),
1674  true, /* update style */
1675  true, /* update ref */
1676  true, /* update other fields */
1677  false, /* reset ref */
1678  false /* reset other fields */ );
1679 
1680  currentScreen->Append( symbol );
1681  selectionTool->SelectHighlightItem( symbol );
1682  GetCanvas()->GetView()->Update( symbol );
1683  }
1684 
1685  if( selection.IsHover() )
1687 
1688  GetCanvas()->Refresh();
1689  OnModify();
1690 }
void ShutdownAllTools()
Shutdown all tools with a currently registered event loop in this tool manager by waking them up with...
const std::string NetlistFileExtension
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
bool ReadyToNetlist(const wxString &aAnnotateMessage)
Check if we are ready to write a netlist file for the current schematic.
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
Definition: sch_symbol.cpp:757
void Stop()
Save the time when this function was called, and set the counter stane to stop.
Definition: profile.h:85
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
bool empty() const
Definition: sch_rtree.h:163
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
const wxString & getAutoSaveFileName() const
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Open a project or set of files given by aFileList.
Definition: kiway_player.h:118
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)
void onSize(wxSizeEvent &aEvent)
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:44
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:239
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
SCHEMATIC * m_schematic
The currently loaded schematic.
const wxString & GetFileName() const
Definition: sch_screen.h:145
KiCad executable names.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
wxString LegacySchematicFileWildcard()
bool Remove(SCH_ITEM *aItem)
Remove aItem from the schematic associated with this screen.
Definition: sch_screen.cpp:273
SCH_SCREEN * GetNext()
void OnKiCadExit()
Definition: kiway.cpp:626
void UpdateNetHighlightStatus()
virtual bool IsConnectable() const
Definition: sch_item.h:347
HIERARCHY_NAVIG_DLG * FindHierarchyNavigator()
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void ForceRefresh()
Force a redraw.
KIID niluuid(0)
void OnLoadFile(wxCommandEvent &event)
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
wxString m_mruPath
void SetPageNumber(const wxString &aPageNumber)
Definition: base_screen.h:79
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1434
void SetVirtualPageNumber(int aPageNumber)
Definition: base_screen.h:76
wxArrayString GetFindEntries() const
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:362
SETTINGS_MANAGER * GetSettingsManager() const
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Holds all the data relating to one schematic.
Definition: schematic.h:59
#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.
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
static TOOL_ACTION doDelete
Definition: actions.h:72
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.).
static void add_search_paths(SEARCH_STACK *aDst, const SEARCH_STACK &aSrc, int aIndex)
bool IsModified() const
Check the entire hierarchy for any modifications.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
double msecs(bool aSinceLast=false)
Definition: profile.h:146
const wxString PCBNEW_EXE
Definition: id.h:87
const std::string LegacyPcbFileExtension
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void SetScreen(BASE_SCREEN *aScreen) override
const SCH_CONNECTION * GetHighlightedConnection() const
virtual void SetScreen(BASE_SCREEN *aScreen)
UNDO_REDO_CONTAINER m_undoList
static TOOL_ACTION zoomTool
Definition: actions.h:99
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
bool IsReadOnly() const
Definition: sch_screen.h:148
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
#define KICTL_CREATE
caller thinks requested project files may not exist.
Definition: kiway_player.h:82
Handle actions specific to the schematic editor.
bool IsMoving() const
Definition: eda_item.h:120
static void LibNamesAndPaths(PROJECT *aProject, bool doSave, wxString *aPaths, wxArrayString *aNames=nullptr)
Save or load the names of the currently configured symbol libraries (without paths).
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:167
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:87
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:487
static TOOL_ACTION placeJunction
Definition: ee_actions.h:83
virtual const wxPoint GetFocusPosition() const
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
Definition: eda_item.h:259
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:156
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
bool IsValid() const
A simple test if the schematic is loaded, not a complete one.
Definition: schematic.h:108
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
wxString KiCadSchematicFileWildcard()
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
void SetBrightened()
Definition: eda_item.h:130
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:158
void ResolveERCExclusions()
Update markers to match recorded exclusions.
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
static TOOL_ACTION millimetersUnits
Definition: actions.h:146
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
wxArrayString m_findStringHistoryList
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
void OnAppendProject(wxCommandEvent &event)
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
NET_SETTINGS & NetSettings()
Definition: project_file.h:94
Symbol library viewer main window.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:383
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:477
SCH_CLEANUP_FLAGS
Schematic editor (Eeschema) main window.
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr)
Updates the connection graph for the given list of sheets.
Look for files in a number of paths.
Definition: search_stack.h:41
static TOOL_ACTION placeBusWireEntry
Definition: ee_actions.h:84
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
void OnPageSettingsChange() override
Called when modifying the page settings.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:128
Manage TOOL_ACTION objects.
virtual _ELEM * GetElem(ELEM_T aIndex)
Get and set the elements for this project.
Definition: project.cpp:246
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:285
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:76
static TOOL_ACTION mirrorH
Definition: ee_actions.h:119
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
The base class for create windows for drawing purpose.
void OnFindDialogClose()
Notification that the Find dialog has closed.
bool HasDriverChanged() const
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
Define a library symbol object.
Definition: lib_symbol.h:96
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
A small class to help profiling.
Definition: profile.h:45
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:132
std::shared_ptr< NGSPICE_SIMULATOR_SETTINGS > m_NgspiceSimulatorSettings
Ngspice simulator settings.
EESCHEMA_SETTINGS * eeconfig()
int ExecuteFile(const wxString &aEditorName, const wxString &aFileName, wxProcess *aCallback)
Call the executable file aEditorName with the parameter aFileName.
Definition: gestfich.cpp:114
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:257
A subgraph is a set of items that are electrically connected on a single sheet.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:299
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
Class that groups generic conditions for editor states.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:331
bool IsContentModified() const override
Get if the current schematic has been modified but not saved.
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1130
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
std::set< wxString > m_ErcExclusions
Definition: erc_settings.h:167
void LoadAllLibraries(PROJECT *aProject, bool aShowProgress=true)
Load all of the project's libraries into this container, which should be cleared before calling it.
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:83
static TOOL_ACTION mirrorV
Definition: ee_actions.h:118
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
static TOOL_ACTION rotateCW
Definition: ee_actions.h:116
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:228
bool IsNew() const
Definition: eda_item.h:119
void OnImportProject(wxCommandEvent &event)
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:184
virtual void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:258
void ClearBrightened()
Definition: eda_item.h:133
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
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
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:119
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
void SetShutdownBlockReason(wxWindow *aWindow, const wxString &aReason)
Sets the block reason why the window/application is preventing OS shutdown.
Definition: gtk/app.cpp:83
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetRoot(SCH_SHEET *aRootSheet)
Initialize the schematic with a new root sheet.
Definition: schematic.cpp:104
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
Handle actions specific to the schematic editor.
KICAD_T Type() override
static TOOL_ACTION drawSheet
Definition: ee_actions.h:88
Master controller class:
Definition: tool_manager.h:54
void ShowChangedLanguage() override
void OnClearFileHistory(wxCommandEvent &aEvent)
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:185
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
Definition: kiid.h:44
static TOOL_ACTION copy
Definition: actions.h:67
void doCloseWindow() override
static TOOL_ACTION rotateCCW
Definition: ee_actions.h:117
wxArrayString GetReplaceEntries() const
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:220
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:175
Item needs to be redrawn.
Definition: view_item.h:52
static TOOL_ACTION placePower
Definition: ee_actions.h:78
void DisplaySheet(SCH_SCREEN *aScreen)
const wxString & GetNameForDriver(SCH_ITEM *aItem)
Returns the candidate net name for a driver.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
#define SCH_EDIT_FRAME_NAME
wxString GetName() const
Definition: sch_sheet.h:101
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
wxArrayString m_replaceStringHistoryList
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Definition: hierarch.cpp:208
static TOOL_ACTION drawWire
Definition: ee_actions.h:79
size_t size() const
Forwarded method from std::vector.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
Tool responsible for drawing/placing items (symbols, wires, buses, labels, etc.)
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:342
void HardRedraw() override
Rebuild the GAL and redraw the screen.
static TOOL_ACTION toggleGrid
Definition: actions.h:140
void SetVirtualPageNumber(int aPageNumber)
Set the sheet instance virtual page number.
virtual void OnSize(wxSizeEvent &event) override
Recalculate the size of toolbars and display panel when the frame size changes.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
static int Split(wxArrayString *aResult, const wxString &aPathString)
Separate aPathString into individual paths.
static void inheritNetclass(const SCH_SHEET_PATH &aSheetPath, SCH_TEXT *aItem)
static TOOL_ACTION inchesUnits
Definition: actions.h:144
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
bool FileExists() const
Definition: sch_screen.h:151
static TOOL_ACTION save
Definition: actions.h:51
void SelectHighlightItem(EDA_ITEM *aItem)
Find (but don't select) node under cursor.
static TOOL_ACTION placeSchematicText
Definition: ee_actions.h:90
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SaveCopyForRepeatItem(const SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
void initScreenZoom()
Initialize the zoom value of the current screen and mark the screen as zoom-initialized.
static TOOL_ACTION placeImage
Definition: ee_actions.h:92
SELECTION_CONDITION ScriptingConsoleVisible()
Create a functor testing if the python scripting console window is visible.
void ShowAllIntersheetRefs(bool aShow)
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:63
ACTIONS * m_actions
Definition: tools_holder.h:159
static TOOL_ACTION cut
Definition: actions.h:66
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
Definition of file extensions used in Kicad.
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:209
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:260
Definition for symbol library class.
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
#define _(s)
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
DIALOG_SCH_FIND * m_findReplaceDialog
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
#define HIERARCHY_NAVIG_DLG_WNAME
Definition: hierarch.h:36
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
bool IsExcluded() const
Definition: marker_base.h:94
std::vector< SCH_ITEM * > m_drivers
wxDC * GetPrintDC() const
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
Definition: gtk/app.cpp:72
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PcbFileExtension
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
SCHEMATIC_SETTINGS * m_SchematicSettings
Definition: project_file.h:128
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:89
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:77
bool isAutoSaveRequired() const override
Return true if the schematic has been modified.
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:161
Container for ERC settings.
Definition: erc_settings.h:106
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:116
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
static TOOL_ACTION addNeededJunctions
Definition: ee_actions.h:75
void SetReplaceEntries(const wxArrayString &aEntries)
wxString Serialize() const
Definition: sch_marker.cpp:66
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:76
Handle actions that are shared between different applications.
void OnUpdatePCB(wxCommandEvent &event)
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
void clear()
Forwarded method from std::vector.
void SetFindEntries(const wxArrayString &aEntries)
Specialization of the wxAuiPaneInfo class for KiCad panels.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
static TOOL_ACTION milsUnits
Definition: actions.h:145
bool Show(bool show) override
wxString UnescapeString(const wxString &aSource)
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:160
Gather all the actions that are shared by tools.
Definition: ee_actions.h:38
Handles action that are shared between different applications.
Definition: common_tools.h:37
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
static TOOL_ACTION drawBus
Definition: ee_actions.h:80
Implementing SIM_PLOT_FRAME_BASE.
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:93
A collection of SYMBOL_LIB objects.
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:475
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
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
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
static bool m_allowRealTime
static TOOL_ACTION placeLabel
Definition: ee_actions.h:85
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr) const
Fetch a SCH_ITEM by ID.
static wxString GetAutoSaveFilePrefix()
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:413
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:698
void Reset()
Initialize this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:51
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
void ClearFindReplaceStatus()
SCH_SHEET_PATH Sheet() const
void SetHighlightedConnection(const SCH_CONNECTION *aConnection)
SCH_SHEET & Root() const
Definition: schematic.h:92
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:118
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:158
see class PGM_BASE
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
void OnExit(wxCommandEvent &event)
SCH_SCREEN * LastScreen()
void Print(const RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:731
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
bool m_zoomInitialized
Definition: sch_screen.h:518
SCH_ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieve the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:164
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:194
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Set the work environment (model, view, view controls and the parent window).
WX_INFOBAR * m_infoBar
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
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.
Tool that displays edit points allowing to modify items by dragging the points.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
void RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:82
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...
Handle the component boundary box.
Definition: eda_rect.h:42
const std::string KiCadSchematicFileExtension
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
#define IU_PER_MILS
Definition: plotter.cpp:136
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:100
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
SCH_ITEM * Parent() const
void ignore_unused(const T &)
Definition: ignore.h:24
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
These settings were stored in SCH_BASE_FRAME previously.
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false) const
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:403
~SCH_EDIT_FRAME() override
wxString GetUniqueFilenameForCurrentSheet()
void SaveSymbolToSchematic(const LIB_SYMBOL &aSymbol)
Update the LIB_SYMBOL of the currently selected symbol.
#define CURRENT_TOOL(action)
wxFindReplaceData * m_findReplaceData
ACTION_MANAGER * GetActionManager() const
Definition: tool_manager.h:199
std::map< wxString, std::set< wxString > > & GetPageRefsMap()
Definition: schematic.h:162
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
#define CHECK(x)
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION deleteTool
Definition: actions.h:73
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
static const KICAD_T SymbolsOnly[]
Definition: ee_collectors.h:45
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
Definition: id.h:86
void FocusOnItem(SCH_ITEM *aItem)
static TOOL_ACTION undo
Definition: actions.h:64
SCH_SCREEN * GetFirst()
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
static TOOL_ACTION drawLines
Definition: ee_actions.h:91
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
void OnGridSettings(wxCommandEvent &event)
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
Definition: sch_view.h:97
static TOOL_ACTION toggleCursorStyle
Definition: actions.h:102
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void Update(SCH_ITEM *aItem)
Update aItem's bounding box in the tree.
Definition: sch_screen.cpp:266
ERC_SETTINGS & ErcSettings() const
Definition: schematic.cpp:174
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
void InitTools()
Initializes all registered tools.
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:86
double GetScale() const
Definition: view.h:264
void ClearEditFlags()
Definition: eda_item.h:172
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:205
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
std::string inputLine
problem line of input [say, from a LINE_READER].
Definition: ki_exception.h:127
void SetPageCount(int aPageCount)
Definition: base_screen.cpp:63
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 selectAll
Definition: actions.h:70
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
void RecordERCExclusions()
Scan existing markers and record data from any that are Excluded.
static TOOL_ACTION paste
Definition: actions.h:68
#define ENABLE(x)
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:104
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
static TOOL_ACTION duplicate
Definition: actions.h:71
PRIORITY GetDriverPriority()
static TOOL_ACTION selectionTool
Definition: actions.h:153
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:568
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:1512
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1088
void RegisterTool(TOOL_BASE *aTool)
Add a tool to the manager set and sets it up.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
void sendNetlistToCvpcb()
Send the KiCad netlist over to CVPCB.
virtual void UpdateMsgPanel()
Redraw the message panel.
bool CheckIfOnDrawList(const SCH_ITEM *aItem) const
Definition: sch_screen.cpp:336
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:276
The symbol library editor main window.