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();
100  aSheet->GetScreen()->SetFileName( aNewFilename );
101 }
102 
103 
105  const wxString& aFileName )
106 {
107  wxASSERT( aSheet && aHierarchy );
108 
109  wxString msg;
110  wxString topLevelSheetPath;
111  wxFileName tmp;
112  wxFileName currentSheetFileName;
113  bool libTableChanged = false;
114  SCH_SCREEN* currentScreen = aHierarchy->LastScreen();
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( new 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( "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 occurred loading schematic file \"%s\"." ), fullFilename );
163  DisplayErrorMessage( this, msg, ioe.What() );
164 
165  msg.Printf( _( "Failed to load schematic \"%s\"" ), fullFilename );
166  AppendMsgPanel( wxEmptyString, msg, CYAN );
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.GetPath( wxPATH_GET_SEPARATOR ) != Prj().GetProjectPath()
176  && newSheet->CountSheets() )
177  {
178  // Give the user the option to choose relative path if possible.
179  if( tmp.MakeRelativeTo( Prj().GetProjectPath() ) )
180  {
181  wxMessageDialog msgDlg2(
182  this,
183  "Do you want to use a relative path to the loaded "
184  "schematic?", "Select Path Type",
185  wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_QUESTION | wxCENTER );
186  msgDlg2.SetYesNoLabels( wxMessageDialog::ButtonLabel( "Use Relative Path" ),
187  wxMessageDialog::ButtonLabel( "Use Absolute Path" ) );
188  int rsp = msgDlg2.ShowModal();
189 
190  if( rsp == wxID_CANCEL )
191  {
192  return false;
193  }
194  else if( rsp == wxID_NO )
195  {
196  topLevelSheetPath = fileName.GetPathWithSep();
197  }
198  else
199  {
200  topLevelSheetPath = tmp.GetPathWithSep();
201  }
202  }
203  else
204  {
205  topLevelSheetPath = tmp.GetPathWithSep();
206  }
207 
208  if( wxFileName::GetPathSeparator() == '\\' )
209  topLevelSheetPath.Replace( "\\", "/" );
210  }
211 
212  // Make sure any new sheet changes do not cause any recursion issues.
213  SCH_SHEET_LIST hierarchy = Schematic().GetSheets(); // This is the schematic sheet hierarchy.
214  SCH_SHEET_LIST sheetHierarchy( newSheet.get() ); // This is the hierarchy of the loaded file.
215 
216  if( CheckSheetForRecursion( newSheet.get(), aHierarchy )
217  || checkForNoFullyDefinedLibIds( newSheet.get() ) )
218  return false;
219 
220  // Make a valiant attempt to warn the user of all possible scenarios where there could
221  // be broken symbol library links.
222  wxArrayString names;
223  wxArrayString newLibNames;
224  SCH_SCREENS newScreens( newSheet.get() ); // All screens associated with the import.
225  SCH_SCREENS prjScreens( &Schematic().Root() );
226 
227  newScreens.GetLibNicknames( names );
228 
229  wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) );
230  wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) );
231 
232  if( fileName.GetPath( wxPATH_GET_SEPARATOR ) == Prj().GetProjectPath()
233  && !prjScreens.HasSchematic( fullFilename ) )
234  {
235  // A schematic in the current project path that isn't part of the current project.
236  // It's possible the user copied this schematic from another project so the library
237  // links may not be avaible. Even this is check is no guarantee that all symbol
238  // library links are valid but it's better than nothing.
239  for( const auto& name : names )
240  {
241  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
242  newLibNames.Add( name );
243  }
244 
245  if( !newLibNames.IsEmpty() )
246  {
247  msg = _( "There are library names in the loaded schematic that are missing "
248  "from the project library table. This may result in broken symbol "
249  "library links for the loaded schematic. Do you wish to continue?" );
250  wxMessageDialog msgDlg3( this, msg, _( "Continue Load Schematic" ),
251  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
252  wxCENTER | wxICON_QUESTION );
253  msgDlg3.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
254 
255  if( msgDlg3.ShowModal() == wxID_CANCEL )
256  return false;
257  }
258  }
259  else if( fileName.GetPath( wxPATH_GET_SEPARATOR ) != Prj().GetProjectPath() )
260  {
261  // A schematic loaded from a path other than the current project path.
262 
263  // If there are symbol libraries in the imported schematic that are not in the
264  // symbol library table of this project, there could be a lot of broken symbol
265  // library links. Attempt to add the missing libraries to the project symbol
266  // library table.
267  wxArrayString duplicateLibNames;
268 
269  for( const auto& name : names )
270  {
271  if( !Prj().SchSymbolLibTable()->HasLibrary( name ) )
272  newLibNames.Add( name );
273  else
274  duplicateLibNames.Add( name );
275  }
276 
277  SYMBOL_LIB_TABLE table;
278  wxFileName symLibTableFn( fileName.GetPath(),
280 
281  // If there are any new or duplicate libraries, check to see if it's possible that
282  // there could be any missing libraries that would cause broken symbol library links.
283  if( !newLibNames.IsEmpty() || !duplicateLibNames.IsEmpty() )
284  {
285  if( !symLibTableFn.Exists() || !symLibTableFn.IsFileReadable() )
286  {
287  msg.Printf( _( "The project library table \"%s\" does not exist or cannot "
288  "be read. This may result in broken symbol links for the "
289  "schematic. Do you wish to continue?" ),
290  fileName.GetFullPath() );
291  wxMessageDialog msgDlg4( this, msg, _( "Continue Load Schematic" ),
292  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
293  wxCENTER | wxICON_QUESTION );
294  msgDlg4.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
295 
296  if( msgDlg4.ShowModal() == wxID_CANCEL )
297  return false;
298  }
299  else
300  {
301  try
302  {
303  table.Load( symLibTableFn.GetFullPath() );
304  }
305  catch( const IO_ERROR& ioe )
306  {
307  msg.Printf( _( "An error occurred loading the symbol library table "
308  "\"%s\"." ),
309  symLibTableFn.GetFullPath() );
310  DisplayErrorMessage( NULL, msg, ioe.What() );
311  return false;
312  }
313  }
314  }
315 
316  // Check to see if any of the symbol libraries found in the appended schematic do
317  // not exist in the current project are missing from the appended project symbol
318  // library table.
319  if( !newLibNames.IsEmpty() )
320  {
321  bool missingLibNames = table.IsEmpty();
322 
323  if( !missingLibNames )
324  {
325  for( const auto& newLibName : newLibNames )
326  {
327  if( !table.HasLibrary( newLibName ) )
328  {
329  missingLibNames = true;
330  break;
331  }
332  }
333  }
334 
335  if( missingLibNames )
336  {
337  msg = _( "There are library names in the loaded schematic that are missing "
338  "from the loaded schematic project library table. This may result "
339  "in broken symbol library links for the schematic. "
340  "Do you wish to continue?" );
341  wxMessageDialog msgDlg5( this, msg, _( "Continue Load Schematic" ),
342  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
343  wxCENTER | wxICON_QUESTION );
344  msgDlg5.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
345 
346  if( msgDlg5.ShowModal() == wxID_CANCEL )
347  return false;
348  }
349  }
350 
351  // The library name already exists in the current project. Check to see if the
352  // duplicate name is the same library in the current project. If it's not, it's
353  // most likely that the symbol library links will be broken.
354  if( !duplicateLibNames.IsEmpty() && !table.IsEmpty() )
355  {
356  bool libNameConflict = false;
357 
358  for( const auto& duplicateLibName : duplicateLibNames )
359  {
360  const SYMBOL_LIB_TABLE_ROW* thisRow = nullptr;
361  const SYMBOL_LIB_TABLE_ROW* otherRow = nullptr;
362 
363  if( Prj().SchSymbolLibTable()->HasLibrary( duplicateLibName ) )
364  thisRow = Prj().SchSymbolLibTable()->FindRow( duplicateLibName );
365 
366  if( table.HasLibrary( duplicateLibName ) )
367  otherRow = table.FindRow( duplicateLibName );
368 
369  // It's in the global library table so there is no conflict.
370  if( thisRow && !otherRow )
371  continue;
372 
373  if( !thisRow || !otherRow )
374  continue;
375 
376  wxFileName otherUriFileName;
377  wxString thisURI = thisRow->GetFullURI( true );
378  wxString otherURI = otherRow->GetFullURI( false);
379 
380  if( otherURI.Contains( "${KIPRJMOD}" ) || otherURI.Contains( "$(KIPRJMOD)" ) )
381  {
382  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
383  // not expand to a valid symbol library path.
384  otherUriFileName.SetPath( fileName.GetPath() );
385  otherUriFileName.SetFullName( otherURI.AfterLast( '}' ) );
386  otherURI = otherUriFileName.GetFullPath();
387  }
388 
389  if( thisURI != otherURI )
390  {
391  libNameConflict = true;
392  break;
393  }
394  }
395 
396  if( libNameConflict )
397  {
398  msg = _( "A duplicate library name that references a different library exists "
399  "in the current library table. This conflict cannot be resolved and "
400  "may result in broken symbol library links for the schematic. "
401  "Do you wish to continue?" );
402  wxMessageDialog msgDlg6( this, msg, _( "Continue Load Schematic" ),
403  wxOK | wxCANCEL | wxCANCEL_DEFAULT |
404  wxCENTER | wxICON_QUESTION );
405  msgDlg6.SetOKCancelLabels( okButtonLabel, cancelButtonLabel );
406 
407  if( msgDlg6.ShowModal() == wxID_CANCEL )
408  return false;
409  }
410  }
411 
412  // All (most?) of the possible broken symbol library link cases are covered. Map the
413  // new appended schematic project symbol library table entries to the current project
414  // symbol library table.
415  if( !newLibNames.IsEmpty() && !table.IsEmpty() )
416  {
417  for( const auto& libName : newLibNames )
418  {
419  if( !table.HasLibrary( libName )
420  || Prj().SchSymbolLibTable()->HasLibrary( libName ) )
421  continue;
422 
423  // Don't expand environment variable because KIPRJMOD will not be correct
424  // for a different project.
425  wxString uri = table.GetFullURI( libName, false );
426  wxFileName newLib;
427 
428  if( uri.Contains( "${KIPRJMOD}" ) || uri.Contains( "$(KIPRJMOD)" ) )
429  {
430  // Cannot use relative paths here, "${KIPRJMOD}../path-to-cache-lib" does
431  // not expand to a valid symbol library path.
432  newLib.SetPath( fileName.GetPath() );
433  newLib.SetFullName( uri.AfterLast( '}' ) );
434  uri = newLib.GetFullPath();
435  }
436  else
437  {
438  uri = table.GetFullURI( libName );
439  }
440 
441  // Add the library from the imported project to the current project
442  // symbol library table.
443  const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
444 
445  auto newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri, row->GetType(),
446  row->GetOptions(), row->GetDescr() );
447 
448  Prj().SchSymbolLibTable()->InsertRow( newRow );
449  libTableChanged = true;
450  }
451  }
452  }
453 
454  SCH_SCREEN* newScreen = newSheet->GetScreen();
455  wxCHECK_MSG( newScreen, false, "No screen defined for sheet." );
456 
457  // Set all sheets loaded into the correct sheet file paths.
458 
459  for( auto aItem : currentScreen->Items().OfType( SCH_SHEET_T ) )
460  {
461  auto sheet = static_cast<SCH_SHEET*>( aItem );
462  sheet->SetFileName( topLevelSheetPath + sheet->GetFileName() );
463  }
464 
465  if( libTableChanged )
466  Prj().SchSymbolLibTable()->Save( Prj().GetProjectPath() +
468 
469  // It is finally safe to add or append the imported schematic.
470  if( aSheet->GetScreen() == nullptr )
471  aSheet->SetScreen( newScreen );
472  else
473  aSheet->GetScreen()->Append( newScreen );
474 
475  SCH_SCREENS allScreens( Schematic().Root() );
476  allScreens.ReplaceDuplicateTimeStamps();
477 
478  return true;
479 }
480 
481 
483  bool* aClearAnnotationNewItems )
484 {
485  if( aSheet == NULL || aHierarchy == NULL )
486  return false;
487 
488  // Get the new texts
489  DIALOG_SCH_SHEET_PROPS dlg( this, aSheet, aClearAnnotationNewItems );
490 
491  if( dlg.ShowModal() == wxID_CANCEL )
492  return false;
493 
494  return true;
495 }
496 
497 
499 
500 
502 {
503  SCHEMATIC_SETTINGS& settings = aSheet->Schematic()->Settings();
504  wxString text;
505  SCH_SHEET_PIN* sheetPin;
506 
507  if( aLabel )
508  {
509  text = aLabel->GetText();
510  m_lastSheetPinType = aLabel->GetShape();
511  }
512 
513  sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), text );
514  sheetPin->SetFlags( IS_NEW );
515  sheetPin->SetTextSize( wxSize( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
516  sheetPin->SetShape( m_lastSheetPinType );
517 
518  if( !aLabel )
519  {
520  DIALOG_EDIT_SHEET_PIN dlg( this, sheetPin );
521 
522  if( dlg.ShowModal() != wxID_OK || sheetPin->GetText().IsEmpty() )
523  {
524  delete sheetPin;
525  return nullptr;
526  }
527  }
528 
529  m_lastSheetPinType = sheetPin->GetShape();
530 
531  sheetPin->SetPosition( (wxPoint) GetCanvas()->GetViewControls()->GetCursorPosition() );
532 
533  return sheetPin;
534 }
535 
536 
538 {
539  if( !aSheet->GetScreen() )
540  return nullptr;
541 
542  for( auto item : aSheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) )
543  {
544  auto label = static_cast<SCH_HIERLABEL*>( item );
545 
546  /* A global label has been found: check if there a corresponding sheet label. */
547  if( !aSheet->HasPin( label->GetText() ) )
548  return label;
549  }
550 
551  return nullptr;
552 }
553 
554 
556 {
557  wxRect DrawArea;
558  BASE_SCREEN* screen = GetScreen();
559 
560  DrawArea.SetSize( GetPageSizeIU() );
561 
562  // Calculate a reasonable dc size, in pixels, and the dc scale to fit
563  // the drawings into the dc size
564  // scale is the ratio resolution (in PPI) / internal units
565  double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
566  double inch2Iu = 1000.0 * IU_PER_MILS;
567  double scale = ppi / inch2Iu;
568 
569  wxSize dcsize = DrawArea.GetSize();
570 
571  int maxdim = std::max( dcsize.x, dcsize.y );
572 
573  // the max size in pixels of the bitmap used to build the sheet copy
574  const int maxbitmapsize = 5600;
575 
576  while( int( maxdim * scale ) > maxbitmapsize )
577  {
578  ppi = ppi / 1.5;
579  scale = ppi / inch2Iu;
580  }
581 
582  dcsize.x *= scale;
583  dcsize.y *= scale;
584 
585  // Set draw offset, zoom... to values needed to draw in the memory DC
586  // after saving initial values:
587  wxPoint tmp_startvisu = screen->m_StartVisu;
588  wxPoint old_org = screen->m_DrawOrg;
589  screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
590  screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
591 
592  wxMemoryDC dc;
593  wxBitmap image( dcsize );
594  dc.SelectObject( image );
595  dc.Clear();
596 
597  GRResetPenAndBrush( &dc );
598  GRForceBlackPen( false );
599  dc.SetUserScale( scale, scale );
600 
601  GetRenderSettings()->SetPrintDC( &dc );
602 
604 
605  if( wxTheClipboard->Open() )
606  {
607  // This data objects are held by the clipboard, so do not delete them in the app.
608  wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
609  wxTheClipboard->SetData( clipbrd_data );
610  wxTheClipboard->Close();
611  }
612 
613  // Deselect Bitmap from DC in order to delete the MemoryDC
614  dc.SelectObject( wxNullBitmap );
615 
616  GRForceBlackPen( false );
617 
618  screen->m_StartVisu = tmp_startvisu;
619  screen->m_DrawOrg = old_org;
620 }
621 
622 
623 bool SCH_EDIT_FRAME::AllowCaseSensitiveFileNameClashes( const wxString& aSchematicFileName )
624 {
625  wxString msg;
626  SCH_SCREENS screens( Schematic().Root() );
627  wxFileName fn = aSchematicFileName;
628 
629  wxCHECK( fn.IsAbsolute(), false );
630 
632  && screens.CanCauseCaseSensitivityIssue( aSchematicFileName ) )
633  {
634  msg.Printf( _( "The file name \"%s\" can cause issues with an existing file name\n"
635  "already defined in the schematic on systems that support case\n"
636  "insensitive file names. This will cause issues if you copy this\n"
637  "project to an operating system that supports case insensitive file\n"
638  "names.\n\nDo you wish to continue?" ),
639  fn.GetName() );
640 
641  wxRichMessageDialog dlg( this, msg, _( "Warning" ),
642  wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION );
643  dlg.ShowCheckBox( _( "Do not show this message again." ) );
644  dlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Create New Sheet" ) ),
645  wxMessageDialog::ButtonLabel( _( "Discard New Sheet" ) ) );
646 
647  if( dlg.ShowModal() == wxID_NO )
648  return false;
649 
651  !dlg.IsCheckBoxChecked();
652  }
653 
654  return true;
655 }
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:120
void SetShape(PINSHEETLABEL_SHAPE aShape)
Definition: sch_text.h:239
const wxString & GetFileName() const
Definition: sch_screen.h:189
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:92
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:134
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:151
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:113
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:555
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
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: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...
#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:171
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Definition: base_screen.h:67
Definition: common.h:68
bool TestForRecursion(const SCH_SHEET_LIST &aSrcSheetHierarchy, const wxString &aDestFileName)
Function TestForRecursion.
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:104
bool AllowCaseSensitiveFileNameClashes(const wxString &aSchematicFileName)
Check aSchematicFileName for a potential file name case sensitivity clashes.
Definition: sheet.cpp:623
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:33
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:201
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:44
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.
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:468
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
Set the schematic item position to aPosition.
Definition: sch_sheet.h:205
PINSHEETLABEL_SHAPE
Definition: sch_text.h:150
const int scale
SCH_HIERLABEL * ImportHierLabel(SCH_SHEET *aSheet)
Import a hierarchical label with no attached sheet pin.
Definition: sheet.cpp:537
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:205
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:133
#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:62
void SetMaxUndoItems(int aMax)
Definition: base_screen.h:172
#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:482
bool HasPin(const wxString &aName)
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:307
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:187
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:183
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
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:501
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:550
bool IsEmpty(bool aIncludeFallback=true)
Return true if the table is empty.
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:237