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 <fctsys.h>
26 #include <sch_draw_panel.h>
27 #include <confirm.h>
28 #include <kiface_i.h>
29 #include <project.h>
31 #include <tool/tool_manager.h>
32 #include <wx/clipbrd.h>
33 #include <sch_edit_frame.h>
34 #include <sch_legacy_plugin.h>
35 #include <sch_sheet.h>
36 #include <sch_sheet_path.h>
37 #include <sch_view.h>
38 #include <sch_painter.h>
39 #include <schematic.h>
40 #include <symbol_lib_table.h>
43 #include <tool/actions.h>
44 
45 
47 {
48  wxASSERT( aSheet && aHierarchy );
49 
50  wxString msg;
51  SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // The full schematic sheet hierarchy.
52  SCH_SHEET_LIST sheetHierarchy( aSheet ); // This is the hierarchy of the loaded file.
53 
54  wxFileName destFile = aHierarchy->LastScreen()->GetFileName();
55 
56  // SCH_SCREEN object file paths are expected to be absolute. If this assert fires,
57  // something is seriously broken.
58  wxASSERT( destFile.IsAbsolute() );
59 
60  if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath() ) )
61  {
62  msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
63  "has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
64  "the schematic hierarchy." ),
65  destFile.GetFullPath() );
66  DisplayError( this, msg );
67  return true;
68  }
69 
70  return false;
71 }
72 
73 
75 {
76  wxASSERT( aSheet && aSheet->GetScreen() );
77 
78  wxString msg;
79  SCH_SCREENS newScreens( aSheet );
80 
81  if( newScreens.HasNoFullyDefinedLibIds() )
82  {
83  msg.Printf( _( "The schematic \"%s\" has not had it's symbol library links remapped "
84  "to the symbol library table. The project this schematic belongs to "
85  "must first be remapped before it can be imported into the current "
86  "project." ), aSheet->GetScreen()->GetFileName() );
87  DisplayInfoMessage( this, msg );
88  return true;
89  }
90 
91  return false;
92 }
93 
94 
95 void SCH_EDIT_FRAME::InitSheet( SCH_SHEET* aSheet, const wxString& aNewFilename )
96 {
97  aSheet->SetScreen( new SCH_SCREEN( &Schematic() ) );
98  aSheet->GetScreen()->SetModify();
99  aSheet->GetScreen()->SetFileName( aNewFilename );
100 }
101 
102 
104  const wxString& aFileName )
105 {
106  wxASSERT( aSheet && aHierarchy );
107 
108  wxString msg;
109  wxString topLevelSheetPath;
110  wxFileName tmp;
111  wxFileName currentSheetFileName;
112  bool libTableChanged = false;
113  SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
114  SCH_IO_MGR::SCH_FILE_T schFileType = SCH_IO_MGR::GuessPluginTypeFromSchPath( aFileName );
115  SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( schFileType ) );
116  std::unique_ptr< SCH_SHEET> newSheet( new SCH_SHEET( &Schematic() ) );
117 
118  // This will cause the sheet UUID to be set to the loaded schematic UUID. This is required
119  // to ensure all of the sheet paths in any subsheets are correctly generated.
120  const_cast<KIID&>( newSheet->m_Uuid ) = KIID( 0 );
121 
122  wxFileName fileName( aFileName );
123 
124  if( !fileName.IsAbsolute() && !fileName.MakeAbsolute() )
125  {
126  wxFAIL_MSG( wxString::Format( "Cannot make file name \"%s\" path absolute.", aFileName ) );
127  return false;
128  }
129 
130  wxString fullFilename = fileName.GetFullPath();
131 
132  try
133  {
134  if( aSheet->GetScreen() != nullptr )
135  {
136  newSheet.reset( pi->Load( fullFilename, &Schematic() ) );
137  }
138  else
139  {
140  newSheet->SetFileName( fullFilename );
141  pi->Load( fullFilename, &Schematic(), newSheet.get() );
142  }
143 
144  if( !pi->GetError().IsEmpty() )
145  {
146  msg = _( "The entire schematic could not be loaded. Errors occurred attempting "
147  "to load hierarchical sheet schematics." );
148 
149  wxMessageDialog msgDlg1( this, msg, _( "Schematic Load Error" ),
150  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
151  wxCENTER | wxICON_QUESTION );
152  msgDlg1.SetOKLabel( wxMessageDialog::ButtonLabel( _( "Use partial schematic" ) ) );
153  msgDlg1.SetExtendedMessage( pi->GetError() );
154 
155  if( msgDlg1.ShowModal() == wxID_CANCEL )
156  return false;
157  }
158  }
159  catch( const IO_ERROR& ioe )
160  {
161  msg.Printf( _( "Error occurred loading schematic file \"%s\"." ), fullFilename );
162  DisplayErrorMessage( this, msg, ioe.What() );
163 
164  msg.Printf( _( "Failed to load schematic \"%s\"" ), fullFilename );
165  AppendMsgPanel( wxEmptyString, msg, CYAN );
166 
167  return false;
168  }
169 
170  tmp = fileName;
171 
172  // If the loaded schematic is in a different folder from the current project and
173  // it contains hierarchical sheets, the hierarchical sheet paths need to be updated.
174  if( fileName.GetPathWithSep() != Prj().GetProjectPath() && newSheet->CountSheets() )
175  {
176  // Give the user the option to choose relative path if possible.
177  if( tmp.MakeRelativeTo( Prj().GetProjectPath() ) )
178  topLevelSheetPath = tmp.GetPathWithSep();
179  else
180  topLevelSheetPath = fileName.GetPathWithSep();
181 
182  if( wxFileName::GetPathSeparator() == '\\' )
183  topLevelSheetPath.Replace( "\\", "/" );
184  }
185 
186  // Make sure any new sheet changes do not cause any recursion issues.
187  SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
188  SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the loaded file.
189 
190  if( CheckSheetForRecursion( newSheet.get(), aHierarchy )
191  || checkForNoFullyDefinedLibIds( newSheet.get() ) )
192  return false;
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 "
282  "\"%s\"." ),
283  symLibTableFn.GetFullPath() );
284  DisplayErrorMessage( NULL, msg, ioe.What() );
285  return false;
286  }
287  }
288  }
289 
290  // Check to see if any of the symbol libraries found in the appended schematic do
291  // not exist in the current project are missing from the appended project symbol
292  // library table.
293  if( !newLibNames.IsEmpty() )
294  {
295  bool missingLibNames = table.IsEmpty();
296 
297  if( !missingLibNames )
298  {
299  for( const auto& newLibName : newLibNames )
300  {
301  if( !table.HasLibrary( newLibName ) )
302  {
303  missingLibNames = true;
304  break;
305  }
306  }
307  }
308 
309  if( missingLibNames )
310  {
311  msg = _( "There are library names in the loaded schematic that are missing "
312  "from the loaded schematic project library table. This may result "
313  "in broken symbol library links for the schematic. "
314  "Do you wish to continue?" );
315  wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
316  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
317  wxCENTER | wxICON_QUESTION );
318  msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
319 
320  if( msgDlg5.ShowModal() == wxID_CANCEL )
321  return false;
322  }
323  }
324 
325  // The library name already exists in the current project. Check to see if the
326  // duplicate name is the same library in the current project. If it's not, it's
327  // most likely that the symbol library links will be broken.
328  if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
329  {
330  bool libNameConflict = false;
331 
332  for( const auto& duplicateLibName : duplicateLibNames )
333  {
334  const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
335  const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
336 
337  if( Prj().SchSymbolLibTable()->HasLibrary( duplicateLibName ) )
338  thisRow = Prj().SchSymbolLibTable()->FindRow( duplicateLibName );
339 
340  if( table.HasLibrary( duplicateLibName ) )
341  otherRow = table.FindRow( duplicateLibName );
342 
343  // It's in the global library table so there is no conflict.
344  if( thisRow && !otherRow )
345  continue;
346 
347  if( !thisRow || !otherRow )
348  continue;
349 
350  wxFileName otherUriFileName;
351  wxString thisURI = thisRow->GetFullURI( true );
352  wxString otherURI = otherRow->GetFullURI( false);
353 
354  if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
355  {
356  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
357  // not expand to a valid symbol library path.
358  otherUriFileName.SetPath( fileName.GetPath() );
359  otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
360  otherURI = otherUriFileName.GetFullPath();
361  }
362 
363  if( thisURI != otherURI )
364  {
365  libNameConflict = true;
366  break;
367  }
368  }
369 
370  if( libNameConflict )
371  {
372  msg = _( "A duplicate library name that references a different library exists "
373  "in the current library table. This conflict cannot be resolved and "
374  "may result in broken symbol library links for the schematic. "
375  "Do you wish to continue?" );
376  wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
377  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
378  wxCENTER | wxICON_QUESTION );
379  msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
380 
381  if( msgDlg6.ShowModal() == wxID_CANCEL )
382  return false;
383  }
384  }
385 
386  // All (most?) of the possible broken symbol library link cases are covered. Map the
387  // new appended schematic project symbol library table entries to the current project
388  // symbol library table.
389  if( !newLibNames.IsEmpty() && !table.IsEmpty() )
390  {
391  for( const wxString& libName : newLibNames )
392  {
393  if( !table.HasLibrary( libName )
394  || Prj().SchSymbolLibTable()->HasLibrary( libName ) )
395  {
396  continue;
397  }
398 
399  // Don't expand environment variable because KIPRJMOD will not be correct
400  // for a different project.
401  wxString uri = table.GetFullURI( libName, false );
402  wxFileName newLib;
403 
404  if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
405  {
406  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
407  // not expand to a valid symbol library path.
408  newLib.SetPath( fileName.GetPath() );
409  newLib.SetFullName( uri.AfterLast( '}' ) );
410  uri = newLib.GetFullPath();
411  }
412  else
413  {
414  uri = table.GetFullURI( libName );
415  }
416 
417  // Add the library from the imported project to the current project
418  // symbol library table.
419  const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
420 
421  SYMBOL_LIB_TABLE_ROW* newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri,
422  row->GetType(),
423  row->GetOptions(),
424  row->GetDescr() );
425 
426  Prj().SchSymbolLibTable()->InsertRow( newRow );
427  libTableChanged = true;
428  }
429  }
430  }
431 
432  SCH_SCREEN* newScreen = newSheet->GetScreen();
433  wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
434 
435  // Set all sheets loaded into the correct sheet file paths.
436 
437  for( SCH_ITEM* aItem : currentScreen->Items().OfType( SCH_SHEET_T ) )
438  {
439  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
440 
441  if( wxFileName( sheet->GetFileName() ).IsRelative( wxPATH_UNIX ) )
442  sheet->SetFileName( topLevelSheetPath + sheet->GetFileName() );
443  }
444 
445  if( libTableChanged )
446  {
447  Prj().SchSymbolLibTable()->Save( Prj().GetProjectPath() +
449  }
450 
451  // It is finally safe to add or append the imported schematic.
452  if( aSheet->GetScreen() == nullptr )
453  aSheet->SetScreen( newScreen );
454  else
455  aSheet->GetScreen()->Append( newScreen );
456 
457  SCH_SCREENS allScreens( Schematic().Root() );
458  allScreens.ReplaceDuplicateTimeStamps();
459 
460  return true;
461 }
462 
463 
465  bool* aClearAnnotationNewItems )
466 {
467  if( aSheet == NULL || aHierarchy == NULL )
468  return false;
469 
470  // Get the new texts
471  DIALOG_SCH_SHEET_PROPS dlg( this, aSheet, aClearAnnotationNewItems );
472 
473  if( dlg.ShowModal() == wxID_CANCEL )
474  return false;
475 
476  return true;
477 }
478 
479 
481 
482 
484 {
485  SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
486  wxString text;
487  SCH_SHEET_PIN* sheetPin;
488 
489  if( aLabel )
490  {
491  text = aLabel->GetText();
492  m_lastSheetPinType = aLabel->GetShape();
493  }
494 
495  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
496  sheetPin->SetFlags( IS_NEW );
497  sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
498  sheetPin->SetShape( m_lastSheetPinType );
499 
500  if( !aLabel )
501  {
502  DIALOG_EDIT_SHEET_PIN dlg( this, sheetPin );
503 
504  if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
505  {
506  delete sheetPin;
507  return nullptr;
508  }
509  }
510 
511  m_lastSheetPinType = sheetPin->GetShape();
512 
513  sheetPin->SetPosition( (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
514 
515  return sheetPin;
516 }
517 
518 
520 {
521  if( !aSheet->GetScreen() )
522  return nullptr;
523 
524  for( auto item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
525  {
526  auto label = static_cast<SCH_HIERLABEL*>( item );
527 
528  /* A global label has been found: check if there a corresponding sheet label. */
529  if( !aSheet->HasPin( label->GetText() ) )
530  return label;
531  }
532 
533  return nullptr;
534 }
535 
536 
538 {
539  wxRect DrawArea;
540  BASE_SCREEN* screen = GetScreen();
541 
542  DrawArea.SetSize( GetPageSizeIU() );
543 
544  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
545  // the drawings into the dc size
546  // scale is the ratio resolution (in PPI) / internal units
547  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
548  double inch2Iu = 1000.0 * IU_PER_MILS;
549  double scale = ppi / inch2Iu;
550 
551  wxSize dcsize = DrawArea.GetSize();
552 
553  int maxdim = std::max( dcsize.x, dcsize.y );
554 
555  // the max size in pixels of the bitmap used to build the sheet copy
556  const int maxbitmapsize = 5600;
557 
558  while( int( maxdim * scale ) > maxbitmapsize )
559  {
560  ppi = ppi / 1.5;
561  scale = ppi / inch2Iu;
562  }
563 
564  dcsize.x *= scale;
565  dcsize.y *= scale;
566 
567  // Set draw offset, zoom... to values needed to draw in the memory DC
568  // after saving initial values:
569  wxPoint tmp_startvisu = screen->m_StartVisu;
570  wxPoint old_org = screen->m_DrawOrg;
571  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
572  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
573 
574  wxMemoryDC dc;
575  wxBitmap image( dcsize );
576  dc.SelectObject( image );
577  dc.Clear();
578 
579  GRResetPenAndBrush( &dc );
580  GRForceBlackPen( false );
581  dc.SetUserScale( scale, scale );
582 
583  GetRenderSettings()->SetPrintDC( &dc );
584 
586 
587  if( wxTheClipboard->Open() )
588  {
589  // This data objects are held by the clipboard, so do not delete them in the app.
590  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
591  wxTheClipboard->SetData( clipbrd_data );
592  wxTheClipboard->Close();
593  }
594 
595  // Deselect Bitmap from DC in order to delete the MemoryDC
596  dc.SelectObject( wxNullBitmap );
597 
598  GRForceBlackPen( false );
599 
600  screen->m_StartVisu = tmp_startvisu;
601  screen->m_DrawOrg = old_org;
602 }
603 
604 
605 bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes( const wxString& aSchematicFileName )
606 {
607  wxString msg;
608  SCH_SCREENS screens( Schematic().Root() );
609  wxFileName fn = aSchematicFileName;
610 
611  wxCHECK( fn.IsAbsolute(), false );
612 
614  && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
615  {
616  msg.Printf( _( "The file name \"%s\" can cause issues with an existing file name\n"
617  "already defined in the schematic on systems that support case\n"
618  "insensitive file names. This will cause issues if you copy this\n"
619  "project to an operating system that supports case insensitive file\n"
620  "names.\n\nDo you wish to continue?" ),
621  fn.GetName() );
622 
623  wxRichMessageDialog dlg( this, msg, _( "Warning" ),
624  wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
625  dlg.ShowCheckBox( _( "Do not show this message again." ) );
626  dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
627  wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
628 
629  if( dlg.ShowModal() == wxID_NO )
630  return false;
631 
633  !dlg.IsCheckBoxChecked();
634  }
635 
636  return true;
637 }
bool CheckSheetForRecursion(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy)
Verify that aSheet will not cause a recursion error in aHierarchy.
Definition: sheet.cpp:46
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
SCH_SHEET_LIST.
static const wxString & GetSymbolLibTableFileName()
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:122
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:241
const wxString & GetFileName() const
Definition: sch_screen.h:185
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
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.
SCH_SHEET_LIST GetSheets() const
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:89
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:252
This file is part of the common library.
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:124
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:150
EE_TYPE OfType(KICAD_T aType)
Definition: sch_rtree.h:219
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:116
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:95
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:537
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:238
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:282
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:124
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...
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
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:179
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:65
Definition: common.h:68
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Function TestForRecursion.
void SetFileName(wxString aFilename)
Definition: sch_sheet.h:502
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:103
bool AllowCaseSensitiveFileNameClashes(const wxString &aSchematicFileName)
Check aSchematicFileName for a potential file name case sensitivity clashes.
Definition: sheet.cpp:605
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
#define NULL
static PINSHEETLABEL_SHAPE m_lastSheetPinType
Last sheet pin type.
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:29
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:203
PROJECT & Prj() const
Function Prj returns 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.
BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:43
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
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.
Definition: color4d.h:58
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
bool HasNoFullyDefinedLibIds()
Test all of the schematic symbols to see if all LIB_ID objects library nickname is not set.
SCH_SHEET_PATH.
virtual void PrintPage(RENDER_SETTINGS *aSettings) override
Plot or print the current sheet to the clipboard.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:496
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:216
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:469
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
void SetPosition(const wxPoint &aPosition) override
Definition: sch_sheet.h:205
PINSHEETLABEL_SHAPE
Definition: sch_text.h:152
const int scale
SCH_HIERLABEL * ImportHierLabel(SCH_SHEET *aSheet)
Import a hierarchical label with no attached sheet pin.
Definition: sheet.cpp:519
SCH_SCREEN * LastScreen()
Function LastScreen.
const char * name
Definition: DXF_plotter.cpp:60
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:201
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:131
#define _(s)
Definition: 3d_actions.cpp:33
EE_RTREE & Items()
Definition: sch_screen.h:158
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Definition: base_screen.h:60
#define IU_PER_MILS
Definition: plotter.cpp:138
These settings were stored in SCH_BASE_FRAME previously.
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:464
bool HasPin(const wxString &aName)
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:306
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:183
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:74
void SetModify()
Definition: base_screen.h:100
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:267
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
void SetPrintDC(wxDC *aDC)
SCH_SHEET_PIN * CreateSheetPin(SCH_SHEET *aSheet, SCH_HIERLABEL *aLabel)
Create a new SCH_SHEET_PIN object and add it to aSheet at the current cursor position.
Definition: sheet.cpp:483
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:515
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:239