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