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 <invoke_sch_dialog.h>
37 #include <kicad_string.h>
38 #include <kiface_i.h>
39 #include <kiplatform/app.h>
40 #include <kiway.h>
41 #include <symbol_edit_frame.h>
42 #include <symbol_viewer_frame.h>
43 #include <pgm_base.h>
44 #include <profile.h>
45 #include <project.h>
46 #include <project/project_file.h>
47 #include <project/net_settings.h>
48 #include <python_scripting.h>
49 #include <sch_edit_frame.h>
50 #include <sch_painter.h>
51 #include <sch_sheet.h>
52 #include <sch_marker.h>
53 #include <schematic.h>
55 #include <advanced_config.h>
56 #include <sim/sim_plot_frame.h>
57 #include <sim/spice_settings.h>
58 #include <tool/action_manager.h>
59 #include <tool/action_toolbar.h>
60 #include <tool/common_control.h>
61 #include <tool/common_tools.h>
62 #include <tool/editor_conditions.h>
63 #include <tool/picker_tool.h>
64 #include <tool/selection.h>
65 #include <tool/tool_dispatcher.h>
66 #include <tool/tool_manager.h>
67 #include <tool/zoom_tool.h>
68 #include <tools/ee_actions.h>
70 #include <tools/ee_point_editor.h>
73 #include <tools/sch_edit_tool.h>
76 #include <tools/sch_move_tool.h>
78 #include <view/view_controls.h>
79 #include <widgets/infobar.h>
81 #include <wx/cmdline.h>
82 #include <wx/app.h>
83 #include <wx/filedlg.h>
84 #include <wx/socket.h>
85 
88 
89 // non-member so it can be moved easily, and kept REALLY private.
90 // Do NOT Clear() in here.
91 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
92 {
93  for( unsigned i=0; i<aSrc.GetCount(); ++i )
94  aDst->AddPaths( aSrc[i], aIndex );
95 }
96 
97 
98 SEARCH_STACK* PROJECT::SchSearchS()
99 {
101 
102  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
103 
104  if( !ss )
105  {
106  ss = new SEARCH_STACK();
107 
108  // Make PROJECT the new SEARCH_STACK owner.
110 
111  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
112  ss->AddPaths( m_project_name.GetPath() );
113 
114  // next add the paths found in *.pro, variable "LibDir"
115  wxString libDir;
116 
117  try
118  {
119  SYMBOL_LIBS::LibNamesAndPaths( this, false, &libDir );
120  }
121  catch( const IO_ERROR& )
122  {
123  }
124 
125  if( !!libDir )
126  {
127  wxArrayString paths;
128 
129  SEARCH_STACK::Split( &paths, libDir );
130 
131  for( unsigned i =0; i<paths.GetCount(); ++i )
132  {
133  wxString path = AbsolutePath( paths[i] );
134 
135  ss->AddPaths( path ); // at the end
136  }
137  }
138 
139  // append all paths from aSList
140  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
141  }
142 
143  return ss;
144 }
145 
146 
147 SYMBOL_LIBS* PROJECT::SchLibs()
148 {
150 
151  wxASSERT( !libs || libs->Type() == SYMBOL_LIBS_T );
152 
153  if( !libs )
154  {
155  libs = new SYMBOL_LIBS();
156 
157  // Make PROJECT the new SYMBOL_LIBS owner.
159 
160  try
161  {
162  libs->LoadAllLibraries( this );
163  }
164  catch( const PARSE_ERROR& pe )
165  {
166  wxString lib_list = UTF8( pe.inputLine );
167  wxWindow* parent = Pgm().App().GetTopWindow();
168 
169  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
170  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
171 
172  dlg.MessageSet( _( "The following libraries were not found:" ) );
173 
174  dlg.ListSet( lib_list );
175 
176  dlg.Layout();
177 
178  dlg.ShowModal();
179  }
180  catch( const IO_ERROR& ioe )
181  {
182  wxWindow* parent = Pgm().App().GetTopWindow();
183 
184  DisplayError( parent, ioe.What() );
185  }
186  }
187 
188  return libs;
189 }
190 
191 
192 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
195 
196  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
197 
200 
203 
204  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
205  EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
206 
208 END_EVENT_TABLE()
209 
210 
211 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
212  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ), wxDefaultPosition,
214  m_highlightedConn( nullptr ),
215  m_item_to_repeat( nullptr )
216 {
217  m_maximizeByDefault = true;
218  m_schematic = new SCHEMATIC( nullptr );
219 
220  m_showBorderAndTitleBlock = true; // true to show sheet references
221  m_hasAutoSave = true;
222  m_aboutTitle = _( "KiCad Schematic Editor" );
223 
224  m_findReplaceDialog = nullptr;
225 
226  // Give an icon
227  wxIcon icon;
228  wxIconBundle icon_bundle;
229 
230  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema ) );
231  icon_bundle.AddIcon( icon );
232  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_32 ) );
233  icon_bundle.AddIcon( icon );
234  icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_eeschema_16 ) );
235  icon_bundle.AddIcon( icon );
236 
237  SetIcons( icon_bundle );
238 
239  LoadSettings( eeconfig() );
240 
241  // Also links the schematic to the loaded project
242  CreateScreens();
243 
244  // After schematic has been linked to project, SCHEMATIC_SETTINGS works
245  m_defaults = &m_schematic->Settings();
246 
247  setupTools();
248  setupUIConditions();
249  ReCreateMenuBar();
250  ReCreateHToolbar();
251  ReCreateVToolbar();
252  ReCreateOptToolbar();
253 
254  // Initialize common print setup dialog settings.
255  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
256  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
257  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
258  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
259 
260  m_auimgr.SetManagedWindow( this );
261 
262  CreateInfoBar();
263  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
264  .Top().Layer( 6 ) );
265  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
266  .Left().Layer( 3 ) );
267  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
268  .Right().Layer( 2 ) );
269  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
270  .Center() );
271  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
272  .Bottom().Layer( 6 ) );
273 
274  FinishAUIInitialization();
275 
276  resolveCanvasType();
277  SwitchCanvas( m_canvasType );
278 
279  LoadProjectSettings();
280 
281  initScreenZoom();
282 
283  // This is used temporarily to fix a client size issue on GTK that causes zoom to fit
284  // to calculate the wrong zoom size. See SCH_EDIT_FRAME::onSize().
285  Bind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
286 
287  if( GetCanvas() )
288  {
289  GetCanvas()->GetGAL()->SetAxesEnabled( false );
290 
291  if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
292  p->SetSchematic( m_schematic );
293  }
294 
295  setupUnits( eeconfig() );
296 
297  // Net list generator
298  DefaultExecFlags();
299 
300  UpdateTitle();
301 
302  // Default shutdown reason until a file is loaded
303  KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New schematic file is unsaved" ) );
304 
305  // Ensure the window is on top
306  Raise();
307 }
308 
309 
311 {
312  // Ensure m_canvasType is up to date, to save it in config
314 
315  // Shutdown all running tools
316  if( m_toolManager )
317  {
319  delete m_toolManager;
320  m_toolManager = nullptr;
321  }
322 
323  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
324 
325  SetScreen( nullptr );
326 
327  delete m_schematic;
328  m_schematic = nullptr;
329 
330  // Close the project if we are standalone, so it gets cleaned up properly
331  if( Kiface().IsSingle() )
332  GetSettingsManager()->UnloadProject( &Prj(), false );
333 }
334 
335 
337 {
338  // Create the manager and dispatcher & route draw panel events to the dispatcher
340  m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
341  GetCanvas()->GetViewControls(), config(), this );
342  m_actions = new EE_ACTIONS();
344 
345  // Register tools
360 
361  // Run the selection tool, it is supposed to be always active
363 
365 }
366 
367 
369 {
371 
373  EDITOR_CONDITIONS cond( this );
374 
375  wxASSERT( mgr );
376 
377  auto hasElements =
378  [ this ] ( const SELECTION& aSel )
379  {
380  return !GetScreen()->Items().empty() || !SELECTION_CONDITIONS::Idle( aSel );
381  };
382 
383 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
384 #define CHECK( x ) ACTION_CONDITIONS().Check( x )
385 
387  mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
388  mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
389 
393  CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
396 
397  mgr->SetConditions( ACTIONS::cut, ENABLE( hasElements ) );
398  mgr->SetConditions( ACTIONS::copy, ENABLE( hasElements ) );
401  mgr->SetConditions( ACTIONS::doDelete, ENABLE( hasElements ) );
402  mgr->SetConditions( ACTIONS::duplicate, ENABLE( hasElements ) );
403  mgr->SetConditions( ACTIONS::selectAll, ENABLE( hasElements ) );
404 
405  mgr->SetConditions( EE_ACTIONS::rotateCW, ENABLE( hasElements ) );
406  mgr->SetConditions( EE_ACTIONS::rotateCCW, ENABLE( hasElements ) );
407  mgr->SetConditions( EE_ACTIONS::mirrorH, ENABLE( hasElements ) );
408  mgr->SetConditions( EE_ACTIONS::mirrorV, ENABLE( hasElements ) );
409 
411  CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
414 
415  if( SCRIPTING::IsWxAvailable() )
417  CHECK( cond.ScriptingConsoleVisible() ) );
418 
419  auto showHiddenPinsCond =
420  [this] ( const SELECTION& )
421  {
422  return GetShowAllPins();
423  };
424 
425  auto forceHVCond =
426  [this] ( const SELECTION& )
427  {
428  return eeconfig()->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 
559 
560  SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
561  m_schematic->Root().SetScreen( rootScreen );
562  SetScreen( Schematic().RootScreen() );
563 
564  m_schematic->RootScreen()->SetFileName( wxEmptyString );
565 
566  // Don't leave root page number empty
567  SCH_SHEET_PATH rootSheetPath;
568  rootSheetPath.push_back( &m_schematic->Root() );
569  m_schematic->RootScreen()->SetPageNumber( wxT( "1" ) );
570  m_schematic->Root().AddInstance( rootSheetPath.Path() );
571  m_schematic->Root().SetPageNumber( rootSheetPath, wxT( "1" ) );
572 
573  if( GetScreen() == nullptr )
574  {
575  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
576  SetScreen( screen );
577  }
578 }
579 
580 
582 {
583  return m_schematic->CurrentSheet();
584 }
585 
586 
588 {
589  if( aSheet != GetCurrentSheet() )
590  {
591  FocusOnItem( nullptr );
592 
593  Schematic().SetCurrentSheet( aSheet );
594  GetCanvas()->DisplaySheet( aSheet.LastScreen() );
595  }
596 }
597 
598 
600 {
602 
603  FocusOnItem( nullptr );
604 
605  GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
606  GetCanvas()->ForceRefresh();
607 }
608 
609 
610 bool SCH_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
611 {
612  // Exit interactive editing
613  // Note this this will commit *some* pending changes. For instance, the EE_POINT_EDITOR
614  // will cancel any drag currently in progress, but commit all changes from previous drags.
615  if( m_toolManager )
617 
618  // Shutdown blocks must be determined and vetoed as early as possible
619  if( KIPLATFORM::APP::SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
620  && Schematic().GetSheets().IsModified() )
621  {
622  return false;
623  }
624 
625  if( Kiface().IsSingle() )
626  {
627  auto* symbolEditor = (SYMBOL_EDIT_FRAME*) Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
628 
629  if( symbolEditor && !symbolEditor->Close() ) // Can close symbol editor?
630  return false;
631 
632  auto* symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
633 
634  if( symbolViewer && !symbolViewer->Close() ) // Can close symbol viewer?
635  return false;
636 
637  symbolViewer = (SYMBOL_VIEWER_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
638 
639  if( symbolViewer && !symbolViewer->Close() ) // Can close modal symbol viewer?
640  return false;
641  }
642 
643  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
644 
645  if( simFrame && !simFrame->Close() ) // Can close the simulator?
646  return false;
647 
648  // We may have gotten multiple events; don't clean up twice
649  if( !Schematic().IsValid() )
650  return false;
651 
652  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
653 
654  if( sheetlist.IsModified() )
655  {
656  wxFileName fileName = Schematic().RootScreen()->GetFileName();
657  wxString msg = _( "Save changes to '%s' before closing?" );
658 
659  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
660  [&]()->bool { return SaveProject(); } ) )
661  {
662  return false;
663  }
664  }
665 
666  return true;
667 }
668 
669 
671 {
672  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
673 
674  // Shutdown all running tools
675  if( m_toolManager )
677 
679 
680  // Close the find dialog and preserve its setting if it is displayed.
681  if( m_findReplaceDialog )
682  {
685 
686  m_findReplaceDialog->Destroy();
687  m_findReplaceDialog = nullptr;
688  }
689 
690  if( FindHierarchyNavigator() )
691  FindHierarchyNavigator()->Close( true );
692 
693  if( Kiway().Player( FRAME_SIMULATOR, false ) )
695 
696  SCH_SCREENS screens( Schematic().Root() );
697  wxFileName fn;
698 
699  for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
700  {
701  fn = Prj().AbsolutePath( screen->GetFileName() );
702 
703  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
704  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
705 
706  if( fn.FileExists() && fn.IsFileWritable() )
707  wxRemoveFile( fn.GetFullPath() );
708  }
709 
710  sheetlist.ClearModifyStatus();
711 
712  wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
713 
714  if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
715  UpdateFileHistory( fileName );
716 
717  Schematic().RootScreen()->Clear();
718 
719  // all sub sheets are deleted, only the main sheet is usable
721 
722  // Clear view before destroying schematic as repaints depend on schematic being valid
723  SetScreen( nullptr );
724 
725  Schematic().Reset();
726 
727  Destroy();
728 }
729 
730 
732 {
733  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
734  ERC_SETTINGS& ercSettings = Schematic().ErcSettings();
735 
736  ercSettings.m_ErcExclusions.clear();
737 
738  for( unsigned i = 0; i < sheetList.size(); i++ )
739  {
740  for( SCH_ITEM* item : sheetList[i].LastScreen()->Items().OfType( SCH_MARKER_T ) )
741  {
742  SCH_MARKER* marker = static_cast<SCH_MARKER*>( item );
743 
744  if( marker->IsExcluded() )
745  ercSettings.m_ErcExclusions.insert( marker->Serialize() );
746  }
747  }
748 }
749 
750 
752 {
753  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
754 
755  for( SCH_MARKER* marker : Schematic().ResolveERCExclusions() )
756  {
757  SCH_SHEET_PATH errorPath;
758  (void) sheetList.GetItem( marker->GetRCItem()->GetMainItemID(), &errorPath );
759 
760  if( errorPath.LastScreen() )
761  errorPath.LastScreen()->Append( marker );
762  else
763  Schematic().RootScreen()->Append( marker );
764  }
765 }
766 
767 
769 {
770  // Filename is rootSheetName-sheetName-...-sheetName
771  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
772  // name is just a timestamp.
773 
774  wxFileName rootFn( GetCurrentSheet().at( 0 )->GetFileName() );
775  wxString filename = rootFn.GetName();
776 
777  for( unsigned i = 1; i < GetCurrentSheet().size(); i++ )
778  filename += wxT( "-" ) + GetCurrentSheet().at( i )->GetName();
779 
780  return filename;
781 }
782 
783 
785 {
786  wxASSERT( GetScreen() );
787 
788  if( !GetScreen() )
789  return;
790 
792 
793  if( ADVANCED_CFG::GetCfg().m_RealTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
795 
796  GetCanvas()->Refresh();
798 
799  if( !GetTitle().StartsWith( "*" ) )
800  UpdateTitle();
801 }
802 
803 
804 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
805 {
806  if( Kiface().IsSingle() )
807  {
808  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
809  " in stand-alone mode. In order to create/update PCBs from"
810  " schematics, launch the KiCad shell and create a project." ) );
811  return;
812  }
813 
814  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
815 
816  if( !frame )
817  {
818  wxFileName fn = Prj().GetProjectFullName();
819  fn.SetExt( PcbFileExtension );
820 
821  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
822  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
823  }
824 
825  if( !frame->IsVisible() )
826  frame->Show( true );
827 
828  // On Windows, Raise() does not bring the window on screen, when iconized
829  if( frame->IsIconized() )
830  frame->Iconize( false );
831 
832  frame->Raise();
833 
834  std::string payload;
835  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
836 }
837 
838 
840 {
841  if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
842  && !m_findReplaceData->GetFindString().IsEmpty() )
843  {
844  return m_findReplaceData;
845  }
846 
847  return nullptr;
848 }
849 
850 
852 {
853  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
854 
855  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
856 }
857 
858 
860 {
861  if( aForceUpdate )
862  {
863  if( FindHierarchyNavigator() )
864  FindHierarchyNavigator()->Close();
865 
866  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
867 
868  hierarchyDialog->Show( true );
869  }
870  else
871  {
872  if( FindHierarchyNavigator() )
874  }
875 }
876 
877 
879 {
880  if( m_findReplaceDialog )
881  m_findReplaceDialog->Destroy();
882 
883  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
884  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
885 
888  m_findReplaceDialog->Show( true );
889 }
890 
891 
892 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
893 {
894  // Prepare the infobar, since we don't know its state
897 
898  m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
899 }
900 
901 
903 {
904  m_infoBar->Dismiss();
905 }
906 
907 
909 {
912 
913  m_findReplaceDialog->Destroy();
914  m_findReplaceDialog = nullptr;
915 
917 }
918 
919 
920 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
921 {
922  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
923 
924  if( fn.size() )
925  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
926 }
927 
928 
929 void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
930 {
932 }
933 
934 
936 {
937  wxString pro_dir = m_mruPath;
938 
939  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
940  KiCadSchematicFileWildcard(), wxFD_SAVE );
941 
942  if( dlg.ShowModal() != wxID_CANCEL )
943  {
944  // Enforce the extension, wxFileDialog is inept.
945  wxFileName create_me = dlg.GetPath();
946  create_me.SetExt( KiCadSchematicFileExtension );
947 
948  if( create_me.FileExists() )
949  {
950  wxString msg;
951  msg.Printf( _( "Schematic file '%s' already exists." ), create_me.GetFullName() );
952  DisplayError( this, msg );
953  return ;
954  }
955 
956  // OpenProjectFiles() requires absolute
957  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
958 
959  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
960  m_mruPath = create_me.GetPath();
961  }
962 }
963 
964 
966 {
967  wxString pro_dir = m_mruPath;
968  wxString wildcards = KiCadSchematicFileWildcard();
969 
970  wildcards += "|" + LegacySchematicFileWildcard();
971 
972  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
973  wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
974 
975  if( dlg.ShowModal() != wxID_CANCEL )
976  {
977  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
979  }
980 }
981 
982 
983 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
984 {
985  wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
986 
987  if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() )
988  {
989  kicad_board.SetExt( PcbFileExtension );
990  wxFileName legacy_board( kicad_board );
991  legacy_board.SetExt( LegacyPcbFileExtension );
992  wxFileName& boardfn = legacy_board;
993 
994  if( !legacy_board.FileExists() || kicad_board.FileExists() )
995  boardfn = kicad_board;
996 
997  if( Kiface().IsSingle() )
998  {
999  wxString filename = QuoteFullPath( boardfn );
1000  ExecuteFile( this, PCBNEW_EXE, filename );
1001  }
1002  else
1003  {
1004  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
1005 
1006  if( !frame )
1007  {
1008  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
1009  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
1010  }
1011 
1012  if( !frame->IsVisible() )
1013  frame->Show( true );
1014 
1015  // On Windows, Raise() does not bring the window on screen, when iconized
1016  if( frame->IsIconized() )
1017  frame->Iconize( false );
1018 
1019  frame->Raise();
1020  }
1021  }
1022  else
1023  {
1024  // If we are running inside a project, it should be impossible for this case to happen
1025  wxASSERT( Kiface().IsSingle() );
1026  ExecuteFile( this, PCBNEW_EXE );
1027  }
1028 }
1029 
1030 
1031 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
1032 {
1033  wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
1034  fn.SetExt( NetlistFileExtension );
1035 
1036  if( !ReadyToNetlist( _( "Assigning footprints requires a fully annotated schematic." ) ) )
1037  return;
1038 
1039  try
1040  {
1041  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
1042 
1043  if( !player )
1044  {
1045  player = Kiway().Player( FRAME_CVPCB, true );
1046  player->Show( true );
1047  }
1048 
1050 
1051  player->Raise();
1052  }
1053  catch( const IO_ERROR& )
1054  {
1055  DisplayError( this, _( "Could not open CvPcb" ) );
1056  }
1057 }
1058 
1059 
1060 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
1061 {
1062  if( event.GetId() == wxID_EXIT )
1063  Kiway().OnKiCadExit();
1064 
1065  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
1066  Close( false );
1067 }
1068 
1069 
1071 {
1072  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1073 
1074  const wxBrush& brush =
1075  wxBrush( GetColorSettings()->GetColor( LAYER_SCHEMATIC_BACKGROUND ).ToColour() );
1076  aSettings->GetPrintDC()->SetBackground( brush );
1077  aSettings->GetPrintDC()->Clear();
1078 
1079  aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
1080  GetScreen()->Print( aSettings );
1081  PrintDrawingSheet( aSettings, GetScreen(), IU_PER_MILS, fileName );
1082 }
1083 
1084 
1086 {
1087  // In case this event happens before g_RootSheet is initialized which does happen
1088  // on mingw64 builds.
1089 
1090  if( Schematic().IsValid() )
1091  {
1092  return IsContentModified();
1093  }
1094 
1095  return false;
1096 }
1097 
1098 
1099 static void inheritNetclass( const SCH_SHEET_PATH& aSheetPath, SCH_TEXT* aItem )
1100 {
1101  // Netclasses are assigned to subgraphs by association with their netname. However, when
1102  // a new label is attached to an existing subgraph (with an existing netclass association),
1103  // the association will be lost as the label will drive its name on to the graph.
1104  //
1105  // Here we find the previous driver of the subgraph and if it had a netclass we associate
1106  // the new netname with that netclass as well.
1107  //
1108  SCHEMATIC* schematic = aItem->Schematic();
1109  CONNECTION_SUBGRAPH* subgraph = schematic->ConnectionGraph()->GetSubgraphForItem( aItem );
1110 
1111  std::map<wxString, wxString>& netclassAssignments =
1113 
1114  if( subgraph )
1115  {
1116  SCH_ITEM* previousDriver = nullptr;
1118 
1119  for( SCH_ITEM* item : subgraph->m_drivers )
1120  {
1121  if( item == aItem )
1122  continue;
1123 
1125 
1126  if( p > priority )
1127  {
1128  priority = p;
1129  previousDriver = item;
1130  }
1131  }
1132 
1133  if( previousDriver )
1134  {
1135  wxString path = aSheetPath.PathHumanReadable();
1136  wxString oldDrivenName = path + subgraph->GetNameForDriver( previousDriver );
1137  wxString drivenName = path + subgraph->GetNameForDriver( aItem );
1138 
1139  if( netclassAssignments.count( oldDrivenName ) )
1140  netclassAssignments[ drivenName ] = netclassAssignments[ oldDrivenName ];
1141  }
1142  }
1143 }
1144 
1145 
1147  bool aUndoAppend )
1148 {
1149  wxCHECK_RET( aItem != nullptr, wxT( "Cannot add null item to list." ) );
1150 
1151  SCH_SHEET* parentSheet = nullptr;
1152  SCH_SYMBOL* parentSymbol = nullptr;
1153  SCH_ITEM* undoItem = aItem;
1154 
1155  if( aItem->Type() == SCH_SHEET_PIN_T )
1156  {
1157  parentSheet = (SCH_SHEET*) aItem->GetParent();
1158 
1159  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
1160  wxT( "Cannot place sheet pin in invalid schematic sheet." ) );
1161 
1162  undoItem = parentSheet;
1163  }
1164 
1165  else if( aItem->Type() == SCH_FIELD_T )
1166  {
1167  parentSymbol = (SCH_SYMBOL*) aItem->GetParent();
1168 
1169  wxCHECK_RET( parentSymbol && parentSymbol->Type() == SCH_SYMBOL_T,
1170  wxT( "Cannot place field in invalid schematic symbol." ) );
1171 
1172  undoItem = parentSymbol;
1173  }
1174 
1175  if( aItem->IsNew() )
1176  {
1177  if( aItem->Type() == SCH_SHEET_PIN_T )
1178  {
1179  // Sheet pins are owned by their parent sheet.
1180  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::CHANGED, aUndoAppend );
1181 
1182  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
1183  }
1184  else if( aItem->Type() == SCH_FIELD_T )
1185  {
1186  // Symbol fields are also owned by their parent, but new symbol fields are
1187  // handled elsewhere.
1188  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1189  }
1190  else
1191  {
1192  if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1193  AddToScreen( aItem, aScreen );
1194 
1195  SaveCopyForRepeatItem( aItem );
1196  SaveCopyInUndoList( aScreen, undoItem, UNDO_REDO::NEWITEM, aUndoAppend );
1197  }
1198 
1199  // Update connectivity info for new item
1200  if( !aItem->IsMoving() )
1201  {
1203 
1204  if( SCH_TEXT* textItem = dynamic_cast<SCH_TEXT*>( aItem ) )
1205  inheritNetclass( GetCurrentSheet(), textItem );
1206  }
1207  }
1208 
1209  aItem->ClearFlags( IS_NEW );
1210 
1211  aScreen->SetContentModified();
1212  UpdateItem( aItem );
1213 
1214  if( !aItem->IsMoving() && aItem->IsConnectable() )
1215  {
1216  std::vector< wxPoint > pts = aItem->GetConnectionPoints();
1217 
1218  for( auto i = pts.begin(); i != pts.end(); i++ )
1219  {
1220  for( auto j = i + 1; j != pts.end(); j++ )
1221  TrimWire( *i, *j );
1222 
1223  if( aScreen->IsJunctionNeeded( *i, true ) )
1224  AddJunction( aScreen, *i, true, false );
1225  }
1226 
1227  TestDanglingEnds();
1228 
1229  for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
1230  UpdateItem( item );
1231  }
1232 
1233  aItem->ClearEditFlags();
1234  GetCanvas()->Refresh();
1235 }
1236 
1237 
1239 {
1240  wxString title;
1241 
1242  if( !GetScreen()->GetFileName().IsEmpty() )
1243  {
1244  wxFileName fn( Prj().AbsolutePath( GetScreen()->GetFileName() ) );
1245  bool readOnly = false;
1246  bool unsaved = false;
1247 
1248  if( fn.IsOk() && fn.FileExists() )
1249  readOnly = !fn.IsFileWritable();
1250  else
1251  unsaved = true;
1252 
1253  if( IsContentModified() )
1254  title = wxT( "*" );
1255 
1256  title += fn.GetName();
1257  title += wxString::Format( wxT( " [%s]" ), GetCurrentSheet().PathHumanReadable( false ) );
1258 
1259  if( readOnly )
1260  title += wxS( " " ) + _( "[Read Only]" );
1261 
1262  if( unsaved )
1263  title += wxS( " " ) + _( "[Unsaved]" );
1264  }
1265  else
1266  {
1267  title = _( "[no schematic loaded]" );
1268  }
1269 
1270  title += wxT( " \u2014 " ) + _( "Schematic Editor" );
1271 
1272  SetTitle( title );
1273 }
1274 
1275 
1277 {
1279  GetScreen()->m_zoomInitialized = true;
1280 }
1281 
1282 
1284 {
1285  const SCH_CONNECTION* highlight = GetHighlightedConnection();
1286  SCH_ITEM* highlightedItem = highlight ? highlight->Parent() : nullptr;
1287  SCH_SHEET_PATH highlightPath;
1288 
1289  if( highlight )
1290  highlightPath = highlight->Sheet();
1291 
1292  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1293  SCH_SHEET_LIST list = Schematic().GetSheets();
1294 #ifdef PROFILE
1295  PROF_COUNTER timer;
1296 #endif
1297 
1298  // Ensure schematic graph is accurate
1299  if( aCleanupFlags == LOCAL_CLEANUP )
1300  {
1302  }
1303  else if( aCleanupFlags == GLOBAL_CLEANUP )
1304  {
1305  for( const SCH_SHEET_PATH& sheet : list )
1306  SchematicCleanUp( sheet.LastScreen() );
1307  }
1308 
1309 #ifdef PROFILE
1310  timer.Stop();
1311  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1312 #endif
1313 
1314  if( settings.m_IntersheetRefsShow )
1316 
1317  std::function<void( SCH_ITEM* )> changeHandler =
1318  [&]( SCH_ITEM* aChangedItem ) -> void
1319  {
1320  GetCanvas()->GetView()->Update( aChangedItem, KIGFX::REPAINT );
1321  };
1322 
1323  Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler );
1324 
1326  []( KIGFX::VIEW_ITEM* aItem )
1327  {
1328  SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItem );
1329  SCH_CONNECTION* connection = item ? item->Connection() : nullptr;
1330 
1331  if( connection && connection->HasDriverChanged() )
1332  {
1333  connection->ClearDriverChanged();
1334  return true;
1335  }
1336 
1337  EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
1338 
1339  if( text && text->HasTextVars() )
1340  return true;
1341 
1342  return false;
1343  } );
1344 
1345  if( highlightedItem )
1346  SetHighlightedConnection( highlightedItem->Connection( &highlightPath ) );
1347 }
1348 
1349 
1351 {
1352  std::map<wxString, std::set<wxString>>& pageRefsMap = Schematic().GetPageRefsMap();
1353 
1354  pageRefsMap.clear();
1355 
1356  SCH_SCREENS screens( Schematic().Root() );
1357  std::vector<wxString> pageNumbers;
1358 
1359  /* Iterate over screens */
1360  for( SCH_SCREEN* screen = screens.GetFirst(); screen != nullptr; screen = screens.GetNext() )
1361  {
1362  pageNumbers.clear();
1363 
1364  /* Find in which sheets this screen is used */
1365  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
1366  {
1367  if( sheet.LastScreen() == screen )
1368  pageNumbers.push_back( sheet.GetPageNumber() );
1369  }
1370 
1371  for( SCH_ITEM* item : screen->Items() )
1372  {
1373  if( item->Type() == SCH_GLOBAL_LABEL_T )
1374  {
1375  SCH_GLOBALLABEL* globalLabel = static_cast<SCH_GLOBALLABEL*>( item );
1376  std::set<wxString>& pageList = pageRefsMap[ globalLabel->GetText() ];
1377 
1378  for( const wxString& pageNo : pageNumbers )
1379  pageList.insert( pageNo );
1380  }
1381  }
1382  }
1383 
1384  bool show = Schematic().Settings().m_IntersheetRefsShow;
1385 
1386  /* Refresh all global labels */
1387  for( EDA_ITEM* item : GetScreen()->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1388  {
1389  SCH_GLOBALLABEL* global = static_cast<SCH_GLOBALLABEL*>( item );
1390 
1391  global->GetIntersheetRefs()->SetVisible( show );
1392 
1393  if( show )
1394  GetCanvas()->GetView()->Update( global );
1395  }
1396 }
1397 
1398 
1400 {
1401  if( aShow )
1403 
1404  SCH_SCREENS screens( Schematic().Root() );
1405 
1406  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
1407  {
1408  for( SCH_ITEM* item : screen->Items().OfType( SCH_GLOBAL_LABEL_T ) )
1409  {
1410  SCH_GLOBALLABEL* gLabel = (SCH_GLOBALLABEL*)( item );
1411  SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs();
1412 
1413  intersheetRef->SetVisible( aShow );
1414  UpdateItem( intersheetRef, true );
1415  }
1416  }
1417 }
1418 
1419 
1420 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1421 {
1422  SCHEMATIC_SETTINGS& settings = Schematic().Settings();
1423  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1424 
1426 
1427  RecreateToolbars();
1428  Layout();
1429  SendSizeEvent();
1430 }
1431 
1432 
1434 {
1435  // Store the current zoom level into the current screen before calling
1436  // DisplayCurrentSheet() that set the zoom to GetScreen()->m_LastZoomLevel
1438  // Rebuild the sheet view (draw area and any other items):
1440 }
1441 
1442 
1444 {
1445  // call my base class
1447 
1448  // tooltips in toolbars
1449  RecreateToolbars();
1450 
1451  // status bar
1452  UpdateMsgPanel();
1453 
1454  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1455  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1456  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1457  // toolbar to update correctly.
1458 #if defined( __WXMSW__ )
1459  PostSizeEvent();
1460 #endif
1461 }
1462 
1463 
1465 {
1466  if( const SCH_CONNECTION* conn = GetHighlightedConnection() )
1467  {
1468  SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
1469  UnescapeString( conn->Name() ) ) );
1470  }
1471  else
1472  {
1473  SetStatusText( wxT( "" ) );
1474  }
1475 }
1476 
1477 
1479 {
1480  if( m_toolManager )
1482 
1483  SCH_BASE_FRAME::SetScreen( aScreen );
1484  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1485 }
1486 
1487 
1488 const BOX2I SCH_EDIT_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
1489 {
1490  BOX2I bBoxDoc;
1491 
1492  if( aIncludeAllVisible )
1493  {
1494  // Get the whole page size and return that
1495  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1496  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1497  bBoxDoc = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( sizeX, sizeY ) );
1498  }
1499  else
1500  {
1501  // Get current drawing-sheet in a form we can compare to an EDA_ITEM
1503  EDA_ITEM* dsAsItem = static_cast<EDA_ITEM*>( ds );
1504 
1505  // Need an EDA_RECT so the first ".Merge" sees it's uninitialized
1506  EDA_RECT bBoxItems;
1507 
1508  // Calc the bounding box of all items on screen except the page border
1509  for( EDA_ITEM* item : GetScreen()->Items() )
1510  {
1511  if( item != dsAsItem ) // Ignore the drawing-sheet itself
1512  {
1513  if( item->Type() == SCH_SYMBOL_T )
1514  {
1515  // For symbols we need to get the bounding box without invisible text
1516  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1517  bBoxItems.Merge( symbol->GetBoundingBox( false ) );
1518  }
1519  else
1520  bBoxItems.Merge( item->GetBoundingBox() );
1521  }
1522  bBoxDoc = bBoxItems;
1523  }
1524  }
1525  return bBoxDoc;
1526 }
1527 
1528 
1530 {
1531  // Save the current sheet, to retrieve it later
1532  SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1533 
1534  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1535 
1536  for( const SCH_SHEET_PATH& sheet : sheetList )
1537  {
1538  size_t num_undos = m_undoList.m_CommandsList.size();
1539 
1540  // We require a set here to avoid adding multiple junctions to the same spot
1541  std::set<wxPoint> junctions;
1542 
1543  SetCurrentSheet( sheet );
1545 
1546  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
1547 
1548  EE_SELECTION allItems;
1549 
1550  for( auto item : screen->Items() )
1551  allItems.Add( item );
1552 
1554 
1555  // Check if we modified anything during this routine
1556  // Needs to happen for every sheet to set the proper modified flag
1557  if( m_undoList.m_CommandsList.size() > num_undos )
1558  OnModify();
1559  }
1560 
1561  // Reselect the initial sheet:
1562  SetCurrentSheet( oldsheetpath );
1564  SetScreen( GetCurrentSheet().LastScreen() );
1565 }
1566 
1567 
1569 {
1570  return Schematic().GetSheets().IsModified();
1571 }
1572 
1573 
1575 {
1576  EESCHEMA_SETTINGS* cfg = eeconfig();
1577  return cfg->m_Appearance.show_hidden_pins;
1578 }
1579 
1580 
1582 {
1583  static KIID lastBrightenedItemID( niluuid );
1584 
1585  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1587  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1588 
1589  if( lastItem && lastItem != aItem )
1590  {
1591  lastItem->ClearBrightened();
1592 
1593  UpdateItem( lastItem );
1594  lastBrightenedItemID = niluuid;
1595  }
1596 
1597  if( aItem )
1598  {
1599  aItem->SetBrightened();
1600 
1601  UpdateItem( aItem );
1602  lastBrightenedItemID = aItem->m_Uuid;
1603 
1604  FocusOnLocation( aItem->GetFocusPosition() );
1605  }
1606 }
1607 
1608 
1610 {
1611  return Schematic().GetFileName();
1612 }
1613 
1614 
1616 {
1617  return m_toolManager->GetTool<EE_SELECTION_TOOL>()->GetSelection();
1618 }
1619 
1620 
1621 void SCH_EDIT_FRAME::onSize( wxSizeEvent& aEvent )
1622 {
1623  if( IsShown() )
1624  {
1625  // We only need this until the frame is done resizing and the final client size is
1626  // established.
1627  Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::onSize, this );
1629  }
1630 
1631  // Skip() is called in the base class.
1632  EDA_DRAW_FRAME::OnSize( aEvent );
1633 }
1634 
1635 
1637 {
1638  wxString msg;
1639  bool appendToUndo = false;
1640 
1641  wxCHECK( m_toolManager, /* void */ );
1642 
1644 
1645  wxCHECK( selectionTool, /* void */ );
1646 
1647  EE_SELECTION& selection = selectionTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
1648 
1649  if( selection.Empty() )
1650  return;
1651 
1652  SCH_SCREEN* currentScreen = GetScreen();
1653 
1654  wxCHECK( currentScreen, /* void */ );
1655 
1656  // This should work for multiple selections of the same symbol even though the editor
1657  // only works for a single symbol selection.
1658  for( EDA_ITEM* item : selection )
1659  {
1660  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
1661 
1662  wxCHECK( symbol, /* void */ );
1663 
1664  // This needs to be done before the LIB_SYMBOL is changed to prevent stale library
1665  // symbols in the schematic file.
1666  currentScreen->Remove( symbol );
1667 
1668  if( !symbol->IsNew() )
1669  {
1670  SaveCopyInUndoList( currentScreen, symbol, UNDO_REDO::CHANGED, appendToUndo );
1671  appendToUndo = true;
1672  }
1673 
1674  symbol->SetLibSymbol( aSymbol.Flatten().release() );
1675  symbol->UpdateFields( &GetCurrentSheet(),
1676  true, /* update style */
1677  true, /* update ref */
1678  true, /* update other fields */
1679  false, /* reset ref */
1680  false /* reset other fields */ );
1681 
1682  currentScreen->Append( symbol );
1683  selectionTool->SelectHighlightItem( symbol );
1684  GetCanvas()->GetView()->Update( symbol );
1685  }
1686 
1687  if( selection.IsHover() )
1689 
1690  GetCanvas()->Refresh();
1691  OnModify();
1692 }
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:748
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:247
bool empty() const
Definition: sch_rtree.h:163
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:123
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:207
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:137
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:260
SCH_SCREEN * GetNext()
void OnKiCadExit()
Definition: kiway.cpp:625
void UpdateNetHighlightStatus()
virtual bool IsConnectable() const
Definition: sch_item.h:362
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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)
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
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:1425
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:377
This file is part of the common library TODO brief description.
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:31
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
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
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:84
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:475
static TOOL_ACTION placeJunction
Definition: ee_actions.h:80
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:157
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:155
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:382
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:476
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:81
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.
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:81
static TOOL_ACTION mirrorH
Definition: ee_actions.h:116
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:124
std::shared_ptr< NGSPICE_SIMULATOR_SETTINGS > m_NgspiceSimulatorSettings
Ngspice simulator settings.
EESCHEMA_SETTINGS * eeconfig()
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:248
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:300
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:332
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:1136
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:115
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:113
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:215
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:181
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
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:71
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:85
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:114
wxArrayString GetReplaceEntries() const
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:217
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:176
Item needs to be redrawn.
Definition: view_item.h:57
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
static TOOL_ACTION placePower
Definition: ee_actions.h:75
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
bool IsSingle() const
Is this KIFACE_I running under single_top?
Definition: kiface_i.h:104
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:76
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
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:87
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
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:89
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:206
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)
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:43
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:86
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
static TOOL_ACTION placeSymbol
Definition: ee_actions.h:74
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:72
SCHEMATIC_SETTINGS * m_defaults
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:287
static TOOL_ACTION milsUnits
Definition: actions.h:145
bool Show(bool show) override
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:97
static TOOL_ACTION drawBus
Definition: ee_actions.h:77
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:82
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:403
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:692
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:728
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:506
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:144
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:191
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
wxString QuoteFullPath(wxFileName &fn, wxPathFormat format)
Quote return value of wxFileName::GetFullPath().
Definition: gestfich.cpp:334
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 ...
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:222
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
EE_RTREE & Items()
Definition: sch_screen.h:102
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
static TOOL_ACTION placeNoConnect
Definition: ee_actions.h:79
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:137
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 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:390
~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:88
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...
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:108
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:83
double GetScale() const
Definition: view.h:263
void ClearEditFlags()
Definition: eda_item.h:172
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:202
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.
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Call the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:115
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:197
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)
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:551
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:1503
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1094
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:323
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:277
The symbol library editor main window.