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 
51 
52 //#define USE_SCH_LEGACY_IO_PLUGIN
53 
54 
55 bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName,
56  bool aCreateBackupFile )
57 {
58  wxString msg;
59  wxFileName schematicFileName;
60  bool success;
61 
62  if( aScreen == NULL )
63  aScreen = GetScreen();
64 
65  // If no name exists in the window yet - save as new.
66  if( aScreen->GetFileName().IsEmpty() )
67  aSaveUnderNewName = true;
68 
69  // Construct the name of the file to be saved
70  schematicFileName = Prj().AbsolutePath( aScreen->GetFileName() );
71 
72  if( aSaveUnderNewName )
73  {
74  wxFileDialog dlg( this, _( "Schematic Files" ),
75  wxPathOnly( Prj().GetProjectFullName() ),
76  schematicFileName.GetFullName(), SchematicFileWildcard,
77  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
78 
79  if( dlg.ShowModal() == wxID_CANCEL )
80  return false;
81 
82  schematicFileName = dlg.GetPath();
83 
84  if( schematicFileName.GetExt() != SchematicFileExtension )
85  schematicFileName.SetExt( SchematicFileExtension );
86  }
87 
88  if( !IsWritable( schematicFileName ) )
89  return false;
90 
91  // Create backup if requested
92  if( aCreateBackupFile && schematicFileName.FileExists() )
93  {
94  wxFileName backupFileName = schematicFileName;
95 
96  // Rename the old file to a '.bak' one:
97  backupFileName.SetExt( SchematicBackupFileExtension );
98 
99  if( backupFileName.FileExists() )
100  wxRemoveFile( backupFileName.GetFullPath() );
101 
102  if( !wxRenameFile( schematicFileName.GetFullPath(), backupFileName.GetFullPath() ) )
103  {
104  msg.Printf( _( "Could not save backup of file '%s'" ),
105  GetChars( schematicFileName.GetFullPath() ) );
106  DisplayError( this, msg );
107  }
108  }
109 
110  // Save
111  wxLogTrace( traceAutoSave,
112  wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) );
113 
115 
116  try
117  {
118  pi->Save( schematicFileName.GetFullPath(), aScreen, &Kiway() );
119  success = true;
120  }
121  catch( const IO_ERROR& ioe )
122  {
123  msg.Printf( _( "Error saving schematic file '%s'.\n%s" ),
124  GetChars( schematicFileName.GetFullPath() ), GetChars( ioe.What() ) );
125  DisplayError( this, msg );
126 
127  msg.Printf( _( "Failed to save '%s'" ), GetChars( schematicFileName.GetFullPath() ) );
128  AppendMsgPanel( wxEmptyString, msg, CYAN );
129 
130  success = false;
131  }
132 
133  if( success )
134  {
135  // Delete auto save file.
136  wxFileName autoSaveFileName = schematicFileName;
137  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + schematicFileName.GetName() );
138 
139  if( autoSaveFileName.FileExists() )
140  {
141  wxLogTrace( traceAutoSave,
142  wxT( "Removing auto save file <" ) + autoSaveFileName.GetFullPath() +
143  wxT( ">" ) );
144 
145  wxRemoveFile( autoSaveFileName.GetFullPath() );
146  }
147 
148  // Update the screen and frame info.
149  if( aSaveUnderNewName )
150  aScreen->SetFileName( schematicFileName.GetFullPath() );
151 
152  aScreen->ClrSave();
153  aScreen->ClrModify();
154 
155  msg.Printf( _( "File %s saved" ), GetChars( aScreen->GetFileName() ) );
156  SetStatusText( msg, 0 );
157  }
158  else
159  {
160  DisplayError( this, _( "File write operation failed." ) );
161  }
162 
163  return success;
164 }
165 
166 
167 void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event )
168 {
169  int id = event.GetId();
170 
171  switch( id )
172  {
173  case ID_UPDATE_ONE_SHEET:
174  SaveEEFile( NULL );
175  break;
176 
178  if( SaveEEFile( NULL, true ) )
179  {
181  }
182  break;
183  }
184 
185  UpdateTitle();
186 }
187 
188 
189 bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
190 {
191  // implement the pseudo code from KIWAY_PLAYER.h:
192 
193  SCH_SCREENS screenList;
194 
195  // This is for python:
196  if( aFileSet.size() != 1 )
197  {
198  UTF8 msg = StrPrintf( "Eeschema:%s() takes only a single filename", __func__ );
199  DisplayError( this, msg );
200  return false;
201  }
202 
203  wxString fullFileName( aFileSet[0] );
204 
205  // We insist on caller sending us an absolute path, if it does not, we say it's a bug.
206  wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(),
207  wxT( "bug in single_top.cpp or project manager." ) );
208 
209  if( !LockFile( fullFileName ) )
210  {
211  wxString msg = wxString::Format( _(
212  "Schematic file '%s' is already open." ),
213  GetChars( fullFileName )
214  );
215  DisplayError( this, msg );
216  return false;
217  }
218 
219  // Save any currently open and modified project files.
220  for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
221  {
222  if( screen->IsModify() )
223  {
224  int response = YesNoCancelDialog( this, _(
225  "The current schematic has been modified. Do you wish to save the changes?" ),
226  wxEmptyString,
227  _( "Save and Load" ),
228  _( "Load Without Saving" )
229  );
230 
231  if( response == wxID_CANCEL )
232  {
233  return false;
234  }
235  else if( response == wxID_YES )
236  {
237  wxCommandEvent dummy;
238  OnSaveProject( dummy );
239  }
240  else
241  {
242  // response == wxID_NO, fall thru
243  }
244  break;
245  }
246  }
247 
248  wxFileName pro = fullFileName;
249  pro.SetExt( ProjectFileExtension );
250 
251  bool is_new = !wxFileName::IsFileReadable( fullFileName );
252 
253  // If its a non-existent schematic and caller thinks it exists
254  if( is_new && !( aCtl & KICTL_CREATE ) )
255  {
256  // notify user that fullFileName does not exist, ask if user wants to create it.
257  wxString ask = wxString::Format( _(
258  "Schematic '%s' does not exist. Do you wish to create it?" ),
259  GetChars( fullFileName )
260  );
261  if( !IsOK( this, ask ) )
262  return false;
263  }
264 
265  // unload current project file before loading new
266  {
267  delete g_RootSheet;
268  g_RootSheet = NULL;
269 
270  CreateScreens();
271  }
272 
273  GetScreen()->SetFileName( fullFileName );
274  g_RootSheet->SetFileName( fullFileName );
275 
276  SetStatusText( wxEmptyString );
277  ClearMsgPanel();
278 
279  LoadProjectFile();
280 
281  // PROJECT::SetProjectFullName() is an impactful function. It should only be
282  // called under carefully considered circumstances.
283 
284  // The calling code should know not to ask me here to change projects unless
285  // it knows what consequences that will have on other KIFACEs running and using
286  // this same PROJECT. It can be very harmful if that calling code is stupid.
287 
288  // Don't reload the symbol libraries if we are just launching Eeschema from KiCad again.
289  // They are already saved in the kiface project object.
290  if( pro.GetFullPath() != Prj().GetProjectFullName()
292  {
293  Prj().SetProjectFullName( pro.GetFullPath() );
294 
295  // load the libraries here, not in SCH_SCREEN::Draw() which is a context
296  // that will not tolerate DisplayError() dialog since we're already in an
297  // event handler in there.
298  // And when a schematic file is loaded, we need these libs to initialize
299  // some parameters (links to PART LIB, dangling ends ...)
301  Prj().SchLibs();
302  }
303 
304  // Load the symbol library table, this will be used forever more.
306  Prj().SchSymbolLibTable();
307 
308  if( is_new )
309  {
310  // mark new, unsaved file as modified.
311  GetScreen()->SetModify();
312  }
313  else
314  {
315  delete g_RootSheet; // Delete the current project.
316  g_RootSheet = NULL; // Force CreateScreens() to build new empty project on load failure.
317 
319 
320  try
321  {
322  g_RootSheet = pi->Load( fullFileName, &Kiway() );
323  m_CurrentSheet->clear();
324  m_CurrentSheet->push_back( g_RootSheet );
325  }
326  catch( const IO_ERROR& ioe )
327  {
328  // Do not leave g_RootSheet == NULL because it is expected to be
329  // a valid sheet. Therefore create a dummy empty root sheet and screen.
330  CreateScreens();
331  Zoom_Automatique( false );
332 
333  wxString msg;
334  msg.Printf( _( "Error loading schematic file '%s'.\n%s" ),
335  GetChars( fullFileName ), GetChars( ioe.What() ) );
336  DisplayError( this, msg );
337 
338  msg.Printf( _( "Failed to load '%s'" ), GetChars( fullFileName ) );
339  AppendMsgPanel( wxEmptyString, msg, CYAN );
340 
341  return false;
342  }
343 
345 
346  // It's possible the schematic parser fixed errors due to bugs so warn the user
347  // that the schematic has been fixed (modified).
348  SCH_SHEET_LIST sheetList( g_RootSheet );
349 
350  if( sheetList.IsModified() )
351  {
352  DisplayInfoMessage( this,
353  _( "An error was found when loading the schematic that has "
354  "been automatically fixed. Please save the schematic to "
355  "repair the broken file or it may not be usable with other "
356  "versions of KiCad." ) );
357  }
358 
359  UpdateFileHistory( fullFileName );
360 
361  // Check to see whether some old library parts need to be rescued
362  // Only do this if RescueNeverShow was not set.
363  wxConfigBase *config = Kiface().KifaceSettings();
364  bool rescueNeverShow = false;
365  config->Read( RescueNeverShowEntry, &rescueNeverShow, false );
366 
367  if( !rescueNeverShow )
368  {
369  RescueProject( false );
370  }
371 
372  SCH_SCREENS schematic;
373 
374  schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets.
375  GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
376  }
377 
379  Zoom_Automatique( false );
381  m_canvas->Refresh( true );
382 
383  return true;
384 }
385 
386 
388 {
389  wxString fullFileName;
390 
391  SCH_SCREEN* screen = GetScreen();
392 
393  if( !screen )
394  {
395  wxLogError( wxT( "Document not ready, cannot import" ) );
396  return false;
397  }
398 
399  // open file chooser dialog
400  wxString path = wxPathOnly( Prj().GetProjectFullName() );
401 
402  wxFileDialog dlg( this, _( "Import Schematic" ), path,
403  wxEmptyString, SchematicFileWildcard,
404  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
405 
406  if( dlg.ShowModal() == wxID_CANCEL )
407  return false;
408 
409  fullFileName = dlg.GetPath();
410 
411  wxFileName fn = fullFileName;
412 
413  if( fn.IsRelative() )
414  {
415  fn.MakeAbsolute();
416  fullFileName = fn.GetFullPath();
417  }
418 
419  wxString cache_name = PART_LIBS::CacheName( fullFileName );
420 
421  if( !!cache_name )
422  {
423  PART_LIBS* libs = Prj().SchLibs();
424 
425  try
426  {
427  if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
428  lib->SetCache();
429  }
430  catch( const IO_ERROR& ioe )
431  {
432  DisplayError( this, ioe.What() );
433  }
434  }
435 
436  wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
437 
438  // Keep trace of the last item in list.
439  // New items will be loaded after this one.
440  SCH_ITEM* bs = screen->GetDrawItems();
441 
442  if( bs )
443  {
444  while( bs->Next() )
445  bs = bs->Next();
446  }
447 
448  // load the project
449  bool success = LoadOneEEFile( screen, fullFileName, true );
450 
451  if( success )
452  {
453  // the new loaded items need cleaning to avoid duplicate parameters
454  // which should be unique (ref and time stamp).
455  // Clear ref and set a new time stamp for new items
456  if( bs == NULL )
457  bs = screen->GetDrawItems();
458  else
459  bs = bs->Next();
460 
461  while( bs )
462  {
463  SCH_ITEM* nextbs = bs->Next();
464 
465  // To avoid issues with the current hieratchy,
466  // do not load included sheets files and give new filenames
467  // and new sheet names.
468  // There are many tricky cases (loops, creation of complex hierarchies
469  // with duplicate file names, duplicate sheet names...)
470  // So the included sheets names are renamed if existing,
471  // and filenames are just renamed to avoid loops and
472  // creation of complex hierarchies.
473  // If someone want to change it for a better append function, remember
474  // these cases need work to avoid issues.
475  if( bs->Type() == SCH_SHEET_T )
476  {
477  SCH_SHEET * sheet = (SCH_SHEET *) bs;
478  time_t newtimestamp = GetNewTimeStamp();
479  sheet->SetTimeStamp( newtimestamp );
480 
481  // Check for existing subsheet name in the current sheet
482  wxString tmp = sheet->GetName();
483  sheet->SetName( wxEmptyString );
484  const SCH_SHEET* subsheet = GetScreen()->GetSheet( tmp );
485 
486  if( subsheet )
487  sheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), (long) newtimestamp ) );
488  else
489  sheet->SetName( tmp );
490 
491  sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ),
492  (long) newtimestamp ) );
493  SCH_SCREEN* new_screen = new SCH_SCREEN( &Kiway() );
494  new_screen->SetMaxUndoItems( m_UndoRedoCountMax );
495  sheet->SetScreen( new_screen );
496  sheet->GetScreen()->SetFileName( sheet->GetFileName() );
497  }
498  // clear annotation and init new time stamp for the new components
499  else if( bs->Type() == SCH_COMPONENT_T )
500  {
501  ( (SCH_COMPONENT*) bs )->SetTimeStamp( GetNewTimeStamp() );
502  ( (SCH_COMPONENT*) bs )->ClearAnnotation( NULL );
503 
504  // Clear flags, which are set by these previous modifications:
505  bs->ClearFlags();
506  }
507 
508  bs = nextbs;
509  }
510  }
511 
512  OnModify();
513 
514  // redraw base screen (ROOT) if necessary
516  Zoom_Automatique( false );
518  m_canvas->Refresh( true );
519  return success;
520 }
521 
522 
523 void SCH_EDIT_FRAME::OnAppendProject( wxCommandEvent& event )
524 {
525  wxString msg = _( "This operation cannot be undone. "
526  "Besides, take into account that hierarchical sheets will not be appended.\n\n"
527  "Do you want to save the current document before proceeding?" );
528 
529  if( IsOK( this, msg ) )
530  OnSaveProject( event );
531 
533 }
534 
535 
536 void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent )
537 {
538  SCH_SCREEN* screen;
539  SCH_SCREENS screenList;
540 
541  // I want to see it in the debugger, show me the string! Can't do that with wxFileName.
542  wxString fileName = Prj().AbsolutePath( g_RootSheet->GetFileName() );
543 
544  wxFileName fn = fileName;
545 
546  if( !fn.IsDirWritable() )
547  {
548  wxString msg = wxString::Format( _(
549  "Directory '%s' is not writable" ),
550  GetChars( fn.GetPath() )
551  );
552 
553  DisplayError( this, msg );
554  return;
555  }
556 
557  for( screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
558  SaveEEFile( screen );
559 
561 
562  UpdateTitle();
563 }
564 
565 
567 {
568  wxFileName tmpFileName = g_RootSheet->GetFileName();
569  wxFileName fn = tmpFileName;
570  wxFileName tmp;
571  SCH_SCREENS screens;
572 
573  bool autoSaveOk = true;
574 
575  tmp.AssignDir( fn.GetPath() );
576 
577  if( !tmp.IsOk() )
578  return false;
579 
580  if( !IsWritable( tmp ) )
581  return false;
582 
583  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
584  {
585  // Only create auto save files for the schematics that have been modified.
586  if( !screen->IsSave() )
587  continue;
588 
589  tmpFileName = fn = screen->GetFileName();
590 
591  // Auto save file name is the normal file name prefixed with AUTOSAVE_PREFIX_FILENAME.
592  fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() );
593 
594  screen->SetFileName( fn.GetFullPath() );
595 
596  if( SaveEEFile( screen, false, NO_BACKUP_FILE ) )
597  screen->SetModify();
598  else
599  autoSaveOk = false;
600 
601  screen->SetFileName( tmpFileName.GetFullPath() );
602  }
603 
604  if( autoSaveOk )
605  m_autoSaveState = false;
606 
607  return autoSaveOk;
608 }
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:198
bool m_autoSaveState
Flag to indicate the last auto save state.
Definition: wxstruct.h:146
const wxChar traceAutoSave[]
Custom trace mask to enable and disable auto save tracing.
Definition: basicframe.cpp:53
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
Definition: draw_panel.cpp:326
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:768
const wxString ProjectFileExtension
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:140
static 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:48
#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:105
const wxString & GetFileName() const
#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 wxChar RescueNeverShowEntry[]
void UpdateTitle()
Function UpdateTitle sets the main window title bar text.
Definition: schframe.cpp:1386
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:361
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:532
static const wxString CacheName(const wxString &aFullProjectFilename)
Function cacheName returns the name of the cache library after potentially fixing it from an older na...
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:388
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
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:527
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...
Legacy Eeschema file formats prior to s-expression.
Definition: sch_io_mgr.h:54
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...
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:88
const wxString SchematicFileWildcard
int m_LastGridSizeId
Definition: draw_frame.h:77
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:849
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:541
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:501
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:753
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:492
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)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
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:764
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:235