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 <project/project_file.h>
49 #include <reporter.h>
50 #include <sch_edit_frame.h>
51 #include <sch_painter.h>
52 #include <sch_sheet.h>
53 #include <schematic.h>
55 #include <advanced_config.h>
56 #include <sim/sim_plot_frame.h>
57 #include <symbol_lib_table.h>
58 #include <tool/action_toolbar.h>
59 #include <tool/common_control.h>
60 #include <tool/common_tools.h>
61 #include <tool/picker_tool.h>
62 #include <tool/tool_dispatcher.h>
63 #include <tool/tool_manager.h>
64 #include <tool/zoom_tool.h>
65 #include <tools/ee_actions.h>
67 #include <tools/ee_point_editor.h>
70 #include <tools/sch_edit_tool.h>
73 #include <tools/sch_move_tool.h>
74 #include <widgets/infobar.h>
76 #include <wx/cmdline.h>
77 
79 
80 // non-member so it can be moved easily, and kept REALLY private.
81 // Do NOT Clear() in here.
82 static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
83 {
84  for( unsigned i=0; i<aSrc.GetCount(); ++i )
85  aDst->AddPaths( aSrc[i], aIndex );
86 }
87 
88 
89 //-----<SCH "data on demand" functions>-------------------------------------------
90 
91 SEARCH_STACK* PROJECT::SchSearchS()
92 {
94 
95  wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
96 
97  if( !ss )
98  {
99  ss = new SEARCH_STACK();
100 
101  // Make PROJECT the new SEARCH_STACK owner.
103 
104  // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
105  ss->AddPaths( m_project_name.GetPath() );
106 
107  // next add the paths found in *.pro, variable "LibDir"
108  wxString libDir;
109 
110  try
111  {
112  PART_LIBS::LibNamesAndPaths( this, false, &libDir );
113  }
114  catch( const IO_ERROR& DBG( ioe ) )
115  {
116  DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );)
117  }
118 
119  if( !!libDir )
120  {
121  wxArrayString paths;
122 
123  SEARCH_STACK::Split( &paths, libDir );
124 
125  for( unsigned i =0; i<paths.GetCount(); ++i )
126  {
127  wxString path = AbsolutePath( paths[i] );
128 
129  ss->AddPaths( path ); // at the end
130  }
131  }
132 
133  // append all paths from aSList
134  add_search_paths( ss, Kiface().KifaceSearch(), -1 );
135  }
136 
137  return ss;
138 }
139 
140 
141 PART_LIBS* PROJECT::SchLibs()
142 {
144 
145  wxASSERT( !libs || libs->Type() == PART_LIBS_T );
146 
147  if( !libs )
148  {
149  libs = new PART_LIBS();
150 
151  // Make PROJECT the new PART_LIBS owner.
153 
154  try
155  {
156  libs->LoadAllLibraries( this );
157  }
158  catch( const PARSE_ERROR& pe )
159  {
160  wxString lib_list = UTF8( pe.inputLine );
161  wxWindow* parent = Pgm().App().GetTopWindow();
162 
163  // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
164  HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
165 
166  dlg.MessageSet( _( "The following libraries were not found:" ) );
167 
168  dlg.ListSet( lib_list );
169 
170  dlg.Layout();
171 
172  dlg.ShowModal();
173  }
174  catch( const IO_ERROR& ioe )
175  {
176  wxWindow* parent = Pgm().App().GetTopWindow();
177 
178  DisplayError( parent, ioe.What() );
179  }
180  }
181 
182  return libs;
183 }
184 
185 //-----</SCH "data on demand" functions>------------------------------------------
186 
187 
188 BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
191 
192  EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
193  EVT_SIZE( SCH_EDIT_FRAME::OnSize )
194 
197 
200 
201  EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
202  EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
203 
205 END_EVENT_TABLE()
206 
207 
208 SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
209  SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
210  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
211  m_highlightedConn( nullptr ),
212  m_item_to_repeat( nullptr )
213 {
214  m_schematic = new SCHEMATIC( nullptr );
215 
216  m_showBorderAndTitleBlock = true; // true to show sheet references
217  m_hasAutoSave = true;
218  m_AboutTitle = "Eeschema";
219 
220  m_findReplaceDialog = nullptr;
221 
222  // Give an icon
223  wxIcon icon;
224  icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
225  SetIcon( icon );
226 
227  LoadSettings( eeconfig() );
228 
229  // Also links the schematic to the loaded project
230  CreateScreens();
231 
232  // After schematic has been linked to project, SCHEMATIC_SETTINGS works
233  m_defaults = &m_schematic->Settings();
234  LoadProjectSettings();
235 
236  setupTools();
237  ReCreateMenuBar();
238  ReCreateHToolbar();
239  ReCreateVToolbar();
240  ReCreateOptToolbar();
241 
242  // Create the infobar
243  m_infoBar = new WX_INFOBAR( this, &m_auimgr );
244 
245  // Initialize common print setup dialog settings.
246  m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
247  m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
248  m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
249  m_pageSetupData.GetPrintData().SetNoCopies( 1 );
250 
251  m_auimgr.SetManagedWindow( this );
252 
253  m_auimgr.AddPane( m_mainToolBar,
254  EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
255  m_auimgr.AddPane( m_optionsToolBar,
256  EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
257  m_auimgr.AddPane( m_drawToolBar,
258  EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
259  m_auimgr.AddPane( m_infoBar,
260  EDA_PANE().InfoBar().Name( "InfoBar" ).Top().Layer(1) );
261  m_auimgr.AddPane( GetCanvas(),
262  EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
263  m_auimgr.AddPane( m_messagePanel,
264  EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
265 
266  // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before
267  // hidding it.
268  m_auimgr.Update();
269 
270  // We don't want the infobar displayed right away
271  m_auimgr.GetPane( "InfoBar" ).Hide();
272  m_auimgr.Update();
273 
274  GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
275 
276  if( GetCanvas() )
277  {
278  GetCanvas()->GetGAL()->SetAxesEnabled( false );
279 
280  if( auto p = dynamic_cast<KIGFX::SCH_PAINTER*>( GetCanvas()->GetView()->GetPainter() ) )
281  p->SetSchematic( m_schematic );
282  }
283 
284  InitExitKey();
285 
286  // Net list generator
287  DefaultExecFlags();
288 
289  UpdateTitle();
290 
291  // Default shutdown reason until a file is loaded
292  SetShutdownBlockReason( _( "New schematic file is unsaved" ) );
293 
294  // Ensure the window is on top
295  Raise();
296 }
297 
298 
300 {
301  // Shutdown all running tools
302  if( m_toolManager )
304 
305  delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
306 
307  SetScreen( NULL );
308 
309  delete m_schematic;
310 }
311 
312 
314 {
315  // Create the manager and dispatcher & route draw panel events to the dispatcher
317  m_toolManager->SetEnvironment( &Schematic(), GetCanvas()->GetView(),
318  GetCanvas()->GetViewControls(), config(), this );
319  m_actions = new EE_ACTIONS();
321 
322  // Register tools
336 
337  // Run the selection tool, it is supposed to be always active
339 
341 }
342 
343 
345 {
346  // we cannot store a pointer to an item in the display list here since
347  // that item may be deleted, such as part of a line concatenation or other.
348  // So simply always keep a copy of the object which is to be repeated.
349 
350  if( aItem )
351  {
352  delete m_item_to_repeat;
353 
354  m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
355  // Clone() preserves the flags, we want 'em cleared.
357  }
358 }
359 
360 
362 {
363  return Schematic().GetSheets().GetItem( aId );
364 }
365 
366 
368 {
369  SCH_SCREEN* screen;
370  SCH_SCREENS s_list( Schematic().Root() );
371 
372  // Set the sheet count, and the sheet number (1 for root sheet)
373  int sheet_count = Schematic().Root().CountSheets();
374  int sheet_number = 1;
375  const KIID_PATH& current_sheetpath = GetCurrentSheet().Path();
376 
377  // Examine all sheets path to find the current sheets path,
378  // and count them from root to the current sheet path:
379  for( const SCH_SHEET_PATH& sheet : Schematic().GetSheets() )
380  {
381  if( sheet.Path() == current_sheetpath ) // Current sheet path found
382  break;
383 
384  sheet_number++; // Not found, increment before this current path
385  }
386 
387  GetCurrentSheet().SetPageNumber( sheet_number );
388 
389  for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
390  screen->m_NumberOfScreens = sheet_count;
391 
392  GetScreen()->m_ScreenNumber = sheet_number;
393 }
394 
395 
397 {
398  return GetCurrentSheet().LastScreen();
399 }
400 
401 
403 {
404  return *m_schematic;
405 }
406 
407 
409 {
410  wxString s = GetCurrentSheet().PathHumanReadable();
411 
412  return s;
413 }
414 
415 
417 {
418  m_schematic->Reset();
419  m_schematic->SetProject( &Prj() );
421 
423 
425 
426  SCH_SCREEN* rootScreen = new SCH_SCREEN( m_schematic );
427  m_schematic->Root().SetScreen( rootScreen );
428  SetScreen( Schematic().RootScreen() );
429 
430  m_schematic->RootScreen()->SetFileName( wxEmptyString );
431 
432  if( GetScreen() == NULL )
433  {
434  SCH_SCREEN* screen = new SCH_SCREEN( m_schematic );
435  SetScreen( screen );
436  }
437 }
438 
439 
441 {
442  return m_schematic->CurrentSheet();
443 }
444 
445 
447 {
448  if( aSheet != GetCurrentSheet() )
449  {
450  FocusOnItem( nullptr );
451 
452  Schematic().SetCurrentSheet( aSheet );
453  GetCanvas()->DisplaySheet( aSheet.LastScreen() );
454  }
455 }
456 
457 
459 {
461 
462  FocusOnItem( nullptr );
463 
464  GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );
465  GetCanvas()->ForceRefresh();
466 }
467 
468 
469 void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
470 {
471  // Shutdown blocks must be determined and vetoed as early as possible
472  if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION
473  && Schematic().GetSheets().IsModified() )
474  {
475  aEvent.Veto();
476  return;
477  }
478 
479  if( Kiface().IsSingle() )
480  {
481  LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
482  if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
483  return;
484 
485  LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
486  if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
487  return;
488 
489  viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
490 
491  if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
492  return;
493  }
494 
495  SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
496 
497  if( simFrame && !simFrame->Close() ) // Can close the simulator?
498  return;
499 
500  SCH_SHEET_LIST sheetlist = Schematic().GetSheets();
501 
502  if( sheetlist.IsModified() )
503  {
504  wxFileName fileName = Schematic().RootScreen()->GetFileName();
505  wxString msg = _( "Save changes to \"%s\" before closing?" );
506 
507  if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ),
508  [&]()->bool { return SaveProject(); } ) )
509  {
510  aEvent.Veto();
511  return;
512  }
513  }
514 
515  //
516  // OK, we're really closing now. No more returns after this.
517  //
518 
519  // Shutdown all running tools ( and commit any pending change )
520  if( m_toolManager )
522 
523  // Close the find dialog and preserve it's setting if it is displayed.
524  if( m_findReplaceDialog )
525  {
528 
529  m_findReplaceDialog->Destroy();
530  m_findReplaceDialog = nullptr;
531  }
532 
533  if( FindHierarchyNavigator() )
534  FindHierarchyNavigator()->Close( true );
535 
536  SCH_SCREENS screens( Schematic().Root() );
537  wxFileName fn;
538 
539  for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
540  {
541  fn = Prj().AbsolutePath( screen->GetFileName() );
542 
543  // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
544  fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
545 
546  if( fn.FileExists() && fn.IsFileWritable() )
547  wxRemoveFile( fn.GetFullPath() );
548  }
549 
550  sheetlist.ClearModifyStatus();
551 
552  wxString fileName = Prj().AbsolutePath( Schematic().RootScreen()->GetFileName() );
553 
554  if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
555  UpdateFileHistory( fileName );
556 
557  Schematic().RootScreen()->Clear();
558 
559  // all sub sheets are deleted, only the main sheet is usable
561 
563  Schematic().SetTemplateFieldNames( nullptr );
564  Schematic().Reset();
565 
566  Destroy();
567 }
568 
569 
571 {
572  // Filename is rootSheetName-sheetName-...-sheetName
573  // Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
574  // name is just a timestamp.
575 
576  wxFileName rootFn( GetCurrentSheet().at( 0 )->GetFileName() );
577  wxString filename = rootFn.GetName();
578 
579  for( unsigned i = 1; i < GetCurrentSheet().size(); i++ )
580  filename += wxT( "-" ) + GetCurrentSheet().at( i )->GetName();
581 
582  return filename;
583 }
584 
585 
587 {
588  wxASSERT( GetScreen() );
589 
590  if( !GetScreen() )
591  return;
592 
593  GetScreen()->SetModify();
594  GetScreen()->SetSave();
595 
596  if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
598 
599  GetCanvas()->Refresh();
600 }
601 
602 
603 void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
604 {
605  if( Kiface().IsSingle() )
606  {
607  DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is opened"
608  " in stand-alone mode. In order to create/update PCBs from"
609  " schematics, launch the Kicad shell and create a project." ) );
610  return;
611  }
612 
613  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
614 
615  if( !frame )
616  {
617  wxFileName fn = Prj().GetProjectFullName();
618  fn.SetExt( PcbFileExtension );
619 
620  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
621  frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
622  }
623 
624  if( !frame->IsVisible() )
625  frame->Show( true );
626 
627  // On Windows, Raise() does not bring the window on screen, when iconized
628  if( frame->IsIconized() )
629  frame->Iconize( false );
630 
631  frame->Raise();
632 
633  std::string payload;
634  Kiway().ExpressMail( FRAME_PCB_EDITOR, MAIL_PCB_UPDATE, payload, this );
635 }
636 
637 
639 {
640  if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
641  && !m_findReplaceData->GetFindString().IsEmpty() )
642  {
643  return m_findReplaceData;
644  }
645 
646  return nullptr;
647 }
648 
649 
651 {
652  wxWindow* navigator = wxWindow::FindWindowByName( HIERARCHY_NAVIG_DLG_WNAME );
653 
654  return static_cast< HIERARCHY_NAVIG_DLG* >( navigator );
655 }
656 
658 {
659  if( aForceUpdate )
660  {
661  if( FindHierarchyNavigator() )
662  FindHierarchyNavigator()->Close();
663 
664  HIERARCHY_NAVIG_DLG* hierarchyDialog = new HIERARCHY_NAVIG_DLG( this );
665 
666  hierarchyDialog->Show( true );
667  }
668  else
669  {
670  if( FindHierarchyNavigator() )
672  }
673 }
674 
675 
677 {
678  if( m_findReplaceDialog )
679  m_findReplaceDialog->Destroy();
680 
681  m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
682  wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
683 
686  m_findReplaceDialog->Show( true );
687 }
688 
689 
690 void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg, int aStatusTime )
691 {
692  // Prepare the infobar, since we don't know its state
695 
696  m_infoBar->ShowMessageFor( aMsg, aStatusTime, wxICON_INFORMATION );
697 }
698 
699 
701 {
702  m_infoBar->Dismiss();
703 }
704 
705 
707 {
710 
711  m_findReplaceDialog->Destroy();
712  m_findReplaceDialog = nullptr;
713 }
714 
715 
716 void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
717 {
718  wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
719 
720  if( fn.size() )
721  OpenProjectFiles( std::vector<wxString>( 1, fn ) );
722 }
723 
724 
725 void SCH_EDIT_FRAME::OnClearFileHistory( wxCommandEvent& aEvent )
726 {
728 }
729 
730 
732 {
733  wxString pro_dir = m_mruPath;
734 
735  wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString,
736  LegacySchematicFileWildcard(), wxFD_SAVE );
737 
738  if( dlg.ShowModal() != wxID_CANCEL )
739  {
740  // Enforce the extension, wxFileDialog is inept.
741  wxFileName create_me = dlg.GetPath();
742  create_me.SetExt( KiCadSchematicFileExtension );
743 
744  if( create_me.FileExists() )
745  {
746  wxString msg;
747  msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
748  DisplayError( this, msg );
749  return ;
750  }
751 
752  // OpenProjectFiles() requires absolute
753  wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
754 
755  OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
756  m_mruPath = create_me.GetPath();
757  }
758 }
759 
760 
762 {
763  wxString pro_dir = m_mruPath;
764  wxString wildcards = KiCadSchematicFileWildcard();
765 
766  wildcards += "|" + LegacySchematicFileWildcard();
767 
768  wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString,
769  wildcards, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
770 
771  if( dlg.ShowModal() != wxID_CANCEL )
772  {
773  OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
775  }
776 }
777 
778 
779 void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
780 {
781  wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() );
782 
783  if( kicad_board.IsOk() )
784  {
785  kicad_board.SetExt( PcbFileExtension );
786  wxFileName legacy_board( kicad_board );
787  legacy_board.SetExt( LegacyPcbFileExtension );
788  wxFileName& boardfn = legacy_board;
789 
790  if( !legacy_board.FileExists() || kicad_board.FileExists() )
791  boardfn = kicad_board;
792 
793  if( Kiface().IsSingle() )
794  {
795  wxString filename = QuoteFullPath( boardfn );
796  ExecuteFile( this, PCBNEW_EXE, filename );
797  }
798  else
799  {
800  KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_EDITOR, false );
801 
802  if( !frame )
803  {
804  frame = Kiway().Player( FRAME_PCB_EDITOR, true );
805  frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
806  }
807 
808  if( !frame->IsVisible() )
809  frame->Show( true );
810 
811  // On Windows, Raise() does not bring the window on screen, when iconized
812  if( frame->IsIconized() )
813  frame->Iconize( false );
814 
815  frame->Raise();
816  }
817  }
818  else
819  {
820  ExecuteFile( this, PCBNEW_EXE );
821  }
822 }
823 
824 
825 void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
826 {
827  wxFileName fn = Prj().AbsolutePath( Schematic().GetFileName() );
828  fn.SetExt( NetlistFileExtension );
829 
830  if( !ReadyToNetlist() )
831  return;
832 
833  try
834  {
835  KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
836 
837  if( !player )
838  {
839  player = Kiway().Player( FRAME_CVPCB, true );
840  player->Show( true );
841  }
842 
844 
845  player->Raise();
846  }
847  catch( const IO_ERROR& )
848  {
849  DisplayError( this, _( "Could not open CvPcb" ) );
850  }
851 }
852 
853 
854 void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
855 {
856  if( event.GetId() == wxID_EXIT )
857  Kiway().OnKiCadExit();
858 
859  if( event.GetId() == wxID_CLOSE || Kiface().IsSingle() )
860  Close( false );
861 }
862 
863 
865 {
866  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
867 
868  aSettings->GetPrintDC()->SetLogicalFunction( wxCOPY );
869  GetScreen()->Print( aSettings );
870  PrintWorkSheet( aSettings, GetScreen(), IU_PER_MILS, fileName );
871 }
872 
873 
875 {
876  // In case this event happens before g_RootSheet is initialized which does happen
877  // on mingw64 builds.
878 
879  if( Schematic().IsValid() )
880  {
881  SCH_SCREENS screenList( Schematic().Root() );
882 
883  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
884  {
885  if( screen->IsSave() )
886  return true;
887  }
888  }
889 
890  return false;
891 }
892 
893 
895  bool aUndoAppend )
896 {
897  wxCHECK_RET( aItem != NULL, wxT( "Cannot add null item to list." ) );
898 
899  SCH_SHEET* parentSheet = nullptr;
900  SCH_COMPONENT* parentComponent = nullptr;
901  SCH_ITEM* undoItem = aItem;
902 
903  if( aItem->Type() == SCH_SHEET_PIN_T )
904  {
905  parentSheet = (SCH_SHEET*) aItem->GetParent();
906 
907  wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
908  wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
909 
910  undoItem = parentSheet;
911  }
912 
913  else if( aItem->Type() == SCH_FIELD_T )
914  {
915  parentComponent = (SCH_COMPONENT*) aItem->GetParent();
916 
917  wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
918  wxT( "Cannot place field in invalid schematic component object." ) );
919 
920  undoItem = parentComponent;
921  }
922 
923  if( aItem->IsNew() )
924  {
925  if( aItem->Type() == SCH_SHEET_PIN_T )
926  {
927  // Sheet pins are owned by their parent sheet.
928  SaveCopyInUndoList( aScreen, undoItem, UR_CHANGED, aUndoAppend );
929 
930  parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
931  }
932  else if( aItem->Type() == SCH_FIELD_T )
933  {
934  // Component fields are also owned by their parent, but new component fields
935  // are handled elsewhere.
936  wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
937  }
938  else
939  {
940  if( !aScreen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
941  AddToScreen( aItem, aScreen );
942 
943  SaveCopyForRepeatItem( aItem );
944  SaveCopyInUndoList( aScreen, undoItem, UR_NEW, aUndoAppend );
945  }
946 
947  // Update connectivity info for new item
948  if( !aItem->IsMoving() )
950  }
951 
952  aItem->ClearFlags( IS_NEW );
953 
954  aScreen->SetModify();
955  RefreshItem( aItem );
956 
957  if( !aItem->IsMoving() && aItem->IsConnectable() )
958  {
959  std::vector< wxPoint > pts;
960  aItem->GetConnectionPoints( pts );
961 
962  for( auto i = pts.begin(); i != pts.end(); i++ )
963  {
964  for( auto j = i + 1; j != pts.end(); j++ )
965  TrimWire( *i, *j );
966 
967  if( aScreen->IsJunctionNeeded( *i, true ) )
968  AddJunction( aScreen, *i, true, false );
969  }
970 
972 
973  for( SCH_ITEM* item : aItem->ConnectedItems( GetCurrentSheet() ) )
974  RefreshItem( item );
975  }
976 
977  aItem->ClearEditFlags();
978  GetCanvas()->Refresh();
979 }
980 
981 
983 {
984  wxString title;
985 
986  if( GetScreen()->GetFileName().IsEmpty() )
987  {
988  title.Printf( _( "Eeschema" ) + wxT( " \u2014" ) + _( " [no file]" ) );
989  }
990  else
991  {
992  wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
993  wxFileName fn = fileName;
994 
995  title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
996  fn.GetFullName(),
998  fn.GetPath() );
999 
1000  if( fn.FileExists() )
1001  {
1002  if( !fn.IsFileWritable() )
1003  title += _( " [Read Only]" );
1004  }
1005  else
1006  title += _( " [no file]" );
1007  }
1008 
1009  SetTitle( title );
1010 }
1011 
1012 
1014 {
1015  SCH_SHEET_LIST list = Schematic().GetSheets();
1016  PROF_COUNTER timer;
1017 
1018  // Ensure schematic graph is accurate
1019  if( aCleanupFlags == LOCAL_CLEANUP )
1020  {
1022  }
1023  else if( aCleanupFlags == GLOBAL_CLEANUP )
1024  {
1025  for( const auto& sheet : list )
1026  SchematicCleanUp( sheet.LastScreen() );
1027  }
1028 
1029  timer.Stop();
1030  wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
1031 
1032  Schematic().ConnectionGraph()->Recalculate( list, true );
1033 }
1034 
1035 
1036 void SCH_EDIT_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
1037 {
1038  SCH_BASE_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
1039 
1041  GetCanvas()->Refresh();
1042 
1043  RecreateToolbars();
1044  Layout();
1045  SendSizeEvent();
1046 }
1047 
1048 
1050 {
1051  // Rebuild the sheet view (draw area and any other items):
1053 }
1054 
1055 
1057 {
1058  // call my base class
1060 
1061  // tooltips in toolbars
1062  RecreateToolbars();
1063 
1064  // status bar
1065  UpdateMsgPanel();
1066 
1067  // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
1068  // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
1069  // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
1070  // toolbar to update correctly.
1071 #if defined( __WXMSW__ )
1072  PostSizeEvent();
1073 #endif
1074 }
1075 
1076 
1078 {
1079  SCH_BASE_FRAME::SetScreen( aScreen );
1080  GetCanvas()->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
1081 }
1082 
1083 
1085 {
1086  int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
1087  int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
1088 
1089  return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
1090 }
1091 
1093 {
1094  // Save the current sheet, to retrieve it later
1095  SCH_SHEET_PATH oldsheetpath = GetCurrentSheet();
1096 
1097  bool modified = false;
1098 
1099  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1100 
1101  for( const SCH_SHEET_PATH& sheet : sheetList )
1102  {
1103  // We require a set here to avoid adding multiple junctions to the same spot
1104  std::set<wxPoint> junctions;
1105 
1106  SetCurrentSheet( sheet );
1108 
1109  SCH_SCREEN* screen = GetCurrentSheet().LastScreen();
1110 
1111  for( auto aItem : screen->Items().OfType( SCH_COMPONENT_T ) )
1112  {
1113  auto cmp = static_cast<SCH_COMPONENT*>( aItem );
1114 
1115  for( const SCH_PIN* pin : cmp->GetSchPins( &sheet ) )
1116  {
1117  auto pos = pin->GetPosition();
1118 
1119  // Test if a _new_ junction is needed, and add it if missing
1120  if( screen->IsJunctionNeeded( pos, true ) )
1121  junctions.insert( pos );
1122  }
1123  }
1124 
1125  for( const wxPoint& pos : junctions )
1126  AddJunction( screen, pos, false, false );
1127 
1128  if( junctions.size() )
1129  modified = true;
1130  }
1131 
1132  if( modified )
1133  OnModify();
1134 
1135  // Reselect the initial sheet:
1136  SetCurrentSheet( oldsheetpath );
1138  SetScreen( GetCurrentSheet().LastScreen() );
1139 }
1140 
1141 
1143 {
1144  return Schematic().GetSheets().IsModified();
1145 }
1146 
1147 
1149 {
1150  EESCHEMA_SETTINGS* cfg = eeconfig();
1151  return cfg->m_Appearance.show_hidden_pins;
1152 }
1153 
1154 
1156 {
1157  static KIID lastBrightenedItemID( niluuid );
1158 
1159  SCH_SHEET_LIST sheetList = Schematic().GetSheets();
1161  SCH_ITEM* lastItem = sheetList.GetItem( lastBrightenedItemID, &dummy );
1162 
1163  if( lastItem && lastItem != aItem )
1164  {
1165  lastItem->ClearBrightened();
1166 
1167  RefreshItem( lastItem );
1168  lastBrightenedItemID = niluuid;
1169  }
1170 
1171  if( aItem )
1172  {
1173  aItem->SetBrightened();
1174 
1175  RefreshItem( aItem );
1176  lastBrightenedItemID = aItem->m_Uuid;
1177 
1178  FocusOnLocation( aItem->GetFocusPosition() );
1179  }
1180 }
1181 
1182 
1184 {
1185  // Remove this once this method is fully implemented. Otherwise, don't use it.
1186  wxCHECK( false, /* void */ );
1187 
1188  // Replace sheet and symbol time stamps with real UUIDs and update symbol instance
1189  // sheet paths using the new UUID based sheet paths.
1190 
1191  // Save the time stamp sheet paths.
1192  SCH_SHEET_LIST timeStampSheetPaths = Schematic().GetSheets();
1193 
1194  std::vector<KIID_PATH> oldSheetPaths = timeStampSheetPaths.GetPaths();
1195 
1196  // The root sheet now gets a permanent UUID.
1197  const_cast<KIID&>( Schematic().Root().m_Uuid ).ConvertTimestampToUuid();
1198 
1199  SCH_SCREENS schematic( Schematic().Root() );
1200 
1201  // Change the sheet and symbol time stamps to UUIDs.
1202  for( SCH_SCREEN* screen = schematic.GetFirst(); screen; screen = schematic.GetNext() )
1203  {
1204  for( auto sheet : screen->Items().OfType( SCH_SHEET_T ) )
1205  const_cast<KIID&>( sheet->m_Uuid ).ConvertTimestampToUuid();
1206 
1207  for( auto symbol : screen->Items().OfType( SCH_COMPONENT_T ) )
1208  const_cast<KIID&>( symbol->m_Uuid ).ConvertTimestampToUuid();
1209  }
1210 
1211  timeStampSheetPaths.ReplaceLegacySheetPaths( oldSheetPaths );
1212 }
1213 
1214 
1216 {
1217  return Schematic().GetFileName();
1218 }
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 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
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:108
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.
KIGFX::SCH_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
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 ...
bool IsModified()
Function IsModified checks the entire hierarchy for any modifications.
SCHEMATIC * m_schematic
The currently loaded schematic.
const wxString & GetFileName() const
Definition: sch_screen.h:185
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:522
wxString LegacySchematicFileWildcard()
SCH_SCREEN * GetNext()
void OnKiCadExit()
Definition: kiway.cpp:527
int m_ScreenNumber
Definition: base_screen.h:79
virtual bool IsConnectable() const
Definition: sch_item.h:370
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:104
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:176
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_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:92
This file is part of the common library TODO brief description.
SETTINGS_MANAGER * GetSettingsManager() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
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.
SCH_ITEM * GetItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr)
Fetch a SCH_ITEM by ID.
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
void SetSave()
Definition: base_screen.h:102
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:42
CONNECTION_GRAPH * ConnectionGraph() const
Definition: schematic.h:132
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
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:371
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
const std::string LegacyPcbFileExtension
void OnSockRequestServer(wxSocketEvent &evt)
Definition: eda_dde.cpp:103
void SetScreen(BASE_SCREEN *aScreen) override
virtual void SetScreen(BASE_SCREEN *aScreen)
void Recalculate(const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false)
Updates the connection graph for the given list of sheets.
void SetPageNumber(int aPageNumber)
#define KICTL_CREATE
caller thinks requested project files may not exist
Definition: kiway_player.h:79
bool IsMoving() const
Definition: base_struct.h:200
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:138
virtual const wxPoint GetFocusPosition() const
Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rath...
Definition: base_struct.h:344
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:151
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
void UpdateAllItems(int aUpdateFlags)
Updates all items in the view according to the given flags.
Definition: view.cpp:1448
wxString KiCadSchematicFileWildcard()
TEMPLATES m_templateFieldNames
void OnCloseWindow(wxCloseEvent &Event)
void SetBrightened()
Definition: base_struct.h:209
virtual void GetConnectionPoints(std::vector< wxPoint > &aPoints) const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:379
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
EDA_ITEM * GetItem(const KIID &aId) override
Fetch an item by KIID.
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.
void PrintWorkSheet(RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the page layout with the frame and the basic inscriptions.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
void OnAppendProject(wxCommandEvent &event)
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.
bool ReadyToNetlist(bool aSilent=false, bool aSilentAnnotate=false)
Checks if we are ready to write a netlist file for the current schematic.
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:247
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:229
wxString GetFileName() const
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:132
void UpdateAllScreenReferences()
Function UpdateAllScreenReferences updates the reference and the m_Multi parameter (part selection) f...
Item needs to be redrawn.
Definition: view_item.h:63
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
const PAGE_INFO & GetPageSettings() const
Definition: sch_screen.h:180
EESCHEMA_SETTINGS * eeconfig()
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:279
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:123
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
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:277
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:199
bool IsNew() const
Definition: base_struct.h:199
void OnImportProject(wxCommandEvent &event)
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:259
void ClearBrightened()
Definition: base_struct.h:212
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches the file name from the file history list.
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
EESCHEMA_SETTINGS * eeconfig() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetRoot(SCH_SHEET *aRootSheet)
Initializes the schematic with a new root sheet.
Definition: schematic.cpp:113
wxString GetScreenDesc() const override
Return a human-readable description of the current screen.
SCH_EDITOR_CONTROL.
TOOL_MANAGER.
Definition: tool_manager.h:51
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
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]
Definition: common.h:68
wxArrayString GetReplaceEntries() const
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Definition: infobar.cpp:139
void SetTemplateFieldNames(TEMPLATES *aTemplates)
Sets up the template fieldnames link if this project is opened in eeschema.
Definition: schematic.cpp:101
#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:342
wxArrayString m_replaceStringHistoryList
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
void UpdateHierarchyTree()
Update the hierarchical tree of the schematic.
Definition: hierarch.cpp:191
size_t size() const
Forwarded method from std::vector.
SCH_LINE_DRAWING_TOOL.
wxFileName m_project_name
<fullpath>/<basename>.pro
Definition: project.h:332
void HardRedraw() override
Rebuild the GAL and redraw the screen.
KICAD_T Type() override
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:43
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.
KIID niluuid(0)
Subclass of DIALOG_DISPLAY_HTML_TEXT_BASE, which is generated by wxFormBuilder.
ACTIONS * m_actions
Definition: tools_holder.h:49
SCHEMATIC & Schematic() const
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.
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
void Print(RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
Definition: sch_screen.cpp:709
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:46
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
bool isAutoSaveRequired() const override
Returns true if the schematic has been modified.
SCH_SHEET_PATH.
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:117
virtual void PrintPage(RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
HTML_MESSAGE_BOX.
SCHEMATIC_SETTINGS * m_defaults
void SetReplaceEntries(const wxArrayString &aEntries)
void SetProject(PROJECT *aPrj)
Definition: schematic.cpp:72
COMMON_CONTROL.
void OnUpdatePCB(wxCommandEvent &event)
void clear()
Forwarded method from std::vector.
void SetFindEntries(const wxArrayString &aEntries)
Specialization of the wxAuiPaneInfo class for KiCad panels.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:212
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...
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:50
EESCHEMA_ACTIONS.
Definition: ee_actions.h:41
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:216
const KIID m_Uuid
Definition: base_struct.h:162
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
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()
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:697
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:432
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:68
void Reset()
Initializes this schematic to a blank one, unloading anything existing.
Definition: schematic.cpp:49
void OnSockRequest(wxSocketEvent &evt)
Definition: eda_dde.cpp:71
void ClearFindReplaceStatus()
SCH_SHEET & Root() const
Definition: schematic.h:97
Struct PARSE_ERROR contains a filename or source description, a problem input line,...
Definition: ki_exception.h:123
The symbol library editor main window.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
see class PGM_BASE
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
void OnExit(wxCommandEvent &event)
SCH_SCREEN * LastScreen()
Function LastScreen.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
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.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void RefreshItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, APP_SETTINGS_BASE *aSettings, TOOLS_HOLDER *aFrame)
Sets the work environment (model, view, view controls and the parent window).
WX_INFOBAR * m_infoBar
wxString QuoteFullPath(wxFileName &fn, wxPathFormat format)
Quote return value of wxFileName::GetFullPath().
Definition: gestfich.cpp: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
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, bool aAppend, const wxPoint &aTransformPoint=wxPoint(0, 0))
Create a copy of the current schematic item, and put it in the undo list.
EE_POINT_EDITOR.
EE_RTREE & Items()
Definition: sch_screen.h:158
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
bool SaveProject(const wxString &aFullPath=wxEmptyString)
Saves a loaded project.
std::vector< KIID_PATH > GetPaths() const
void ReplaceLegacySheetPaths(const std::vector< KIID_PATH > &aOldSheetPaths)
Update all of the symbol sheet paths to the sheet paths defined in aOldSheetPaths.
const std::string KiCadSchematicFileExtension
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.
void OnOpenPcbnew(wxCommandEvent &event)
Schematic symbol object.
Definition: sch_component.h:88
#define IU_PER_MILS
Definition: plotter.cpp:138
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
wxString GetCurrentFileName() const override
Get the full filename + path of the currently opened file in the frame.
#define TO_UTF8(wxstring)
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
~SCH_EDIT_FRAME() override
wxString GetUniqueFilenameForCurrentSheet()
wxFindReplaceData * m_findReplaceData
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void ConvertTimeStampUuids()
Convert sheet and symbol legacy time stamp UUIDs to full UUIDs.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
int m_NumberOfScreens
Definition: base_screen.h:80
SCH_SHEET_PATH & GetCurrentSheet() const
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 FocusOnItem(SCH_ITEM *aItem)
#define DBG(x)
Definition: fctsys.h:33
SCH_SCREEN * GetFirst()
void OnGridSettings(wxCommandEvent &event)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:183
void InitTools()
Function InitTools() Initializes all registered tools.
Definition for part library class.
SCH_SCREEN * RootScreen() const
Helper to retreive the screen of the root sheet.
Definition: schematic.cpp:126
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:100
void ClearEditFlags()
Definition: base_struct.h:251
bool CheckIfOnDrawList(SCH_ITEM *st)
Definition: sch_screen.cpp:303
void SetCurrentSheet(const SCH_SHEET_PATH &aPath)
Definition: schematic.h:127
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions Move the graphic cursor (crosshair cursor...
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
int ExecuteFile(wxWindow *frame, const wxString &ExecFile, const wxString &param, wxProcess *callback)
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
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
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:187
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:528
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:193
void sendNetlistToCvpcb()
Send the kicad netlist over to CVPCB.
virtual void UpdateMsgPanel()
Redraw the message panel.
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:122
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
Definition: infobar.cpp:202