KiCad PCB EDA Suite
sheet.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2004-2020 KiCad Developers, see change_log.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 <sch_draw_panel.h>
26 #include <confirm.h>
27 #include <kiface_i.h>
28 #include <project.h>
30 #include <tool/tool_manager.h>
31 #include <wx/clipbrd.h>
32 #include <sch_edit_frame.h>
34 #include <sch_sheet.h>
35 #include <sch_sheet_path.h>
36 #include <sch_view.h>
37 #include <sch_painter.h>
38 #include <schematic.h>
39 #include <symbol_lib_table.h>
41 #include <tool/actions.h>
42 
43 
45 {
46  wxASSERT( aSheet && aHierarchy );
47 
48  wxString msg;
49  SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // The full schematic sheet hierarchy.
50  SCH_SHEET_LIST sheetHierarchy( aSheet ); // This is the hierarchy of the loaded file.
51 
52  wxFileName destFile = aHierarchy->LastScreen()->GetFileName();
53 
54  // SCH_SCREEN object file paths are expected to be absolute. If this assert fires,
55  // something is seriously broken.
56  wxASSERT( destFile.IsAbsolute() );
57 
58  if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath() ) )
59  {
60  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
61  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
62  "the schematic hierarchy." ),
63  destFile.GetFullPath() );
64  DisplayError( this, msg );
65  return true;
66  }
67 
68  return false;
69 }
70 
71 
73 {
74  wxASSERT( aSheet && aSheet->GetScreen() );
75 
76  wxString msg;
77  SCH_SCREENS newScreens( aSheet );
78 
79  if( newScreens.HasNoFullyDefinedLibIds() )
80  {
81  msg.Printf( _( "The schematic \"%s\" has not had it's symbol library links remapped "
82  "to the symbol library table. The project this schematic belongs to "
83  "must first be remapped before it can be imported into the current "
84  "project." ), aSheet->GetScreen()->GetFileName() );
85  DisplayInfoMessage( this, msg );
86  return true;
87  }
88 
89  return false;
90 }
91 
92 
93 void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename )
94 {
95  aSheet->SetScreen( new SCH_SCREEN( &Schematic() ) );
96  aSheet->GetScreen()->SetModify();
97  aSheet->GetScreen()->SetFileName( aNewFilename );
98 }
99 
100 
102  const wxString& aFileName )
103 {
104  wxASSERT( aSheet && aHierarchy );
105 
106  wxString msg;
107  wxString topLevelSheetPath;
108  wxFileName tmp;
109  wxFileName currentSheetFileName;
110  bool libTableChanged = false;
111  SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
112  SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( aFileName );
113  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( schFileType ) );
114  std::unique_ptr< SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( &Schematic() );
115 
116  // This will cause the sheet UUID to be set to the loaded schematic UUID. This is required
117  // to ensure all of the sheet paths in any subsheets are correctly generated.
118  const_cast<KIID&>( newSheet->m_Uuid ) = KIID( 0 );
119 
120  wxFileName fileName( aFileName );
121 
122  if( !fileName.IsAbsolute() && !fileName.MakeAbsolute() )
123  {
124  wxFAIL_MSG( wxString::Format( "Cannot make file name \"%s\" path absolute.", aFileName ) );
125  return false;
126  }
127 
128  wxString fullFilename = fileName.GetFullPath();
129 
130  try
131  {
132  if( aSheet->GetScreen() != nullptr )
133  {
134  newSheet.reset( pi->Load( fullFilename, &Schematic() ) );
135  }
136  else
137  {
138  newSheet->SetFileName( fullFilename );
139  pi->Load( fullFilename, &Schematic(), newSheet.get() );
140  }
141 
142  if( !pi->GetError().IsEmpty() )
143  {
144  msg = _( "The entire schematic could not be loaded. Errors occurred attempting "
145  "to load hierarchical sheet schematics." );
146 
147  wxMessageDialog msgDlg1( this, msg, _( "Schematic Load Error" ),
148  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
149  wxCENTER | wxICON_QUESTION );
150  msgDlg1.SetOKLabel( wxMessageDialog::ButtonLabel( _( "Use partial schematic" ) ) );
151  msgDlg1.SetExtendedMessage( pi->GetError() );
152 
153  if( msgDlg1.ShowModal() == wxID_CANCEL )
154  return false;
155  }
156  }
157  catch( const IO_ERROR& ioe )
158  {
159  msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), fullFilename );
160  DisplayErrorMessage( this, msg, ioe.What() );
161 
162  msg.Printf( _( "Failed to load schematic \"%s\"" ), fullFilename );
163  SetMsgPanel( wxEmptyString, msg );
164 
165  return false;
166  }
167 
168  tmp = fileName;
169 
170  // If the loaded schematic is in a different folder from the current project and
171  // it contains hierarchical sheets, the hierarchical sheet paths need to be updated.
172  if( fileName.GetPathWithSep() != Prj().GetProjectPath() && newSheet->CountSheets() )
173  {
174  // Give the user the option to choose relative path if possible.
175  if( tmp.MakeRelativeTo( Prj().GetProjectPath() ) )
176  topLevelSheetPath = tmp.GetPathWithSep();
177  else
178  topLevelSheetPath = fileName.GetPathWithSep();
179 
180  if( wxFileName::GetPathSeparator() == '\\' )
181  topLevelSheetPath.Replace( "\\", "/" );
182  }
183 
184  // Make sure any new sheet changes do not cause any recursion issues.
185  SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
186  SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the loaded file.
187 
188  if( CheckSheetForRecursion( newSheet.get(), aHierarchy )
189  || checkForNoFullyDefinedLibIds( newSheet.get() ) )
190  {
191  return false;
192  }
193 
194  // Make a valiant attempt to warn the user of all possible scenarios where there could
195  // be broken symbol library links.
196  wxArrayString names;
197  wxArrayString newLibNames;
198  SCH_SCREENS newScreens( newSheet.get() ); // All screens associated with the import.
199  SCH_SCREENS prjScreens( &Schematic().Root() );
200 
201  newScreens.GetLibNicknames( names );
202 
203  wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
204  wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
205 
206  if( fileName.GetPathWithSep() == Prj().GetProjectPath()
207  && !prjScreens.HasSchematic( fullFilename ) )
208  {
209  // A schematic in the current project path that isn't part of the current project.
210  // It's possible the user copied this schematic from another project so the library
211  // links may not be avaible. Even this is check is no guarantee that all symbol
212  // library links are valid but it's better than nothing.
213  for( const auto& name : names )
214  {
215  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
216  newLibNames.Add( name );
217  }
218 
219  if( !newLibNames.IsEmpty() )
220  {
221  msg = _( "There are library names in the loaded schematic that are missing "
222  "from the project library table. This may result in broken symbol "
223  "library links for the loaded schematic. Do you wish to continue?" );
224  wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
225  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
226  wxCENTER | wxICON_QUESTION );
227  msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
228 
229  if( msgDlg3.ShowModal() == wxID_CANCEL )
230  return false;
231  }
232  }
233  else if( fileName.GetPathWithSep() != Prj().GetProjectPath() )
234  {
235  // A schematic loaded from a path other than the current project path.
236 
237  // If there are symbol libraries in the imported schematic that are not in the
238  // symbol library table of this project, there could be a lot of broken symbol
239  // library links. Attempt to add the missing libraries to the project symbol
240  // library table.
241  wxArrayString duplicateLibNames;
242 
243  for( const auto& name : names )
244  {
245  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
246  newLibNames.Add( name );
247  else
248  duplicateLibNames.Add( name );
249  }
250 
251  SYMBOL_LIB_TABLE table;
252  wxFileName symLibTableFn( fileName.GetPath(),
254 
255  // If there are any new or duplicate libraries, check to see if it's possible that
256  // there could be any missing libraries that would cause broken symbol library links.
257  if( !newLibNames.IsEmpty() || !duplicateLibNames.IsEmpty() )
258  {
259  if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
260  {
261  msg.Printf( _( "The project library table \"%s\" does not exist or cannot "
262  "be read. This may result in broken symbol links for the "
263  "schematic. Do you wish to continue?" ),
264  fileName.GetFullPath() );
265  wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
266  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
267  wxCENTER | wxICON_QUESTION );
268  msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
269 
270  if( msgDlg4.ShowModal() == wxID_CANCEL )
271  return false;
272  }
273  else
274  {
275  try
276  {
277  table.Load( symLibTableFn.GetFullPath() );
278  }
279  catch( const IO_ERROR& ioe )
280  {
281  msg.Printf( _( "An error occurred loading the symbol library table \"%s\"." ),
282  symLibTableFn.GetFullPath() );
283  DisplayErrorMessage( NULL, msg, ioe.What() );
284  return false;
285  }
286  }
287  }
288 
289  // Check to see if any of the symbol libraries found in the appended schematic do
290  // not exist in the current project are missing from the appended project symbol
291  // library table.
292  if( !newLibNames.IsEmpty() )
293  {
294  bool missingLibNames = table.IsEmpty();
295 
296  if( !missingLibNames )
297  {
298  for( const auto& newLibName : newLibNames )
299  {
300  if( !table.HasLibrary( newLibName ) )
301  {
302  missingLibNames = true;
303  break;
304  }
305  }
306  }
307 
308  if( missingLibNames )
309  {
310  msg = _( "There are library names in the loaded schematic that are missing "
311  "from the loaded schematic project library table. This may result "
312  "in broken symbol library links for the schematic. "
313  "Do you wish to continue?" );
314  wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
315  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
316  wxCENTER | wxICON_QUESTION );
317  msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
318 
319  if( msgDlg5.ShowModal() == wxID_CANCEL )
320  return false;
321  }
322  }
323 
324  // The library name already exists in the current project. Check to see if the
325  // duplicate name is the same library in the current project. If it's not, it's
326  // most likely that the symbol library links will be broken.
327  if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
328  {
329  bool libNameConflict = false;
330 
331  for( const auto& duplicateLibName : duplicateLibNames )
332  {
333  const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
334  const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
335 
336  if( Prj().SchSymbolLibTable()->HasLibrary( duplicateLibName ) )
337  thisRow = Prj().SchSymbolLibTable()->FindRow( duplicateLibName );
338 
339  if( table.HasLibrary( duplicateLibName ) )
340  otherRow = table.FindRow( duplicateLibName );
341 
342  // It's in the global library table so there is no conflict.
343  if( thisRow && !otherRow )
344  continue;
345 
346  if( !thisRow || !otherRow )
347  continue;
348 
349  wxFileName otherUriFileName;
350  wxString thisURI = thisRow->GetFullURI( true );
351  wxString otherURI = otherRow->GetFullURI( false);
352 
353  if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
354  {
355  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
356  // not expand to a valid symbol library path.
357  otherUriFileName.SetPath( fileName.GetPath() );
358  otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
359  otherURI = otherUriFileName.GetFullPath();
360  }
361 
362  if( thisURI != otherURI )
363  {
364  libNameConflict = true;
365  break;
366  }
367  }
368 
369  if( libNameConflict )
370  {
371  msg = _( "A duplicate library name that references a different library exists "
372  "in the current library table. This conflict cannot be resolved and "
373  "may result in broken symbol library links for the schematic. "
374  "Do you wish to continue?" );
375  wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
376  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
377  wxCENTER | wxICON_QUESTION );
378  msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
379 
380  if( msgDlg6.ShowModal() == wxID_CANCEL )
381  return false;
382  }
383  }
384 
385  // All (most?) of the possible broken symbol library link cases are covered. Map the
386  // new appended schematic project symbol library table entries to the current project
387  // symbol library table.
388  if( !newLibNames.IsEmpty() && !table.IsEmpty() )
389  {
390  for( const wxString& libName : newLibNames )
391  {
392  if( !table.HasLibrary( libName )
393  || Prj().SchSymbolLibTable()->HasLibrary( libName ) )
394  {
395  continue;
396  }
397 
398  // Don't expand environment variable because KIPRJMOD will not be correct
399  // for a different project.
400  wxString uri = table.GetFullURI( libName, false );
401  wxFileName newLib;
402 
403  if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
404  {
405  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
406  // not expand to a valid symbol library path.
407  newLib.SetPath( fileName.GetPath() );
408  newLib.SetFullName( uri.AfterLast( '}' ) );
409  uri = newLib.GetFullPath();
410  }
411  else
412  {
413  uri = table.GetFullURI( libName );
414  }
415 
416  // Add the library from the imported project to the current project
417  // symbol library table.
418  const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
419 
420  wxCHECK( row, false );
421 
422  SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri,
423  row->GetType(),
424  row->GetOptions(),
425  row->GetDescr() );
426 
427  Prj().SchSymbolLibTable()->InsertRow( newRow );
428  libTableChanged = true;
429  }
430  }
431  }
432 
433  SCH_SCREEN* newScreen = newSheet->GetScreen();
434  wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
435 
436  // Set all sheets loaded into the correct sheet file paths.
437 
438  for( SCH_ITEM* aItem : currentScreen->Items().OfType( SCH_SHEET_T ) )
439  {
440  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
441 
442  if( wxFileName( sheet->GetFileName() ).IsRelative( wxPATH_UNIX ) )
443  sheet->SetFileName( topLevelSheetPath + sheet->GetFileName() );
444  }
445 
446  if( libTableChanged )
447  {
448  Prj().SchSymbolLibTable()->Save( Prj().GetProjectPath() +
450  }
451 
452  // It is finally safe to add or append the imported schematic.
453  if( aSheet->GetScreen() == nullptr )
454  aSheet->SetScreen( newScreen );
455  else
456  aSheet->GetScreen()->Append( newScreen );
457 
458  SCH_SCREENS allScreens( Schematic().Root() );
459  allScreens.ReplaceDuplicateTimeStamps();
460 
461  return true;
462 }
463 
464 
466  bool* aClearAnnotationNewItems )
467 {
468  if( aSheet == NULL || aHierarchy == NULL )
469  return false;
470 
471  // Get the new texts
472  DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems );
473 
474  if( dlg.ShowModal() == wxID_CANCEL )
475  return false;
476 
477  return true;
478 }
479 
480 
482 {
483  wxRect DrawArea;
484  BASE_SCREEN* screen = GetScreen();
485 
486  DrawArea.SetSize( GetPageSizeIU() );
487 
488  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
489  // the drawings into the dc size
490  // scale is the ratio resolution (in PPI) / internal units
491  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
492  double inch2Iu = 1000.0 * IU_PER_MILS;
493  double scale = ppi / inch2Iu;
494 
495  wxSize dcsize = DrawArea.GetSize();
496 
497  int maxdim = std::max( dcsize.x, dcsize.y );
498 
499  // the max size in pixels of the bitmap used to build the sheet copy
500  const int maxbitmapsize = 5600;
501 
502  while( int( maxdim * scale ) > maxbitmapsize )
503  {
504  ppi = ppi / 1.5;
505  scale = ppi / inch2Iu;
506  }
507 
508  dcsize.x *= scale;
509  dcsize.y *= scale;
510 
511  // Set draw offset, zoom... to values needed to draw in the memory DC
512  // after saving initial values:
513  wxPoint tmp_startvisu = screen->m_StartVisu;
514  wxPoint old_org = screen->m_DrawOrg;
515  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
516  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
517 
518  wxMemoryDC dc;
519  wxBitmap image( dcsize );
520  dc.SelectObject( image );
521  dc.Clear();
522 
523  GRResetPenAndBrush( &dc );
524  GRForceBlackPen( false );
525  dc.SetUserScale( scale, scale );
526 
527  GetRenderSettings()->SetPrintDC( &dc );
528 
530 
531  {
532  wxLogNull doNotLog; // disable logging of failed clipboard actions
533 
534  if( wxTheClipboard->Open() )
535  {
536  // This data objects are held by the clipboard, so do not delete them in the app.
537  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
538  wxTheClipboard->SetData( clipbrd_data );
539  wxTheClipboard->Close();
540  }
541  }
542 
543  // Deselect Bitmap from DC in order to delete the MemoryDC
544  dc.SelectObject( wxNullBitmap );
545 
546  GRForceBlackPen( false );
547 
548  screen->m_StartVisu = tmp_startvisu;
549  screen->m_DrawOrg = old_org;
550 }
551 
552 
553 bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes( const wxString& aSchematicFileName )
554 {
555  wxString msg;
556  SCH_SCREENS screens( Schematic().Root() );
557  wxFileName fn = aSchematicFileName;
558 
559  wxCHECK( fn.IsAbsolute(), false );
560 
562  && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
563  {
564  msg.Printf( _( "The file name \"%s\" can cause issues with an existing file name\n"
565  "already defined in the schematic on systems that support case\n"
566  "insensitive file names. This will cause issues if you copy this\n"
567  "project to an operating system that supports case insensitive file\n"
568  "names.\n\nDo you wish to continue?" ),
569  fn.GetName() );
570 
571  wxRichMessageDialog dlg( this, msg, _( "Warning" ),
572  wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
573  dlg.ShowCheckBox( _( "Do not show this message again." ) );
574  dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
575  wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
576 
577  if( dlg.ShowModal() == wxID_NO )
578  return false;
579 
581  !dlg.IsCheckBoxChecked();
582  }
583 
584  return true;
585 }
bool CheckSheetForRecursion(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Verify that aSheet will not cause a recursion error in aHierarchy.
Definition: sheet.cpp:44
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:253
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:219
static const wxString & GetSymbolLibTableFileName()
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:118
const wxString & GetFileName() const
Definition: sch_screen.h:192
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:266
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
This file is part of the common library.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:154
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:93
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:481
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:285
virtual const wxString GetProjectPath() const
Return the full path of the project.
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
const wxString & GetDescr() const
Return the description of the library referenced by this row.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
EESCHEMA_SETTINGS * eeconfig() const
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
static SCH_FILE_T GuessPluginTypeFromSchPath(const wxString &aSchematicPath)
Return a plugin type given a schematic using the file extension of aSchematicPath.
Definition: sch_io_mgr.cpp:187
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:97
Definition: kiid.h:44
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Test every SCH_SHEET_PATH in this SCH_SHEET_LIST to verify if adding the sheets stored in aSrcSheetHi...
void SetFileName(wxString aFilename)
Definition: sch_sheet.h:505
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:101
bool AllowCaseSensitiveFileNameClashes(const wxString &aSchematicFileName)
Check aSchematicFileName for a potential file name case sensitivity clashes.
Definition: sheet.cpp:553
#define NULL
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:199
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString GetFullURI(const wxString &aLibNickname, bool aExpandEnvVars=true) const
Return the full URI of the library mapped to aLibNickname.
Handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:40
const wxString GetType() const override
Return the type of symbol library table represented by this row.
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:499
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:219
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:470
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:111
const int scale
SCH_SCREEN * LastScreen()
const char * name
Definition: DXF_plotter.cpp:59
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:127
#define _(s)
Definition: 3d_actions.cpp:33
EE_RTREE & Items()
Definition: sch_screen.h:162
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:92
#define IU_PER_MILS
Definition: plotter.cpp:137
bool EditSheetProperties(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, bool *aClearAnnotationNewItems)
Edit an existing sheet or add a new sheet to the schematic.
Definition: sheet.cpp:465
int ReplaceDuplicateTimeStamps()
Test all sheet and component objects in the schematic for duplicate time stamps and replaces them as ...
bool CanCauseCaseSensitivityIssue(const wxString &aSchematicFileName) const
Check aSchematicFileName for a potential file name case sensitivity issue.
void SetFileName(const wxString &aFileName)
Definition: sch_screen.h:190
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
bool checkForNoFullyDefinedLibIds(SCH_SHEET *aSheet)
Verify that the symbol library links aSheet and all of it's child sheets have been remapped to the sy...
Definition: sheet.cpp:72
void SetModify()
Definition: base_screen.h:59
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:281
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
void SetPrintDC(wxDC *aDC)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:534
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.