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-2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <base_units.h>
26 #include <class_library.h>
27 #include <confirm.h>
28 #include <connection_graph.h>
29 #include <dialog_symbol_remap.h>
31 #include <eeschema_config.h>
32 #include <eeschema_id.h>
33 #include <executable_names.h>
34 #include <fctsys.h>
35 #include <general.h>
36 #include <gestfich.h>
37 #include <gr_basic.h>
38 #include <hierarch.h>
39 #include <html_messagebox.h>
40 #include <invoke_sch_dialog.h>
41 #include <kiface_i.h>
42 #include <kiway.h>
43 #include <lib_edit_frame.h>
44 #include <lib_view_frame.h>
45 #include <pgm_base.h>
46 #include <profile.h>
47 #include <project.h>
48 #include <reporter.h>
49 #include <sch_edit_frame.h>
50 #include <sch_painter.h>
51 #include <sch_sheet.h>
52 #include <advanced_config.h>
53 #include <sim/sim_plot_frame.h>
54 #include <symbol_lib_table.h>
55 #include <tool/action_toolbar.h>
56 #include <tool/common_control.h>
57 #include <tool/common_tools.h>
58 #include <tool/picker_tool.h>
59 #include <tool/tool_dispatcher.h>
60 #include <tool/tool_manager.h>
61 #include <tool/zoom_tool.h>
62 #include <tools/ee_actions.h>
64 #include <tools/ee_point_editor.h>
67 #include <tools/sch_edit_tool.h>
70 #include <tools/sch_move_tool.h>
72 
74 
75 SCH_SHEET_PATH* g_CurrentSheet = nullptr; // declared in general.h
78 
79 // non-member so it can be moved easily, and kept REALLY private.
80 // Do NOT Clear() in here.
81 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
82 {
83  for( unsigned i=0; i<aSrc.GetCount(); ++i )
84  aDst->AddPaths( aSrc[i], aIndex );
85 }
86 
87 
88 //-----<SCH "data on demand" functions>-------------------------------------------
89 
90 SEARCH_STACK* PROJECT::SchSearchS()
91 {
93 
94  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
95 
96  if( !ss )
97  {
98  ss = new SEARCH_STACK();
99 
100  // Make PROJECT the new SEARCH_STACK owner.
102 
103  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
104  ss->AddPaths( m_project_name.GetPath() );
105 
106  // next add the paths found in *.pro, variable "LibDir"
107  wxString libDir;
108 
109  try
110  {
111  PART_LIBS::LibNamesAndPaths( this, false, &libDir );
112  }
113  catch( const IO_ERROR& DBG( ioe ) )
114  {
115  DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );)
116  }
117 
118  if( !!libDir )
119  {
120  wxArrayString paths;
121 
122  SEARCH_STACK::Split( &paths, libDir );
123 
124  for( unsigned i =0; i<paths.GetCount(); ++i )
125  {
126  wxString path = AbsolutePath( paths[i] );
127 
128  ss->AddPaths( path ); // at the end
129  }
130  }
131 
132  // append all paths from aSList
133  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
134  }
135 
136  return ss;
137 }
138 
139 
140 PART_LIBS* PROJECT::SchLibs()
141 {
143 
144  wxASSERT( !libs || libs->Type() == PART_LIBS_T );
145 
146  if( !libs )
147  {
148  libs = new PART_LIBS();
149 
150  // Make PROJECT the new PART_LIBS owner.
152 
153  try
154  {
155  libs->LoadAllLibraries( this );
156  }
157  catch( const PARSE_ERROR& pe )
158  {
159  wxString lib_list = UTF8( pe.inputLine );
160  wxWindow* parent = Pgm().App().GetTopWindow();
161 
162  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
163  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
164 
165  dlg.MessageSet( _( "The following libraries were not found:" ) );
166 
167  dlg.ListSet( lib_list );
168 
169  dlg.Layout();
170 
171  dlg.ShowModal();
172  }
173  catch( const IO_ERROR& ioe )
174  {
175  wxWindow* parent = Pgm().App().GetTopWindow();
176 
177  DisplayError( parent, ioe.What() );
178  }
179  }
180 
181  return libs;
182 }
183 
184 //-----</SCH "data on demand" functions>------------------------------------------
185 
186 
187 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
190 
191  EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
192  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
193 
196 
199 
200  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
201  EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
202 
205 
207 END_EVENT_TABLE()
208 
209 
210 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
211  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
212  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
213  m_item_to_repeat( nullptr )
214 {
216  g_ConnectionGraph = new CONNECTION_GRAPH( this );
217  g_ErcSettings = new ERC_SETTINGS();
218 
219  m_showBorderAndTitleBlock = true; // true to show sheet references
220  m_showAllPins = false;
221  m_selectPinSelectSymbol = true;
222  m_printMonochrome = true;
223  m_printSheetReference = true;
224  SetShowPageLimits( true );
225  m_hasAutoSave = true;
226  m_showIllegalSymbolLibDialog = true;
227  m_showSheetFileNameCaseSensitivityDlg = true;
228  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
229  m_AboutTitle = "Eeschema";
230 
231  m_findReplaceDialog = nullptr;
232  m_findReplaceStatusPopup = nullptr;
233 
234  SetForceHVLines( true );
235  SetSpiceAdjustPassiveValues( false );
236 
237  // Give an icon
238  wxIcon icon;
239  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
240  SetIcon( icon );
241 
242  // Initialize grid id to the default value (50 mils):
244 
245  LoadSettings( config() );
246 
247  CreateScreens();
248 
249  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
250 
251  setupTools();
252  ReCreateMenuBar();
253  ReCreateHToolbar();
254  ReCreateVToolbar();
255  ReCreateOptToolbar();
256 
257  // Initialize common print setup dialog settings.
258  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
259  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
260  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
261  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
262 
263  m_auimgr.SetManagedWindow( this );
264 
265  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
266  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
267  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
268  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
269  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
270 
271  m_auimgr.Update();
272 
273  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
274 
275  // Init grid size and visibility
276  GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
277 
278  if( GetCanvas() )
279  GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
280 
281  InitExitKey();
282 
283  // Net list generator
284  DefaultExecFlags();
285 
286  UpdateTitle();
287 
288  // Default shutdown reason until a file is loaded
289  SetShutdownBlockReason( _( "New schematic file is unsaved" ) );
290 }
291 
292 
294 {
295  // Shutdown all running tools
296  if( m_toolManager )
298 
299  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
300 
301  SetScreen( NULL );
302 
303  delete g_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
304  delete g_ConnectionGraph;
305  delete g_RootSheet;
306  delete g_ErcSettings;
307 
308  g_CurrentSheet = nullptr;
309  g_ConnectionGraph = nullptr;
310  g_RootSheet = nullptr;
311  g_ErcSettings = nullptr;
312 }
313 
314 
316 {
317  // Create the manager and dispatcher & route draw panel events to the dispatcher
320  GetCanvas()->GetViewControls(), this );
321  m_actions = new EE_ACTIONS();
323 
324  // Register tools
338 
339  // Run the selection tool, it is supposed to be always active
341 
343 }
344 
345 
347 {
348  // we cannot store a pointer to an item in the display list here since
349  // that item may be deleted, such as part of a line concatenation or other.
350  // So simply always keep a copy of the object which is to be repeated.
351 
352  if( aItem )
353  {
354  delete m_item_to_repeat;
355 
356  m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
357  // Clone() preserves the flags, we want 'em cleared.
359  }
360 }
361 
362 
364 {
365  SCH_SCREEN* screen;
366  SCH_SCREENS s_list;
367 
368  // Set the sheet count, and the sheet number (1 for root sheet)
369  int sheet_count = g_RootSheet->CountSheets();
370  int SheetNumber = 1;
371  const KIID_PATH& current_sheetpath = g_CurrentSheet->Path();
372  SCH_SHEET_LIST sheetList( g_RootSheet );
373 
374  // Examine all sheets path to find the current sheets path,
375  // and count them from root to the current sheet path:
376  for( const SCH_SHEET_PATH& sheet : sheetList )
377  {
378  if( sheet.Path() == current_sheetpath ) // Current sheet path found
379  break;
380 
381  SheetNumber++; // Not found, increment before this current path
382  }
383 
384  g_CurrentSheet->SetPageNumber( SheetNumber );
385 
386  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
387  screen->m_NumberOfScreens = sheet_count;
388 
389  GetScreen()->m_ScreenNumber = SheetNumber;
390 }
391 
392 
394 {
395  if( !g_CurrentSheet )
396  return nullptr;
397 
398  return g_CurrentSheet->LastScreen();
399 }
400 
401 
403 {
404  if(! g_CurrentSheet )
405  return wxT("<unknown>");
406 
407  wxString s = g_CurrentSheet->PathHumanReadable();
408 
409  return s;
410 }
411 
412 
414 {
415  if( g_RootSheet == NULL )
416  g_RootSheet = new SCH_SHEET();
417 
418  if( g_RootSheet->GetScreen() == NULL )
419  {
420  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
422  g_RootSheet->SetScreen( screen );
424  }
425 
426  g_RootSheet->GetScreen()->SetFileName( wxEmptyString );
427 
431 
432  if( GetScreen() == NULL )
433  {
434  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
436  SetScreen( screen );
437  }
438 
439  GetScreen()->SetZoom( 32.0 );
440 }
441 
442 
444 {
445  wxASSERT_MSG( g_CurrentSheet != NULL, wxT( "SCH_EDIT_FRAME g_CurrentSheet member is NULL." ) );
446 
447  return *g_CurrentSheet;
448 }
449 
450 
452 {
453  if( aSheet != *g_CurrentSheet )
454  {
455  FocusOnItem( nullptr );
456 
457  *g_CurrentSheet = aSheet;
459  }
460 }
461 
462 
464 {
465  FocusOnItem( nullptr );
466 
468  GetCanvas()->ForceRefresh();
469 }
470 
471 
472 void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
473 {
474  SCH_SHEET_LIST sheetList( g_RootSheet );
475 
476  // Shutdown blocks must be determined and vetoed as early as possible
477  if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
478  && sheetList.IsModified() )
479  {
480  aEvent.Veto();
481  return;
482  }
483 
484  // Shutdown all running tools ( and commit any pending change )
485  if( m_toolManager )
487 
488  if( Kiface().IsSingle() )
489  {
490  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
491  if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
492  return;
493 
494  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
495  if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
496  return;
497 
498  viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
499 
500  if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
501  return;
502  }
503 
504  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
505 
506  if( simFrame && !simFrame->Close() ) // Can close the simulator?
507  return;
508 
509 
510  if( sheetList.IsModified() )
511  {
512  wxFileName fileName = g_RootSheet->GetScreen()->GetFileName();
513  wxString msg = _( "Save changes to \"%s\" before closing?" );
514 
515  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
516  [&]()->bool { return SaveProject(); } ) )
517  {
518  aEvent.Veto();
519  return;
520  }
521  }
522 
523  // Close the find dialog and preserve it's setting if it is displayed.
524  if( m_findReplaceDialog )
525  {
528 
529  m_findReplaceStatusPopup->Destroy();
530  m_findReplaceStatusPopup = nullptr;
531 
532  // Must destroy statusPopup first as it holds a pointer to the dialog
533 
534  m_findReplaceDialog->Destroy();
535  m_findReplaceDialog = nullptr;
536  }
537 
538  if( FindHierarchyNavigator() )
539  {
540  FindHierarchyNavigator()->Close( true );
541  }
542 
543  SCH_SCREENS screens;
544  wxFileName fn;
545 
546  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
547  {
548  fn = Prj().AbsolutePath( screen->GetFileName() );
549 
550  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
551  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
552 
553  if( fn.FileExists() && fn.IsFileWritable() )
554  wxRemoveFile( fn.GetFullPath() );
555  }
556 
557  sheetList.ClearModifyStatus();
558 
559  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
560 
561  if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() && !g_RootSheet->GetScreen()->IsEmpty() )
562  {
563  UpdateFileHistory( fileName );
564  }
565 
567 
568  // all sub sheets are deleted, only the main sheet is usable
570 
571  Destroy();
572 }
573 
574 
576 {
577  // Filename is rootSheetName-sheetName-...-sheetName
578  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
579  // name is just a timestamp.
580 
581  wxFileName rootFn( g_CurrentSheet->at( 0 )->GetFileName() );
582  wxString filename = rootFn.GetName();
583 
584  for( unsigned i = 1; i < g_CurrentSheet->size(); i++ )
585  filename += wxT( "-" ) + g_CurrentSheet->at( i )->GetName();
586 
587  return filename;
588 }
589 
590 
592 {
593  wxASSERT( GetScreen() );
594 
595  if( !GetScreen() )
596  return;
597 
598  GetScreen()->SetModify();
599  GetScreen()->SetSave();
600 
601  if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
603 
604  GetCanvas()->Refresh();
605 }
606 
607 
608 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
609 {
610  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
611 
612  fn.SetExt( PcbFileExtension );
613 
614  if( Kiface().IsSingle() )
615  {
616  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
617  " in stand-alone mode. In order to create/update PCBs from"
618  " schematics, launch the Kicad shell and create a project." ) );
619  return;
620  }
621 
622  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, true );
623 
624  // a pcb frame can be already existing, but not yet used.
625  // this is the case when running the footprint editor, or the footprint viewer first
626  // if the frame is not visible, the board is not yet loaded
627  if( !frame->IsVisible() )
628  {
629  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
630  frame->Show( true );
631  }
632 
633  // On Windows, Raise() does not bring the window on screen, when iconized
634  if( frame->IsIconized() )
635  frame->Iconize( false );
636 
637  frame->Raise();
638 
639  std::string payload;
640  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
641 }
642 
643 
645 {
646  if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
647  && !m_findReplaceData->GetFindString().IsEmpty() )
648  {
649  return m_findReplaceData;
650  }
651 
652  return nullptr;
653 }
654 
655 
657 {
658  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
659 
660  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
661 }
662 
664 {
665  if( aForceUpdate )
666  {
667  if( FindHierarchyNavigator() )
668  FindHierarchyNavigator()->Close();
669 
670  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
671 
672  hierarchyDialog->Show( true );
673  }
674  else
675  {
676  if( FindHierarchyNavigator() )
678  }
679 }
680 
681 
683 {
685  m_findReplaceStatusPopup->Destroy();
686 
687  // Must destroy statusPopup first as it holds a pointer to the dialog
688 
689  if( m_findReplaceDialog )
690  m_findReplaceDialog->Destroy();
691 
692  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
693  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
694 
697  m_findReplaceDialog->Show( true );
698 
700  m_findReplaceStatusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
701 }
702 
703 
704 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg )
705 {
706  wxPoint pos = wxGetMousePosition() - m_findReplaceStatusPopup->GetSize() - wxPoint( 10, 10 );
707 
711 }
712 
713 
715 {
716  m_findReplaceStatusPopup->Hide();
717 }
718 
719 
721 {
724 
725  m_findReplaceStatusPopup->Destroy();
726  m_findReplaceStatusPopup = nullptr;
727 
728  // Must destroy statusPopup first as it holds a pointer to the dialog
729 
730  m_findReplaceDialog->Destroy();
731  m_findReplaceDialog = nullptr;
732 }
733 
734 
735 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
736 {
737  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
738 
739  if( fn.size() )
740  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
741 }
742 
743 
744 void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
745 {
747 }
748 
749 
751 {
752  wxString pro_dir = m_mruPath;
753 
754  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
755  LegacySchematicFileWildcard(), wxFD_SAVE );
756 
757  if( dlg.ShowModal() != wxID_CANCEL )
758  {
759  // Enforce the extension, wxFileDialog is inept.
760  wxFileName create_me = dlg.GetPath();
761  create_me.SetExt( LegacySchematicFileExtension );
762 
763  if( create_me.FileExists() )
764  {
765  wxString msg;
766  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
767  DisplayError( this, msg );
768  return ;
769  }
770 
771  // OpenProjectFiles() requires absolute
772  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
773 
774  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
775  m_mruPath = create_me.GetPath();
776  }
777 }
778 
779 
781 {
782  wxString pro_dir = m_mruPath;
783 
784  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
785  LegacySchematicFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
786 
787  if( dlg.ShowModal() != wxID_CANCEL )
788  {
789  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
791  }
792 }
793 
794 
795 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
796 {
797  wxFileName kicad_board = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
798 
799  if( kicad_board.IsOk() )
800  {
801  kicad_board.SetExt( PcbFileExtension );
802  wxFileName legacy_board( kicad_board );
803  legacy_board.SetExt( LegacyPcbFileExtension );
804  wxFileName& boardfn = legacy_board;
805 
806  if( !legacy_board.FileExists() || kicad_board.FileExists() )
807  boardfn = kicad_board;
808 
809  if( Kiface().IsSingle() )
810  {
811  wxString filename = QuoteFullPath( boardfn );
812  ExecuteFile( this, PCBNEW_EXE, filename );
813  }
814  else
815  {
816  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, true );
817 
818  // a pcb frame can be already existing, but not yet used.
819  // this is the case when running the footprint editor, or the footprint viewer first
820  // if the frame is not visible, the board is not yet loaded
821  if( !frame->IsVisible() )
822  {
823  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
824  frame->Show( true );
825  }
826 
827  // On Windows, Raise() does not bring the window on screen, when iconized
828  if( frame->IsIconized() )
829  frame->Iconize( false );
830 
831  frame->Raise();
832  }
833  }
834  else
835  {
836  ExecuteFile( this, PCBNEW_EXE );
837  }
838 }
839 
840 
841 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
842 {
843  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
844  fn.SetExt( NetlistFileExtension );
845 
846  if( !prepareForNetlist() )
847  return;
848 
849  try
850  {
851  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
852 
853  if( !player )
854  {
855  player = Kiway().Player( FRAME_CVPCB, true );
856  player->Show( true );
857  }
858 
860 
861  player->Raise();
862  }
863  catch( const IO_ERROR& )
864  {
865  DisplayError( this, _( "Could not open CvPcb" ) );
866  }
867 }
868 
869 
870 void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
871 {
872  SCH_SCREENS schematic;
873 
874  if( schematic.HasNoFullyDefinedLibIds() )
875  RescueLegacyProject( true );
876  else
878 }
879 
880 
881 void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
882 {
883  DIALOG_SYMBOL_REMAP dlgRemap( this );
884 
885  dlgRemap.ShowQuasiModal();
886 
887  GetCanvas()->Refresh( true );
888 }
889 
890 
891 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
892 {
893  if( event.GetId() == wxID_EXIT )
894  Kiway().OnKiCadExit();
895 
896  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
897  Close( false );
898 }
899 
900 
902 {
904 
905  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
906 
907  if( fn.GetName() != NAMELESS_PROJECT )
908  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() );
909 }
910 
911 
912 void SCH_EDIT_FRAME::PrintPage( wxDC* aDC )
913 {
914  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
915 
916  aDC->SetLogicalFunction( wxCOPY );
917  GetScreen()->Print( aDC );
919 }
920 
921 
923 {
924  // In case this event happens before g_RootSheet is initialized which does happen
925  // on mingw64 builds.
926 
927  if( g_RootSheet != NULL )
928  {
929  SCH_SCREENS screenList;
930 
931  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
932  {
933  if( screen->IsSave() )
934  return true;
935  }
936  }
937 
938  return false;
939 }
940 
941 
942 void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppend )
943 {
944  SCH_SCREEN* screen = GetScreen();
945 
946  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
947 
948  SCH_SHEET* parentSheet = nullptr;
949  SCH_COMPONENT* parentComponent = nullptr;
950  SCH_ITEM* undoItem = aItem;
951 
952  if( aItem->Type() == SCH_SHEET_PIN_T )
953  {
954  parentSheet = (SCH_SHEET*) aItem->GetParent();
955 
956  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
957  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
958 
959  undoItem = parentSheet;
960  }
961 
962  else if( aItem->Type() == SCH_FIELD_T )
963  {
964  parentComponent = (SCH_COMPONENT*) aItem->GetParent();
965 
966  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
967  wxT( "Cannot place field in invalid schematic component object." ) );
968 
969  undoItem = parentComponent;
970  }
971 
972  if( aItem->IsNew() )
973  {
974  if( aItem->Type() == SCH_SHEET_PIN_T )
975  {
976  // Sheet pins are owned by their parent sheet.
977  SaveCopyInUndoList( undoItem, UR_CHANGED, aUndoAppend ); // save the parent sheet
978 
979  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
980  }
981  else if( aItem->Type() == SCH_FIELD_T )
982  {
983  // Component fields are also owned by their parent, but new component fields
984  // are handled elsewhere.
985  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
986  }
987  else
988  {
989  if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
990  AddToScreen( aItem );
991 
992  SaveCopyForRepeatItem( aItem );
993  SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend );
994  }
995 
996  // Update connectivity info for new item
997  if( !aItem->IsMoving() )
999  }
1000 
1001  aItem->ClearFlags( IS_NEW );
1002 
1003  screen->SetModify();
1004  RefreshItem( aItem );
1005 
1006  if( !aItem->IsMoving() && aItem->IsConnectable() )
1007  {
1008  std::vector< wxPoint > pts;
1009  aItem->GetConnectionPoints( pts );
1010 
1011  for( auto i = pts.begin(); i != pts.end(); i++ )
1012  {
1013  for( auto j = i + 1; j != pts.end(); j++ )
1014  TrimWire( *i, *j );
1015 
1016  if( screen->IsJunctionNeeded( *i, true ) )
1017  AddJunction( *i, true, false );
1018  }
1019 
1020  TestDanglingEnds();
1021 
1022  for( SCH_ITEM* item : aItem->ConnectedItems( *g_CurrentSheet ) )
1023  RefreshItem( item );
1024  }
1025 
1026  aItem->ClearEditFlags();
1027  GetCanvas()->Refresh();
1028 }
1029 
1030 
1032 {
1033  wxString title;
1034 
1035  if( GetScreen()->GetFileName().IsEmpty() )
1036  {
1037  title.Printf( _( "Eeschema" ) + wxT( " \u2014" ) + _( " [no file]" ) );
1038  }
1039  else
1040  {
1041  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1042  wxFileName fn = fileName;
1043 
1044  title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
1045  fn.GetFullName(),
1047  fn.GetPath() );
1048 
1049  if( fn.FileExists() )
1050  {
1051  if( !fn.IsFileWritable() )
1052  title += _( " [Read Only]" );
1053  }
1054  else
1055  title += _( " [no file]" );
1056  }
1057 
1058  SetTitle( title );
1059 }
1060 
1061 
1063 {
1064  SCH_SHEET_LIST list( g_RootSheet );
1065  PROF_COUNTER timer;
1066 
1067  // Ensure schematic graph is accurate
1068  if( aCleanupFlags == LOCAL_CLEANUP )
1069  {
1071  }
1072  else if( aCleanupFlags == GLOBAL_CLEANUP )
1073  {
1074  for( const auto& sheet : list )
1075  SchematicCleanUp( sheet.LastScreen() );
1076  }
1077 
1078  timer.Stop();
1079  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1080 
1081  g_ConnectionGraph->Recalculate( list, true );
1082 }
1083 
1084 
1085 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
1086 {
1087  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1088 
1089  RecreateToolbars();
1090  Layout();
1091  SendSizeEvent();
1092 }
1093 
1094 
1096 {
1097  // Rebuild the sheet view (draw area and any other items):
1099 }
1100 
1101 
1103 {
1104  // call my base class
1106 
1107  // tooltips in toolbars
1108  RecreateToolbars();
1109 
1110  // status bar
1111  UpdateMsgPanel();
1112 
1113  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1114  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1115  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1116  // toolbar to update correctly.
1117 #if defined( __WXMSW__ )
1118  PostSizeEvent();
1119 #endif
1120 }
1121 
1122 
1124 {
1125  SCH_BASE_FRAME::SetScreen( aScreen );
1126  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1127 }
1128 
1129 
1131 {
1132  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1133  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1134 
1135  return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
1136 }
1137 
1139 {
1140  // Save the current sheet, to retrieve it later
1141  auto currSheet = GetCurrentSheet();
1142 
1143  SCH_SHEET_LIST sheetList;
1144  sheetList.BuildSheetList( g_RootSheet );
1145 
1146  for( const SCH_SHEET_PATH& sheet : sheetList )
1147  {
1148  // We require a set here to avoid adding multiple junctions to the same spot
1149  std::set<wxPoint> junctions;
1150 
1151  SetCurrentSheet( sheet );
1153 
1154  auto screen = GetCurrentSheet().LastScreen();
1155 
1156  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1157  {
1158  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1159  auto xform = cmp->GetTransform();
1160 
1161  for( const SCH_PIN* pin : cmp->GetSchPins( &sheet ) )
1162  {
1163  auto pos = cmp->GetPosition() + xform.TransformCoordinate( pin->GetPosition() );
1164 
1165  // Test if a _new_ junction is needed, and add it if missing
1166  if( screen->IsJunctionNeeded( pos, true ) )
1167  junctions.insert( pos );
1168  }
1169  }
1170 
1171  for( auto& pos : junctions )
1172  AddJunction( pos );
1173  }
1174 
1175  // Reselect the initial sheet:
1176  SetCurrentSheet( currSheet );
1178  SetScreen( GetCurrentSheet().LastScreen() );
1179 }
1180 
1181 
1183 {
1184  SCH_SHEET_LIST sheetList( g_RootSheet );
1185 
1186  return sheetList.IsModified();
1187 }
void DisplaySheet(const SCH_SCREEN *aScreen)
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)
void SetScreen(BASE_SCREEN *aScreen) override
void Stop()
save the time when this function was called, and set the counter stane to stop
Definition: profile.h:82
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to...
Definition: utf8.h:73
SCH_SHEET_LIST.
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:118
void OnOpenCvpcb(wxCommandEvent &event)
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:201
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
STATUS_TEXT_POPUP * m_findReplaceStatusPopup
bool IsModified()
Function IsModified checks the entire hierarchy for any modifications.
const wxString & GetFileName() const
Definition: sch_screen.h:157
KiCad executable names.
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
BOX2< VECTOR2I > BOX2I
Definition: box2.h:521
wxString LegacySchematicFileWildcard()
void SetTextColor(const wxColour &aColor)
Change text color.
void PrintWorkSheet(wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString, COLOR4D aColor=COLOR4D::UNSPECIFIED)
Prints the page layout with the frame and the basic inscriptions.
SCH_SCREEN * GetNext()
Definition: sch_screen.cpp:970
void OnKiCadExit()
Definition: kiway.cpp:522
int m_ScreenNumber
Definition: base_screen.h:135
virtual bool IsConnectable() const
Function IsConnectable returns true if the schematic item can connect to another schematic item.
Definition: sch_item.h:337
HIERARCHY_NAVIG_DLG * FindHierarchyNavigator()
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
void OnLoadFile(wxCommandEvent &event)
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
ITEM_SET & ConnectedItems(const SCH_SHEET_PATH &aPath)
Retrieves the set of items connected to this item on the given sheet.
Definition: sch_item.cpp:138
static void LibNamesAndPaths(PROJECT *aProject, bool doSave, wxString *aPaths, wxArrayString *aNames=NULL)
Save or load the names of the currently configured part libraries (without paths).
wxString m_mruPath
wxArrayString GetFindEntries() const
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
This file is part of the common library TODO brief description.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generates the connection data for the entire schematic hierarchy.
void LoadAllLibraries(PROJECT *aProject, bool aShowProgress=true)
Load all of the project's libraries into this container, which should be cleared before calling it.
void SetSave()
Definition: base_screen.h:226
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
TOOL_DISPATCHER * m_toolDispatcher
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
Definition: sch_screen.cpp:335
SCH_DRAWING_TOOLS.
static void add_search_paths(SEARCH_STACK *aDst, const SEARCH_STACK &aSrc, int aIndex)
double msecs(bool aSinceLast=false)
Definition: profile.h:143
const wxString PCBNEW_EXE
Definition: id.h:88
Calculates the connectivity of a schematic and generates netlists.
const std::string LegacyPcbFileExtension
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:103
void SetScreen(BASE_SCREEN *aScreen) override
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false)
Updates the connection graph for the given list of sheets.
ERC_SETTINGS * g_ErcSettings
This also wants to live in the eventual SCHEMATIC object.
void SetPageNumber(int aPageNumber)
int CountSheets()
Count the number of sheets found in "this" sheet includeing all of the subsheets.
Definition: sch_sheet.cpp:646
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
#define KICTL_CREATE
caller thinks requested project files may not exist
Definition: kiway_player.h:79
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
bool IsMoving() const
Definition: base_struct.h:222
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:149
bool IsEmpty()
Definition: sch_screen.h:137
ACTIONS * m_actions
void OnCloseWindow(wxCloseEvent &Event)
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Function GetConnectionPoints add all the connection points for this item to aPoints.
Definition: sch_item.h:347
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of ckeck 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)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
void OnAppendProject(wxCommandEvent &event)
void CommonSettingsChanged(bool aEnvVarsChanged) override
Called after the preferences dialog is run.
SCH_CLEANUP_FLAGS
Schematic editor (Eeschema) main window.
SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
bool TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void OnPageSettingsChange() override
Called when modifying the page settings.
void OnRescueProject(wxCommandEvent &event)
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:232
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:218
std::vector< PARAM_CFG * > & GetProjectFileParameters()
Return the project file parameter list for Eeschema.
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
The base class for create windows for drawing purpose.
void OnFindDialogClose()
Notification that the Find dialog has closed.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
The class PROF_COUNTER is a small class to help profiling.
Definition: profile.h:44
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:282
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:152
void ClearFileHistory(FILE_HISTORY *aFileHistory=NULL)
Removes all files from the file history.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:230
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
Symbol library viewer main window.
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:413
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:198
bool IsNew() const
Definition: base_struct.h:220
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=NULL)
Update the list of recently opened files.
void OnImportProject(wxCommandEvent &event)
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:244
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
SCH_EDITOR_CONTROL.
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
TOOL_MANAGER.
Definition: tool_manager.h:50
const BOX2I GetDocumentExtents() const override
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
#define NAMELESS_PROJECT
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
void OnClearFileHistory(wxCommandEvent &aEvent)
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
const BITMAP_OPAQUE icon_eeschema_xpm[1]
wxArrayString GetReplaceEntries() const
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
static TOOL_ACTION gridPreset
Definition: actions.h:134
#define SCH_EDIT_FRAME_NAME
wxString GetName() const
Definition: sch_sheet.h:280
#define NULL
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:117
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:341
wxArrayString m_replaceStringHistoryList
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Definition: hierarch.cpp:184
size_t size() const
Forwarded method from std::vector.
SCH_LINE_DRAWING_TOOL.
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:337
void HardRedraw() override
Rebuild the GAL and redraw the screen.
bool prepareForNetlist()
Verify that annotation is complete so that a proper netlist is even possible.
KICAD_T Type() override
int ShowQuasiModal()
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
static int Split(wxArrayString *aResult, const wxString &aPathString)
Function Split separates aPathString into individual paths.
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:74
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.
SCH_SHEET_PATH & GetCurrentSheet()
Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder.
void SaveCopyInUndoList(SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend=false, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
Definition of file extensions used in Kicad.
void SaveCopyForRepeatItem(SCH_ITEM *aItem)
Clone aItem and owns that clone in this container.
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const std::vector< PARAM_CFG * > &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative.
Definition: project.cpp:350
SCH_JUNCTION * AddJunction(const wxPoint &aPos, bool aAppendToUndo=false, bool aFinal=true)
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
#define GROUP_SCH_EDIT
Definition: config_params.h:42
EDA_ITEM * GetParent() const
Definition: base_struct.h:217
SCH_ITEM * m_item_to_repeat
Last item to insert by the repeat command.
DIALOG_SCH_FIND * m_findReplaceDialog
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
#define HIERARCHY_NAVIG_DLG_WNAME
Definition: hierarch.h:35
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PcbFileExtension
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:48
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
bool isAutoSaveRequired() const override
Returns true if the schematic has been modified.
virtual bool SetZoom(double iu_per_du)
Function SetZoom adjusts the current zoom factor.
Definition: base_screen.cpp:88
Container for ERC settings.
Definition: erc_settings.h:37
SCH_SHEET_PATH.
virtual void Move(const wxPoint &aWhere)
HTML_MESSAGE_BOX.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:491
void SetReplaceEntries(const wxArrayString &aEntries)
void BuildSheetList(SCH_SHEET *aSheet)
Function BuildSheetList builds the list of sheets and their sheet path from aSheet.
COMMON_CONTROL.
void OnUpdatePCB(wxCommandEvent &event)
virtual void PopupFor(int aMsecs)
void clear()
Forwarded method from std::vector.
void SetFindEntries(const wxArrayString &aEntries)
Specialization of the wxAuiPaneInfo class for KiCad panels.
const std::string LegacySchematicFileExtension
void FocusOnItem(SCH_ITEM *aItem)
bool Show(bool show) override
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
EESCHEMA_ACTIONS.
Definition: ee_actions.h:43
COMMON_TOOLS.
Definition: common_tools.h:38
TOOL_DISPATCHER.
Implementing SIM_PLOT_FRAME_BASE.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215
bool SupportsShutdownBlockReason()
Whether or not the window supports setting a shutdown block reason.
static bool m_allowRealTime
A collection of PART_LIB objects.
static wxString GetAutoSaveFilePrefix()
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:427
void OnRemapSymbols(wxCommandEvent &aEvent)
virtual void PrintPage(wxDC *aDC) override
Plot or print the current sheet to the clipboard.
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:71
CONNECTION_GRAPH * g_ConnectionGraph
This also wants to live in the eventual SCHEMATIC object.
void ClearFindReplaceStatus()
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=NULL)
Fetches the file name from the file history list.
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
The symbol library editor main window.
see class PGM_BASE
void OnExit(wxCommandEvent &event)
SCH_SCREEN * LastScreen()
Function LastScreen.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
wxString QuoteFullPath(wxFileName &fn, wxPathFormat format)
Quote return value of wxFileName::GetFullPath().
Definition: gestfich.cpp:378
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
#define _(s)
Definition: 3d_actions.cpp:33
EE_POINT_EDITOR.
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
void SetMaxUndoItems(int aMax)
Definition: base_screen.h:213
#define IU_PER_MILS
Definition: plotter.cpp:137
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
~SCH_EDIT_FRAME() override
wxString GetUniqueFilenameForCurrentSheet()
wxFindReplaceData * m_findReplaceData
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
void OnGridSettings(wxCommandEvent &aEvent) override
void CommonSettingsChanged(bool aEnvVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
int m_NumberOfScreens
Definition: base_screen.h:136
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 ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers of advanced config.
Definition: id.h:87
void Print(wxDC *aDC)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:531
#define DBG(x)
Definition: fctsys.h:33
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:959
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
TOOL_MANAGER * m_toolManager
SCH_SHEET * g_RootSheet
void Print()
Show the print dialog.
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:155
void InitTools()
Function InitTools() Initializes all registered tools.
Definition for part library class.
wxString PathHumanReadable() const
Function PathHumanReadable returns the sheet path in a human readable form, i.e.
bool IsContentModified() override
Get if the current schematic has been modified but not saved.
void SetModify()
Definition: base_screen.h:224
bool RescueLegacyProject(bool aRunningOnDemand)
void ClearEditFlags()
Definition: base_struct.h:275
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:267
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
Function ExecuteFile calls the executable file ExecFile with the command line parameters param.
Definition: gestfich.cpp:174
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME,...
std::string inputLine
problem line of input [say, from a LINE_READER].
Definition: ki_exception.h:132
void ShowFindReplaceStatus(const wxString &aMsg)
virtual void ShowChangedLanguage()
Redraw the menus and what not in current language.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
SCH->PCB forward update.
Definition: mail_type.h:43
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)
void SetText(const wxString &aText)
Display a text.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:491
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
void sendNetlistToCvpcb()
Send the kicad netlist over to CVPCB.
virtual void UpdateMsgPanel()
Redraw the message panel.
void AddItemToScreenAndUndoList(SCH_ITEM *aItem, bool aUndoAppend=false)
Add an item to the schematic and adds the changes to the undo/redo container.