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 <advanced_config.h>
26 #include <base_units.h>
27 #include <class_library.h>
28 #include <confirm.h>
29 #include <connection_graph.h>
30 #include <dialog_symbol_remap.h>
32 #include <eeschema_config.h>
33 #include <eeschema_id.h>
34 #include <executable_names.h>
35 #include <fctsys.h>
36 #include <general.h>
37 #include <gestfich.h>
38 #include <gr_basic.h>
39 #include <hierarch.h>
40 #include <html_messagebox.h>
41 #include <invoke_sch_dialog.h>
42 #include <kiface_i.h>
43 #include <kiway.h>
44 #include <lib_edit_frame.h>
45 #include <lib_view_frame.h>
46 #include <pgm_base.h>
47 #include <profile.h>
48 #include <project.h>
49 #include <reporter.h>
50 #include <sch_edit_frame.h>
51 #include <sch_painter.h>
52 #include <sch_sheet.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
77 
78 // non-member so it can be moved easily, and kept REALLY private.
79 // Do NOT Clear() in here.
80 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
81 {
82  for( unsigned i=0; i<aSrc.GetCount(); ++i )
83  aDst->AddPaths( aSrc[i], aIndex );
84 }
85 
86 
87 // non-member so it can be moved easily, and kept REALLY private.
88 // Do NOT Clear() in here.
89 static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
90 {
91  for( int i=1; true; ++i )
92  {
93  wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
94  wxString upath = aCfg->Read( key, wxEmptyString );
95 
96  if( !upath )
97  break;
98 
99  aDst->AddPaths( upath, aIndex );
100  }
101 }
102 
103 //-----<SCH "data on demand" functions>-------------------------------------------
104 
105 SEARCH_STACK* PROJECT::SchSearchS()
106 {
108 
109  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
110 
111  if( !ss )
112  {
113  ss = new SEARCH_STACK();
114 
115  // Make PROJECT the new SEARCH_STACK owner.
117 
118  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
119  ss->AddPaths( m_project_name.GetPath() );
120 
121  // next add the paths found in *.pro, variable "LibDir"
122  wxString libDir;
123 
124  try
125  {
126  PART_LIBS::LibNamesAndPaths( this, false, &libDir );
127  }
128  catch( const IO_ERROR& DBG( ioe ) )
129  {
130  DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );)
131  }
132 
133  if( !!libDir )
134  {
135  wxArrayString paths;
136 
137  SEARCH_STACK::Split( &paths, libDir );
138 
139  for( unsigned i =0; i<paths.GetCount(); ++i )
140  {
141  wxString path = AbsolutePath( paths[i] );
142 
143  ss->AddPaths( path ); // at the end
144  }
145  }
146 
147  // append all paths from aSList
148  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
149 
150  // addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
151  // This is undocumented, but somebody wanted to store !schematic!
152  // library search paths in the .kicad_common file?
153  add_search_paths( ss, Pgm().CommonSettings(), -1 );
154  }
155 
156  return ss;
157 }
158 
159 
160 PART_LIBS* PROJECT::SchLibs()
161 {
163 
164  wxASSERT( !libs || libs->Type() == PART_LIBS_T );
165 
166  if( !libs )
167  {
168  libs = new PART_LIBS();
169 
170  // Make PROJECT the new PART_LIBS owner.
172 
173  try
174  {
175  libs->LoadAllLibraries( this );
176  }
177  catch( const PARSE_ERROR& pe )
178  {
179  wxString lib_list = UTF8( pe.inputLine );
180  wxWindow* parent = Pgm().App().GetTopWindow();
181 
182  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
183  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
184 
185  dlg.MessageSet( _( "The following libraries were not found:" ) );
186 
187  dlg.ListSet( lib_list );
188 
189  dlg.Layout();
190 
191  dlg.ShowModal();
192  }
193  catch( const IO_ERROR& ioe )
194  {
195  wxWindow* parent = Pgm().App().GetTopWindow();
196 
197  DisplayError( parent, ioe.What() );
198  }
199  }
200 
201  return libs;
202 }
203 
204 //-----</SCH "data on demand" functions>------------------------------------------
205 
206 
207 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
210 
211  EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
212  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
213 
215 
218 
219  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
220  EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
221 
224 
226 END_EVENT_TABLE()
227 
228 
229 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
230  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
231  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
232  m_item_to_repeat( nullptr )
233 {
235  g_ConnectionGraph = new CONNECTION_GRAPH( this );
236 
237  m_showBorderAndTitleBlock = true; // true to show sheet references
238  m_showAllPins = false;
239  m_selectPinSelectSymbol = true;
240  m_printMonochrome = true;
241  m_printSheetReference = true;
242  SetShowPageLimits( true );
243  m_undoItem = NULL;
244  m_hasAutoSave = true;
245  m_showIllegalSymbolLibDialog = true;
246  m_showSheetFileNameCaseSensitivityDlg = true;
247  m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
248  m_AboutTitle = "Eeschema";
249 
250  m_findReplaceDialog = nullptr;
251  m_findReplaceStatusPopup = nullptr;
252 
253  SetForceHVLines( true );
254  SetSpiceAdjustPassiveValues( false );
255 
256  // Give an icon
257  wxIcon icon;
258  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
259  SetIcon( icon );
260 
261  // Initialize grid id to the default value (50 mils):
263 
264  LoadSettings( config() );
265 
266  CreateScreens();
267 
268  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
269 
270  setupTools();
271  ReCreateMenuBar();
272  ReCreateHToolbar();
273  ReCreateVToolbar();
274  ReCreateOptToolbar();
275 
276  // Initialize common print setup dialog settings.
277  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
278  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
279  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
280  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
281 
282  m_auimgr.SetManagedWindow( this );
283 
284  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
285  m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
286  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
287  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
288  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
289 
290  m_auimgr.Update();
291 
292  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
293 
294  // Init grid size and visibility
295  GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
296 
297  if( GetCanvas() )
298  GetCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
299 
300  InitExitKey();
301 
302  // Net list generator
303  DefaultExecFlags();
304 
305  UpdateTitle();
306 
307  // Default shutdown reason until a file is loaded
308  SetShutdownBlockReason( _( "New schematic file is unsaved" ) );
309 }
310 
311 
313 {
314  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
315 
316  SetScreen( NULL );
317 
318  delete g_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
319  delete g_ConnectionGraph;
320  delete m_undoItem;
321  delete g_RootSheet;
322 
323  g_CurrentSheet = nullptr;
324  g_ConnectionGraph = nullptr;
325  g_RootSheet = NULL;
326 
327  // Since the file menu contains file history menus, we must ensure that the menu
328  // destructor is called before the file history objects are deleted since their destructor
329  // unregisters the menu from the history.
330  wxMenu* fileMenu = GetMenuBar()->Remove( 0 );
331  delete fileMenu;
332 }
333 
334 
336 {
337  // Create the manager and dispatcher & route draw panel events to the dispatcher
340  GetCanvas()->GetViewControls(), this );
341  m_actions = new EE_ACTIONS();
343 
344  // Register tools
358 
359  // Run the selection tool, it is supposed to be always active
361 
363 }
364 
365 
367 {
368  // we cannot store a pointer to an item in the display list here since
369  // that item may be deleted, such as part of a line concatenation or other.
370  // So simply always keep a copy of the object which is to be repeated.
371 
372  if( aItem )
373  {
374  delete m_item_to_repeat;
375 
376  m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
377  // Clone() preserves the flags, we want 'em cleared.
379  }
380 }
381 
382 
384 {
385  SCH_SCREEN* screen;
386  SCH_SCREENS s_list;
387 
388  /* Set the sheet count, and the sheet number (1 for root sheet)
389  */
390  int sheet_count = g_RootSheet->CountSheets();
391  int SheetNumber = 1;
392  wxString current_sheetpath = g_CurrentSheet->Path();
393  SCH_SHEET_LIST sheetList( g_RootSheet );
394 
395  // Examine all sheets path to find the current sheets path,
396  // and count them from root to the current sheet path:
397  for( const SCH_SHEET_PATH& sheet : sheetList )
398  {
399  wxString sheetpath = sheet.Path();
400 
401  if( sheetpath == current_sheetpath ) // Current sheet path found
402  break;
403 
404  SheetNumber++; // Not found, increment before this current path
405  }
406 
407  g_CurrentSheet->SetPageNumber( SheetNumber );
408 
409  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
410  screen->m_NumberOfScreens = sheet_count;
411 
412  GetScreen()->m_ScreenNumber = SheetNumber;
413 }
414 
415 
417 {
418  if( !g_CurrentSheet )
419  return nullptr;
420 
421  return g_CurrentSheet->LastScreen();
422 }
423 
424 
426 {
427  if(! g_CurrentSheet )
428  return wxT("<unknown>");
429 
430  wxString s = g_CurrentSheet->PathHumanReadable();
431 
432  return s;
433 }
434 
435 
437 {
438  if( g_RootSheet == NULL )
439  g_RootSheet = new SCH_SHEET();
440 
441  if( g_RootSheet->GetScreen() == NULL )
442  {
443  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
445  g_RootSheet->SetScreen( screen );
447  }
448 
449  g_RootSheet->GetScreen()->SetFileName( wxEmptyString );
450 
454 
455  if( GetScreen() == NULL )
456  {
457  SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
459  SetScreen( screen );
460  }
461 
462  GetScreen()->SetZoom( 32.0 );
463 }
464 
465 
467 {
468  wxASSERT_MSG( g_CurrentSheet != NULL, wxT( "SCH_EDIT_FRAME g_CurrentSheet member is NULL." ) );
469 
470  return *g_CurrentSheet;
471 }
472 
473 
475 {
476  if( aSheet != *g_CurrentSheet )
477  {
478  *g_CurrentSheet = aSheet;
480  }
481 }
482 
483 
485 {
487  GetCanvas()->ForceRefresh();
488 }
489 
490 
492 {
493  wxCHECK_RET( aItem != NULL, wxT( "Cannot swap undo item structures." ) );
494  wxCHECK_RET( m_undoItem != NULL, wxT( "Cannot swap undo item structures." ) );
495  wxCHECK_RET( aItem->Type() == m_undoItem->Type(), wxT( "Cannot swap undo item structures." ) );
496 
497  aItem->SwapData( m_undoItem );
498  SaveCopyInUndoList( aItem, UR_CHANGED, aAppend );
499  aItem->SwapData( m_undoItem );
500 }
501 
502 
503 void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
504 {
505  SCH_SHEET_LIST sheetList( g_RootSheet );
506 
507  // Shutdown blocks must be determined and vetoed as early as possible
508  if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
509  && sheetList.IsModified() )
510  {
511  aEvent.Veto();
512  return;
513  }
514 
515  if( Kiface().IsSingle() )
516  {
517  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
518  if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
519  return;
520 
521  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
522  if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
523  return;
524 
525  viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
526 
527  if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
528  return;
529  }
530 
531  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
532 
533  if( simFrame && !simFrame->Close() ) // Can close the simulator?
534  return;
535 
536 
537  if( sheetList.IsModified() )
538  {
539  wxFileName fileName = g_RootSheet->GetScreen()->GetFileName();
540  wxString msg = _( "Save changes to \"%s\" before closing?" );
541 
542  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
543  [&]()->bool { return SaveProject(); } ) )
544  {
545  aEvent.Veto();
546  return;
547  }
548  }
549 
550  // Close the find dialog and preserve it's setting if it is displayed.
551  if( m_findReplaceDialog )
552  {
555 
556  m_findReplaceStatusPopup->Destroy();
557  m_findReplaceStatusPopup = nullptr;
558 
559  // Must destroy statusPopup first as it holds a pointer to the dialog
560 
561  m_findReplaceDialog->Destroy();
562  m_findReplaceDialog = nullptr;
563  }
564 
565  if( FindHierarchyNavigator() )
566  {
567  FindHierarchyNavigator()->Close( true );
568  }
569 
570  SCH_SCREENS screens;
571  wxFileName fn;
572 
573  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
574  {
575  fn = Prj().AbsolutePath( screen->GetFileName() );
576 
577  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
578  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
579 
580  if( fn.FileExists() && fn.IsFileWritable() )
581  wxRemoveFile( fn.GetFullPath() );
582  }
583 
584  sheetList.ClearModifyStatus();
585 
586  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
587 
588  if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() && !g_RootSheet->GetScreen()->IsEmpty() )
589  {
590  UpdateFileHistory( fileName );
591  }
592 
594 
595  // all sub sheets are deleted, only the main sheet is usable
597 
598  Destroy();
599 }
600 
601 
603 {
604  // Filename is rootSheetName-sheetName-...-sheetName
605  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
606  // name is just a timestamp.
607 
608  wxFileName rootFn( g_CurrentSheet->at( 0 )->GetFileName() );
609  wxString filename = rootFn.GetName();
610 
611  for( unsigned i = 1; i < g_CurrentSheet->size(); i++ )
612  filename += wxT( "-" ) + g_CurrentSheet->at( i )->GetName();
613 
614  return filename;
615 }
616 
617 
619 {
620  GetScreen()->SetModify();
621  GetScreen()->SetSave();
622 
623  if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
625 
626  GetCanvas()->Refresh();
627 }
628 
629 
630 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
631 {
632  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
633 
634  fn.SetExt( PcbFileExtension );
635 
636  if( Kiface().IsSingle() )
637  {
638  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
639  " in stand-alone mode. In order to create/update PCBs from"
640  " schematics, launch the Kicad shell and create a project." ) );
641  return;
642  }
643 
644  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, true );
645 
646  // a pcb frame can be already existing, but not yet used.
647  // this is the case when running the footprint editor, or the footprint viewer first
648  // if the frame is not visible, the board is not yet loaded
649  if( !frame->IsVisible() )
650  {
651  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
652  frame->Show( true );
653  }
654 
655  // On Windows, Raise() does not bring the window on screen, when iconized
656  if( frame->IsIconized() )
657  frame->Iconize( false );
658 
659  frame->Raise();
660 
661  std::string payload;
662  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
663 }
664 
665 
667 {
668  if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
669  && !m_findReplaceData->GetFindString().IsEmpty() )
670  {
671  return m_findReplaceData;
672  }
673 
674  return nullptr;
675 }
676 
677 
679 {
680  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
681 
682  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
683 }
684 
686 {
687  if( aForceUpdate )
688  {
689  if( FindHierarchyNavigator() )
690  FindHierarchyNavigator()->Close();
691 
692  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
693 
694  hierarchyDialog->Show( true );
695  }
696  else
697  {
698  if( FindHierarchyNavigator() )
700  }
701 }
702 
703 
705 {
707  m_findReplaceStatusPopup->Destroy();
708 
709  // Must destroy statusPopup first as it holds a pointer to the dialog
710 
711  if( m_findReplaceDialog )
712  m_findReplaceDialog->Destroy();
713 
714  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
715  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
716 
719  m_findReplaceDialog->Show( true );
720 
722  m_findReplaceStatusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
723 }
724 
725 
726 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg )
727 {
728  wxPoint pos = wxGetMousePosition() - m_findReplaceStatusPopup->GetSize() - wxPoint( 10, 10 );
729 
733 }
734 
735 
737 {
738  m_findReplaceStatusPopup->Hide();
739 }
740 
741 
743 {
746 
747  m_findReplaceStatusPopup->Destroy();
748  m_findReplaceStatusPopup = nullptr;
749 
750  // Must destroy statusPopup first as it holds a pointer to the dialog
751 
752  m_findReplaceDialog->Destroy();
753  m_findReplaceDialog = nullptr;
754 }
755 
756 
757 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
758 {
759  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
760 
761  if( fn.size() )
762  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
763 }
764 
765 
767 {
768  wxString pro_dir = m_mruPath;
769 
770  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard(),
771  wxFD_SAVE );
772 
773  if( dlg.ShowModal() != wxID_CANCEL )
774  {
775  // Enforce the extension, wxFileDialog is inept.
776  wxFileName create_me = dlg.GetPath();
777  create_me.SetExt( SchematicFileExtension );
778 
779  if( create_me.FileExists() )
780  {
781  wxString msg;
782  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
783  DisplayError( this, msg );
784  return ;
785  }
786 
787  // OpenProjectFiles() requires absolute
788  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
789 
790  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
791  m_mruPath = create_me.GetPath();
792  }
793 }
794 
795 
797 {
798  wxString pro_dir = m_mruPath;
799 
800  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard(),
801  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
802 
803  if( dlg.ShowModal() != wxID_CANCEL )
804  {
805  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
807  }
808 }
809 
810 
811 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
812 {
813  wxFileName kicad_board = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
814 
815  if( kicad_board.IsOk() )
816  {
817  kicad_board.SetExt( PcbFileExtension );
818  wxFileName legacy_board( kicad_board );
819  legacy_board.SetExt( LegacyPcbFileExtension );
820  wxFileName& boardfn = legacy_board;
821 
822  if( !legacy_board.FileExists() || kicad_board.FileExists() )
823  boardfn = kicad_board;
824 
825  if( Kiface().IsSingle() )
826  {
827  wxString filename = QuoteFullPath( boardfn );
828  ExecuteFile( this, PCBNEW_EXE, filename );
829  }
830  else
831  {
832  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, true );
833 
834  // a pcb frame can be already existing, but not yet used.
835  // this is the case when running the footprint editor, or the footprint viewer first
836  // if the frame is not visible, the board is not yet loaded
837  if( !frame->IsVisible() )
838  {
839  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
840  frame->Show( true );
841  }
842 
843  // On Windows, Raise() does not bring the window on screen, when iconized
844  if( frame->IsIconized() )
845  frame->Iconize( false );
846 
847  frame->Raise();
848  }
849  }
850  else
851  {
852  ExecuteFile( this, PCBNEW_EXE );
853  }
854 }
855 
856 
857 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
858 {
859  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
860  fn.SetExt( NetlistFileExtension );
861 
862  if( !prepareForNetlist() )
863  return;
864 
865  try
866  {
867  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
868 
869  if( !player )
870  {
871  player = Kiway().Player( FRAME_CVPCB, true );
872  player->Show( true );
873  }
874 
876 
877  player->Raise();
878  }
879  catch( const IO_ERROR& )
880  {
881  DisplayError( this, _( "Could not open CvPcb" ) );
882  }
883 }
884 
885 
886 void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
887 {
888  SCH_SCREENS schematic;
889 
890  if( schematic.HasNoFullyDefinedLibIds() )
891  RescueLegacyProject( true );
892  else
894 }
895 
896 
897 void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
898 {
899  DIALOG_SYMBOL_REMAP dlgRemap( this );
900 
901  dlgRemap.ShowQuasiModal();
902 
903  GetCanvas()->Refresh( true );
904 }
905 
906 
907 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
908 {
909  if( event.GetId() == wxID_EXIT )
910  Kiway().OnKiCadExit();
911 
912  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
913  Close( false );
914 }
915 
916 
918 {
920 
921  wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
922 
923  if( fn.GetName() != NAMELESS_PROJECT )
924  Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() );
925 }
926 
927 
928 void SCH_EDIT_FRAME::PrintPage( wxDC* aDC )
929 {
930  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
931 
932  aDC->SetLogicalFunction( wxCOPY );
933  GetScreen()->Print( aDC );
935 }
936 
937 
939 {
940  // In case this event happens before g_RootSheet is initialized which does happen
941  // on mingw64 builds.
942 
943  if( g_RootSheet != NULL )
944  {
945  SCH_SCREENS screenList;
946 
947  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
948  {
949  if( screen->IsSave() )
950  return true;
951  }
952  }
953 
954  return false;
955 }
956 
957 
958 void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppend )
959 {
960  SCH_SCREEN* screen = GetScreen();
961 
962  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
963 
964  SCH_SHEET* parentSheet = nullptr;
965  SCH_COMPONENT* parentComponent = nullptr;
966  SCH_ITEM* undoItem = aItem;
967 
968  if( aItem->Type() == SCH_SHEET_PIN_T )
969  {
970  parentSheet = (SCH_SHEET*) aItem->GetParent();
971 
972  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
973  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
974 
975  undoItem = parentSheet;
976  }
977 
978  else if( aItem->Type() == SCH_FIELD_T )
979  {
980  parentComponent = (SCH_COMPONENT*) aItem->GetParent();
981 
982  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
983  wxT( "Cannot place field in invalid schematic component object." ) );
984 
985  undoItem = parentComponent;
986  }
987 
988  if( aItem->IsNew() )
989  {
990  if( aItem->Type() == SCH_SHEET_PIN_T )
991  {
992  // Sheet pins are owned by their parent sheet.
993  SaveCopyInUndoList( undoItem, UR_CHANGED, aUndoAppend ); // save the parent sheet
994 
995  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
996  }
997  else if( aItem->Type() == SCH_FIELD_T )
998  {
999  // Component fields are also owned by their parent, but new component fields
1000  // are handled elsewhere.
1001  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
1002  }
1003  else
1004  {
1005  if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
1006  AddToScreen( aItem );
1007 
1008  SaveCopyForRepeatItem( aItem );
1009  SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend );
1010  }
1011 
1012  // Update connectivity info for new item
1013  if( !aItem->IsMoving() )
1015  }
1016  else
1017  {
1018  SaveUndoItemInUndoList( undoItem, aUndoAppend );
1019  }
1020 
1021  aItem->ClearFlags( IS_NEW );
1022 
1023  screen->SetModify();
1024  RefreshItem( aItem );
1025 
1026  if( !aItem->IsMoving() && aItem->IsConnectable() )
1027  {
1028  std::vector< wxPoint > pts;
1029  aItem->GetConnectionPoints( pts );
1030 
1031  for( auto i = pts.begin(); i != pts.end(); i++ )
1032  {
1033  for( auto j = i + 1; j != pts.end(); j++ )
1034  TrimWire( *i, *j );
1035 
1036  if( screen->IsJunctionNeeded( *i, true ) )
1037  AddJunction( *i, true, false );
1038  }
1039 
1040  TestDanglingEnds();
1041 
1042  for( SCH_ITEM* item : aItem->ConnectedItems() )
1043  RefreshItem( item );
1044  }
1045 
1046  aItem->ClearEditFlags();
1047  GetCanvas()->Refresh();
1048 }
1049 
1050 
1052 {
1053  wxString title;
1054 
1055  if( GetScreen()->GetFileName().IsEmpty() )
1056  {
1057  title.Printf( _( "Eeschema" ) + wxT( " \u2014" ) + _( " [no file]" ) );
1058  }
1059  else
1060  {
1061  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
1062  wxFileName fn = fileName;
1063 
1064  title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
1065  fn.GetFullName(),
1067  fn.GetPath() );
1068 
1069  if( fn.FileExists() )
1070  {
1071  if( !fn.IsFileWritable() )
1072  title += _( " [Read Only]" );
1073  }
1074  else
1075  title += _( " [no file]" );
1076  }
1077 
1078  SetTitle( title );
1079 }
1080 
1081 
1083 {
1084  SCH_SHEET_LIST list( g_RootSheet );
1085  PROF_COUNTER timer;
1086 
1087  // Ensure schematic graph is accurate
1088  if( aCleanupFlags == LOCAL_CLEANUP )
1089  {
1091  }
1092  else if( aCleanupFlags == GLOBAL_CLEANUP )
1093  {
1094  for( const auto& sheet : list )
1095  SchematicCleanUp( sheet.LastScreen() );
1096  }
1097 
1098  timer.Stop();
1099  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1100 
1101  g_ConnectionGraph->Recalculate( list, true );
1102 }
1103 
1104 
1105 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
1106 {
1107  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged );
1108 
1109  RecreateToolbars();
1110  Layout();
1111  SendSizeEvent();
1112 }
1113 
1114 
1116 {
1117  // Rebuild the sheet view (draw area and any other items):
1119 }
1120 
1121 
1123 {
1124  // call my base class
1126 
1127  // tooltips in toolbars
1128  RecreateToolbars();
1129 
1130  // status bar
1131  UpdateMsgPanel();
1132 
1133  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1134  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1135  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1136  // toolbar to update correctly.
1137 #if defined( __WXMSW__ )
1138  PostSizeEvent();
1139 #endif
1140 }
1141 
1142 
1144 {
1145  SCH_BASE_FRAME::SetScreen( aScreen );
1146  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1147 }
1148 
1149 
1151 {
1152  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1153  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1154 
1155  return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
1156 }
1157 
1159 {
1160  // Save the current sheet, to retrieve it later
1161  auto currSheet = GetCurrentSheet();
1162 
1163  SCH_SHEET_LIST sheetList;
1164  sheetList.BuildSheetList( g_RootSheet );
1165 
1166  for( const SCH_SHEET_PATH& sheet : sheetList )
1167  {
1168  // We require a set here to avoid adding multiple junctions to the same spot
1169  std::set<wxPoint> junctions;
1170 
1171  SetCurrentSheet( sheet );
1173 
1174  auto screen = GetCurrentSheet().LastScreen();
1175  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1176  {
1177  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1178  auto xform = cmp->GetTransform();
1179 
1180  for( const SCH_PIN& pin : cmp->GetPins() )
1181  {
1182  auto pos = cmp->GetPosition() + xform.TransformCoordinate( pin.GetPosition() );
1183 
1184  // Test if a _new_ junction is needed, and add it if missing
1185  if( screen->IsJunctionNeeded( pos, true ) )
1186  junctions.insert( pos );
1187  }
1188  }
1189 
1190  for( auto& pos : junctions )
1191  AddJunction( pos );
1192  }
1193 
1194  // Reselect the initial sheet:
1195  SetCurrentSheet( currSheet );
1197  SetScreen( GetCurrentSheet().LastScreen() );
1198 }
1199 
1200 
1202 {
1203  SCH_SHEET_LIST sheetList( g_RootSheet );
1204 
1205  return sheetList.IsModified();
1206 }
void DisplaySheet(const SCH_SCREEN *aScreen)
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:236
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
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:981
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:317
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:98
wxString SchematicFileWildcard()
void OnLoadFile(wxCommandEvent &event)
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
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:332
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.
void SetPageNumber(int aPageNumber)
int CountSheets()
Count the number of sheets found in "this" sheet includeing all of the subsheets.
Definition: sch_sheet.cpp:602
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:220
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:111
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:327
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:109
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:205
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:278
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:152
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:179
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:386
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:196
bool IsNew() const
Definition: base_struct.h:218
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:217
#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:79
#define NAMELESS_PROJECT
void ShowChangedLanguage() override
Redraw the menus and what not in current language.
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:131
#define SCH_EDIT_FRAME_NAME
wxString GetName() const
Definition: sch_sheet.h:269
#define NULL
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:115
virtual void SwapData(SCH_ITEM *aItem)
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_item.cpp:166
wxString Path() const
Function Path the path uses the time stamps which do not changes even when editing sheet parameters a...
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:331
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
const std::string SchematicFileExtension
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:323
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:274
#define GROUP_SCH_EDIT
Definition: config_params.h:45
EDA_ITEM * GetParent() const
Definition: base_struct.h:215
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:75
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
SCH_SHEET_PATH.
virtual void Move(const wxPoint &aWhere)
HTML_MESSAGE_BOX.
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)
void SaveUndoItemInUndoList(SCH_ITEM *aItem, bool aAppend=false)
Swap the cloned item in member variable m_undoItem with aItem and saves it to the undo list then swap...
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.
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
std::unordered_set< SCH_ITEM * > & ConnectedItems()
Retrieves the set of items connected to this item (schematic only)
Definition: sch_item.cpp:138
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:206
wxString GetFileName(void) const
Return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:616
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:31
EE_POINT_EDITOR.
SCH_ITEM * m_undoItem
Copy of the current item being edited.
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:89
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:256
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:527
#define DBG(x)
Definition: fctsys.h:33
SCH_SCREEN * GetFirst()
Definition: sch_screen.cpp:970
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:273
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:264
EVT_MENU_RANGE(ID_POPUP_3D_VIEW_START, ID_POPUP_3D_VIEW_END, EDA_3D_CANVAS::OnPopUpMenu) EDA_3D_CANVAS
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:136
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:498
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:207
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.