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-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <sch_draw_panel.h>
26 #include <confirm.h>
27 #include <kiface_base.h>
28 #include <project.h>
30 #include <tool/tool_manager.h>
31 #include <sch_edit_frame.h>
33 #include <sch_sheet.h>
34 #include <sch_sheet_path.h>
35 #include <sch_view.h>
36 #include <sch_painter.h>
37 #include <schematic.h>
38 #include <symbol_lib_table.h>
40 #include <tool/actions.h>
41 
42 #include <wx/clipbrd.h>
43 #include <wx/dcmemory.h>
44 #include <wx/log.h>
45 
46 
48 {
49  wxASSERT( aSheet && aHierarchy );
50 
51  wxString msg;
52  SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // The full schematic sheet hierarchy.
53  SCH_SHEET_LIST sheetHierarchy( aSheet ); // This is the hierarchy of the loaded file.
54 
55  wxFileName destFile = aHierarchy->LastScreen()->GetFileName();
56 
57  // SCH_SCREEN object file paths are expected to be absolute. If this assert fires,
58  // something is seriously broken.
59  wxASSERT( destFile.IsAbsolute() );
60 
61  if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath() ) )
62  {
63  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
64  "has the sheet '%s' or one of its subsheets as a parent somewhere in the "
65  "schematic hierarchy." ),
66  destFile.GetFullPath() );
67  DisplayError( this, msg );
68  return true;
69  }
70 
71  return false;
72 }
73 
74 
76 {
77  wxASSERT( aSheet && aSheet->GetScreen() );
78 
79  wxString msg;
80  SCH_SCREENS newScreens( aSheet );
81 
82  if( newScreens.HasNoFullyDefinedLibIds() )
83  {
84  msg.Printf( _( "The schematic '%s' has not had its symbol library links remapped "
85  "to the symbol library table. The project this schematic belongs to "
86  "must first be remapped before it can be imported into the current "
87  "project." ),
88  aSheet->GetScreen()->GetFileName() );
89  DisplayInfoMessage( this, msg );
90  return true;
91  }
92 
93  return false;
94 }
95 
96 
97 void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename )
98 {
99  aSheet->SetScreen( new SCH_SCREEN( &Schematic() ) );
100  aSheet->GetScreen()->SetContentModified();
101  aSheet->GetScreen()->SetFileName( aNewFilename );
102 }
103 
104 
106  const wxString& aFileName )
107 {
108  wxASSERT( aSheet && aHierarchy );
109 
110  wxString msg;
111  wxString topLevelSheetPath;
112  wxFileName tmp;
113  wxFileName currentSheetFileName;
114  bool libTableChanged = false;
115  SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( aFileName );
116  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( schFileType ) );
117  std::unique_ptr< SCH_SHEET> newSheet = std::make_unique<SCH_SHEET>( &Schematic() );
118 
119  // This will cause the sheet UUID to be set to the loaded schematic UUID. This is required
120  // to ensure all of the sheet paths in any subsheets are correctly generated.
121  const_cast<KIID&>( newSheet->m_Uuid ) = KIID( 0 );
122 
123  wxFileName fileName( aFileName );
124 
125  if( !fileName.IsAbsolute() && !fileName.MakeAbsolute() )
126  {
127  wxFAIL_MSG( wxString::Format( wxT( "Cannot make file name '%s' path absolute." ), aFileName ) );
128  return false;
129  }
130 
131  wxString fullFilename = fileName.GetFullPath();
132 
133  try
134  {
135  if( aSheet->GetScreen() != nullptr )
136  {
137  newSheet.reset( pi->Load( fullFilename, &Schematic() ) );
138  }
139  else
140  {
141  newSheet->SetFileName( fullFilename );
142  pi->Load( fullFilename, &Schematic(), newSheet.get() );
143  }
144 
145  if( !pi->GetError().IsEmpty() )
146  {
147  msg = _( "The entire schematic could not be loaded. Errors occurred attempting "
148  "to load hierarchical sheet schematics." );
149 
150  wxMessageDialog msgDlg1( this, msg, _( "Schematic Load Error" ),
151  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
152  wxCENTER | wxICON_QUESTION );
153  msgDlg1.SetOKLabel( wxMessageDialog::ButtonLabel( _( "Use partial schematic" ) ) );
154  msgDlg1.SetExtendedMessage( pi->GetError() );
155 
156  if( msgDlg1.ShowModal() == wxID_CANCEL )
157  return false;
158  }
159  }
160  catch( const IO_ERROR& ioe )
161  {
162  msg.Printf( _( "Error loading schematic '%s'." ), fullFilename );
163  DisplayErrorMessage( this, msg, ioe.What() );
164 
165  msg.Printf( _( "Failed to load '%s'." ), fullFilename );
166  SetMsgPanel( wxEmptyString, msg );
167 
168  return false;
169  }
170 
171  tmp = fileName;
172 
173  // If the loaded schematic is in a different folder from the current project and
174  // it contains hierarchical sheets, the hierarchical sheet paths need to be updated.
175  if( fileName.GetPathWithSep() != Prj().GetProjectPath() && newSheet->CountSheets() )
176  {
177  // Give the user the option to choose relative path if possible.
178  if( tmp.MakeRelativeTo( Prj().GetProjectPath() ) )
179  topLevelSheetPath = tmp.GetPathWithSep();
180  else
181  topLevelSheetPath = fileName.GetPathWithSep();
182 
183  if( wxFileName::GetPathSeparator() == '\\' )
184  topLevelSheetPath.Replace( wxT( "\\" ), wxT( "/" ) );
185  }
186 
187  // Make sure any new sheet changes do not cause any recursion issues.
188  SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
189  SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the loaded file.
190 
191  if( CheckSheetForRecursion( newSheet.get(), aHierarchy )
192  || checkForNoFullyDefinedLibIds( newSheet.get() ) )
193  {
194  return false;
195  }
196 
197  // Make a valiant attempt to warn the user of all possible scenarios where there could
198  // be broken symbol library links.
199  wxArrayString names;
200  wxArrayString newLibNames;
201  SCH_SCREENS newScreens( newSheet.get() ); // All screens associated with the import.
202  SCH_SCREENS prjScreens( &Schematic().Root() );
203 
204  newScreens.GetLibNicknames( names );
205 
206  wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
207  wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
208 
209  if( !prjScreens.HasSchematic( fullFilename ) )
210  {
211  if( fileName.GetPathWithSep() == Prj().GetProjectPath() )
212  {
213  // A schematic in the current project path that isn't part of the current project.
214  // It's possible the user copied this schematic from another project so the library
215  // links may not be available. Even this is check is no guarantee that all symbol
216  // library links are valid but it's better than nothing.
217  for( const wxString& name : names )
218  {
219  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
220  newLibNames.Add( name );
221  }
222 
223  if( !newLibNames.IsEmpty() )
224  {
225  msg = _( "There are library names in the selected schematic that are missing "
226  "from the current project library table. This may result in broken "
227  "symbol library references for the loaded schematic.\n\n"
228  "Do you wish to continue?" );
229  wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
230  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
231  wxCENTER | wxICON_QUESTION );
232  msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
233 
234  if( msgDlg3.ShowModal() == wxID_CANCEL )
235  return false;
236  }
237  }
238  else if( fileName.GetPathWithSep() != Prj().GetProjectPath() )
239  {
240  // A schematic loaded from a path other than the current project path.
241 
242  // If there are symbol libraries in the imported schematic that are not in the
243  // symbol library table of this project, there could be a lot of broken symbol
244  // library links. Attempt to add the missing libraries to the project symbol
245  // library table.
246  wxArrayString duplicateLibNames;
247 
248  for( const wxString& name : names )
249  {
250  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
251  newLibNames.Add( name );
252  else
253  duplicateLibNames.Add( name );
254  }
255 
256  SYMBOL_LIB_TABLE table;
257  wxFileName symLibTableFn( fileName.GetPath(),
259 
260  // If there are any new or duplicate libraries, check to see if it's possible that
261  // there could be any missing libraries that would cause broken symbol library links.
262  if( !newLibNames.IsEmpty() || !duplicateLibNames.IsEmpty() )
263  {
264  if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
265  {
266  msg = _( "The selected file was created as part of a different project. "
267  "Linking the file to this project may result in missing or "
268  "incorrect symbol library references.\n\n"
269  "Do you wish to continue?" );
270  wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
271  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
272  wxCENTER | wxICON_QUESTION );
273  msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
274 
275  if( msgDlg4.ShowModal() == wxID_CANCEL )
276  return false;
277  }
278  else
279  {
280  try
281  {
282  table.Load( symLibTableFn.GetFullPath() );
283  }
284  catch( const IO_ERROR& ioe )
285  {
286  msg.Printf( _( "Error loading the symbol library table '%s'." ),
287  symLibTableFn.GetFullPath() );
288  DisplayErrorMessage( nullptr, msg, ioe.What() );
289  return false;
290  }
291  }
292  }
293 
294  // Check to see if any of the symbol libraries found in the appended schematic do
295  // not exist in the current project are missing from the appended project symbol
296  // library table.
297  if( !newLibNames.IsEmpty() )
298  {
299  bool missingLibNames = table.IsEmpty();
300 
301  if( !missingLibNames )
302  {
303  for( const wxString& newLibName : newLibNames )
304  {
305  if( !table.HasLibrary( newLibName ) )
306  {
307  missingLibNames = true;
308  break;
309  }
310  }
311  }
312 
313  if( missingLibNames )
314  {
315  msg = _( "There are symbol library names in the selected schematic that "
316  "are missing from the selected schematic project library table. "
317  "This may result in broken symbol library references.\n\n"
318  "Do you wish to continue?" );
319  wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
320  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
321  wxCENTER | wxICON_QUESTION );
322  msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
323 
324  if( msgDlg5.ShowModal() == wxID_CANCEL )
325  return false;
326  }
327  }
328 
329  // The library name already exists in the current project. Check to see if the
330  // duplicate name is the same library in the current project. If it's not, it's
331  // most likely that the symbol library links will be broken.
332  if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
333  {
334  bool libNameConflict = false;
335 
336  for( const wxString& duplicateLibName : duplicateLibNames )
337  {
338  const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
339  const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
340 
341  if( Prj().SchSymbolLibTable()->HasLibrary( duplicateLibName ) )
342  thisRow = Prj().SchSymbolLibTable()->FindRow( duplicateLibName );
343 
344  if( table.HasLibrary( duplicateLibName ) )
345  otherRow = table.FindRow( duplicateLibName );
346 
347  // It's in the global library table so there is no conflict.
348  if( thisRow && !otherRow )
349  continue;
350 
351  if( !thisRow || !otherRow )
352  continue;
353 
354  wxFileName otherUriFileName;
355  wxString thisURI = thisRow->GetFullURI( true );
356  wxString otherURI = otherRow->GetFullURI( false);
357 
358  if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
359  {
360  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
361  // not expand to a valid symbol library path.
362  otherUriFileName.SetPath( fileName.GetPath() );
363  otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
364  otherURI = otherUriFileName.GetFullPath();
365  }
366 
367  if( thisURI != otherURI )
368  {
369  libNameConflict = true;
370  break;
371  }
372  }
373 
374  if( libNameConflict )
375  {
376  msg = _( "A duplicate library name that references a different library exists "
377  "in the current library table. This conflict cannot be resolved and "
378  "may result in broken symbol library references.\n\n"
379  "Do you wish to continue?" );
380  wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
381  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
382  wxCENTER | wxICON_QUESTION );
383  msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
384 
385  if( msgDlg6.ShowModal() == wxID_CANCEL )
386  return false;
387  }
388  }
389 
390  // All (most?) of the possible broken symbol library link cases are covered. Map the
391  // new appended schematic project symbol library table entries to the current project
392  // symbol library table.
393  if( !newLibNames.IsEmpty() && !table.IsEmpty() )
394  {
395  for( const wxString& libName : newLibNames )
396  {
397  if( !table.HasLibrary( libName )
398  || Prj().SchSymbolLibTable()->HasLibrary( libName ) )
399  {
400  continue;
401  }
402 
403  // Don't expand environment variable because KIPRJMOD will not be correct
404  // for a different project.
405  wxString uri = table.GetFullURI( libName, false );
406  wxFileName newLib;
407 
408  if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
409  {
410  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
411  // not expand to a valid symbol library path.
412  newLib.SetPath( fileName.GetPath() );
413  newLib.SetFullName( uri.AfterLast( '}' ) );
414  uri = newLib.GetFullPath();
415  }
416  else
417  {
418  uri = table.GetFullURI( libName );
419  }
420 
421  // Add the library from the imported project to the current project
422  // symbol library table.
423  const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
424 
425  wxCHECK( row, false );
426 
427  SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri,
428  row->GetType(),
429  row->GetOptions(),
430  row->GetDescr() );
431 
432  Prj().SchSymbolLibTable()->InsertRow( newRow );
433  libTableChanged = true;
434  }
435  }
436  }
437  }
438 
439  SCH_SCREEN* newScreen = newSheet->GetScreen();
440  wxCHECK_MSG( newScreen, false, wxT( "No screen defined for sheet." ) );
441 
442  if( libTableChanged )
443  {
444  Prj().SchSymbolLibTable()->Save( Prj().GetProjectPath() +
446  }
447 
448  // It is finally safe to add or append the imported schematic.
449  if( aSheet->GetScreen() == nullptr )
450  aSheet->SetScreen( newScreen );
451  else
452  aSheet->GetScreen()->Append( newScreen );
453 
454  SCH_SCREENS allScreens( Schematic().Root() );
455  allScreens.ReplaceDuplicateTimeStamps();
456 
457  return true;
458 }
459 
460 
462  bool* aClearAnnotationNewItems )
463 {
464  if( aSheet == nullptr || aHierarchy == nullptr )
465  return false;
466 
467  // Get the new texts
468  DIALOG_SHEET_PROPERTIES dlg( this, aSheet, aClearAnnotationNewItems );
469 
470  if( dlg.ShowModal() == wxID_CANCEL )
471  return false;
472 
473  return true;
474 }
475 
476 
478 {
479  wxRect DrawArea;
480  BASE_SCREEN* screen = GetScreen();
481 
482  DrawArea.SetSize( GetPageSizeIU() );
483 
484  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
485  // the drawings into the dc size
486  // scale is the ratio resolution (in PPI) / internal units
487  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
488  double inch2Iu = 1000.0 * IU_PER_MILS;
489  double scale = ppi / inch2Iu;
490 
491  wxSize dcsize = DrawArea.GetSize();
492 
493  int maxdim = std::max( dcsize.x, dcsize.y );
494 
495  // the max size in pixels of the bitmap used to build the sheet copy
496  const int maxbitmapsize = 5600;
497 
498  while( int( maxdim * scale ) > maxbitmapsize )
499  {
500  ppi = ppi / 1.5;
501  scale = ppi / inch2Iu;
502  }
503 
504  dcsize.x *= scale;
505  dcsize.y *= scale;
506 
507  // Set draw offset, zoom... to values needed to draw in the memory DC
508  // after saving initial values:
509  wxPoint tmp_startvisu = screen->m_StartVisu;
510  wxPoint old_org = screen->m_DrawOrg;
511  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
512  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
513 
514  wxMemoryDC dc;
515  wxBitmap image( dcsize );
516  dc.SelectObject( image );
517  dc.Clear();
518 
519  GRResetPenAndBrush( &dc );
520  GRForceBlackPen( false );
521  dc.SetUserScale( scale, scale );
522 
523  GetRenderSettings()->SetPrintDC( &dc );
524  // Init the color of the layer actually used to print the drawing sheet:
527 
529 
530  {
531  wxLogNull doNotLog; // disable logging of failed clipboard actions
532 
533  if( wxTheClipboard->Open() )
534  {
535  // This data objects are held by the clipboard, so do not delete them in the app.
536  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
537  wxTheClipboard->SetData( clipbrd_data );
538  wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
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:47
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
static const wxString & GetSymbolLibTableFileName()
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:107
const wxString & GetFileName() const
Definition: sch_screen.h:145
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:292
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:175
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Helper to retrieve a layer color from the global color settings.
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:97
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:477
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
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:169
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:93
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...
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:105
bool AllowCaseSensitiveFileNameClashes(const wxString &aSchematicFileName)
Check aSchematicFileName for a potential file name case sensitivity clashes.
Definition: sheet.cpp:553
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
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)
Definition: gr_basic.cpp:185
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.
#define _(s)
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
drawingsheet frame and titleblock
Definition: layer_ids.h:224
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
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:54
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
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:479
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
const int scale
SCH_SCREEN * LastScreen()
const char * name
Definition: DXF_plotter.cpp:56
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:88
#define IU_PER_MILS
Definition: plotter.cpp:130
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:461
int ReplaceDuplicateTimeStamps()
Test all sheet and symbol objects in the schematic for duplicate time stamps and replaces them as nec...
bool CanCauseCaseSensitivityIssue(const wxString &aSchematicFileName) const
Check aSchematicFileName for a potential file name case sensitivity issue.
void SetFileName(const wxString &aFileName)
Set the file name for this screen to aFileName.
Definition: sch_screen.cpp:110
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 its child sheets have been remapped to the sym...
Definition: sheet.cpp:75
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:307
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
void SetPrintDC(wxDC *aDC)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.