KiCad PCB EDA Suite
eeschema/files-io.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) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013-2017 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 2013 CERN (www.cern.ch)
7  * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
31 #include <fctsys.h>
32 #include <class_drawpanel.h>
33 #include <confirm.h>
34 #include <gestfich.h>
35 #include <schframe.h>
36 #include <pgm_base.h>
37 #include <kiface_i.h>
38 #include <richio.h>
39 
40 #include <eeschema_id.h>
41 #include <class_library.h>
42 #include <libeditframe.h>
43 #include <sch_sheet.h>
44 #include <sch_sheet_path.h>
45 #include <sch_component.h>
47 #include <project_rescue.h>
48 #include <eeschema_config.h>
49 #include <sch_legacy_plugin.h>
50 #include <sch_eagle_plugin.h>
51 
52 
53 //#define USE_SCH_LEGACY_IO_PLUGIN
54 
55 
56 bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
57  bool aCreateBackupFile )
58 {
59  wxString msg;
60  wxFileName schematicFileName;
61  bool success;
62 
63  if( aScreen == NULL )
64  aScreen = GetScreen();
65 
66  // If no name exists in the window yet - save as new.
67  if( aScreen->GetFileName().IsEmpty() )
68  aSaveUnderNewName = true;
69 
70  // Construct the name of the file to be saved
71  schematicFileName = Prj().AbsolutePath( aScreen->GetFileName() );
72 
73  if( aSaveUnderNewName )
74  {
75  wxFileDialog dlg( this, _( "Schematic Files" ),
76  wxPathOnly( Prj().GetProjectFullName() ),
77  schematicFileName.GetFullName(), SchematicFileWildcard,
78  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
79 
80  if( dlg.ShowModal() == wxID_CANCEL )
81  return false;
82 
83  schematicFileName = dlg.GetPath();
84 
85  if( schematicFileName.GetExt() != SchematicFileExtension )
86  schematicFileName.SetExt( SchematicFileExtension );
87  }
88 
89  if( !IsWritable( schematicFileName ) )
90  return false;
91 
92  // Create backup if requested
93  if( aCreateBackupFile && schematicFileName.FileExists() )
94  {
95  wxFileName backupFileName = schematicFileName;
96 
97  // Rename the old file to a '.bak' one:
98  backupFileName.SetExt( SchematicBackupFileExtension );
99 
100  if( backupFileName.FileExists() )
101  wxRemoveFile( backupFileName.GetFullPath() );
102 
103  if( !wxRenameFile( schematicFileName.GetFullPath(), backupFileName.GetFullPath() ) )
104  {
105  msg.Printf( _( "Could not save backup of file '%s'" ),
106  GetChars( schematicFileName.GetFullPath() ) );
107  DisplayError( this, msg );
108  }
109  }
110 
111  // Save
112  wxLogTrace( traceAutoSave,
113  wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) );
114 
115  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
116 
117  try
118  {
119  pi->Save( schematicFileName.GetFullPath(), aScreen, &Kiway() );
120  success = true;
121  }
122  catch( const IO_ERROR& ioe )
123  {
124  msg.Printf( _( "Error saving schematic file '%s'.\n%s" ),
125  GetChars( schematicFileName.GetFullPath() ), GetChars( ioe.What() ) );
126  DisplayError( this, msg );
127 
128  msg.Printf( _( "Failed to save '%s'" ), GetChars( schematicFileName.GetFullPath() ) );
129  AppendMsgPanel( wxEmptyString, msg, CYAN );
130 
131  success = false;
132  }
133 
134  if( success )
135  {
136  // Delete auto save file.
137  wxFileName autoSaveFileName = schematicFileName;
138  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + schematicFileName.GetName() );
139 
140  if( autoSaveFileName.FileExists() )
141  {
142  wxLogTrace( traceAutoSave,
143  wxT( "Removing auto save file <" ) + autoSaveFileName.GetFullPath() +
144  wxT( ">" ) );
145 
146  wxRemoveFile( autoSaveFileName.GetFullPath() );
147  }
148 
149  // Update the screen and frame info.
150  if( aSaveUnderNewName )
151  aScreen->SetFileName( schematicFileName.GetFullPath() );
152 
153  aScreen->ClrSave();
154  aScreen->ClrModify();
155 
156  msg.Printf( _( "File %s saved" ), GetChars( aScreen->GetFileName() ) );
157  SetStatusText( msg, 0 );
158  }
159  else
160  {
161  DisplayError( this, _( "File write operation failed." ) );
162  }
163 
164  return success;
165 }
166 
167 
168 void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event )
169 {
170  int id = event.GetId();
171 
172  switch( id )
173  {
174  case ID_UPDATE_ONE_SHEET:
175  SaveEEFile( NULL );
176  break;
177 
179  if( SaveEEFile( NULL, true ) )
180  {
182  }
183  break;
184  }
185 
186  UpdateTitle();
187 }
188 
189 
190 bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
191 {
192  // implement the pseudo code from KIWAY_PLAYER.h:
193 
194  // This is for python:
195  if( aFileSet.size() != 1 )
196  {
197  UTF8 msg = StrPrintf( "Eeschema:%s() takes only a single filename", __func__ );
198  DisplayError( this, msg );
199  return false;
200  }
201 
202  wxString fullFileName( aFileSet[0] );
203 
204  // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
205  wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(),
206  wxT( "bug in single_top.cpp or project manager." ) );
207 
208  if( !LockFile( fullFileName ) )
209  {
210  wxString msg = wxString::Format( _(
211  "Schematic file '%s' is already open." ),
212  GetChars( fullFileName )
213  );
214  DisplayError( this, msg );
215  return false;
216  }
217 
218  if( !AskToSaveChanges() )
219  return false;
220 
221  wxFileName pro = fullFileName;
222  pro.SetExt( ProjectFileExtension );
223 
224  bool is_new = !wxFileName::IsFileReadable( fullFileName );
225 
226  // If its a non-existent schematic and caller thinks it exists
227  if( is_new && !( aCtl & KICTL_CREATE ) )
228  {
229  // notify user that fullFileName does not exist, ask if user wants to create it.
230  wxString ask = wxString::Format( _(
231  "Schematic '%s' does not exist. Do you wish to create it?" ),
232  GetChars( fullFileName )
233  );
234  if( !IsOK( this, ask ) )
235  return false;
236  }
237 
238  // unload current project file before loading new
239  {
240  delete g_RootSheet;
241  g_RootSheet = NULL;
242 
243  CreateScreens();
244  }
245 
246  GetScreen()->SetFileName( fullFileName );
247  g_RootSheet->SetFileName( fullFileName );
248 
249  SetStatusText( wxEmptyString );
250  ClearMsgPanel();
251 
252  LoadProjectFile();
253 
254  // PROJECT::SetProjectFullName() is an impactful function. It should only be
255  // called under carefully considered circumstances.
256 
257  // The calling code should know not to ask me here to change projects unless
258  // it knows what consequences that will have on other KIFACEs running and using
259  // this same PROJECT. It can be very harmful if that calling code is stupid.
260 
261  // Don't reload the symbol libraries if we are just launching Eeschema from KiCad again.
262  // They are already saved in the kiface project object.
263  if( pro.GetFullPath() != Prj().GetProjectFullName()
265  {
266  Prj().SetProjectFullName( pro.GetFullPath() );
267 
268  // load the libraries here, not in SCH_SCREEN::Draw() which is a context
269  // that will not tolerate DisplayError() dialog since we're already in an
270  // event handler in there.
271  // And when a schematic file is loaded, we need these libs to initialize
272  // some parameters (links to PART LIB, dangling ends ...)
274  Prj().SchLibs();
275  }
276 
277  // Load the symbol library table, this will be used forever more.
279  Prj().SchSymbolLibTable();
280 
281  if( is_new )
282  {
283  // mark new, unsaved file as modified.
284  GetScreen()->SetModify();
285  }
286  else
287  {
288  delete g_RootSheet; // Delete the current project.
289  g_RootSheet = NULL; // Force CreateScreens() to build new empty project on load failure.
290  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_LEGACY ) );
291 
292  try
293  {
294  g_RootSheet = pi->Load( fullFileName, &Kiway() );
295  m_CurrentSheet->clear();
296  m_CurrentSheet->push_back( g_RootSheet );
297  }
298  catch( const IO_ERROR& ioe )
299  {
300  // Do not leave g_RootSheet == NULL because it is expected to be
301  // a valid sheet. Therefore create a dummy empty root sheet and screen.
302  CreateScreens();
303  Zoom_Automatique( false );
304 
305  wxString msg;
306  msg.Printf( _( "Error loading schematic file '%s'.\n%s" ),
307  GetChars( fullFileName ), GetChars( ioe.What() ) );
308  DisplayError( this, msg );
309 
310  msg.Printf( _( "Failed to load '%s'" ), GetChars( fullFileName ) );
311  AppendMsgPanel( wxEmptyString, msg, CYAN );
312 
313  return false;
314  }
315 
317 
318  // It's possible the schematic parser fixed errors due to bugs so warn the user
319  // that the schematic has been fixed (modified).
320  SCH_SHEET_LIST sheetList( g_RootSheet );
321 
322  if( sheetList.IsModified() )
323  {
324  DisplayInfoMessage( this,
325  _( "An error was found when loading the schematic that has "
326  "been automatically fixed. Please save the schematic to "
327  "repair the broken file or it may not be usable with other "
328  "versions of KiCad." ) );
329  }
330 
331  UpdateFileHistory( fullFileName );
332 
333  // Check to see whether some old library parts need to be rescued
334  // Only do this if RescueNeverShow was not set.
335  wxConfigBase *config = Kiface().KifaceSettings();
336  bool rescueNeverShow = false;
337  config->Read( RescueNeverShowEntry, &rescueNeverShow, false );
338 
339  if( !rescueNeverShow )
340  {
341  RescueProject( false );
342  }
343 
344  SCH_SCREENS schematic;
345 
346  schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
347  GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
348  }
349 
351  Zoom_Automatique( false );
353  m_canvas->Refresh( true );
354 
355  return true;
356 }
357 
358 
360 {
361  wxString fullFileName;
362 
363  SCH_SCREEN* screen = GetScreen();
364 
365  if( !screen )
366  {
367  wxLogError( wxT( "Document not ready, cannot import" ) );
368  return false;
369  }
370 
371  // open file chooser dialog
372  wxString path = wxPathOnly( Prj().GetProjectFullName() );
373 
374  wxFileDialog dlg( this, _( "Append Schematic" ), path,
375  wxEmptyString, SchematicFileWildcard,
376  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
377 
378  if( dlg.ShowModal() == wxID_CANCEL )
379  return false;
380 
381  fullFileName = dlg.GetPath();
382 
383  wxFileName fn = fullFileName;
384 
385  if( fn.IsRelative() )
386  {
387  fn.MakeAbsolute();
388  fullFileName = fn.GetFullPath();
389  }
390 
391  wxString cache_name = PART_LIBS::CacheName( fullFileName );
392 
393  if( !!cache_name )
394  {
395  PART_LIBS* libs = Prj().SchLibs();
396 
397  try
398  {
399  if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
400  lib->SetCache();
401  }
402  catch( const IO_ERROR& ioe )
403  {
404  DisplayError( this, ioe.What() );
405  }
406  }
407 
408  wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
409 
410  // Keep trace of the last item in list.
411  // New items will be loaded after this one.
412  SCH_ITEM* bs = screen->GetDrawItems();
413 
414  if( bs )
415  {
416  while( bs->Next() )
417  bs = bs->Next();
418  }
419 
420  // load the project
421  bool success = LoadOneEEFile( screen, fullFileName, true );
422 
423  if( success )
424  {
425  // the new loaded items need cleaning to avoid duplicate parameters
426  // which should be unique (ref and time stamp).
427  // Clear ref and set a new time stamp for new items
428  if( bs == NULL )
429  bs = screen->GetDrawItems();
430  else
431  bs = bs->Next();
432 
433  while( bs )
434  {
435  SCH_ITEM* nextbs = bs->Next();
436 
437  // To avoid issues with the current hieratchy,
438  // do not load included sheets files and give new filenames
439  // and new sheet names.
440  // There are many tricky cases (loops, creation of complex hierarchies
441  // with duplicate file names, duplicate sheet names...)
442  // So the included sheets names are renamed if existing,
443  // and filenames are just renamed to avoid loops and
444  // creation of complex hierarchies.
445  // If someone want to change it for a better append function, remember
446  // these cases need work to avoid issues.
447  if( bs->Type() == SCH_SHEET_T )
448  {
449  SCH_SHEET * sheet = (SCH_SHEET *) bs;
450  time_t newtimestamp = GetNewTimeStamp();
451  sheet->SetTimeStamp( newtimestamp );
452 
453  // Check for existing subsheet name in the current sheet
454  wxString tmp = sheet->GetName();
455  sheet->SetName( wxEmptyString );
456  const SCH_SHEET* subsheet = GetScreen()->GetSheet( tmp );
457 
458  if( subsheet )
459  sheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), (long) newtimestamp ) );
460  else
461  sheet->SetName( tmp );
462 
463  sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ),
464  (long) newtimestamp ) );
465  SCH_SCREEN* new_screen = new SCH_SCREEN( &Kiway() );
466  new_screen->SetMaxUndoItems( m_UndoRedoCountMax );
467  sheet->SetScreen( new_screen );
468  sheet->GetScreen()->SetFileName( sheet->GetFileName() );
469  }
470  // clear annotation and init new time stamp for the new components
471  else if( bs->Type() == SCH_COMPONENT_T )
472  {
473  ( (SCH_COMPONENT*) bs )->SetTimeStamp( GetNewTimeStamp() );
474  ( (SCH_COMPONENT*) bs )->ClearAnnotation( NULL );
475 
476  // Clear flags, which are set by these previous modifications:
477  bs->ClearFlags();
478  }
479 
480  bs = nextbs;
481  }
482  }
483 
484  OnModify();
485 
486  // redraw base screen (ROOT) if necessary
488  Zoom_Automatique( false );
490  m_canvas->Refresh( true );
491  return success;
492 }
493 
494 
495 void SCH_EDIT_FRAME::OnAppendProject( wxCommandEvent& event )
496 {
497  wxString msg = _( "This operation cannot be undone. "
498  "Besides, take into account that hierarchical sheets will not be appended.\n\n"
499  "Do you want to save the current document before proceeding?" );
500 
501  if( IsOK( this, msg ) )
502  OnSaveProject( event );
503 
505 }
506 
507 
508 void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
509 {
510  if( !AskToSaveChanges() )
511  return;
512 
513  wxString path = wxPathOnly( Prj().GetProjectFullName() );
514 
515  wxFileDialog dlg( this, _( "Import Schematic" ), path,
516  wxEmptyString, EagleSchematicFileWildcard,
517  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
518 
519  if( dlg.ShowModal() == wxID_CANCEL )
520  return;
521 
522  // For now there is only one import plugin
523  ImportFile( dlg.GetPath(), SCH_IO_MGR::SCH_EAGLE );
524 }
525 
526 
527 void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent )
528 {
529  SCH_SCREEN* screen;
530  SCH_SCREENS screenList;
531 
532  // I want to see it in the debugger, show me the string! Can't do that with wxFileName.
533  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetFileName() );
534 
535  wxFileName fn = fileName;
536 
537  if( !fn.IsDirWritable() )
538  {
539  wxString msg = wxString::Format( _(
540  "Directory '%s' is not writable" ),
541  GetChars( fn.GetPath() )
542  );
543 
544  DisplayError( this, msg );
545  return;
546  }
547 
548  for( screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
549  SaveEEFile( screen );
550 
552 
553  UpdateTitle();
554 }
555 
556 
558 {
559  wxFileName tmpFileName = g_RootSheet->GetFileName();
560  wxFileName fn = tmpFileName;
561  wxFileName tmp;
562  SCH_SCREENS screens;
563 
564  bool autoSaveOk = true;
565 
566  tmp.AssignDir( fn.GetPath() );
567 
568  if( !tmp.IsOk() )
569  return false;
570 
571  if( !IsWritable( tmp ) )
572  return false;
573 
574  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
575  {
576  // Only create auto save files for the schematics that have been modified.
577  if( !screen->IsSave() )
578  continue;
579 
580  tmpFileName = fn = screen->GetFileName();
581 
582  // Auto save file name is the normal file name prefixed with AUTOSAVE_PREFIX_FILENAME.
583  fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() );
584 
585  screen->SetFileName( fn.GetFullPath() );
586 
587  if( SaveEEFile( screen, false, NO_BACKUP_FILE ) )
588  screen->SetModify();
589  else
590  autoSaveOk = false;
591 
592  screen->SetFileName( tmpFileName.GetFullPath() );
593  }
594 
595  if( autoSaveOk )
596  m_autoSaveState = false;
597 
598  return autoSaveOk;
599 }
600 
601 
602 bool SCH_EDIT_FRAME::ImportFile( const wxString& aFileName, int aFileType )
603 {
604  wxString fullFileName( aFileName );
605 
607  wxString projectpath;
608  wxFileName newfilename;
609  SCH_SHEET_LIST sheetList( g_RootSheet );
610  SCH_SCREENS schematic;
611 
612  switch( (SCH_IO_MGR::SCH_FILE_T) aFileType )
613  {
614  case SCH_IO_MGR::SCH_EAGLE:
615  // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
616  wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(),
617  wxT( "Import eagle schematic caller didn't send full filename" ) );
618 
619  if( !LockFile( fullFileName ) )
620  {
621  wxString msg = wxString::Format( _( "Schematic file '%s' is already open." ),
622  GetChars( fullFileName ) );
623  DisplayError( this, msg );
624  return false;
625  }
626 
627  try
628  {
629  pi.set( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ) );
630  g_RootSheet = pi->Load( fullFileName, &Kiway() );
631 
632  projectpath = Kiway().Prj().GetProjectPath();
633  newfilename = Prj().AbsolutePath( Prj().GetProjectName() );
634  newfilename.SetExt( SchematicFileExtension );
635 
636  m_CurrentSheet->clear();
637  m_CurrentSheet->push_back( g_RootSheet );
639 
640  g_RootSheet->SetFileName( newfilename.GetFullPath() );
641  GetScreen()->SetFileName( newfilename.GetFullPath() );
642  GetScreen()->SetModify();
643 
644  UpdateFileHistory( fullFileName );
645  schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
646  GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
647 
649  Zoom_Automatique( false );
651  m_canvas->Refresh( true );
652  UpdateTitle();
653  }
654  catch( const IO_ERROR& ioe )
655  {
656  // Do not leave g_RootSheet == NULL because it is expected to be
657  // a valid sheet. Therefore create a dummy empty root sheet and screen.
658  CreateScreens();
659  Zoom_Automatique( false );
660 
661  wxString msg;
662  msg.Printf( _( "Error loading schematic file '%s'.\n%s" ),
663  GetChars( fullFileName ), GetChars( ioe.What() ) );
664  DisplayError( this, msg );
665 
666  msg.Printf( _( "Failed to load '%s'" ), GetChars( fullFileName ) );
667  AppendMsgPanel( wxEmptyString, msg, CYAN );
668 
669  return false;
670  }
671 
672  return true;
673 
674  default:
675  return false;
676  }
677 
678  return false;
679 }
680 
681 
683 {
684  SCH_SCREENS screenList;
685 
686  // Save any currently open and modified project files.
687  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
688  {
689  if( screen->IsModify() )
690  {
691  int response = YesNoCancelDialog( m_parent, _(
692  "The current schematic has been modified. Do you wish to save the changes?" ),
693  wxEmptyString,
694  _( "Save and Load" ),
695  _( "Load Without Saving" )
696  );
697 
698  if( response == wxID_CANCEL )
699  {
700  return false;
701  }
702  else if( response == wxID_YES )
703  {
704  wxCommandEvent dummy;
705  OnSaveProject( dummy );
706  }
707  // else wxID_NO, so do not save
708 
709  break;
710  }
711  }
712 
713  return true;
714 }
Definition of the SCH_SHEET class for Eeschema.
Class UTF8 is an 8 bit string that is assuredly encoded in UTF8, and supplies special conversion supp...
Definition: utf8.h:73
Class SCH_SHEET_LIST.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:155
SCH_SCREEN * GetNext()
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
This file is part of the common library TODO brief description.
bool RescueProject(bool aRunningOnDemand)
Function RescueProject performs rescue operations to recover old projects from before certain changes...
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
This file is part of the common library.
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:503
SCH_SHEET * GetSheet(const wxString &aName)
Function GetSheet returns a sheet object pointer that is named aName.
Definition: sch_screen.cpp:684
void OnModify()
Function OnModify Must be called after a schematic change in order to set the "modify" flag of the cu...
Definition: schframe.cpp:771
const wxString ProjectFileExtension
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:141
static APIEXPORT SCH_PLUGIN * FindPlugin(SCH_FILE_T aFileType)
Return a SCH_PLUGIN which the caller can use to import, export, save, or load design documents...
Definition: sch_io_mgr.cpp:49
#define KICTL_CREATE
caller thinks requested project files may not exist
Definition: kiway_player.h:131
void SetScreen(SCH_SCREEN *aScreen)
Function SetScreen sets the screen associated with this sheet to aScreen.
Definition: sch_sheet.cpp:103
const wxString & GetFileName() const
bool AskToSaveChanges()
Checks whether any of the screens has unsaved changes and asks the user whether to save or drop them...
#define NO_BACKUP_FILE
Definition: wxstruct.h:60
virtual SCH_SHEET * Load(const wxString &aFileName, KIWAY *aKiway, SCH_SHEET *aAppendToMe=NULL, const PROPERTIES *aProperties=NULL)
Load information from some input file format that this SCH_PLUGIN implementation knows about...
Definition: sch_plugin.cpp:58
time_t GetNewTimeStamp()
Definition: common.cpp:166
const wxString EagleSchematicFileWildcard
const wxChar RescueNeverShowEntry[]
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
Definition: schframe.cpp:1404
void OnAppendProject(wxCommandEvent &event)
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:380
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:541
SCH_SCREEN * LastScreen() const
Function LastScreen.
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:196
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:553
static const wxString CacheName(const wxString &aFullProjectFilename)
Function cacheName returns the name of the cache library after potentially fixing it from an older na...
bool ImportFile(const wxString &aFileName, int aFileType) override
Function ImportFile load the given filename but sets the path to the current project path...
SCH_SCREEN * GetScreen()
Definition: sch_sheet.h:286
SCH_ITEM * Next() const
void UpdateFileHistory(const wxString &FullFileName, wxFileHistory *aFileHistory=NULL)
Function UpdateFileHistory Updates the list of recently opened files.
Definition: basicframe.cpp:407
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:217
void OnImportProject(wxCommandEvent &event)
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:208
int StrPrintf(std::string *result, const char *format,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:75
SCH_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: schframe.cpp:530
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SCH_SHEET_PATH * m_CurrentSheet
which sheet we are presently working on.
Definition: schframe.h:120
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:77
void Save_File(wxCommandEvent &event)
SCH_SHEET * g_RootSheet
Definition: eeschema.cpp:55
bool AppendOneEEProject()
Function AppendOneEEProject read an entire project and loads it into the schematic editor without rep...
void SetName(const wxString &aName)
Definition: sch_sheet.h:276
void UpdateSymbolLinks()
initializes or reinitializes the weak reference to the LIB_PART for each SCH_COMPONENT found in the f...
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:144
PART_LIB * AddLibrary(const wxString &aFileName)
Function AddLibrary allocates and adds a part library to the library list.
Definition: colors.h:59
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:371
The common library.
bool SaveEEFile(SCH_SCREEN *aScreen, bool aSaveUnderNewName=false, bool aCreateBackupFile=CREATE_BACKUP_FILE)
Function SaveEEFile saves aScreen to a schematic file.
bool CreateArchiveLibraryCacheFile(bool aUseCurrentSheetFilename=false)
Function CreateArchiveLibraryCacheFile creates a library file with the name of the root document plus...
Definition: libarch.cpp:43
void OnSaveProject(wxCommandEvent &aEvent)
Function OnSaveProject is the command event handler to save the entire project and create a component...
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
bool LoadProjectFile()
Function LoadProjectFile loads the KiCad project file (*.pro) settings specific to Eeschema...
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString aExtraInfo)
Function DisplayInfoMessage displays an informational message box with aMessage.
Definition: confirm.cpp:102
int m_UndoRedoCountMax
default Undo/Redo command Max depth, to be handed
Definition: draw_frame.h:89
const wxString SchematicFileWildcard
int m_LastGridSizeId
Definition: draw_frame.h:78
VTBL_ENTRY void SetProjectFullName(const wxString &aFullPathAndName)
Function SetProjectFullName sets the: 1) full directory, 2) basename, and 3) extension of the project...
Definition: project.cpp:65
wxString GetFileName(void) const
Function GetFileName return the filename corresponding to this sheet.
Definition: sch_sheet.cpp:880
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
virtual bool doAutoSave() override
Function doAutoSave saves the schematic files that have been modified and not yet saved...
const wxString SchematicFileExtension
void CreateScreens()
Definition: schframe.cpp:544
Class PART_LIBS is a collection of PART_LIBs.
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:513
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:764
SCH_ITEM * GetDrawItems() const
Function GetDrawItems().
Definition the SCH_COMPONENT class for Eeschema.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
see class PGM_BASE
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
const wxString SchematicBackupFileExtension
void SetSheetNumberAndCount()
Function SetSheetNumberAndCount Set the m_ScreenNumber and m_NumberOfScreens members for screens must...
Definition: schframe.cpp:495
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
bool LoadOneEEFile(SCH_SCREEN *aScreen, const wxString &aFullFileName, bool append=false)
Function LoadOneEEFile loads the schematic (.sch) file aFullFileName into aScreen.
bool TestDanglingEnds()
Function TestDanglingEnds tests all of the connectible objects in the schematic for unused connection...
Definition: sch_screen.cpp:915
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
void SetMaxUndoItems(int aMax)
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
SCH_SCREEN * GetFirst()
void SetFileName(const wxString &aFileName)
Definition for part library class.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
Definition: wxstruct.h:71
wxString GetName() const
Definition: sch_sheet.h:274
Class PART_LIB is used to load, save, search, and otherwise manipulate part library files...
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:47
int YesNoCancelDialog(wxWindow *aParent, const wxString &aPrimaryMessage, const wxString &aSecondaryMessage, const wxString &aYesButtonText, const wxString &aNoButtonText, const wxString &aCancelButtonText)
Function YesNoCancelDialog displays a yes/no/cancel dialog with aMessage and returns the user respons...
Definition: confirm.cpp:166
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:129
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:775
Definition of class LIB_EDIT_FRAME.
Class SCH_SCREENS is a container class that holds multiple SCH_SCREENs in a hierarchy.
bool LockFile(const wxString &aFileName)
Function LockFile marks a schematic file as being in use.
Definition: draw_frame.cpp:246
const wxChar traceAutoSave[]
Flag to enable auto save feature debug tracing.
Definition: basicframe.cpp:53